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

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

Issue 1818923002: [stubs] Split ToNumberStub into reusable subparts. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE 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 | « src/arm/macro-assembler-arm.cc ('k') | src/arm64/macro-assembler-arm64.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/arm64/code-stubs-arm64.cc
diff --git a/src/arm64/code-stubs-arm64.cc b/src/arm64/code-stubs-arm64.cc
index aab8bfd0e31515b720ee304ce4aed9ac2c767ba6..62ec4857257741c148412f01b93ad9606592ec2f 100644
--- a/src/arm64/code-stubs-arm64.cc
+++ b/src/arm64/code-stubs-arm64.cc
@@ -3262,27 +3262,28 @@ void ToNumberStub::Generate(MacroAssembler* masm) {
__ Bind(&not_smi);
Label not_heap_number;
- __ Ldr(x1, FieldMemOperand(x0, HeapObject::kMapOffset));
- __ Ldrb(x1, FieldMemOperand(x1, Map::kInstanceTypeOffset));
- // x0: object
- // x1: instance type
- __ Cmp(x1, HEAP_NUMBER_TYPE);
+ __ CompareObjectType(x0, x1, x1, HEAP_NUMBER_TYPE);
+ // x0: receiver
+ // x1: receiver instance type
__ B(ne, &not_heap_number);
__ Ret();
__ Bind(&not_heap_number);
- Label not_string, slow_string;
- __ Cmp(x1, FIRST_NONSTRING_TYPE);
+ NonNumberToNumberStub stub(masm->isolate());
+ __ TailCallStub(&stub);
+}
+
+void NonNumberToNumberStub::Generate(MacroAssembler* masm) {
+ // The NonNumberToNumber stub takes one argument in x0.
+ __ AssertNotNumber(x0);
+
+ Label not_string;
+ __ CompareObjectType(x0, x1, x1, FIRST_NONSTRING_TYPE);
+ // x0: receiver
+ // x1: receiver instance type
__ B(hs, &not_string);
- // Check if string has a cached array index.
- __ Ldr(x2, FieldMemOperand(x0, String::kHashFieldOffset));
- __ Tst(x2, Operand(String::kContainsCachedArrayIndexMask));
- __ B(ne, &slow_string);
- __ IndexFromHash(x2, x0);
- __ Ret();
- __ Bind(&slow_string);
- __ Push(x0); // Push argument.
- __ TailCallRuntime(Runtime::kStringToNumber);
+ StringToNumberStub stub(masm->isolate());
+ __ TailCallStub(&stub);
__ Bind(&not_string);
Label not_oddball;
@@ -3296,6 +3297,22 @@ void ToNumberStub::Generate(MacroAssembler* masm) {
__ TailCallRuntime(Runtime::kToNumber);
}
+void StringToNumberStub::Generate(MacroAssembler* masm) {
+ // The StringToNumber stub takes one argument in x0.
+ __ AssertString(x0);
+
+ // Check if string has a cached array index.
+ Label runtime;
+ __ Ldr(x2, FieldMemOperand(x0, String::kHashFieldOffset));
+ __ Tst(x2, Operand(String::kContainsCachedArrayIndexMask));
+ __ B(ne, &runtime);
+ __ IndexFromHash(x2, x0);
+ __ Ret();
+
+ __ Bind(&runtime);
+ __ Push(x0); // Push argument.
+ __ TailCallRuntime(Runtime::kStringToNumber);
+}
void ToLengthStub::Generate(MacroAssembler* masm) {
// The ToLength stub takes one argument in x0.
« no previous file with comments | « src/arm/macro-assembler-arm.cc ('k') | src/arm64/macro-assembler-arm64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698