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

Side by Side Diff: src/arm/code-stubs-arm.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 | « no previous file | src/arm/interface-descriptors-arm.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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_ARM 5 #if V8_TARGET_ARCH_ARM
6 6
7 #include "src/base/bits.h" 7 #include "src/base/bits.h"
8 #include "src/bootstrapper.h" 8 #include "src/bootstrapper.h"
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 3301 matching lines...) Expand 10 before | Expand all | Expand 10 after
3312 __ ldrb(scratch1, MemOperand(left, index)); 3312 __ ldrb(scratch1, MemOperand(left, index));
3313 __ ldrb(scratch2, MemOperand(right, index)); 3313 __ ldrb(scratch2, MemOperand(right, index));
3314 __ cmp(scratch1, scratch2); 3314 __ cmp(scratch1, scratch2);
3315 __ b(ne, chars_not_equal); 3315 __ b(ne, chars_not_equal);
3316 __ add(index, index, Operand(1), SetCC); 3316 __ add(index, index, Operand(1), SetCC);
3317 __ b(ne, &loop); 3317 __ b(ne, &loop);
3318 } 3318 }
3319 3319
3320 3320
3321 void StringCompareStub::Generate(MacroAssembler* masm) { 3321 void StringCompareStub::Generate(MacroAssembler* masm) {
3322 Label runtime; 3322 // ----------- S t a t e -------------
3323 3323 // -- r1 : left
3324 Counters* counters = isolate()->counters(); 3324 // -- r0 : right
3325 3325 // -- lr : return address
3326 // Stack frame on entry. 3326 // -----------------------------------
3327 // sp[0]: right string 3327 __ AssertString(r1);
3328 // sp[4]: left string 3328 __ AssertString(r0);
3329 __ Ldrd(r0 , r1, MemOperand(sp)); // Load right in r0, left in r1.
3330 3329
3331 Label not_same; 3330 Label not_same;
3332 __ cmp(r0, r1); 3331 __ cmp(r0, r1);
3333 __ b(ne, &not_same); 3332 __ b(ne, &not_same);
3334 STATIC_ASSERT(EQUAL == 0);
3335 STATIC_ASSERT(kSmiTag == 0);
3336 __ mov(r0, Operand(Smi::FromInt(EQUAL))); 3333 __ mov(r0, Operand(Smi::FromInt(EQUAL)));
3337 __ IncrementCounter(counters->string_compare_native(), 1, r1, r2); 3334 __ IncrementCounter(isolate()->counters()->string_compare_native(), 1, r1,
3338 __ add(sp, sp, Operand(2 * kPointerSize)); 3335 r2);
3339 __ Ret(); 3336 __ Ret();
3340 3337
3341 __ bind(&not_same); 3338 __ bind(&not_same);
3342 3339
3343 // Check that both objects are sequential one-byte strings. 3340 // Check that both objects are sequential one-byte strings.
3341 Label runtime;
3344 __ JumpIfNotBothSequentialOneByteStrings(r1, r0, r2, r3, &runtime); 3342 __ JumpIfNotBothSequentialOneByteStrings(r1, r0, r2, r3, &runtime);
3345 3343
3346 // Compare flat one-byte strings natively. Remove arguments from stack first. 3344 // Compare flat one-byte strings natively.
3347 __ IncrementCounter(counters->string_compare_native(), 1, r2, r3); 3345 __ IncrementCounter(isolate()->counters()->string_compare_native(), 1, r2,
3348 __ add(sp, sp, Operand(2 * kPointerSize)); 3346 r3);
3349 StringHelper::GenerateCompareFlatOneByteStrings(masm, r1, r0, r2, r3, r4, r5); 3347 StringHelper::GenerateCompareFlatOneByteStrings(masm, r1, r0, r2, r3, r4, r5);
3350 3348
3351 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) 3349 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater)
3352 // tagged as a small integer. 3350 // tagged as a small integer.
3353 __ bind(&runtime); 3351 __ bind(&runtime);
3352 __ Push(r1, r0);
3354 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); 3353 __ TailCallRuntime(Runtime::kStringCompare, 2, 1);
3355 } 3354 }
3356 3355
3357 3356
3358 void BinaryOpICWithAllocationSiteStub::Generate(MacroAssembler* masm) { 3357 void BinaryOpICWithAllocationSiteStub::Generate(MacroAssembler* masm) {
3359 // ----------- S t a t e ------------- 3358 // ----------- S t a t e -------------
3360 // -- r1 : left 3359 // -- r1 : left
3361 // -- r0 : right 3360 // -- r0 : right
3362 // -- lr : return address 3361 // -- lr : return address
3363 // ----------------------------------- 3362 // -----------------------------------
(...skipping 2174 matching lines...) Expand 10 before | Expand all | Expand 10 after
5538 MemOperand(fp, 6 * kPointerSize), NULL); 5537 MemOperand(fp, 6 * kPointerSize), NULL);
5539 } 5538 }
5540 5539
5541 5540
5542 #undef __ 5541 #undef __
5543 5542
5544 } // namespace internal 5543 } // namespace internal
5545 } // namespace v8 5544 } // namespace v8
5546 5545
5547 #endif // V8_TARGET_ARCH_ARM 5546 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/arm/interface-descriptors-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698