Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(302)

Issue 6594037: Strict Mode assignment to read only property. (Closed)

Created:
9 years, 9 months ago by Martin Maly
Modified:
9 years, 7 months ago
CC:
v8-dev
Visibility:
Public.

Description

Assignment to read only property. BUG= TEST=test/mjsunit/strict-mode.js I also uploaded this patch to the original CL although bunch of intervening changes make it harder to review. http://codereview.chromium.org/6576024/

Patch Set 1 #

Total comments: 50

Patch Set 2 : CR Feedback. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+955 lines, -523 lines) Patch
M src/api.cc View 1 2 chunks +4 lines, -2 lines 0 comments Download
M src/arm/codegen-arm.cc View 1 12 chunks +31 lines, -12 lines 0 comments Download
M src/arm/full-codegen-arm.cc View 11 chunks +36 lines, -18 lines 0 comments Download
M src/arm/ic-arm.cc View 1 7 chunks +19 lines, -8 lines 0 comments Download
M src/arm/lithium-codegen-arm.cc View 2 chunks +6 lines, -4 lines 0 comments Download
M src/arm/stub-cache-arm.cc View 1 2 chunks +10 lines, -2 lines 0 comments Download
M src/arm/virtual-frame-arm.h View 1 chunk +1 line, -1 line 0 comments Download
M src/arm/virtual-frame-arm.cc View 1 2 chunks +7 lines, -5 lines 0 comments Download
M src/builtins.h View 1 1 chunk +110 lines, -105 lines 0 comments Download
M src/builtins.cc View 3 chunks +15 lines, -5 lines 0 comments Download
M src/debug.cc View 1 chunk +2 lines, -1 line 0 comments Download
M src/handles.h View 2 chunks +6 lines, -3 lines 0 comments Download
M src/handles.cc View 2 chunks +12 lines, -6 lines 0 comments Download
M src/ia32/codegen-ia32.cc View 1 8 chunks +17 lines, -8 lines 0 comments Download
M src/ia32/full-codegen-ia32.cc View 11 chunks +30 lines, -11 lines 0 comments Download
M src/ia32/ic-ia32.cc View 1 7 chunks +17 lines, -10 lines 0 comments Download
M src/ia32/lithium-codegen-ia32.cc View 2 chunks +6 lines, -2 lines 0 comments Download
M src/ia32/stub-cache-ia32.cc View 1 2 chunks +7 lines, -3 lines 0 comments Download
M src/ia32/virtual-frame-ia32.h View 1 chunk +1 line, -1 line 0 comments Download
M src/ia32/virtual-frame-ia32.cc View 1 3 chunks +7 lines, -5 lines 0 comments Download
M src/ic.h View 1 6 chunks +33 lines, -12 lines 0 comments Download
M src/ic.cc View 1 24 chunks +64 lines, -38 lines 0 comments Download
M src/ic-inl.h View 1 chunk +9 lines, -0 lines 0 comments Download
M src/messages.js View 1 1 chunk +2 lines, -0 lines 0 comments Download
M src/objects.h View 2 chunks +8 lines, -4 lines 0 comments Download
M src/objects.cc View 1 9 chunks +30 lines, -11 lines 0 comments Download
M src/objects-inl.h View 2 chunks +4 lines, -2 lines 0 comments Download
M src/parser.cc View 1 chunk +36 lines, -21 lines 0 comments Download
M src/runtime.h View 3 chunks +6 lines, -5 lines 0 comments Download
M src/runtime.cc View 1 27 chunks +101 lines, -37 lines 0 comments Download
M src/stub-cache.h View 5 chunks +21 lines, -12 lines 0 comments Download
M src/stub-cache.cc View 1 14 chunks +46 lines, -32 lines 0 comments Download
M src/x64/codegen-x64.cc View 1 8 chunks +19 lines, -8 lines 0 comments Download
M src/x64/full-codegen-x64.cc View 10 chunks +27 lines, -10 lines 0 comments Download
M src/x64/ic-x64.cc View 1 7 chunks +16 lines, -9 lines 0 comments Download
M src/x64/lithium-codegen-x64.cc View 2 chunks +6 lines, -2 lines 0 comments Download
M src/x64/stub-cache-x64.cc View 1 2 chunks +6 lines, -2 lines 0 comments Download
M src/x64/virtual-frame-x64.h View 1 chunk +1 line, -1 line 0 comments Download
M src/x64/virtual-frame-x64.cc View 1 3 chunks +7 lines, -5 lines 0 comments Download
M test/cctest/test-api.cc View 1 chunk +5 lines, -4 lines 0 comments Download
M test/cctest/test-compiler.cc View 1 chunk +1 line, -1 line 0 comments Download
M test/cctest/test-debug.cc View 1 chunk +2 lines, -1 line 0 comments Download
M test/cctest/test-heap.cc View 10 chunks +38 lines, -25 lines 0 comments Download
M test/cctest/test-mark-compact.cc View 2 chunks +8 lines, -3 lines 0 comments Download
M test/es5conform/es5conform.status View 1 chunk +0 lines, -66 lines 0 comments Download
M test/mjsunit/strict-mode.js View 1 chunk +115 lines, -0 lines 0 comments Download

Messages

Total messages: 5 (0 generated)
Martin Maly
I believe this is now ready for review. Still few todos where I am not ...
9 years, 9 months ago (2011-02-27 23:04:04 UTC) #1
Lasse Reichstein
LGTM http://codereview.chromium.org/6594037/diff/1/src/api.cc File src/api.cc (right): http://codereview.chromium.org/6594037/diff/1/src/api.cc#newcode2290 src/api.cc:2290: i::kNonStrictMode); // TODO(mmaly): v8::Object::Set API. Needs strict? I'd ...
9 years, 9 months ago (2011-02-28 11:18:30 UTC) #2
Vitaly Repeshko
http://codereview.chromium.org/6594037/diff/1/src/ic.h File src/ic.h (right): http://codereview.chromium.org/6594037/diff/1/src/ic.h#newcode436 src/ic.h:436: ASSERT(code->extra_ic_state() == target()->extra_ic_state()); On 2011/02/28 11:18:30, Lasse Reichstein wrote: ...
9 years, 9 months ago (2011-02-28 11:35:05 UTC) #3
Mads Ager (chromium)
Only had a quick look but looks good to me as well. http://codereview.chromium.org/6594037/diff/1/src/builtins.h File src/builtins.h ...
9 years, 9 months ago (2011-02-28 12:23:06 UTC) #4
Martin Maly
9 years, 9 months ago (2011-03-01 01:40:29 UTC) #5
Thanks for the review. I made the changes and am going ahead with the commit.

Thank you!
Martin

http://codereview.chromium.org/6594037/diff/1/src/api.cc
File src/api.cc (right):

http://codereview.chromium.org/6594037/diff/1/src/api.cc#newcode2290
src/api.cc:2290: i::kNonStrictMode);  // TODO(mmaly): v8::Object::Set API. Needs
strict?
On 2011/02/28 11:18:30, Lasse Reichstein wrote:
> I'd say to keep it non-strict. The C++-API isn't part of the language, but is
a
> separate way to work on the JS data. We can reuse the non-strict JS
> functionality for that because it doesn't add restrictions.

Done.

http://codereview.chromium.org/6594037/diff/1/src/builtins.h
File src/builtins.h (right):

http://codereview.chromium.org/6594037/diff/1/src/builtins.h#newcode154
src/builtins.h:154: V(KeyedStoreIC_Initialize_Strict,   KEYED_STORE_IC,
UNINITIALIZED,      \
On 2011/02/28 12:23:06, Mads Ager wrote:
> This is the reason why I don't like indentation like this. Either we should
> indent them all so they align or we should drop the alignment altogether. 

Done.

http://codereview.chromium.org/6594037/diff/1/src/ia32/ic-ia32.cc
File src/ia32/ic-ia32.cc (right):

http://codereview.chromium.org/6594037/diff/1/src/ia32/ic-ia32.cc#newcode1637
src/ia32/ic-ia32.cc:1637: __ TailCallRuntime(Runtime::kSetProperty, 5, 1);
On 2011/02/28 11:18:30, Lasse Reichstein wrote:
> You could combine the values into a "StoreICFlag" encoded value (e.g., using
> BitFields), but this should be fine.

I will keep it as-is for now.

http://codereview.chromium.org/6594037/diff/1/src/ia32/stub-cache-ia32.cc
File src/ia32/stub-cache-ia32.cc (right):

http://codereview.chromium.org/6594037/diff/1/src/ia32/stub-cache-ia32.cc#new...
src/ia32/stub-cache-ia32.cc:2555: __
push(Immediate(Smi::FromInt(strict_mode_)));  // strict mode
On 2011/02/28 11:18:30, Lasse Reichstein wrote:
> Comment isn't necessary here. The variable is self-explanatory :).

Done.

http://codereview.chromium.org/6594037/diff/1/src/ia32/stub-cache-ia32.cc#new...
src/ia32/stub-cache-ia32.cc:3720: : kNonStrictMode)));
On 2011/02/28 11:18:30, Lasse Reichstein wrote:
> Is the conditional necessary here? It seems
> Code::ExtractExtraICStateFromFlags(flags) returns kStrictMode directly (or at
> most something castable to it).


Stritly speaking, the extra state is 2 bits so I think the best thing is to mask
out the strict mode bit and push that directly. Done that.

http://codereview.chromium.org/6594037/diff/1/src/ia32/virtual-frame-ia32.cc
File src/ia32/virtual-frame-ia32.cc (right):

http://codereview.chromium.org/6594037/diff/1/src/ia32/virtual-frame-ia32.cc#...
src/ia32/virtual-frame-ia32.cc:1042: strict_mode == kStrictMode ?
Builtins::StoreIC_Initialize_Strict
On 2011/02/28 11:18:30, Lasse Reichstein wrote:
> Put parentheses around any non-trivial condition of a ?: operator.

Done across the change.

http://codereview.chromium.org/6594037/diff/1/src/ic.cc
File src/ic.cc (right):

http://codereview.chromium.org/6594037/diff/1/src/ic.cc#newcode1485
src/ic.cc:1485: // Strict mode doesn't allow setting non-existent global
property.
On 2011/02/28 12:23:06, Mads Ager wrote:
> Update comment to reflect the read-only part of this code.

Done.

http://codereview.chromium.org/6594037/diff/1/src/ic.cc#newcode1488
src/ic.cc:1488: return TypeError("strict_rdonly_property", object, name);
On 2011/02/28 12:23:06, Mads Ager wrote:
> Please don't abbreviate read to rd.

Done.

http://codereview.chromium.org/6594037/diff/1/src/ic.cc#newcode1947
src/ic.cc:1947: // ASSERT(extra_ic_state == ic.target()->extra_ic_state());
On 2011/02/28 11:18:30, Lasse Reichstein wrote:
> Should be removed before commit.

Done.

http://codereview.chromium.org/6594037/diff/1/src/ic.h
File src/ic.h (right):

http://codereview.chromium.org/6594037/diff/1/src/ic.h#newcode436
src/ic.h:436: ASSERT(code->extra_ic_state() == target()->extra_ic_state());
On 2011/02/28 11:35:05, Vitaly wrote:
> On 2011/02/28 11:18:30, Lasse Reichstein wrote:
> > If the "extra_ic_state" is only strict/non-strict, just call it
> strict_ic_state
> > and return the correct enum value directly. The way you use it seems to
assume
> > that the value is exactly kStrictMode.
> > If we ever need more state, we can add more accessors.
> 
> Please don't kill extra_ic_state. It's also used as an opaque extra state to
> gather more type feedback. But having another accessor that wraps it is a
> probably a good idea. 

I am keeping the extra_ic_state but changing the condition to mask only for the
bit that this code cares about. This leaves the rest of the VM to use the other
bit.

http://codereview.chromium.org/6594037/diff/1/src/runtime.cc
File src/runtime.cc (right):

http://codereview.chromium.org/6594037/diff/1/src/runtime.cc#newcode550
src/runtime.cc:550: // Passing non-strict per Ecma-262 5th Ed. 12.14. Catch,
bullet #4.
On 2011/02/28 11:18:30, Lasse Reichstein wrote:
> Upper-case ECMA.

Done.

http://codereview.chromium.org/6594037/diff/1/src/runtime.cc#newcode1184
src/runtime.cc:1184: // TODO(mmaly): Runtime_DeclareContextSlot. Needs strict
mode?
On 2011/02/28 11:18:30, Lasse Reichstein wrote:
> I don't think the declaration needs it.

Removed comment.

http://codereview.chromium.org/6594037/diff/1/src/runtime.cc#newcode1397
src/runtime.cc:1397: // TODO(mmaly): Strict mode not needed (const disallowed).
On 2011/02/28 11:18:30, Lasse Reichstein wrote:
> Agree. Remove TODOs (but retain rest of comment).

Done.

http://codereview.chromium.org/6594037/diff/1/src/runtime.cc#newcode1680
src/runtime.cc:1680: // No need for strict mode here. Called from SetupArray
(array.js).
On 2011/02/28 11:18:30, Lasse Reichstein wrote:
> Actually, if we make our builtins code strict, we should probably pass true
> here.
> Try using strict, and see if it works anyway.

I am not sure it really matters one way or another. the strict would only result
in an exception if the property already existed and was read only. It won't
affect in any way the attributes of the property or how the function is later
called. strict may be safer because if our initialization code has bugs we get
an exception rather than silently ignoring the assignment.

http://codereview.chromium.org/6594037/diff/1/src/runtime.cc#newcode3808
src/runtime.cc:3808: // TODO(mmaly): Implement SetElement strict mode.
On 2011/02/28 11:18:30, Lasse Reichstein wrote:
> Make an entry in the v8 bug-tracker for the feature and use the issue number
> instead of your name in the TODO.

Done. Issue 1220.

http://codereview.chromium.org/6594037/diff/1/src/x64/ic-x64.cc
File src/x64/ic-x64.cc (right):

http://codereview.chromium.org/6594037/diff/1/src/x64/ic-x64.cc#newcode1597
src/x64/ic-x64.cc:1597: void StoreIC::GenerateGlobalProxy(MacroAssembler* masm,
StrictModeFlag strict) {
On 2011/02/28 11:18:30, Lasse Reichstein wrote:
> Do! :)

Done across the board.

Powered by Google App Engine
This is Rietveld 408576698