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

Unified Diff: src/ppc/code-stubs-ppc.cc

Issue 1826483002: PPC: [stubs] Split ToNumberStub into reusable subparts. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/ppc/macro-assembler-ppc.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ppc/code-stubs-ppc.cc
diff --git a/src/ppc/code-stubs-ppc.cc b/src/ppc/code-stubs-ppc.cc
index 54c611dcd937be718ad6a82c5594070ff6c8c428..f14f54d266529f02c7a53811660ec03a714460c5 100644
--- a/src/ppc/code-stubs-ppc.cc
+++ b/src/ppc/code-stubs-ppc.cc
@@ -2698,29 +2698,28 @@ void SubStringStub::Generate(MacroAssembler* masm) {
void ToNumberStub::Generate(MacroAssembler* masm) {
// The ToNumber stub takes one argument in r3.
- Label not_smi;
- __ JumpIfNotSmi(r3, &not_smi);
- __ blr();
- __ bind(&not_smi);
+ STATIC_ASSERT(kSmiTag == 0);
+ __ TestIfSmi(r3, r0);
+ __ Ret(eq, cr0);
__ CompareObjectType(r3, r4, r4, HEAP_NUMBER_TYPE);
// r3: receiver
// r4: receiver instance type
__ Ret(eq);
- Label not_string, slow_string;
- __ cmpli(r4, Operand(FIRST_NONSTRING_TYPE));
- __ bge(&not_string);
- // Check if string has a cached array index.
- __ lwz(r5, FieldMemOperand(r3, String::kHashFieldOffset));
- __ And(r0, r5, Operand(String::kContainsCachedArrayIndexMask), SetRC);
- __ bne(&slow_string, cr0);
- __ IndexFromHash(r5, r3);
- __ blr();
- __ bind(&slow_string);
- __ push(r3); // Push argument.
- __ TailCallRuntime(Runtime::kStringToNumber);
- __ bind(&not_string);
+ NonNumberToNumberStub stub(masm->isolate());
+ __ TailCallStub(&stub);
+}
+
+void NonNumberToNumberStub::Generate(MacroAssembler* masm) {
+ // The NonNumberToNumber stub takes one argument in r3.
+ __ AssertNotNumber(r3);
+
+ __ CompareObjectType(r3, r4, r4, FIRST_NONSTRING_TYPE);
+ // r3: receiver
+ // r4: receiver instance type
+ StringToNumberStub stub(masm->isolate());
+ __ TailCallStub(&stub, lt);
Label not_oddball;
__ cmpi(r4, Operand(ODDBALL_TYPE));
@@ -2733,6 +2732,22 @@ void ToNumberStub::Generate(MacroAssembler* masm) {
__ TailCallRuntime(Runtime::kToNumber);
}
+void StringToNumberStub::Generate(MacroAssembler* masm) {
+ // The StringToNumber stub takes one argument in r3.
+ __ AssertString(r3);
+
+ // Check if string has a cached array index.
+ Label runtime;
+ __ lwz(r5, FieldMemOperand(r3, String::kHashFieldOffset));
+ __ And(r0, r5, Operand(String::kContainsCachedArrayIndexMask), SetRC);
+ __ bne(&runtime, cr0);
+ __ IndexFromHash(r5, r3);
+ __ blr();
+
+ __ bind(&runtime);
+ __ push(r3); // Push argument.
+ __ TailCallRuntime(Runtime::kStringToNumber);
+}
void ToLengthStub::Generate(MacroAssembler* masm) {
// The ToLength stub takes one argument in r3.
« no previous file with comments | « no previous file | src/ppc/macro-assembler-ppc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698