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

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

Issue 1355983003: X87: [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/x87/interface-descriptors-x87.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_X87 5 #if V8_TARGET_ARCH_X87
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 3055 matching lines...) Expand 10 before | Expand all | Expand 10 after
3066 __ bind(&loop); 3066 __ bind(&loop);
3067 __ mov_b(scratch, Operand(left, index, times_1, 0)); 3067 __ mov_b(scratch, Operand(left, index, times_1, 0));
3068 __ cmpb(scratch, Operand(right, index, times_1, 0)); 3068 __ cmpb(scratch, Operand(right, index, times_1, 0));
3069 __ j(not_equal, chars_not_equal, chars_not_equal_near); 3069 __ j(not_equal, chars_not_equal, chars_not_equal_near);
3070 __ inc(index); 3070 __ inc(index);
3071 __ j(not_zero, &loop); 3071 __ j(not_zero, &loop);
3072 } 3072 }
3073 3073
3074 3074
3075 void StringCompareStub::Generate(MacroAssembler* masm) { 3075 void StringCompareStub::Generate(MacroAssembler* masm) {
3076 Label runtime; 3076 // ----------- S t a t e -------------
3077 3077 // -- edx : left string
3078 // Stack frame on entry. 3078 // -- eax : right string
3079 // esp[0]: return address 3079 // -- esp[0] : return address
3080 // esp[4]: right string 3080 // -----------------------------------
3081 // esp[8]: left string 3081 __ AssertString(edx);
3082 3082 __ AssertString(eax);
3083 __ mov(edx, Operand(esp, 2 * kPointerSize)); // left
3084 __ mov(eax, Operand(esp, 1 * kPointerSize)); // right
3085 3083
3086 Label not_same; 3084 Label not_same;
3087 __ cmp(edx, eax); 3085 __ cmp(edx, eax);
3088 __ j(not_equal, &not_same, Label::kNear); 3086 __ j(not_equal, &not_same, Label::kNear);
3089 STATIC_ASSERT(EQUAL == 0);
3090 STATIC_ASSERT(kSmiTag == 0);
3091 __ Move(eax, Immediate(Smi::FromInt(EQUAL))); 3087 __ Move(eax, Immediate(Smi::FromInt(EQUAL)));
3092 __ IncrementCounter(isolate()->counters()->string_compare_native(), 1); 3088 __ IncrementCounter(isolate()->counters()->string_compare_native(), 1);
3093 __ ret(2 * kPointerSize); 3089 __ Ret();
3094 3090
3095 __ bind(&not_same); 3091 __ bind(&not_same);
3096 3092
3097 // Check that both objects are sequential one-byte strings. 3093 // Check that both objects are sequential one-byte strings.
3094 Label runtime;
3098 __ JumpIfNotBothSequentialOneByteStrings(edx, eax, ecx, ebx, &runtime); 3095 __ JumpIfNotBothSequentialOneByteStrings(edx, eax, ecx, ebx, &runtime);
3099 3096
3100 // Compare flat one-byte strings. 3097 // Compare flat one-byte strings.
3101 // Drop arguments from the stack. 3098 __ IncrementCounter(isolate()->counters()->string_compare_native(), 1);
3102 __ pop(ecx);
3103 __ add(esp, Immediate(2 * kPointerSize));
3104 __ push(ecx);
3105 StringHelper::GenerateCompareFlatOneByteStrings(masm, edx, eax, ecx, ebx, 3099 StringHelper::GenerateCompareFlatOneByteStrings(masm, edx, eax, ecx, ebx,
3106 edi); 3100 edi);
3107 3101
3108 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) 3102 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater)
3109 // tagged as a small integer. 3103 // tagged as a small integer.
3110 __ bind(&runtime); 3104 __ bind(&runtime);
3105 __ PopReturnAddressTo(ecx);
3106 __ Push(edx);
3107 __ Push(eax);
3108 __ PushReturnAddressFrom(ecx);
3111 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); 3109 __ TailCallRuntime(Runtime::kStringCompare, 2, 1);
3112 } 3110 }
3113 3111
3114 3112
3115 void BinaryOpICWithAllocationSiteStub::Generate(MacroAssembler* masm) { 3113 void BinaryOpICWithAllocationSiteStub::Generate(MacroAssembler* masm) {
3116 // ----------- S t a t e ------------- 3114 // ----------- S t a t e -------------
3117 // -- edx : left 3115 // -- edx : left
3118 // -- eax : right 3116 // -- eax : right
3119 // -- esp[0] : return address 3117 // -- esp[0] : return address
3120 // ----------------------------------- 3118 // -----------------------------------
(...skipping 2358 matching lines...) Expand 10 before | Expand all | Expand 10 after
5479 Operand(ebp, 7 * kPointerSize), NULL); 5477 Operand(ebp, 7 * kPointerSize), NULL);
5480 } 5478 }
5481 5479
5482 5480
5483 #undef __ 5481 #undef __
5484 5482
5485 } // namespace internal 5483 } // namespace internal
5486 } // namespace v8 5484 } // namespace v8
5487 5485
5488 #endif // V8_TARGET_ARCH_X87 5486 #endif // V8_TARGET_ARCH_X87
OLDNEW
« no previous file with comments | « no previous file | src/x87/interface-descriptors-x87.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698