Bug 167454 - [JSC] Optimize Number.prototype.toString on Int32 / Int52 / Double
Summary: [JSC] Optimize Number.prototype.toString on Int32 / Int52 / Double
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Yusuke Suzuki
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-01-26 04:32 PST by Yusuke Suzuki
Modified: 2017-03-21 04:31 PDT (History)
5 users (show)

See Also:


Attachments
Patch (53.68 KB, patch)
2017-01-26 06:03 PST, Yusuke Suzuki
saam: review+
Details | Formatted Diff | Diff
Patch (50.09 KB, patch)
2017-03-21 03:38 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yusuke Suzuki 2017-01-26 04:32:27 PST
[JSC] Optimize Number.prototype.toString on Int32 / Int52 / Double
Comment 1 Yusuke Suzuki 2017-01-26 06:03:03 PST
Created attachment 299804 [details]
Patch
Comment 2 Saam Barati 2017-01-26 09:57:51 PST
Comment on attachment 299804 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=299804&action=review

> Source/JavaScriptCore/dfg/DFGOperations.h:162
> +char* JIT_OPERATION operationInt32ToString(ExecState*, int32_t, int32_t);

Why not make these return JSCell*?

> Source/JavaScriptCore/dfg/DFGStrengthReductionPhase.cpp:407
> +                            result = String::numberToStringECMAScript(value.asNumber());

Why not always call this?

> Source/JavaScriptCore/runtime/StringConstructor.cpp:47
> +  fromCharCode          stringFromCharCode         DontEnum|Function 1 FromCharCodeIntrinsic

I think this should be a separate patch.
Comment 3 Saam Barati 2017-01-26 09:58:43 PST
(In reply to comment #2)
> Comment on attachment 299804 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=299804&action=review
> 
> > Source/JavaScriptCore/dfg/DFGOperations.h:162
> > +char* JIT_OPERATION operationInt32ToString(ExecState*, int32_t, int32_t);
> 
> Why not make these return JSCell*?
> 
> > Source/JavaScriptCore/dfg/DFGStrengthReductionPhase.cpp:407
> > +                            result = String::numberToStringECMAScript(value.asNumber());
> 
> Why not always call this?
> 
> > Source/JavaScriptCore/runtime/StringConstructor.cpp:47
> > +  fromCharCode          stringFromCharCode         DontEnum|Function 1 FromCharCodeIntrinsic
> 
> I think this should be a separate patch.
Also please fix 32-bit and windows build issues.
Comment 4 Yusuke Suzuki 2017-01-27 08:51:32 PST
Comment on attachment 299804 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=299804&action=review

Thanks!

>>> Source/JavaScriptCore/dfg/DFGOperations.h:162
>>> +char* JIT_OPERATION operationInt32ToString(ExecState*, int32_t, int32_t);
>> 
>> Why not make these return JSCell*?
> 
> Also please fix 32-bit and windows build issues.

This is because the signatures of these functions are typedefed as P_ (returning pointer) to reuse the existing implementation of callOperation.
I'll check Win32 build issue.

>> Source/JavaScriptCore/dfg/DFGStrengthReductionPhase.cpp:407
>> +                            result = String::numberToStringECMAScript(value.asNumber());
> 
> Why not always call this?

I followed the style of the ValueAdd case. But maybe, calling numberToStringECMAScript is OK.
I'll check that.

>> Source/JavaScriptCore/runtime/StringConstructor.cpp:47
>> +  fromCharCode          stringFromCharCode         DontEnum|Function 1 FromCharCodeIntrinsic
> 
> I think this should be a separate patch.

I've just uploaded this part in the separate patch :)
https://bugs.webkit.org/show_bug.cgi?id=167505
Comment 5 Saam Barati 2017-01-27 09:59:31 PST
(In reply to comment #4)
> Comment on attachment 299804 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=299804&action=review
> 
> Thanks!
> 
> >>> Source/JavaScriptCore/dfg/DFGOperations.h:162
> >>> +char* JIT_OPERATION operationInt32ToString(ExecState*, int32_t, int32_t);
> >> 
> >> Why not make these return JSCell*?
> > 
> > Also please fix 32-bit and windows build issues.
> 
> This is because the signatures of these functions are typedefed as P_
> (returning pointer) to reuse the existing implementation of callOperation.
> I'll check Win32 build issue.
> 
> >> Source/JavaScriptCore/dfg/DFGStrengthReductionPhase.cpp:407
> >> +                            result = String::numberToStringECMAScript(value.asNumber());
> > 
> > Why not always call this?
> 
> I followed the style of the ValueAdd case. But maybe, calling
> numberToStringECMAScript is OK.
> I'll check that.
I think it's OK to be consistent with what Add does here.
> 
> >> Source/JavaScriptCore/runtime/StringConstructor.cpp:47
> >> +  fromCharCode          stringFromCharCode         DontEnum|Function 1 FromCharCodeIntrinsic
> > 
> > I think this should be a separate patch.
> 
> I've just uploaded this part in the separate patch :)
> https://bugs.webkit.org/show_bug.cgi?id=167505
Comment 6 Yusuke Suzuki 2017-03-21 01:11:05 PDT
Oops, I forgot this patch! I'll land it with pointed fixes.
Comment 7 Yusuke Suzuki 2017-03-21 03:38:34 PDT
Created attachment 304995 [details]
Patch

Patch for landing
Comment 8 Yusuke Suzuki 2017-03-21 04:31:54 PDT
Committed r214219: <http://trac.webkit.org/changeset/214219>