Bug 67875

Summary: Remove toPrimitive from JSCell
Product: WebKit Reporter: Mark Hahnenberg <mhahnenberg>
Component: JavaScriptCoreAssignee: Mark Hahnenberg <mhahnenberg>
Status: RESOLVED FIXED    
Severity: Normal CC: darin, ggaren, oliver, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 68389    
Bug Blocks: 67690    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch none

Description Mark Hahnenberg 2011-09-09 16:32:35 PDT
We should remove JSCell::toPrimitive in favor of JSValue::toPrimitive.  The JSValue version in non-virtual, and we're trying to remove all virtual methods from JSCell.
Comment 1 Mark Hahnenberg 2011-09-09 17:23:39 PDT
Created attachment 106945 [details]
Patch
Comment 2 Mark Hahnenberg 2011-09-13 15:05:25 PDT
Comment on attachment 106945 [details]
Patch

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

> Source/JavaScriptCore/ChangeLog:9
> +        all of the implicit functionality provided by the virutal toPrimitive method 

sp

> Source/JavaScriptCore/runtime/JSObject.h:911
> +        return *const_cast<JSValue*>(this);

no const_cast, please

> Source/JavaScriptCore/runtime/JSObject.h:912
> +    if (isCell())

Test isCell first for efficiency. Create separate toPrimitives for JSCell* and JSObject*.
Comment 3 Mark Hahnenberg 2011-09-16 12:56:25 PDT
Created attachment 107708 [details]
Patch
Comment 4 WebKit Review Bot 2011-09-17 02:20:10 PDT
Comment on attachment 107708 [details]
Patch

Attachment 107708 [details] did not pass mac-ews (mac):
Output: http://queues.webkit.org/results/9729359
Comment 5 Geoffrey Garen 2011-09-18 15:44:50 PDT
Comment on attachment 107708 [details]
Patch

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

> Source/JavaScriptCore/runtime/JSCell.cpp:124
> +    if (isString())
> +        return ((JSString*)this)->toPrimitive(exec, preferredType);
> +    return ((JSObject*)this)->toPrimitive(exec, preferredType);

Use C++ static_cast, please. It's more explicit, and provides a little more type safety than a C-style cast.

Are the bot complaints a real issue?
Comment 6 Mark Hahnenberg 2011-09-19 11:28:39 PDT
Created attachment 107892 [details]
Patch
Comment 7 Geoffrey Garen 2011-09-19 12:06:35 PDT
Comment on attachment 107892 [details]
Patch

r=me
Comment 8 WebKit Review Bot 2011-09-19 13:31:59 PDT
Comment on attachment 107892 [details]
Patch

Clearing flags on attachment: 107892

Committed r95466: <http://trac.webkit.org/changeset/95466>
Comment 9 WebKit Review Bot 2011-09-19 13:32:04 PDT
All reviewed patches have been landed.  Closing bug.
Comment 10 Darin Adler 2011-09-19 14:08:38 PDT
Why did this patch move JSValue::toPrimitive from JSCell.h to JSString.h? That change makes no sense to me!
Comment 11 Mark Hahnenberg 2011-09-19 14:19:45 PDT
(In reply to comment #10)
> Why did this patch move JSValue::toPrimitive from JSCell.h to JSString.h? That change makes no sense to me!

Good question.  This is the corrected (for compilation) version of an incorrect (for style) version.  Rolling it out to resubmit the corrected (for both) version.
Comment 12 Mark Hahnenberg 2011-09-19 15:01:42 PDT
Created attachment 107922 [details]
Patch
Comment 13 WebKit Review Bot 2011-09-19 21:32:18 PDT
Comment on attachment 107922 [details]
Patch

Clearing flags on attachment: 107922

Committed r95516: <http://trac.webkit.org/changeset/95516>
Comment 14 WebKit Review Bot 2011-09-19 21:32:23 PDT
All reviewed patches have been landed.  Closing bug.