WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
144731
Special-case Int32 values in JSON.stringify().
https://bugs.webkit.org/show_bug.cgi?id=144731
Summary
Special-case Int32 values in JSON.stringify().
Andreas Kling
Reported
2015-05-07 01:43:19 PDT
We should have a fast-path in JSON.stringify() for Int32 values.
Attachments
Patch
(1.72 KB, patch)
2015-05-07 01:46 PDT
,
Andreas Kling
no flags
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Andreas Kling
Comment 1
2015-05-07 01:46:10 PDT
Created
attachment 252580
[details]
Patch Boom: json-stringify-tinderbox 60.176+-8.602 ^ 39.277+-1.632 ^ definitely 1.5321x faster
Michael Saboff
Comment 2
2015-05-07 07:50:44 PDT
Comment on
attachment 252580
[details]
Patch r=me
Andreas Kling
Comment 3
2015-05-07 08:58:01 PDT
Comment on
attachment 252580
[details]
Patch Clearing flags on attachment: 252580 Committed
r183928
: <
http://trac.webkit.org/changeset/183928
>
Andreas Kling
Comment 4
2015-05-07 08:58:06 PDT
All reviewed patches have been landed. Closing bug.
Darin Adler
Comment 5
2015-05-07 09:14:27 PDT
Comment on
attachment 252580
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=252580&action=review
> Source/JavaScriptCore/runtime/JSONObject.cpp:403 > if (value.isNumber()) { > - double number = value.asNumber(); > - if (!std::isfinite(number)) > - builder.appendLiteral("null"); > - else > - builder.appendECMAScriptNumber(number); > + if (value.isInt32()) > + builder.appendNumber(value.asInt32()); > + else { > + double number = value.asNumber(); > + if (!std::isfinite(number)) > + builder.appendLiteral("null"); > + else > + builder.appendECMAScriptNumber(number); > + } > return StringifySucceeded; > }
Would we get better code by writing these two separately? I ask because isNumber() is really just isInt32() || isDouble(). And if isDouble() is true then we can call asDouble(). Maybe the compiler will fold everything for us and remove all the dead code, but I think it would be nicer to just write it out like this: if (value.isInt32()) { builder.appendNumber(value.asInt32()); return StringifySucceeded; } if (value.isDouble()) { double number = value.asDouble(); if (!std::isfinite(number)) builder.appendLiteral("null"); else builder.appendECMAScriptNumber(number); return StringifySucceeded; }
Geoffrey Garen
Comment 6
2015-05-07 11:25:15 PDT
c:\cygwin\home\buildbot\webkit\webkitbuild\release\include\private\javascriptcore\X86Assembler.h(1811): error C2039: 'twoByteOp64' : is not a member of 'JSC::X86Assembler::X86InstructionFormatter' [C:\cygwin\home\buildbot\WebKit\Source\JavaScriptCore\JavaScriptCore.vcxproj\LLInt\LLIntOffsetsExtractor\LLIntOffsetsExtractor.vcxproj] c:\cygwin\home\buildbot\webkit\webkitbuild\release\include\private\javascriptcore\X86Assembler.h(2332) : see declaration of 'JSC::X86Assembler::X86InstructionFormatter'
Geoffrey Garen
Comment 7
2015-05-07 11:25:39 PDT
Oops! Wrong bug :(.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug