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

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

Issue 1818923002: [stubs] Split ToNumberStub into reusable subparts. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE Created 4 years, 9 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/compiler/verifier.cc ('k') | src/ia32/macro-assembler-ia32.h » ('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/code-stubs.h" 7 #include "src/code-stubs.h"
8 #include "src/api-arguments.h" 8 #include "src/api-arguments.h"
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 2615 matching lines...) Expand 10 before | Expand all | Expand 10 after
2626 __ JumpIfNotSmi(eax, &not_smi, Label::kNear); 2626 __ JumpIfNotSmi(eax, &not_smi, Label::kNear);
2627 __ Ret(); 2627 __ Ret();
2628 __ bind(&not_smi); 2628 __ bind(&not_smi);
2629 2629
2630 Label not_heap_number; 2630 Label not_heap_number;
2631 __ CompareMap(eax, masm->isolate()->factory()->heap_number_map()); 2631 __ CompareMap(eax, masm->isolate()->factory()->heap_number_map());
2632 __ j(not_equal, &not_heap_number, Label::kNear); 2632 __ j(not_equal, &not_heap_number, Label::kNear);
2633 __ Ret(); 2633 __ Ret();
2634 __ bind(&not_heap_number); 2634 __ bind(&not_heap_number);
2635 2635
2636 Label not_string, slow_string; 2636 NonNumberToNumberStub stub(masm->isolate());
2637 __ TailCallStub(&stub);
2638 }
2639
2640 void NonNumberToNumberStub::Generate(MacroAssembler* masm) {
2641 // The NonNumberToNumber stub takes one argument in eax.
2642 __ AssertNotNumber(eax);
2643
2644 Label not_string;
2637 __ CmpObjectType(eax, FIRST_NONSTRING_TYPE, edi); 2645 __ CmpObjectType(eax, FIRST_NONSTRING_TYPE, edi);
2638 // eax: object 2646 // eax: object
2639 // edi: object map 2647 // edi: object map
2640 __ j(above_equal, &not_string, Label::kNear); 2648 __ j(above_equal, &not_string, Label::kNear);
2641 // Check if string has a cached array index. 2649 StringToNumberStub stub(masm->isolate());
2642 __ test(FieldOperand(eax, String::kHashFieldOffset), 2650 __ TailCallStub(&stub);
2643 Immediate(String::kContainsCachedArrayIndexMask));
2644 __ j(not_zero, &slow_string, Label::kNear);
2645 __ mov(eax, FieldOperand(eax, String::kHashFieldOffset));
2646 __ IndexFromHash(eax, eax);
2647 __ Ret();
2648 __ bind(&slow_string);
2649 __ pop(ecx); // Pop return address.
2650 __ push(eax); // Push argument.
2651 __ push(ecx); // Push return address.
2652 __ TailCallRuntime(Runtime::kStringToNumber);
2653 __ bind(&not_string); 2651 __ bind(&not_string);
2654 2652
2655 Label not_oddball; 2653 Label not_oddball;
2656 __ CmpInstanceType(edi, ODDBALL_TYPE); 2654 __ CmpInstanceType(edi, ODDBALL_TYPE);
2657 __ j(not_equal, &not_oddball, Label::kNear); 2655 __ j(not_equal, &not_oddball, Label::kNear);
2658 __ mov(eax, FieldOperand(eax, Oddball::kToNumberOffset)); 2656 __ mov(eax, FieldOperand(eax, Oddball::kToNumberOffset));
2659 __ Ret(); 2657 __ Ret();
2660 __ bind(&not_oddball); 2658 __ bind(&not_oddball);
2661 2659
2662 __ pop(ecx); // Pop return address. 2660 __ pop(ecx); // Pop return address.
2663 __ push(eax); // Push argument. 2661 __ push(eax); // Push argument.
2664 __ push(ecx); // Push return address. 2662 __ push(ecx); // Push return address.
2665 __ TailCallRuntime(Runtime::kToNumber); 2663 __ TailCallRuntime(Runtime::kToNumber);
2666 } 2664 }
2667 2665
2666 void StringToNumberStub::Generate(MacroAssembler* masm) {
2667 // The StringToNumber stub takes one argument in eax.
2668 __ AssertString(eax);
2669
2670 // Check if string has a cached array index.
2671 Label runtime;
2672 __ test(FieldOperand(eax, String::kHashFieldOffset),
2673 Immediate(String::kContainsCachedArrayIndexMask));
2674 __ j(not_zero, &runtime, Label::kNear);
2675 __ mov(eax, FieldOperand(eax, String::kHashFieldOffset));
2676 __ IndexFromHash(eax, eax);
2677 __ Ret();
2678
2679 __ bind(&runtime);
2680 __ PopReturnAddressTo(ecx); // Pop return address.
2681 __ Push(eax); // Push argument.
2682 __ PushReturnAddressFrom(ecx); // Push return address.
2683 __ TailCallRuntime(Runtime::kStringToNumber);
2684 }
2668 2685
2669 void ToLengthStub::Generate(MacroAssembler* masm) { 2686 void ToLengthStub::Generate(MacroAssembler* masm) {
2670 // The ToLength stub takes on argument in eax. 2687 // The ToLength stub takes on argument in eax.
2671 Label not_smi, positive_smi; 2688 Label not_smi, positive_smi;
2672 __ JumpIfNotSmi(eax, &not_smi, Label::kNear); 2689 __ JumpIfNotSmi(eax, &not_smi, Label::kNear);
2673 STATIC_ASSERT(kSmiTag == 0); 2690 STATIC_ASSERT(kSmiTag == 0);
2674 __ test(eax, eax); 2691 __ test(eax, eax);
2675 __ j(greater_equal, &positive_smi, Label::kNear); 2692 __ j(greater_equal, &positive_smi, Label::kNear);
2676 __ xor_(eax, eax); 2693 __ xor_(eax, eax);
2677 __ bind(&positive_smi); 2694 __ bind(&positive_smi);
(...skipping 3185 matching lines...) Expand 10 before | Expand all | Expand 10 after
5863 return_value_operand, NULL); 5880 return_value_operand, NULL);
5864 } 5881 }
5865 5882
5866 5883
5867 #undef __ 5884 #undef __
5868 5885
5869 } // namespace internal 5886 } // namespace internal
5870 } // namespace v8 5887 } // namespace v8
5871 5888
5872 #endif // V8_TARGET_ARCH_IA32 5889 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/compiler/verifier.cc ('k') | src/ia32/macro-assembler-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698