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

Side by Side Diff: src/x64/code-stubs-x64.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/mips64/lithium-codegen-mips64.cc ('k') | src/x64/interface-descriptors-x64.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_X64 5 #if V8_TARGET_ARCH_X64
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 3298 matching lines...) Expand 10 before | Expand all | Expand 10 after
3309 __ bind(&loop); 3309 __ bind(&loop);
3310 __ movb(scratch, Operand(left, index, times_1, 0)); 3310 __ movb(scratch, Operand(left, index, times_1, 0));
3311 __ cmpb(scratch, Operand(right, index, times_1, 0)); 3311 __ cmpb(scratch, Operand(right, index, times_1, 0));
3312 __ j(not_equal, chars_not_equal, near_jump); 3312 __ j(not_equal, chars_not_equal, near_jump);
3313 __ incq(index); 3313 __ incq(index);
3314 __ j(not_zero, &loop); 3314 __ j(not_zero, &loop);
3315 } 3315 }
3316 3316
3317 3317
3318 void StringCompareStub::Generate(MacroAssembler* masm) { 3318 void StringCompareStub::Generate(MacroAssembler* masm) {
3319 Label runtime; 3319 // ----------- S t a t e -------------
3320 3320 // -- rdx : left string
3321 // Stack frame on entry. 3321 // -- rax : right string
3322 // rsp[0] : return address 3322 // -- rsp[0] : return address
3323 // rsp[8] : right string 3323 // -----------------------------------
3324 // rsp[16] : left string 3324 __ AssertString(rdx);
3325 3325 __ AssertString(rax);
3326 StackArgumentsAccessor args(rsp, 2, ARGUMENTS_DONT_CONTAIN_RECEIVER);
3327 __ movp(rdx, args.GetArgumentOperand(0)); // left
3328 __ movp(rax, args.GetArgumentOperand(1)); // right
3329 3326
3330 // Check for identity. 3327 // Check for identity.
3331 Label not_same; 3328 Label not_same;
3332 __ cmpp(rdx, rax); 3329 __ cmpp(rdx, rax);
3333 __ j(not_equal, &not_same, Label::kNear); 3330 __ j(not_equal, &not_same, Label::kNear);
3334 __ Move(rax, Smi::FromInt(EQUAL)); 3331 __ Move(rax, Smi::FromInt(EQUAL));
3335 Counters* counters = isolate()->counters(); 3332 __ IncrementCounter(isolate()->counters()->string_compare_native(), 1);
3336 __ IncrementCounter(counters->string_compare_native(), 1); 3333 __ Ret();
3337 __ ret(2 * kPointerSize);
3338 3334
3339 __ bind(&not_same); 3335 __ bind(&not_same);
3340 3336
3341 // Check that both are sequential one-byte strings. 3337 // Check that both are sequential one-byte strings.
3338 Label runtime;
3342 __ JumpIfNotBothSequentialOneByteStrings(rdx, rax, rcx, rbx, &runtime); 3339 __ JumpIfNotBothSequentialOneByteStrings(rdx, rax, rcx, rbx, &runtime);
3343 3340
3344 // Inline comparison of one-byte strings. 3341 // Inline comparison of one-byte strings.
3345 __ IncrementCounter(counters->string_compare_native(), 1); 3342 __ IncrementCounter(isolate()->counters()->string_compare_native(), 1);
3346 // Drop arguments from the stack
3347 __ PopReturnAddressTo(rcx);
3348 __ addp(rsp, Immediate(2 * kPointerSize));
3349 __ PushReturnAddressFrom(rcx);
3350 StringHelper::GenerateCompareFlatOneByteStrings(masm, rdx, rax, rcx, rbx, rdi, 3343 StringHelper::GenerateCompareFlatOneByteStrings(masm, rdx, rax, rcx, rbx, rdi,
3351 r8); 3344 r8);
3352 3345
3353 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) 3346 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater)
3354 // tagged as a small integer. 3347 // tagged as a small integer.
3355 __ bind(&runtime); 3348 __ bind(&runtime);
3349 __ PopReturnAddressTo(rcx);
3350 __ Push(rdx);
3351 __ Push(rax);
3352 __ PushReturnAddressFrom(rcx);
3356 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); 3353 __ TailCallRuntime(Runtime::kStringCompare, 2, 1);
3357 } 3354 }
3358 3355
3359 3356
3360 void BinaryOpICWithAllocationSiteStub::Generate(MacroAssembler* masm) { 3357 void BinaryOpICWithAllocationSiteStub::Generate(MacroAssembler* masm) {
3361 // ----------- S t a t e ------------- 3358 // ----------- S t a t e -------------
3362 // -- rdx : left 3359 // -- rdx : left
3363 // -- rax : right 3360 // -- rax : right
3364 // -- rsp[0] : return address 3361 // -- rsp[0] : return address
3365 // ----------------------------------- 3362 // -----------------------------------
(...skipping 2195 matching lines...) Expand 10 before | Expand all | Expand 10 after
5561 kStackSpace, nullptr, return_value_operand, NULL); 5558 kStackSpace, nullptr, return_value_operand, NULL);
5562 } 5559 }
5563 5560
5564 5561
5565 #undef __ 5562 #undef __
5566 5563
5567 } // namespace internal 5564 } // namespace internal
5568 } // namespace v8 5565 } // namespace v8
5569 5566
5570 #endif // V8_TARGET_ARCH_X64 5567 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/mips64/lithium-codegen-mips64.cc ('k') | src/x64/interface-descriptors-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698