Bug 144252 - Numeric setter on prototype doesn't get called.
Summary: Numeric setter on prototype doesn't get called.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Yusuke Suzuki
URL:
Keywords:
Depends on:
Blocks: 145358 140491
  Show dependency treegraph
 
Reported: 2015-04-27 01:19 PDT by Ryosuke Niwa
Modified: 2015-08-11 23:48 PDT (History)
8 users (show)

See Also:


Attachments
Patch (9.11 KB, patch)
2015-08-10 23:12 PDT, Yusuke Suzuki
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ryosuke Niwa 2015-04-27 01:19:46 PDT
var y = {set 2(x) { alert(x) }}
y[2] = 5;
var z = {__proto__: {set 3(x) { alert(x) }}};
z[3] = 7;

Chrome and Firefox both alerts 5 and 7.
Safari only alerts 5.

If you replace '3' with 'foo', Safari also alerts 7 and 7.
Comment 1 Yusuke Suzuki 2015-08-05 21:11:27 PDT
I think there are 2 issues, correct?

1.
If the __proto__-executed object is categorized into ALL_BLANK_INDEXING_TYPES, we don't set SlowPut into its structure.


2.
And if the newly generated object is not the array, we don't set the SlowPut into its structure even if there's SlowPut structure in the [[Prototype]] chain.
Comment 2 Ryosuke Niwa 2015-08-05 23:37:56 PDT
FWIW, I have no idea.
Comment 3 Yusuke Suzuki 2015-08-10 23:12:13 PDT
Created attachment 258706 [details]
Patch
Comment 4 Darin Adler 2015-08-11 10:32:38 PDT
Comment on attachment 258706 [details]
Patch

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

> Source/JavaScriptCore/runtime/JSObject.cpp:2045
> +            // Reloop.

This word “reloop” doesn’t exist. I suggest removing this comment unless there’s something clear to say here.
Comment 5 Darin Adler 2015-08-11 10:33:52 PDT
Comment on attachment 258706 [details]
Patch

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

>> Source/JavaScriptCore/runtime/JSObject.cpp:2045
>> +            // Reloop.
> 
> This word “reloop” doesn’t exist. I suggest removing this comment unless there’s something clear to say here.

If we do write a comment here, I think the focus of the comment should be on why it’s safe to call putByIndex and why we’re guaranteed this won’t result in an infinite loop.
Comment 6 Yusuke Suzuki 2015-08-11 10:35:39 PDT
Comment on attachment 258706 [details]
Patch

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

Thank you!

>> Source/JavaScriptCore/runtime/JSObject.cpp:2045
>> +            // Reloop.
> 
> This word “reloop” doesn’t exist. I suggest removing this comment unless there’s something clear to say here.

Oh, I can see many "Reloop"s in JSObject.cpp[1]...
In the mean time, I'll drop this comment!

[1]: http://trac.webkit.org/browser/trunk/Source/JavaScriptCore/runtime/JSObject.cpp
Comment 7 Darin Adler 2015-08-11 10:40:42 PDT
(In reply to comment #6)
> Oh, I can see many "Reloop"s in JSObject.cpp[1]...

I guess I wasn’t there when these changes went in to discourage use of this “word”!
Comment 8 Yusuke Suzuki 2015-08-11 10:42:41 PDT
Comment on attachment 258706 [details]
Patch

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

>>>> Source/JavaScriptCore/runtime/JSObject.cpp:2045
>>>> +            // Reloop.
>>> 
>>> This word “reloop” doesn’t exist. I suggest removing this comment unless there’s something clear to say here.
>> 
>> If we do write a comment here, I think the focus of the comment should be on why it’s safe to call putByIndex and why we’re guaranteed this won’t result in an infinite loop.
> 
> Oh, I can see many "Reloop"s in JSObject.cpp[1]...
> In the mean time, I'll drop this comment!
> 
> [1]: http://trac.webkit.org/browser/trunk/Source/JavaScriptCore/runtime/JSObject.cpp

> If we do write a comment here, I think the focus of the comment should be on why it’s safe to call putByIndex and why we’re guaranteed this won’t result in an infinite loop.

OK, I'll add the comment "Convert the indexing type to the SlowPutArrayStorage and retry.", what do you think of?
Comment 9 Yusuke Suzuki 2015-08-11 12:12:14 PDT
Committed r188269: <http://trac.webkit.org/changeset/188269>
Comment 10 Yusuke Suzuki 2015-08-11 12:12:43 PDT
(In reply to comment #8)
> Comment on attachment 258706 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=258706&action=review
> 
> >>>> Source/JavaScriptCore/runtime/JSObject.cpp:2045
> >>>> +            // Reloop.
> >>> 
> >>> This word “reloop” doesn’t exist. I suggest removing this comment unless there’s something clear to say here.
> >> 
> >> If we do write a comment here, I think the focus of the comment should be on why it’s safe to call putByIndex and why we’re guaranteed this won’t result in an infinite loop.
> > 
> > Oh, I can see many "Reloop"s in JSObject.cpp[1]...
> > In the mean time, I'll drop this comment!
> > 
> > [1]: http://trac.webkit.org/browser/trunk/Source/JavaScriptCore/runtime/JSObject.cpp
> 
> > If we do write a comment here, I think the focus of the comment should be on why it’s safe to call putByIndex and why we’re guaranteed this won’t result in an infinite loop.
> 
> OK, I'll add the comment "Convert the indexing type to the
> SlowPutArrayStorage and retry.", what do you think of?

In the meantime, I've added the above comment here.
Comment 11 Ryosuke Niwa 2015-08-11 22:59:59 PDT
Comment on attachment 258706 [details]
Patch

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

> LayoutTests/ChangeLog:8
> +        Update the test expectation file.

Nit: You're updating the expected result, not a test expectation file.
Test expectation files are files such as LayoutTests/TestExpectations that list the expected outcome of each test.
Comment 12 Yusuke Suzuki 2015-08-11 23:46:51 PDT
Comment on attachment 258706 [details]
Patch

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

>> LayoutTests/ChangeLog:8
>> +        Update the test expectation file.
> 
> Nit: You're updating the expected result, not a test expectation file.
> Test expectation files are files such as LayoutTests/TestExpectations that list the expected outcome of each test.

Oh, I see. Thank you for your comment :D