[es6] Implement spec compliant ToPrimitive in the runtime.
authorbmeurer <bmeurer@chromium.org>
Fri, 28 Aug 2015 09:21:23 +0000 (02:21 -0700)
committerCommit bot <commit-bot@chromium.org>
Fri, 28 Aug 2015 09:21:43 +0000 (09:21 +0000)
commitf6c6d713b4a1bb94457571f9e627ce2dea531b68
tree5a80032e9f681eeb9710e74380a57fc2dcf52cfb
parentbe8564ba43bc3581ba7f4c3a07416e9ff4499404
[es6] Implement spec compliant ToPrimitive in the runtime.

This is the first step towards a spec compliant ToPrimitive
implementation (and therefore spec compliant ToNumber, ToString,
ToName, and friends).  It adds support for the @@toPrimitive
symbol that was introduced with ES2015, and also adds the new
Symbol.prototype[@@toPrimitive] and Date.prototype[@@toPrimitive]
initial properties.

There are now runtime functions for %ToPrimitive, %ToNumber and
%ToString, which do the right thing and should be used as fallbacks
instead of the hairy runtime.js implementations.  I will do the
same for the other conversion operations mentioned by the spec in
follow up CLs.  Once everything is in place we can look into
optimizing things further, so that we don't always call into the
runtime.

Also fixed Date.prototype.toJSON to be spec compliant.

R=mstarzinger@chromium.org, yangguo@chromium.org
BUG=v8:4307
LOG=y

Review URL: https://codereview.chromium.org/1306303003

Cr-Commit-Position: refs/heads/master@{#30434}
42 files changed:
src/accessors.cc
src/api.cc
src/arm/code-stubs-arm.cc
src/arm64/code-stubs-arm64.cc
src/compiler/linkage.cc
src/contexts.h
src/date.js
src/debug/debug.cc
src/execution.cc
src/execution.h
src/full-codegen/arm/full-codegen-arm.cc
src/full-codegen/arm64/full-codegen-arm64.cc
src/full-codegen/ia32/full-codegen-ia32.cc
src/full-codegen/mips/full-codegen-mips.cc
src/full-codegen/mips64/full-codegen-mips64.cc
src/full-codegen/ppc/full-codegen-ppc.cc
src/full-codegen/x64/full-codegen-x64.cc
src/full-codegen/x87/full-codegen-x87.cc
src/heap/heap.h
src/ia32/code-stubs-ia32.cc
src/json-stringifier.h
src/macros.py
src/messages.cc
src/messages.h
src/mips/code-stubs-mips.cc
src/mips64/code-stubs-mips64.cc
src/objects-inl.h
src/objects.cc
src/objects.h
src/ppc/code-stubs-ppc.cc
src/runtime.js
src/runtime/runtime-i18n.cc
src/runtime/runtime-numbers.cc
src/runtime/runtime-object.cc
src/runtime/runtime-scopes.cc
src/runtime/runtime.h
src/symbol.js
src/x64/code-stubs-x64.cc
src/x87/code-stubs-x87.cc
test/cctest/test-heap.cc
test/mjsunit/harmony/to-number.js [new file with mode: 0644]
test/mjsunit/harmony/to-primitive.js [new file with mode: 0644]