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

Side by Side Diff: src/x64/code-stubs-x64.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/mips64/macro-assembler-mips64.cc ('k') | src/x64/macro-assembler-x64.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 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/code-stubs.h" 7 #include "src/code-stubs.h"
8 #include "src/api-arguments.h" 8 #include "src/api-arguments.h"
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 2554 matching lines...) Expand 10 before | Expand all | Expand 10 after
2565 __ Ret(); 2565 __ Ret();
2566 __ bind(&not_smi); 2566 __ bind(&not_smi);
2567 2567
2568 Label not_heap_number; 2568 Label not_heap_number;
2569 __ CompareRoot(FieldOperand(rax, HeapObject::kMapOffset), 2569 __ CompareRoot(FieldOperand(rax, HeapObject::kMapOffset),
2570 Heap::kHeapNumberMapRootIndex); 2570 Heap::kHeapNumberMapRootIndex);
2571 __ j(not_equal, &not_heap_number, Label::kNear); 2571 __ j(not_equal, &not_heap_number, Label::kNear);
2572 __ Ret(); 2572 __ Ret();
2573 __ bind(&not_heap_number); 2573 __ bind(&not_heap_number);
2574 2574
2575 Label not_string, slow_string; 2575 NonNumberToNumberStub stub(masm->isolate());
2576 __ TailCallStub(&stub);
2577 }
2578
2579 void NonNumberToNumberStub::Generate(MacroAssembler* masm) {
2580 // The NonNumberToNumber stub takes one argument in rax.
2581 __ AssertNotNumber(rax);
2582
2583 Label not_string;
2576 __ CmpObjectType(rax, FIRST_NONSTRING_TYPE, rdi); 2584 __ CmpObjectType(rax, FIRST_NONSTRING_TYPE, rdi);
2577 // rax: object 2585 // rax: object
2578 // rdi: object map 2586 // rdi: object map
2579 __ j(above_equal, &not_string, Label::kNear); 2587 __ j(above_equal, &not_string, Label::kNear);
2580 // Check if string has a cached array index. 2588 StringToNumberStub stub(masm->isolate());
2581 __ testl(FieldOperand(rax, String::kHashFieldOffset), 2589 __ TailCallStub(&stub);
2582 Immediate(String::kContainsCachedArrayIndexMask));
2583 __ j(not_zero, &slow_string, Label::kNear);
2584 __ movl(rax, FieldOperand(rax, String::kHashFieldOffset));
2585 __ IndexFromHash(rax, rax);
2586 __ Ret();
2587 __ bind(&slow_string);
2588 __ PopReturnAddressTo(rcx); // Pop return address.
2589 __ Push(rax); // Push argument.
2590 __ PushReturnAddressFrom(rcx); // Push return address.
2591 __ TailCallRuntime(Runtime::kStringToNumber);
2592 __ bind(&not_string); 2590 __ bind(&not_string);
2593 2591
2594 Label not_oddball; 2592 Label not_oddball;
2595 __ CmpInstanceType(rdi, ODDBALL_TYPE); 2593 __ CmpInstanceType(rdi, ODDBALL_TYPE);
2596 __ j(not_equal, &not_oddball, Label::kNear); 2594 __ j(not_equal, &not_oddball, Label::kNear);
2597 __ movp(rax, FieldOperand(rax, Oddball::kToNumberOffset)); 2595 __ movp(rax, FieldOperand(rax, Oddball::kToNumberOffset));
2598 __ Ret(); 2596 __ Ret();
2599 __ bind(&not_oddball); 2597 __ bind(&not_oddball);
2600 2598
2601 __ PopReturnAddressTo(rcx); // Pop return address. 2599 __ PopReturnAddressTo(rcx); // Pop return address.
2602 __ Push(rax); // Push argument. 2600 __ Push(rax); // Push argument.
2603 __ PushReturnAddressFrom(rcx); // Push return address. 2601 __ PushReturnAddressFrom(rcx); // Push return address.
2604 __ TailCallRuntime(Runtime::kToNumber); 2602 __ TailCallRuntime(Runtime::kToNumber);
2605 } 2603 }
2606 2604
2605 void StringToNumberStub::Generate(MacroAssembler* masm) {
2606 // The StringToNumber stub takes one argument in rax.
2607 __ AssertString(rax);
2608
2609 // Check if string has a cached array index.
2610 Label runtime;
2611 __ testl(FieldOperand(rax, String::kHashFieldOffset),
2612 Immediate(String::kContainsCachedArrayIndexMask));
2613 __ j(not_zero, &runtime, Label::kNear);
2614 __ movl(rax, FieldOperand(rax, String::kHashFieldOffset));
2615 __ IndexFromHash(rax, rax);
2616 __ Ret();
2617
2618 __ bind(&runtime);
2619 __ PopReturnAddressTo(rcx); // Pop return address.
2620 __ Push(rax); // Push argument.
2621 __ PushReturnAddressFrom(rcx); // Push return address.
2622 __ TailCallRuntime(Runtime::kStringToNumber);
2623 }
2607 2624
2608 void ToLengthStub::Generate(MacroAssembler* masm) { 2625 void ToLengthStub::Generate(MacroAssembler* masm) {
2609 // The ToLength stub takes on argument in rax. 2626 // The ToLength stub takes on argument in rax.
2610 Label not_smi, positive_smi; 2627 Label not_smi, positive_smi;
2611 __ JumpIfNotSmi(rax, &not_smi, Label::kNear); 2628 __ JumpIfNotSmi(rax, &not_smi, Label::kNear);
2612 STATIC_ASSERT(kSmiTag == 0); 2629 STATIC_ASSERT(kSmiTag == 0);
2613 __ testp(rax, rax); 2630 __ testp(rax, rax);
2614 __ j(greater_equal, &positive_smi, Label::kNear); 2631 __ j(greater_equal, &positive_smi, Label::kNear);
2615 __ xorl(rax, rax); 2632 __ xorl(rax, rax);
2616 __ bind(&positive_smi); 2633 __ bind(&positive_smi);
(...skipping 2972 matching lines...) Expand 10 before | Expand all | Expand 10 after
5589 NULL); 5606 NULL);
5590 } 5607 }
5591 5608
5592 5609
5593 #undef __ 5610 #undef __
5594 5611
5595 } // namespace internal 5612 } // namespace internal
5596 } // namespace v8 5613 } // namespace v8
5597 5614
5598 #endif // V8_TARGET_ARCH_X64 5615 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/mips64/macro-assembler-mips64.cc ('k') | src/x64/macro-assembler-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698