Ignore:
Timestamp:
Jun 17, 2011, 9:25:57 PM (14 years ago)
Author:
[email protected]
Message:

2011-06-17 Oliver Hunt <[email protected]>

Reviewed by Gavin Barraclough.

JSONP is unnecessarily slow
https://bugs.webkit.org/show_bug.cgi?id=62920

JSONP has unfortunately become a fairly common idiom online, yet
it triggers very poor performance in JSC as we end up doing codegen
for a large number of property accesses that will

  • only be run once, so the vast amount of logic we dump to handle caching of accesses is unnecessary.
  • We are doing codegen that is directly proportional to just creating the object in the first place.

This patch extends the use of the literal parser to JSONP-like structures
in global code, handling a number of different forms I have seen online.
In an extreme case this improves performance of JSONP by more than 2x
due to removal of code generation and execution time, and a few optimisations
that I made to the parser itself.

  • API/JSValueRef.cpp: (JSValueMakeFromJSONString):
  • interpreter/Interpreter.cpp: (JSC::Interpreter::callEval): (JSC::Interpreter::execute):
  • parser/Lexer.cpp: (JSC::Lexer::isKeyword):
  • parser/Lexer.h:
  • runtime/JSGlobalObjectFunctions.cpp: (JSC::globalFuncEval):
  • runtime/JSONObject.cpp: (JSC::JSONProtoFuncParse):
  • runtime/LiteralParser.cpp: (JSC::LiteralParser::tryJSONPParse): (JSC::LiteralParser::makeIdentifier): (JSC::LiteralParser::Lexer::lex): (JSC::LiteralParser::Lexer::next): (JSC::isSafeStringCharacter): (JSC::LiteralParser::Lexer::lexString): (JSC::LiteralParser::Lexer::lexNumber): (JSC::LiteralParser::parse):
  • runtime/LiteralParser.h: (JSC::LiteralParser::LiteralParser): (JSC::LiteralParser::tryLiteralParse): (JSC::LiteralParser::Lexer::Lexer):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r89171 r89184  
     12011-06-17  Oliver Hunt  <[email protected]>
     2
     3        Reviewed by Gavin Barraclough.
     4
     5        JSONP is unnecessarily slow
     6        https://bugs.webkit.org/show_bug.cgi?id=62920
     7
     8        JSONP has unfortunately become a fairly common idiom online, yet
     9        it triggers very poor performance in JSC as we end up doing codegen
     10        for a large number of property accesses that will
     11           * only be run once, so the vast amount of logic we dump to handle
     12             caching of accesses is unnecessary.
     13           * We are doing codegen that is directly proportional to just
     14             creating the object in the first place.
     15
     16        This patch extends the use of the literal parser to JSONP-like structures
     17        in global code, handling a number of different forms I have seen online.
     18        In an extreme case this improves performance of JSONP by more than 2x
     19        due to removal of code generation and execution time, and a few optimisations
     20        that I made to the parser itself.
     21
     22        * API/JSValueRef.cpp:
     23        (JSValueMakeFromJSONString):
     24        * interpreter/Interpreter.cpp:
     25        (JSC::Interpreter::callEval):
     26        (JSC::Interpreter::execute):
     27        * parser/Lexer.cpp:
     28        (JSC::Lexer::isKeyword):
     29        * parser/Lexer.h:
     30        * runtime/JSGlobalObjectFunctions.cpp:
     31        (JSC::globalFuncEval):
     32        * runtime/JSONObject.cpp:
     33        (JSC::JSONProtoFuncParse):
     34        * runtime/LiteralParser.cpp:
     35        (JSC::LiteralParser::tryJSONPParse):
     36        (JSC::LiteralParser::makeIdentifier):
     37        (JSC::LiteralParser::Lexer::lex):
     38        (JSC::LiteralParser::Lexer::next):
     39        (JSC::isSafeStringCharacter):
     40        (JSC::LiteralParser::Lexer::lexString):
     41        (JSC::LiteralParser::Lexer::lexNumber):
     42        (JSC::LiteralParser::parse):
     43        * runtime/LiteralParser.h:
     44        (JSC::LiteralParser::LiteralParser):
     45        (JSC::LiteralParser::tryLiteralParse):
     46        (JSC::LiteralParser::Lexer::Lexer):
     47
    1482011-06-17  Geoffrey Garen  <[email protected]>
    249
Note: See TracChangeset for help on using the changeset viewer.