Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8877985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:36:11+00:00 2026-06-14T19:36:11+00:00

I’m optimizing an sha-256 > hmac > pbkdf2 crypto algorithm in javascript for chrome

  • 0

I’m optimizing an sha-256 > hmac > pbkdf2 crypto algorithm in javascript for chrome

http://jsfiddle.net/dtudury/uy3hc/

if I change one line (after the comment // BREADCRUMB ) ei = (di + t1) >>> 0; to ei = (di + t1); my test still passes, but the test runtime jumps from <1s to 7s

I believe the >>> 0 tells chrome that it should store the value as an (actual) int… but there’s some degree of “cargo cult” to it.

My question is: “is this documented anywhere?” I’d love to verify how this works and/or find a zero operation way to tell chrome about ints (and any other secret ways of anticipating the chrome js compiler that such a document would reveal)

thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T19:36:12+00:00Added an answer on June 14, 2026 at 7:36 pm

    The general principle is that yes, Chrome / V8 tries to figure out if your code is consistently dealing with a particular type (like ints), and optimizing for that case. There are a bunch of posts and presentations about Javascript JIT strategies on the web… e.g. here and here.

    In this specific case, though, my guess is that it’s a bug. For one, I can’t reproduce it in node.js. Moreover, replacing (di + t1)>>>0 with other common int-casting ‘type hints’ like (di + t1)|0 and ~~(di+t1) don’t seem to improve things in Chrome. Finally, running Chrome with --js-flags="--trace-opt --trace-deopt --code-comments" shows that in the slow case, _hashWords is getting deoptimized and re-optimized dozens of times, which probably makes it even slower than if no optimizations were attempted at all. (I guess this is the CPU equivalent of thrashing.) Interestingly, the reason provided for deoptimization is shift-i, which sounds like the compiler keeps assuming that the numbers aren’t integers, and then getting surprised each time it encounters an integer-shifting instruction.

    To answer your specific question, the exact way that Chrome compiles things isn’t documented, but the general principles and the methods of profiling and debugging performance issues are. Here’s my favorite series of posts on profiling — it’s written by the guy who works on the Dart-to-JS compiler.

    Edit: Doh, I just realized that >>> 0 is casting to an unsigned int, while |0 and ~~ cast to a signed int. That’s probably why Chrome’s V8 couldn’t resolve the type properly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am reading a book about Javascript and jQuery and using one of the
I used javascript for loading a picture on my website depending on which small
I have a small JavaScript validation script that validates inputs based on Regex. I
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.