[es6] Fix invalid ToString in implementation of ToName.
authorbmeurer <bmeurer@chromium.org>
Mon, 28 Sep 2015 05:33:55 +0000 (22:33 -0700)
committerCommit bot <commit-bot@chromium.org>
Mon, 28 Sep 2015 05:34:08 +0000 (05:34 +0000)
R=jarin@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#30957}

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/x64/full-codegen-x64.cc
src/objects-inl.h
src/objects.cc
src/objects.h

index 0903d92b44bc18bb15d53cda950e254da6840497..ec4d6d4681e2225a7067bdc68957807e726062c0 100644 (file)
@@ -3804,8 +3804,8 @@ void FullCodeGenerator::EmitToName(CallRuntime* expr) {
   __ CompareObjectType(r0, r1, r1, LAST_NAME_TYPE);
   __ b(ls, &done_convert);
   __ bind(&convert);
-  ToStringStub stub(isolate());
-  __ CallStub(&stub);
+  __ Push(r0);
+  __ CallRuntime(Runtime::kToName, 1);
   __ bind(&done_convert);
   context()->Plug(r0);
 }
index 50cbbcc5175a72c77fda7b09dc194ec0b6034a45..484cf1e8d3e4b62585cb931e74a0bd307091c08e 100644 (file)
@@ -3514,8 +3514,8 @@ void FullCodeGenerator::EmitToName(CallRuntime* expr) {
   STATIC_ASSERT(FIRST_NAME_TYPE == FIRST_TYPE);
   __ JumpIfObjectType(x0, x1, x1, LAST_NAME_TYPE, &done_convert, ls);
   __ Bind(&convert);
-  ToStringStub stub(isolate());
-  __ CallStub(&stub);
+  __ Push(x0);
+  __ CallRuntime(Runtime::kToName, 1);
   __ Bind(&done_convert);
   context()->Plug(x0);
 }
index b792657f29a45c3f46c78db9901f6c2f2ee440e2..50d84d06cf7971b020a9e77ecad2e0a5becab661 100644 (file)
@@ -3704,8 +3704,8 @@ void FullCodeGenerator::EmitToName(CallRuntime* expr) {
   __ CmpObjectType(eax, LAST_NAME_TYPE, ecx);
   __ j(below_equal, &done_convert, Label::kNear);
   __ bind(&convert);
-  ToStringStub stub(isolate());
-  __ CallStub(&stub);
+  __ Push(eax);
+  __ CallRuntime(Runtime::kToName, 1);
   __ bind(&done_convert);
   context()->Plug(eax);
 }
index a6d22581590948dd668e4d269b0af4e0ecfe8ea4..ed599ca6f0981ca2ca5a7be7cdb356a391cd4329 100644 (file)
@@ -3819,9 +3819,8 @@ void FullCodeGenerator::EmitToName(CallRuntime* expr) {
   __ GetObjectType(v0, a1, a1);
   __ Branch(&done_convert, le, a1, Operand(LAST_NAME_TYPE));
   __ bind(&convert);
-  ToStringStub stub(isolate());
-  __ mov(a0, v0);
-  __ CallStub(&stub);
+  __ Push(v0);
+  __ CallRuntime(Runtime::kToName, 1);
   __ bind(&done_convert);
   context()->Plug(v0);
 }
index 59142cc07ced4480aceb5656319556e9726d32cb..fe1d74d8ce17d1ed3e4d6d33dfd2382a45329736 100644 (file)
@@ -3822,9 +3822,8 @@ void FullCodeGenerator::EmitToName(CallRuntime* expr) {
   __ GetObjectType(v0, a1, a1);
   __ Branch(&done_convert, le, a1, Operand(LAST_NAME_TYPE));
   __ bind(&convert);
-  ToStringStub stub(isolate());
-  __ mov(a0, v0);
-  __ CallStub(&stub);
+  __ Push(v0);
+  __ CallRuntime(Runtime::kToName, 1);
   __ bind(&done_convert);
   context()->Plug(v0);
 }
index ee716619d8c6e396903731732a49f9fe45d40588..553e6270386cc003873f54530d11794e2def1587 100644 (file)
@@ -3701,8 +3701,8 @@ void FullCodeGenerator::EmitToName(CallRuntime* expr) {
   __ CmpObjectType(rax, LAST_NAME_TYPE, rcx);
   __ j(below_equal, &done_convert, Label::kNear);
   __ bind(&convert);
-  ToStringStub stub(isolate());
-  __ CallStub(&stub);
+  __ Push(rax);
+  __ CallRuntime(Runtime::kToName, 1);
   __ bind(&done_convert);
   context()->Plug(rax);
 }
index 2efd7ef6597a5e9cb174a9a2301eb6898a3ec28d..3fe65c4c15040dd73f6acad1b66af87c4ec1c9f2 100644 (file)
@@ -1145,13 +1145,6 @@ MaybeHandle<JSReceiver> Object::ToObject(Isolate* isolate,
 }
 
 
-// static
-MaybeHandle<Name> Object::ToName(Isolate* isolate, Handle<Object> input) {
-  if (input->IsName()) return Handle<Name>::cast(input);
-  return ToString(isolate, input);
-}
-
-
 // static
 MaybeHandle<Object> Object::ToPrimitive(Handle<Object> input,
                                         ToPrimitiveHint hint) {
index 02d8d3481f636d0b90702251b59684cde3eb8861..af37cb114d615f7a4a6eb0cd51bce840a9527aa7 100644 (file)
@@ -93,6 +93,16 @@ MaybeHandle<JSReceiver> Object::ToObject(Isolate* isolate,
 }
 
 
+// static
+MaybeHandle<Name> Object::ToName(Isolate* isolate, Handle<Object> input) {
+  ASSIGN_RETURN_ON_EXCEPTION(
+      isolate, input, Object::ToPrimitive(input, ToPrimitiveHint::kString),
+      Name);
+  if (input->IsName()) return Handle<Name>::cast(input);
+  return ToString(isolate, input);
+}
+
+
 // static
 MaybeHandle<Object> Object::ToNumber(Handle<Object> input) {
   while (true) {
index 6838f275b9643089032532046f816e5335797637..5766a8ccfb18b0f89490d14df13a8d6318e6c31e 100644 (file)
@@ -1113,8 +1113,8 @@ class Object {
       Isolate* isolate, Handle<Object> object, Handle<Context> context);
 
   // ES6 section 7.1.14 ToPropertyKey
-  MUST_USE_RESULT static inline MaybeHandle<Name> ToName(Isolate* isolate,
-                                                         Handle<Object> input);
+  MUST_USE_RESULT static MaybeHandle<Name> ToName(Isolate* isolate,
+                                                  Handle<Object> input);
 
   // ES6 section 7.1.1 ToPrimitive
   MUST_USE_RESULT static inline MaybeHandle<Object> ToPrimitive(