Index: src/s390/code-stubs-s390.cc |
diff --git a/src/s390/code-stubs-s390.cc b/src/s390/code-stubs-s390.cc |
index 95eaec12443cb239c9da224c51561608cee8c4ee..177505fb16b83bbbaa7e5f94d978a998820c109a 100644 |
--- a/src/s390/code-stubs-s390.cc |
+++ b/src/s390/code-stubs-s390.cc |
@@ -2712,10 +2712,9 @@ void SubStringStub::Generate(MacroAssembler* masm) { |
void ToNumberStub::Generate(MacroAssembler* masm) { |
// The ToNumber stub takes one argument in r2. |
- Label not_smi; |
- __ JumpIfNotSmi(r2, ¬_smi); |
- __ b(r14); |
- __ bind(¬_smi); |
+ STATIC_ASSERT(kSmiTag == 0); |
+ __ TestIfSmi(r2); |
+ __ Ret(eq); |
__ CompareObjectType(r2, r3, r3, HEAP_NUMBER_TYPE); |
// r2: receiver |
@@ -2725,19 +2724,19 @@ void ToNumberStub::Generate(MacroAssembler* masm) { |
__ Ret(); |
__ bind(¬_heap_number); |
- Label not_string, slow_string; |
- __ CmpLogicalP(r3, Operand(FIRST_NONSTRING_TYPE)); |
- __ bge(¬_string, Label::kNear); |
- // Check if string has a cached array index. |
- __ LoadlW(r4, FieldMemOperand(r2, String::kHashFieldOffset)); |
- __ AndP(r0, r4, Operand(String::kContainsCachedArrayIndexMask)); |
- __ bne(&slow_string, Label::kNear); |
- __ IndexFromHash(r4, r2); |
- __ b(r14); |
- __ bind(&slow_string); |
- __ push(r2); // Push argument. |
- __ TailCallRuntime(Runtime::kStringToNumber); |
- __ bind(¬_string); |
+ NonNumberToNumberStub stub(masm->isolate()); |
+ __ TailCallStub(&stub); |
+} |
+ |
+void NonNumberToNumberStub::Generate(MacroAssembler* masm) { |
+ // The NonNumberToNumber stub takes one argument in r2. |
+ __ AssertNotNumber(r2); |
+ |
+ __ CompareObjectType(r2, r3, r3, FIRST_NONSTRING_TYPE); |
+ // r2: receiver |
+ // r3: receiver instance type |
+ StringToNumberStub stub(masm->isolate()); |
+ __ TailCallStub(&stub, lt); |
Label not_oddball; |
__ CmpP(r3, Operand(ODDBALL_TYPE)); |
@@ -2750,6 +2749,23 @@ void ToNumberStub::Generate(MacroAssembler* masm) { |
__ TailCallRuntime(Runtime::kToNumber); |
} |
+void StringToNumberStub::Generate(MacroAssembler* masm) { |
+ // The StringToNumber stub takes one argument in r2. |
+ __ AssertString(r2); |
+ |
+ // Check if string has a cached array index. |
+ Label runtime; |
+ __ LoadlW(r4, FieldMemOperand(r2, String::kHashFieldOffset)); |
+ __ And(r0, r4, Operand(String::kContainsCachedArrayIndexMask)); |
+ __ bne(&runtime); |
+ __ IndexFromHash(r4, r2); |
+ __ Ret(); |
+ |
+ __ bind(&runtime); |
+ __ push(r2); // Push argument. |
+ __ TailCallRuntime(Runtime::kStringToNumber); |
+} |
+ |
void ToLengthStub::Generate(MacroAssembler* masm) { |
// The ToLength stub takes one argument in r2. |
Label not_smi; |