OLD | NEW |
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_X64 | 5 #if V8_TARGET_ARCH_X64 |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.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/debug/debug.h" | 10 #include "src/debug/debug.h" |
(...skipping 3660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3671 // Convert the object to an integer. | 3671 // Convert the object to an integer. |
3672 Label done_convert; | 3672 Label done_convert; |
3673 __ JumpIfSmi(rax, &done_convert, Label::kNear); | 3673 __ JumpIfSmi(rax, &done_convert, Label::kNear); |
3674 __ Push(rax); | 3674 __ Push(rax); |
3675 __ CallRuntime(Runtime::kToInteger, 1); | 3675 __ CallRuntime(Runtime::kToInteger, 1); |
3676 __ bind(&done_convert); | 3676 __ bind(&done_convert); |
3677 context()->Plug(rax); | 3677 context()->Plug(rax); |
3678 } | 3678 } |
3679 | 3679 |
3680 | 3680 |
3681 void FullCodeGenerator::EmitNumberToString(CallRuntime* expr) { | |
3682 ZoneList<Expression*>* args = expr->arguments(); | |
3683 DCHECK_EQ(args->length(), 1); | |
3684 | |
3685 // Load the argument into rax and call the stub. | |
3686 VisitForAccumulatorValue(args->at(0)); | |
3687 | |
3688 NumberToStringStub stub(isolate()); | |
3689 __ CallStub(&stub); | |
3690 context()->Plug(rax); | |
3691 } | |
3692 | |
3693 | |
3694 void FullCodeGenerator::EmitToString(CallRuntime* expr) { | |
3695 ZoneList<Expression*>* args = expr->arguments(); | |
3696 DCHECK_EQ(1, args->length()); | |
3697 | |
3698 // Load the argument into rax and convert it. | |
3699 VisitForAccumulatorValue(args->at(0)); | |
3700 | |
3701 ToStringStub stub(isolate()); | |
3702 __ CallStub(&stub); | |
3703 context()->Plug(rax); | |
3704 } | |
3705 | |
3706 | |
3707 void FullCodeGenerator::EmitToLength(CallRuntime* expr) { | |
3708 ZoneList<Expression*>* args = expr->arguments(); | |
3709 DCHECK_EQ(1, args->length()); | |
3710 | |
3711 // Load the argument into rax and convert it. | |
3712 VisitForAccumulatorValue(args->at(0)); | |
3713 | |
3714 ToLengthStub stub(isolate()); | |
3715 __ CallStub(&stub); | |
3716 context()->Plug(rax); | |
3717 } | |
3718 | |
3719 | |
3720 void FullCodeGenerator::EmitToNumber(CallRuntime* expr) { | |
3721 ZoneList<Expression*>* args = expr->arguments(); | |
3722 DCHECK_EQ(1, args->length()); | |
3723 | |
3724 // Load the argument into rax and convert it. | |
3725 VisitForAccumulatorValue(args->at(0)); | |
3726 | |
3727 ToNumberStub stub(isolate()); | |
3728 __ CallStub(&stub); | |
3729 context()->Plug(rax); | |
3730 } | |
3731 | |
3732 | |
3733 void FullCodeGenerator::EmitToName(CallRuntime* expr) { | 3681 void FullCodeGenerator::EmitToName(CallRuntime* expr) { |
3734 ZoneList<Expression*>* args = expr->arguments(); | 3682 ZoneList<Expression*>* args = expr->arguments(); |
3735 DCHECK_EQ(1, args->length()); | 3683 DCHECK_EQ(1, args->length()); |
3736 | 3684 |
3737 // Load the argument into rax and convert it. | 3685 // Load the argument into rax and convert it. |
3738 VisitForAccumulatorValue(args->at(0)); | 3686 VisitForAccumulatorValue(args->at(0)); |
3739 | 3687 |
3740 // Convert the object to a name. | 3688 // Convert the object to a name. |
3741 Label convert, done_convert; | 3689 Label convert, done_convert; |
3742 __ JumpIfSmi(rax, &convert, Label::kNear); | 3690 __ JumpIfSmi(rax, &convert, Label::kNear); |
3743 STATIC_ASSERT(FIRST_NAME_TYPE == FIRST_TYPE); | 3691 STATIC_ASSERT(FIRST_NAME_TYPE == FIRST_TYPE); |
3744 __ CmpObjectType(rax, LAST_NAME_TYPE, rcx); | 3692 __ CmpObjectType(rax, LAST_NAME_TYPE, rcx); |
3745 __ j(below_equal, &done_convert, Label::kNear); | 3693 __ j(below_equal, &done_convert, Label::kNear); |
3746 __ bind(&convert); | 3694 __ bind(&convert); |
3747 __ Push(rax); | 3695 __ Push(rax); |
3748 __ CallRuntime(Runtime::kToName, 1); | 3696 __ CallRuntime(Runtime::kToName, 1); |
3749 __ bind(&done_convert); | 3697 __ bind(&done_convert); |
3750 context()->Plug(rax); | 3698 context()->Plug(rax); |
3751 } | 3699 } |
3752 | 3700 |
3753 | 3701 |
3754 void FullCodeGenerator::EmitToObject(CallRuntime* expr) { | |
3755 ZoneList<Expression*>* args = expr->arguments(); | |
3756 DCHECK_EQ(1, args->length()); | |
3757 | |
3758 // Load the argument into rax and convert it. | |
3759 VisitForAccumulatorValue(args->at(0)); | |
3760 | |
3761 ToObjectStub stub(isolate()); | |
3762 __ CallStub(&stub); | |
3763 context()->Plug(rax); | |
3764 } | |
3765 | |
3766 | |
3767 void FullCodeGenerator::EmitStringCharFromCode(CallRuntime* expr) { | 3702 void FullCodeGenerator::EmitStringCharFromCode(CallRuntime* expr) { |
3768 ZoneList<Expression*>* args = expr->arguments(); | 3703 ZoneList<Expression*>* args = expr->arguments(); |
3769 DCHECK(args->length() == 1); | 3704 DCHECK(args->length() == 1); |
3770 | 3705 |
3771 VisitForAccumulatorValue(args->at(0)); | 3706 VisitForAccumulatorValue(args->at(0)); |
3772 | 3707 |
3773 Label done; | 3708 Label done; |
3774 StringCharFromCodeGenerator generator(rax, rbx); | 3709 StringCharFromCodeGenerator generator(rax, rbx); |
3775 generator.GenerateFast(masm_); | 3710 generator.GenerateFast(masm_); |
3776 __ jmp(&done); | 3711 __ jmp(&done); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3982 __ movp(rdi, Operand(rsp, rax, times_pointer_size, 0 * kPointerSize)); | 3917 __ movp(rdi, Operand(rsp, rax, times_pointer_size, 0 * kPointerSize)); |
3983 __ Call(isolate()->builtins()->Construct(), RelocInfo::CONSTRUCT_CALL); | 3918 __ Call(isolate()->builtins()->Construct(), RelocInfo::CONSTRUCT_CALL); |
3984 | 3919 |
3985 // Restore context register. | 3920 // Restore context register. |
3986 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 3921 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
3987 | 3922 |
3988 context()->DropAndPlug(1, rax); | 3923 context()->DropAndPlug(1, rax); |
3989 } | 3924 } |
3990 | 3925 |
3991 | 3926 |
3992 void FullCodeGenerator::EmitRegExpConstructResult(CallRuntime* expr) { | |
3993 RegExpConstructResultStub stub(isolate()); | |
3994 ZoneList<Expression*>* args = expr->arguments(); | |
3995 DCHECK(args->length() == 3); | |
3996 VisitForStackValue(args->at(0)); | |
3997 VisitForStackValue(args->at(1)); | |
3998 VisitForAccumulatorValue(args->at(2)); | |
3999 __ Pop(rbx); | |
4000 __ Pop(rcx); | |
4001 __ CallStub(&stub); | |
4002 context()->Plug(rax); | |
4003 } | |
4004 | |
4005 | |
4006 void FullCodeGenerator::EmitHasCachedArrayIndex(CallRuntime* expr) { | 3927 void FullCodeGenerator::EmitHasCachedArrayIndex(CallRuntime* expr) { |
4007 ZoneList<Expression*>* args = expr->arguments(); | 3928 ZoneList<Expression*>* args = expr->arguments(); |
4008 DCHECK(args->length() == 1); | 3929 DCHECK(args->length() == 1); |
4009 | 3930 |
4010 VisitForAccumulatorValue(args->at(0)); | 3931 VisitForAccumulatorValue(args->at(0)); |
4011 | 3932 |
4012 Label materialize_true, materialize_false; | 3933 Label materialize_true, materialize_false; |
4013 Label* if_true = NULL; | 3934 Label* if_true = NULL; |
4014 Label* if_false = NULL; | 3935 Label* if_false = NULL; |
4015 Label* fall_through = NULL; | 3936 Label* fall_through = NULL; |
(...skipping 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5190 Assembler::target_address_at(call_target_address, | 5111 Assembler::target_address_at(call_target_address, |
5191 unoptimized_code)); | 5112 unoptimized_code)); |
5192 return OSR_AFTER_STACK_CHECK; | 5113 return OSR_AFTER_STACK_CHECK; |
5193 } | 5114 } |
5194 | 5115 |
5195 | 5116 |
5196 } // namespace internal | 5117 } // namespace internal |
5197 } // namespace v8 | 5118 } // namespace v8 |
5198 | 5119 |
5199 #endif // V8_TARGET_ARCH_X64 | 5120 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |