Index: src/arm/code-stubs-arm.cc |
diff --git a/src/arm/code-stubs-arm.cc b/src/arm/code-stubs-arm.cc |
index 695bf33dc95637dc20f4ce02c78300c8143d1402..f2828870997759f776d76b73cafb93af3e25804a 100644 |
--- a/src/arm/code-stubs-arm.cc |
+++ b/src/arm/code-stubs-arm.cc |
@@ -3232,15 +3232,10 @@ void ToNumberStub::Generate(MacroAssembler* masm) { |
__ Ret(); |
__ bind(¬_smi); |
- Label not_heap_number; |
- __ ldr(r1, FieldMemOperand(r0, HeapObject::kMapOffset)); |
- __ ldrb(r1, FieldMemOperand(r1, Map::kInstanceTypeOffset)); |
- // r0: object |
- // r1: instance type. |
- __ cmp(r1, Operand(HEAP_NUMBER_TYPE)); |
- __ b(ne, ¬_heap_number); |
- __ Ret(); |
- __ bind(¬_heap_number); |
+ __ CompareObjectType(r0, r1, r1, HEAP_NUMBER_TYPE); |
+ // r0: receiver |
+ // r1: receiver instance type |
+ __ Ret(eq); |
Label not_string, slow_string; |
__ cmp(r1, Operand(FIRST_NONSTRING_TYPE)); |
@@ -3268,6 +3263,36 @@ void ToNumberStub::Generate(MacroAssembler* masm) { |
} |
+void ToStringStub::Generate(MacroAssembler* masm) { |
+ // The ToString stub takes one argument in r0. |
+ Label is_number; |
+ __ JumpIfSmi(r0, &is_number); |
+ |
+ __ CompareObjectType(r0, r1, r1, FIRST_NONSTRING_TYPE); |
+ // r0: receiver |
+ // r1: receiver instance type |
+ __ Ret(lo); |
+ |
+ Label not_heap_number; |
+ __ cmp(r1, Operand(HEAP_NUMBER_TYPE)); |
+ __ b(ne, ¬_heap_number); |
+ __ bind(&is_number); |
+ NumberToStringStub stub(isolate()); |
+ __ TailCallStub(&stub); |
+ __ bind(¬_heap_number); |
+ |
+ Label not_oddball; |
+ __ cmp(r1, Operand(ODDBALL_TYPE)); |
+ __ b(ne, ¬_oddball); |
+ __ ldr(r0, FieldMemOperand(r0, Oddball::kToStringOffset)); |
+ __ Ret(); |
+ __ bind(¬_oddball); |
+ |
+ __ push(r0); // Push argument. |
+ __ TailCallRuntime(Runtime::kToString, 1, 1); |
+} |
+ |
+ |
void StringHelper::GenerateFlatOneByteStringEquals( |
MacroAssembler* masm, Register left, Register right, Register scratch1, |
Register scratch2, Register scratch3) { |