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

Issue 12957004: ES6 symbols: turn symbols into a proper primitive type (Closed)

Created:
7 years, 9 months ago by rossberg
Modified:
7 years, 9 months ago
Reviewers:
Michael Starzinger
CC:
v8-dev
Visibility:
Public.

Description

ES6 symbols: turn symbols into a proper primitive type (qua last week's TC39) Specifically: - Install Symbol constructor function on the global object. - Adjust code generation for typeof. - Remove IsSymbol built-in, IS_SYMBOL macro now defined using typeof. - Remove hack that allowed symbols as constructor results, and some other special cases. - Remove symbol_delegate and GetDelegate function. - Extend ToBoolean stub to handle symbols. - Extend ToNumber to return NaN on symbols. - Poison symbol's toString function, and thereby ToString on symbols. R=mstarzinger@chromium.org BUG=v8:2158 Committed: http://code.google.com/p/v8/source/detail?r=14051

Patch Set 1 #

Total comments: 8

Patch Set 2 : Addressed comments #

Unified diffs Side-by-side diffs Delta from patch set Stats (+222 lines, -208 lines) Patch
M include/v8.h View 1 chunk +1 line, -1 line 0 comments Download
M src/api.cc View 1 chunk +1 line, -1 line 0 comments Download
M src/arm/builtins-arm.cc View 1 chunk +0 lines, -4 lines 0 comments Download
M src/arm/full-codegen-arm.cc View 3 chunks +4 lines, -26 lines 0 comments Download
M src/arm/lithium-codegen-arm.cc View 3 chunks +13 lines, -9 lines 0 comments Download
M src/bootstrapper.cc View 1 2 chunks +11 lines, -4 lines 0 comments Download
M src/code-stubs.h View 1 chunk +1 line, -0 lines 0 comments Download
M src/code-stubs.cc View 3 chunks +5 lines, -0 lines 0 comments Download
M src/contexts.h View 1 4 chunks +2 lines, -2 lines 0 comments Download
M src/d8.js View 1 1 chunk +2 lines, -1 line 0 comments Download
M src/heap.h View 1 chunk +2 lines, -0 lines 0 comments Download
M src/hydrogen.cc View 2 chunks +1 line, -23 lines 0 comments Download
M src/hydrogen-instructions.cc View 1 chunk +2 lines, -1 line 0 comments Download
M src/ia32/builtins-ia32.cc View 1 chunk +0 lines, -4 lines 0 comments Download
M src/ia32/code-stubs-ia32.cc View 1 chunk +8 lines, -0 lines 0 comments Download
M src/ia32/full-codegen-ia32.cc View 4 chunks +4 lines, -27 lines 0 comments Download
M src/ia32/lithium-codegen-ia32.cc View 3 chunks +12 lines, -7 lines 0 comments Download
M src/ic.cc View 1 chunk +1 line, -1 line 0 comments Download
M src/ic-inl.h View 3 chunks +4 lines, -3 lines 0 comments Download
M src/macros.py View 2 chunks +2 lines, -1 line 0 comments Download
M src/messages.js View 1 1 chunk +1 line, -0 lines 0 comments Download
M src/objects.h View 1 chunk +0 lines, -3 lines 0 comments Download
M src/objects.cc View 5 chunks +8 lines, -15 lines 0 comments Download
M src/runtime.h View 1 chunk +0 lines, -1 line 0 comments Download
M src/runtime.cc View 1 chunk +2 lines, -0 lines 0 comments Download
M src/runtime.js View 3 chunks +3 lines, -0 lines 0 comments Download
M src/symbol.js View 1 1 chunk +38 lines, -7 lines 0 comments Download
M src/type-info.cc View 1 chunk +3 lines, -2 lines 0 comments Download
M src/v8globals.h View 1 chunk +1 line, -1 line 0 comments Download
M src/v8natives.js View 1 2 chunks +1 line, -2 lines 0 comments Download
M src/x64/builtins-x64.cc View 1 chunk +0 lines, -4 lines 0 comments Download
M src/x64/full-codegen-x64.cc View 3 chunks +4 lines, -26 lines 0 comments Download
M src/x64/lithium-codegen-x64.cc View 2 chunks +6 lines, -7 lines 0 comments Download
M test/mjsunit/harmony/symbols.js View 1 6 chunks +79 lines, -25 lines 0 comments Download

Messages

Total messages: 3 (0 generated)
rossberg
7 years, 9 months ago (2013-03-20 16:06:56 UTC) #1
Michael Starzinger
LGTM if comments are addressed. https://codereview.chromium.org/12957004/diff/1/src/bootstrapper.cc File src/bootstrapper.cc (right): https://codereview.chromium.org/12957004/diff/1/src/bootstrapper.cc#newcode1288 src/bootstrapper.cc:1288: factory()->NewJSObject(isolate()->object_function(), TENURED); This creates ...
7 years, 9 months ago (2013-03-22 11:39:04 UTC) #2
rossberg
7 years, 9 months ago (2013-03-22 12:37:44 UTC) #3
https://codereview.chromium.org/12957004/diff/1/src/bootstrapper.cc
File src/bootstrapper.cc (right):

https://codereview.chromium.org/12957004/diff/1/src/bootstrapper.cc#newcode1288
src/bootstrapper.cc:1288: factory()->NewJSObject(isolate()->object_function(),
TENURED);
On 2013/03/22 11:39:04, Michael Starzinger wrote:
> This creates a new object for the prototype of the Symbol function. Is this
> intended? I think it should be isolate->initial_object_prototype() instead. It
> might make sense to add test coverage for that.

Done.

https://codereview.chromium.org/12957004/diff/1/src/contexts.h
File src/contexts.h (right):

https://codereview.chromium.org/12957004/diff/1/src/contexts.h#newcode291
src/contexts.h:291: SYMBOL_DELEGATE_INDEX,
On 2013/03/22 11:39:04, Michael Starzinger wrote:
> Is this index still used? If not, let's drop it.

Good catch, done.

https://codereview.chromium.org/12957004/diff/1/src/symbol.js
File src/symbol.js (right):

https://codereview.chromium.org/12957004/diff/1/src/symbol.js#newcode42
src/symbol.js:42: throw new $TypeError("Symbol.prototype.toString is not
allowed");
On 2013/03/22 11:39:04, Michael Starzinger wrote:
> See comments below about MakeTypeError, maybe you can find a message that
suits
> this error or you might have to add a new one.

Done.

https://codereview.chromium.org/12957004/diff/1/src/symbol.js#newcode49
src/symbol.js:49: throw new $TypeError("Symbol.prototype.valueOf is not
generic");
On 2013/03/22 11:39:04, Michael Starzinger wrote:
> Use the following to generate the TypeError instead. This allows us to have
one
> single choke-point where all error objects and messages are generated.
> 
> throw MakeTypeError('incompatible_method_receiver',
>                     ['Symbol.prototype.valueOf', this]);

Done.

Powered by Google App Engine
This is Rietveld 408576698