Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: d981384b263dcf7b8d6f247fc803fa9d34c7c449
      
https://github.com/WebKit/WebKit/commit/d981384b263dcf7b8d6f247fc803fa9d34c7c449
  Author: Sosuke Suzuki <[email protected]>
  Date:   2026-07-09 (Thu, 09 Jul 2026)

  Changed paths:
    A JSTests/microbenchmarks/json-parse-int32-array.js
    A JSTests/stress/json-parse-number-int32-token.js
    A JSTests/stress/jsonp-negative-array-index.js
    M Source/JavaScriptCore/runtime/LiteralParser.cpp
    M Source/JavaScriptCore/runtime/LiteralParser.h

  Log Message:
  -----------
  [JSC] Add `TokNumberInt32` token type to `LiteralParser` to remove number 
conversion overhead
https://bugs.webkit.org/show_bug.cgi?id=318937

Reviewed by Yusuke Suzuki.

LiteralParser's lexer already computes short integer JSON numbers as
int32, but LiteralParserToken can only hold a double, so the lexer
widens the value to double and parsePrimitiveValue's jsNumber(double)
re-derives its int32-ness through a double->int32->double
convert-and-compare chain for every number.

This patch adds a TokNumberInt32 token type that carries the int32
value in the token directly, so parsePrimitiveValue can box it with
jsNumber(int32_t). Negative zero keeps using TokNumber.

                                 Baseline                  Patched

json-parse-int32-array      275.3648+-3.7552     ^    260.3382+-2.3959        ^ 
definitely 1.0577x faster

Tests: JSTests/microbenchmarks/json-parse-int32-array.js
       JSTests/stress/json-parse-number-int32-token.js

* JSTests/microbenchmarks/json-parse-int32-array.js: Added.
* JSTests/stress/json-parse-number-int32-token.js: Added.
(shouldBe):
(s.of.invalid.string_appeared_here.s.string_appeared_here.catch):
* Source/JavaScriptCore/runtime/LiteralParser.cpp:
(JSC::requires):
(JSC::reviverMode>::Lexer::lexNumber):
(JSC::reviverMode>::parsePrimitiveValue):
(JSC::reviverMode>::parse):
* Source/JavaScriptCore/runtime/LiteralParser.h:

Canonical link: https://commits.webkit.org/316806@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to