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

Side by Side Diff: src/arm64/code-stubs-arm64.cc

Issue 1347913003: [stubs] Refactor StringCompareStub and use it for HStringCompareAndBranch. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 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 unified diff | Download patch
« no previous file with comments | « src/arm/lithium-codegen-arm.cc ('k') | src/arm64/interface-descriptors-arm64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #if V8_TARGET_ARCH_ARM64 5 #if V8_TARGET_ARCH_ARM64
6 6
7 #include "src/bootstrapper.h" 7 #include "src/bootstrapper.h"
8 #include "src/code-stubs.h" 8 #include "src/code-stubs.h"
9 #include "src/codegen.h" 9 #include "src/codegen.h"
10 #include "src/ic/handler-compiler.h" 10 #include "src/ic/handler-compiler.h"
(...skipping 4024 matching lines...) Expand 10 before | Expand all | Expand 10 after
4035 __ Ldrb(scratch1, MemOperand(left, index)); 4035 __ Ldrb(scratch1, MemOperand(left, index));
4036 __ Ldrb(scratch2, MemOperand(right, index)); 4036 __ Ldrb(scratch2, MemOperand(right, index));
4037 __ Cmp(scratch1, scratch2); 4037 __ Cmp(scratch1, scratch2);
4038 __ B(ne, chars_not_equal); 4038 __ B(ne, chars_not_equal);
4039 __ Add(index, index, 1); 4039 __ Add(index, index, 1);
4040 __ Cbnz(index, &loop); 4040 __ Cbnz(index, &loop);
4041 } 4041 }
4042 4042
4043 4043
4044 void StringCompareStub::Generate(MacroAssembler* masm) { 4044 void StringCompareStub::Generate(MacroAssembler* masm) {
4045 Label runtime; 4045 // ----------- S t a t e -------------
4046 4046 // -- x1 : left
4047 Counters* counters = isolate()->counters(); 4047 // -- x0 : right
4048 4048 // -- lr : return address
4049 // Stack frame on entry. 4049 // -----------------------------------
4050 // sp[0]: right string 4050 __ AssertString(x1);
4051 // sp[8]: left string 4051 __ AssertString(x0);
4052 Register right = x10;
4053 Register left = x11;
4054 Register result = x0;
4055 __ Pop(right, left);
4056 4052
4057 Label not_same; 4053 Label not_same;
4058 __ Subs(result, right, left); 4054 __ Cmp(x0, x1);
4059 __ B(ne, &not_same); 4055 __ B(ne, &not_same);
4060 STATIC_ASSERT(EQUAL == 0); 4056 __ Mov(x0, Smi::FromInt(EQUAL));
4061 __ IncrementCounter(counters->string_compare_native(), 1, x3, x4); 4057 __ IncrementCounter(isolate()->counters()->string_compare_native(), 1, x3,
4058 x4);
4062 __ Ret(); 4059 __ Ret();
4063 4060
4064 __ Bind(&not_same); 4061 __ Bind(&not_same);
4065 4062
4066 // Check that both objects are sequential one-byte strings. 4063 // Check that both objects are sequential one-byte strings.
4067 __ JumpIfEitherIsNotSequentialOneByteStrings(left, right, x12, x13, &runtime); 4064 Label runtime;
4065 __ JumpIfEitherIsNotSequentialOneByteStrings(x1, x0, x12, x13, &runtime);
4068 4066
4069 // Compare flat one-byte strings natively. Remove arguments from stack first, 4067 // Compare flat one-byte strings natively.
4070 // as this function will generate a return. 4068 __ IncrementCounter(isolate()->counters()->string_compare_native(), 1, x3,
4071 __ IncrementCounter(counters->string_compare_native(), 1, x3, x4); 4069 x4);
4072 StringHelper::GenerateCompareFlatOneByteStrings(masm, left, right, x12, x13, 4070 StringHelper::GenerateCompareFlatOneByteStrings(masm, x1, x0, x12, x13, x14,
4073 x14, x15); 4071 x15);
4074
4075 __ Bind(&runtime);
4076
4077 // Push arguments back on to the stack.
4078 // sp[0] = right string
4079 // sp[8] = left string.
4080 __ Push(left, right);
4081 4072
4082 // Call the runtime. 4073 // Call the runtime.
4083 // Returns -1 (less), 0 (equal), or 1 (greater) tagged as a small integer. 4074 // Returns -1 (less), 0 (equal), or 1 (greater) tagged as a small integer.
4075 __ Bind(&runtime);
4076 __ Push(x1, x0);
4084 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); 4077 __ TailCallRuntime(Runtime::kStringCompare, 2, 1);
4085 } 4078 }
4086 4079
4087 4080
4088 void BinaryOpICWithAllocationSiteStub::Generate(MacroAssembler* masm) { 4081 void BinaryOpICWithAllocationSiteStub::Generate(MacroAssembler* masm) {
4089 // ----------- S t a t e ------------- 4082 // ----------- S t a t e -------------
4090 // -- x1 : left 4083 // -- x1 : left
4091 // -- x0 : right 4084 // -- x0 : right
4092 // -- lr : return address 4085 // -- lr : return address
4093 // ----------------------------------- 4086 // -----------------------------------
(...skipping 1890 matching lines...) Expand 10 before | Expand all | Expand 10 after
5984 MemOperand(fp, 6 * kPointerSize), NULL); 5977 MemOperand(fp, 6 * kPointerSize), NULL);
5985 } 5978 }
5986 5979
5987 5980
5988 #undef __ 5981 #undef __
5989 5982
5990 } // namespace internal 5983 } // namespace internal
5991 } // namespace v8 5984 } // namespace v8
5992 5985
5993 #endif // V8_TARGET_ARCH_ARM64 5986 #endif // V8_TARGET_ARCH_ARM64
OLDNEW
« no previous file with comments | « src/arm/lithium-codegen-arm.cc ('k') | src/arm64/interface-descriptors-arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698