Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 12ea13fb7c877aa23a433af84385978c032abf80
      
https://github.com/WebKit/WebKit/commit/12ea13fb7c877aa23a433af84385978c032abf80
  Author: Yusuke Suzuki <[email protected]>
  Date:   2026-09-24 (Thu, 24 Sep 2026)

  Changed paths:
    A JSTests/stress/json-parse-invalid-property-value.js
    M Source/JavaScriptCore/runtime/LiteralParser.cpp
    M Source/JavaScriptCore/runtime/LiteralParser.h

  Log Message:
  -----------
  [JSC] Add fast path for particular type of token lexing in JSON.parse
https://bugs.webkit.org/show_bug.cgi?id=325207
rdar://188331681

Reviewed by Yijia Huang.

In JSON parsing, we know particular type of token is coming after a
certain element,

1. After parsing primitive value, the next expecting token is `}`, `]`,
   `,`.
2. When parsing a value, likely, string `"`, number `0-9` (and `-`),
   will come.

Good thing is all of them are one character, so instead of calling
full featured `next()`, let's peek one character and take a fast path.
Still it is possible that we may encounter a whitespace, then we go to the
normal path.

Test: JSTests/stress/json-parse-invalid-property-value.js

* JSTests/stress/json-parse-invalid-property-value.js: Added.
(shouldThrowSyntaxError):
* Source/JavaScriptCore/runtime/LiteralParser.cpp:
(JSC::reviverMode>::Lexer::nextAfterValue):
(JSC::reviverMode>::Lexer::nextString):
(JSC::reviverMode>::Lexer::nextNumber):
(JSC::reviverMode>::parsePrimitiveValue):
(JSC::requires):
* Source/JavaScriptCore/runtime/LiteralParser.h:
(JSC::LiteralParser::Lexer::peek const):

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



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

Reply via email to