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

Side by Side Diff: src/ia32/code-stubs-ia32.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/hydrogen-instructions.h ('k') | src/ia32/interface-descriptors-ia32.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_IA32 5 #if V8_TARGET_ARCH_IA32
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 3344 matching lines...) Expand 10 before | Expand all | Expand 10 after
3355 __ bind(&loop); 3355 __ bind(&loop);
3356 __ mov_b(scratch, Operand(left, index, times_1, 0)); 3356 __ mov_b(scratch, Operand(left, index, times_1, 0));
3357 __ cmpb(scratch, Operand(right, index, times_1, 0)); 3357 __ cmpb(scratch, Operand(right, index, times_1, 0));
3358 __ j(not_equal, chars_not_equal, chars_not_equal_near); 3358 __ j(not_equal, chars_not_equal, chars_not_equal_near);
3359 __ inc(index); 3359 __ inc(index);
3360 __ j(not_zero, &loop); 3360 __ j(not_zero, &loop);
3361 } 3361 }
3362 3362
3363 3363
3364 void StringCompareStub::Generate(MacroAssembler* masm) { 3364 void StringCompareStub::Generate(MacroAssembler* masm) {
3365 Label runtime; 3365 // ----------- S t a t e -------------
3366 3366 // -- edx : left string
3367 // Stack frame on entry. 3367 // -- eax : right string
3368 // esp[0]: return address 3368 // -- esp[0] : return address
3369 // esp[4]: right string 3369 // -----------------------------------
3370 // esp[8]: left string 3370 __ AssertString(edx);
3371 3371 __ AssertString(eax);
3372 __ mov(edx, Operand(esp, 2 * kPointerSize)); // left
3373 __ mov(eax, Operand(esp, 1 * kPointerSize)); // right
3374 3372
3375 Label not_same; 3373 Label not_same;
3376 __ cmp(edx, eax); 3374 __ cmp(edx, eax);
3377 __ j(not_equal, &not_same, Label::kNear); 3375 __ j(not_equal, &not_same, Label::kNear);
3378 STATIC_ASSERT(EQUAL == 0);
3379 STATIC_ASSERT(kSmiTag == 0);
3380 __ Move(eax, Immediate(Smi::FromInt(EQUAL))); 3376 __ Move(eax, Immediate(Smi::FromInt(EQUAL)));
3381 __ IncrementCounter(isolate()->counters()->string_compare_native(), 1); 3377 __ IncrementCounter(isolate()->counters()->string_compare_native(), 1);
3382 __ ret(2 * kPointerSize); 3378 __ Ret();
3383 3379
3384 __ bind(&not_same); 3380 __ bind(&not_same);
3385 3381
3386 // Check that both objects are sequential one-byte strings. 3382 // Check that both objects are sequential one-byte strings.
3383 Label runtime;
3387 __ JumpIfNotBothSequentialOneByteStrings(edx, eax, ecx, ebx, &runtime); 3384 __ JumpIfNotBothSequentialOneByteStrings(edx, eax, ecx, ebx, &runtime);
3388 3385
3389 // Compare flat one-byte strings. 3386 // Compare flat one-byte strings.
3390 // Drop arguments from the stack. 3387 __ IncrementCounter(isolate()->counters()->string_compare_native(), 1);
3391 __ pop(ecx);
3392 __ add(esp, Immediate(2 * kPointerSize));
3393 __ push(ecx);
3394 StringHelper::GenerateCompareFlatOneByteStrings(masm, edx, eax, ecx, ebx, 3388 StringHelper::GenerateCompareFlatOneByteStrings(masm, edx, eax, ecx, ebx,
3395 edi); 3389 edi);
3396 3390
3397 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) 3391 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater)
3398 // tagged as a small integer. 3392 // tagged as a small integer.
3399 __ bind(&runtime); 3393 __ bind(&runtime);
3394 __ PopReturnAddressTo(ecx);
3395 __ Push(edx);
3396 __ Push(eax);
3397 __ PushReturnAddressFrom(ecx);
3400 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); 3398 __ TailCallRuntime(Runtime::kStringCompare, 2, 1);
3401 } 3399 }
3402 3400
3403 3401
3404 void BinaryOpICWithAllocationSiteStub::Generate(MacroAssembler* masm) { 3402 void BinaryOpICWithAllocationSiteStub::Generate(MacroAssembler* masm) {
3405 // ----------- S t a t e ------------- 3403 // ----------- S t a t e -------------
3406 // -- edx : left 3404 // -- edx : left
3407 // -- eax : right 3405 // -- eax : right
3408 // -- esp[0] : return address 3406 // -- esp[0] : return address
3409 // ----------------------------------- 3407 // -----------------------------------
(...skipping 2388 matching lines...) Expand 10 before | Expand all | Expand 10 after
5798 Operand(ebp, 7 * kPointerSize), NULL); 5796 Operand(ebp, 7 * kPointerSize), NULL);
5799 } 5797 }
5800 5798
5801 5799
5802 #undef __ 5800 #undef __
5803 5801
5804 } // namespace internal 5802 } // namespace internal
5805 } // namespace v8 5803 } // namespace v8
5806 5804
5807 #endif // V8_TARGET_ARCH_IA32 5805 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/hydrogen-instructions.h ('k') | src/ia32/interface-descriptors-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698