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

Issue 6576024: (early draft) Strict mode - throw exception on assignment to read only property. (Closed)

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

Description

Draft of throwing exception in strict mode when assigning to read only property. All StoreICs and KeyedStoreICs propagate strict mode flag (previous change did it only for globals). The flag then flows into IC miss code and into runtime. There are plenty of todos so I am mostly looking for quick feedback on the direction: - Handle strict mode in SetElement (this needs to be done regardless but I believe it can be done safely after all below is handled, in another CL) - Revert Runtime_SetProperty back to 3-4 arguments, merging the strict flag with PropertyAttributes (optional but I'd find it being cleaner - I used adding the extra argument as means to explicitly track down all places where strict flag needs to go. If I modified the enum directly they'd be hard to find). Ultimately the Strict would be similar to ABSENT flag in PropertyAttributes. Never stored but passed around. - figure out global variables and constants. I am unclear about the overall design on const in V8 (it is not part of standard and V8 implements const differently than jsc/firefox). Lots of TODOs there. - Handle all special cases of StoreIC and KeyedStoreIC to correctly propagate strict mode (or disable the particular specialization in strict mode) BUG= TEST=

Patch Set 1 #

Total comments: 14

Patch Set 2 : Assign to read only property in strict mode. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+864 lines, -423 lines) Patch
M src/api.cc View 2 chunks +4 lines, -2 lines 0 comments Download
M src/arm/codegen-arm.cc View 1 12 chunks +25 lines, -12 lines 0 comments Download
M src/arm/full-codegen-arm.cc View 1 11 chunks +36 lines, -18 lines 0 comments Download
M src/arm/ic-arm.cc View 1 7 chunks +18 lines, -8 lines 0 comments Download
M src/arm/lithium-codegen-arm.cc View 1 2 chunks +6 lines, -4 lines 0 comments Download
M src/arm/stub-cache-arm.cc View 1 2 chunks +12 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 2 chunks +7 lines, -5 lines 0 comments Download
M src/builtins.h View 1 chunk +10 lines, -5 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 1 2 chunks +6 lines, -3 lines 0 comments Download
M src/handles.cc View 1 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 1 11 chunks +30 lines, -11 lines 0 comments Download
M src/ia32/ic-ia32.cc View 1 7 chunks +16 lines, -10 lines 0 comments Download
M src/ia32/lithium-codegen-ia32.cc View 1 2 chunks +6 lines, -2 lines 0 comments Download
M src/ia32/stub-cache-ia32.cc View 1 2 chunks +9 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 3 chunks +7 lines, -5 lines 0 comments Download
M src/ic.h View 1 6 chunks +28 lines, -12 lines 0 comments Download
M src/ic.cc View 1 24 chunks +81 lines, -38 lines 0 comments Download
M src/ic-inl.h View 1 1 chunk +9 lines, -0 lines 0 comments Download
M src/messages.js View 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 1 2 chunks +4 lines, -2 lines 0 comments Download
M src/parser.cc View 1 1 chunk +36 lines, -21 lines 0 comments Download
M src/runtime.h View 1 3 chunks +6 lines, -5 lines 0 comments Download
M src/runtime.cc View 1 26 chunks +103 lines, -36 lines 0 comments Download
M src/stub-cache.h View 1 5 chunks +21 lines, -12 lines 0 comments Download
M src/stub-cache.cc View 1 15 chunks +47 lines, -33 lines 0 comments Download
M src/x64/codegen-x64.cc View 1 8 chunks +16 lines, -8 lines 0 comments Download
M src/x64/full-codegen-x64.cc View 1 10 chunks +27 lines, -10 lines 0 comments Download
M src/x64/ic-x64.cc View 1 7 chunks +15 lines, -9 lines 0 comments Download
M src/x64/lithium-codegen-x64.cc View 1 2 chunks +6 lines, -2 lines 0 comments Download
M src/x64/stub-cache-x64.cc View 1 2 chunks +8 lines, -2 lines 0 comments Download
M src/x64/virtual-frame-x64.h View 1 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 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 1 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 1 chunk +115 lines, -0 lines 0 comments Download

Messages

Total messages: 3 (0 generated)
Martin Maly
early draft... http://codereview.chromium.org/6576024/diff/1/src/arm/ic-arm.cc File src/arm/ic-arm.cc (right): http://codereview.chromium.org/6576024/diff/1/src/arm/ic-arm.cc#newcode1418 src/arm/ic-arm.cc:1418: Once I merge strict flag into PropertyAttributes ...
9 years, 10 months ago (2011-02-24 06:33:34 UTC) #1
Mark Miller
> - figure out global variables and constants. I am unclear > about the overall ...
9 years, 10 months ago (2011-02-24 06:58:12 UTC) #2
Lasse Reichstein
9 years, 10 months ago (2011-02-24 12:37:54 UTC) #3
I think fixing elements in a separate CL is a good idea.

As for const, I'm not too sure what our implementation is either. It *should* be
a read-only variable, except that it can be overwritten by the first execution
of the assignment in the declaration. I think we have a runtime call for that
assignment, so all normal stores should just fail. I think we store "the hole"
in the variable until the first initialization.

If possible, we should not disable any optimizations in strict mode. We do want
people to use strict mode for their code (if nothing else, to encourage them to
avoid using with and leaky eval).

I've only given this a quick look, but it seems fine so far.

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

http://codereview.chromium.org/6576024/diff/1/src/arm/ic-arm.cc#newcode1418
src/arm/ic-arm.cc:1418: 
While I appreciate saving a parameter, beging strict seems a property of the
assigning code, not the property.
At least, call the parameter something else, like assignmentFlags (which
includes PropertyAttributes and strict-mode flag).

http://codereview.chromium.org/6576024/diff/1/src/debug.cc
File src/debug.cc (right):

http://codereview.chromium.org/6576024/diff/1/src/debug.cc#newcode841
src/debug.cc:841: false);
I agree.

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

http://codereview.chromium.org/6576024/diff/1/src/stub-cache.cc#newcode1428
src/stub-cache.cc:1428: MaybeObject* result = recv->SetPropertyWithInterceptor(
I'm guessing "yes" too.

http://codereview.chromium.org/6576024/diff/1/src/stub-cache.h
File src/stub-cache.h (right):

http://codereview.chromium.org/6576024/diff/1/src/stub-cache.h#newcode185
src/stub-cache.h:185: Code::ExtraICState extra_ic_state);
Agree. If the extra IC state is just the one bit, just use the original bit for
it.

http://codereview.chromium.org/6576024/diff/1/test/es5conform/es5conform.status
File test/es5conform/es5conform.status (right):

http://codereview.chromium.org/6576024/diff/1/test/es5conform/es5conform.stat...
test/es5conform/es5conform.status:266: # in strict mode (Global.Infinity)
Good choice. If the Sputnik tests fail, just disable them. I welcome not being
able to overwrite (at least some) basic language features.

Powered by Google App Engine
This is Rietveld 408576698