| 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 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #if V8_TARGET_ARCH_X64 | 7 #if V8_TARGET_ARCH_X64 |
| 8 | 8 |
| 9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
| 10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 | 465 |
| 466 int arg_count = info_->scope()->num_parameters() + 1; | 466 int arg_count = info_->scope()->num_parameters() + 1; |
| 467 int arguments_bytes = arg_count * kPointerSize; | 467 int arguments_bytes = arg_count * kPointerSize; |
| 468 __ Ret(arguments_bytes, rcx); | 468 __ Ret(arguments_bytes, rcx); |
| 469 | 469 |
| 470 info_->AddNoFrameRange(no_frame_start, masm_->pc_offset()); | 470 info_->AddNoFrameRange(no_frame_start, masm_->pc_offset()); |
| 471 } | 471 } |
| 472 } | 472 } |
| 473 | 473 |
| 474 | 474 |
| 475 void FullCodeGenerator::EffectContext::Plug(Variable* var) const { | |
| 476 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | |
| 477 } | |
| 478 | |
| 479 | |
| 480 void FullCodeGenerator::AccumulatorValueContext::Plug(Variable* var) const { | |
| 481 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | |
| 482 codegen()->GetVar(result_register(), var); | |
| 483 } | |
| 484 | |
| 485 | |
| 486 void FullCodeGenerator::StackValueContext::Plug(Variable* var) const { | 475 void FullCodeGenerator::StackValueContext::Plug(Variable* var) const { |
| 487 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | 476 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); |
| 488 MemOperand operand = codegen()->VarOperand(var, result_register()); | 477 MemOperand operand = codegen()->VarOperand(var, result_register()); |
| 489 __ Push(operand); | 478 __ Push(operand); |
| 490 } | 479 } |
| 491 | 480 |
| 492 | 481 |
| 493 void FullCodeGenerator::TestContext::Plug(Variable* var) const { | |
| 494 codegen()->GetVar(result_register(), var); | |
| 495 codegen()->PrepareForBailoutBeforeSplit(condition(), false, NULL, NULL); | |
| 496 codegen()->DoTest(this); | |
| 497 } | |
| 498 | |
| 499 | |
| 500 void FullCodeGenerator::EffectContext::Plug(Heap::RootListIndex index) const { | 482 void FullCodeGenerator::EffectContext::Plug(Heap::RootListIndex index) const { |
| 501 } | 483 } |
| 502 | 484 |
| 503 | 485 |
| 504 void FullCodeGenerator::AccumulatorValueContext::Plug( | 486 void FullCodeGenerator::AccumulatorValueContext::Plug( |
| 505 Heap::RootListIndex index) const { | 487 Heap::RootListIndex index) const { |
| 506 __ LoadRoot(result_register(), index); | 488 __ LoadRoot(result_register(), index); |
| 507 } | 489 } |
| 508 | 490 |
| 509 | 491 |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 } | 634 } |
| 653 | 635 |
| 654 | 636 |
| 655 void FullCodeGenerator::TestContext::Plug(Label* materialize_true, | 637 void FullCodeGenerator::TestContext::Plug(Label* materialize_true, |
| 656 Label* materialize_false) const { | 638 Label* materialize_false) const { |
| 657 DCHECK(materialize_true == true_label_); | 639 DCHECK(materialize_true == true_label_); |
| 658 DCHECK(materialize_false == false_label_); | 640 DCHECK(materialize_false == false_label_); |
| 659 } | 641 } |
| 660 | 642 |
| 661 | 643 |
| 662 void FullCodeGenerator::EffectContext::Plug(bool flag) const { | |
| 663 } | |
| 664 | |
| 665 | |
| 666 void FullCodeGenerator::AccumulatorValueContext::Plug(bool flag) const { | 644 void FullCodeGenerator::AccumulatorValueContext::Plug(bool flag) const { |
| 667 Heap::RootListIndex value_root_index = | 645 Heap::RootListIndex value_root_index = |
| 668 flag ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex; | 646 flag ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex; |
| 669 __ LoadRoot(result_register(), value_root_index); | 647 __ LoadRoot(result_register(), value_root_index); |
| 670 } | 648 } |
| 671 | 649 |
| 672 | 650 |
| 673 void FullCodeGenerator::StackValueContext::Plug(bool flag) const { | 651 void FullCodeGenerator::StackValueContext::Plug(bool flag) const { |
| 674 Heap::RootListIndex value_root_index = | 652 Heap::RootListIndex value_root_index = |
| 675 flag ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex; | 653 flag ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex; |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 916 __ Push(variable->name()); | 894 __ Push(variable->name()); |
| 917 __ Push(Smi::FromInt(NONE)); | 895 __ Push(Smi::FromInt(NONE)); |
| 918 VisitForStackValue(declaration->fun()); | 896 VisitForStackValue(declaration->fun()); |
| 919 __ CallRuntime(Runtime::kDeclareLookupSlot, 4); | 897 __ CallRuntime(Runtime::kDeclareLookupSlot, 4); |
| 920 break; | 898 break; |
| 921 } | 899 } |
| 922 } | 900 } |
| 923 } | 901 } |
| 924 | 902 |
| 925 | 903 |
| 926 void FullCodeGenerator::VisitImportDeclaration(ImportDeclaration* declaration) { | |
| 927 VariableProxy* proxy = declaration->proxy(); | |
| 928 Variable* variable = proxy->var(); | |
| 929 switch (variable->location()) { | |
| 930 case VariableLocation::UNALLOCATED: | |
| 931 case VariableLocation::GLOBAL: | |
| 932 // TODO(rossberg) | |
| 933 break; | |
| 934 | |
| 935 case VariableLocation::CONTEXT: { | |
| 936 Comment cmnt(masm_, "[ ImportDeclaration"); | |
| 937 EmitDebugCheckDeclarationContext(variable); | |
| 938 // TODO(rossberg) | |
| 939 break; | |
| 940 } | |
| 941 | |
| 942 case VariableLocation::PARAMETER: | |
| 943 case VariableLocation::LOCAL: | |
| 944 case VariableLocation::LOOKUP: | |
| 945 UNREACHABLE(); | |
| 946 } | |
| 947 } | |
| 948 | |
| 949 | |
| 950 void FullCodeGenerator::VisitExportDeclaration(ExportDeclaration* declaration) { | |
| 951 // TODO(rossberg) | |
| 952 } | |
| 953 | |
| 954 | |
| 955 void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) { | 904 void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) { |
| 956 // Call the runtime to declare the globals. | 905 // Call the runtime to declare the globals. |
| 957 __ Push(rsi); // The context is the first argument. | 906 __ Push(rsi); // The context is the first argument. |
| 958 __ Push(pairs); | 907 __ Push(pairs); |
| 959 __ Push(Smi::FromInt(DeclareGlobalsFlags())); | 908 __ Push(Smi::FromInt(DeclareGlobalsFlags())); |
| 960 __ CallRuntime(Runtime::kDeclareGlobals, 3); | 909 __ CallRuntime(Runtime::kDeclareGlobals, 3); |
| 961 // Return value is ignored. | 910 // Return value is ignored. |
| 962 } | 911 } |
| 963 | 912 |
| 964 | 913 |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1274 __ Push(info); | 1223 __ Push(info); |
| 1275 __ Push(pretenure | 1224 __ Push(pretenure |
| 1276 ? isolate()->factory()->true_value() | 1225 ? isolate()->factory()->true_value() |
| 1277 : isolate()->factory()->false_value()); | 1226 : isolate()->factory()->false_value()); |
| 1278 __ CallRuntime(Runtime::kNewClosure, 3); | 1227 __ CallRuntime(Runtime::kNewClosure, 3); |
| 1279 } | 1228 } |
| 1280 context()->Plug(rax); | 1229 context()->Plug(rax); |
| 1281 } | 1230 } |
| 1282 | 1231 |
| 1283 | 1232 |
| 1284 void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) { | |
| 1285 Comment cmnt(masm_, "[ VariableProxy"); | |
| 1286 EmitVariableLoad(expr); | |
| 1287 } | |
| 1288 | |
| 1289 | |
| 1290 void FullCodeGenerator::EmitSetHomeObjectIfNeeded(Expression* initializer, | 1233 void FullCodeGenerator::EmitSetHomeObjectIfNeeded(Expression* initializer, |
| 1291 int offset, | 1234 int offset, |
| 1292 FeedbackVectorICSlot slot) { | 1235 FeedbackVectorICSlot slot) { |
| 1293 if (NeedsHomeObject(initializer)) { | 1236 if (NeedsHomeObject(initializer)) { |
| 1294 __ movp(StoreDescriptor::ReceiverRegister(), Operand(rsp, 0)); | 1237 __ movp(StoreDescriptor::ReceiverRegister(), Operand(rsp, 0)); |
| 1295 __ Move(StoreDescriptor::NameRegister(), | 1238 __ Move(StoreDescriptor::NameRegister(), |
| 1296 isolate()->factory()->home_object_symbol()); | 1239 isolate()->factory()->home_object_symbol()); |
| 1297 __ movp(StoreDescriptor::ValueRegister(), | 1240 __ movp(StoreDescriptor::ValueRegister(), |
| 1298 Operand(rsp, offset * kPointerSize)); | 1241 Operand(rsp, offset * kPointerSize)); |
| 1299 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); | 1242 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); |
| (...skipping 2476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3776 __ bind(&null); | 3719 __ bind(&null); |
| 3777 __ LoadRoot(rax, Heap::kNullValueRootIndex); | 3720 __ LoadRoot(rax, Heap::kNullValueRootIndex); |
| 3778 | 3721 |
| 3779 // All done. | 3722 // All done. |
| 3780 __ bind(&done); | 3723 __ bind(&done); |
| 3781 | 3724 |
| 3782 context()->Plug(rax); | 3725 context()->Plug(rax); |
| 3783 } | 3726 } |
| 3784 | 3727 |
| 3785 | 3728 |
| 3786 void FullCodeGenerator::EmitSubString(CallRuntime* expr) { | |
| 3787 // Load the arguments on the stack and call the stub. | |
| 3788 SubStringStub stub(isolate()); | |
| 3789 ZoneList<Expression*>* args = expr->arguments(); | |
| 3790 DCHECK(args->length() == 3); | |
| 3791 VisitForStackValue(args->at(0)); | |
| 3792 VisitForStackValue(args->at(1)); | |
| 3793 VisitForStackValue(args->at(2)); | |
| 3794 __ CallStub(&stub); | |
| 3795 context()->Plug(rax); | |
| 3796 } | |
| 3797 | |
| 3798 | |
| 3799 void FullCodeGenerator::EmitRegExpExec(CallRuntime* expr) { | |
| 3800 // Load the arguments on the stack and call the stub. | |
| 3801 RegExpExecStub stub(isolate()); | |
| 3802 ZoneList<Expression*>* args = expr->arguments(); | |
| 3803 DCHECK(args->length() == 4); | |
| 3804 VisitForStackValue(args->at(0)); | |
| 3805 VisitForStackValue(args->at(1)); | |
| 3806 VisitForStackValue(args->at(2)); | |
| 3807 VisitForStackValue(args->at(3)); | |
| 3808 __ CallStub(&stub); | |
| 3809 context()->Plug(rax); | |
| 3810 } | |
| 3811 | |
| 3812 | |
| 3813 void FullCodeGenerator::EmitValueOf(CallRuntime* expr) { | 3729 void FullCodeGenerator::EmitValueOf(CallRuntime* expr) { |
| 3814 ZoneList<Expression*>* args = expr->arguments(); | 3730 ZoneList<Expression*>* args = expr->arguments(); |
| 3815 DCHECK(args->length() == 1); | 3731 DCHECK(args->length() == 1); |
| 3816 | 3732 |
| 3817 VisitForAccumulatorValue(args->at(0)); // Load the object. | 3733 VisitForAccumulatorValue(args->at(0)); // Load the object. |
| 3818 | 3734 |
| 3819 Label done; | 3735 Label done; |
| 3820 // If the object is a smi return the object. | 3736 // If the object is a smi return the object. |
| 3821 __ JumpIfSmi(rax, &done); | 3737 __ JumpIfSmi(rax, &done); |
| 3822 // If the object is not a value type, return the object. | 3738 // If the object is not a value type, return the object. |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3955 static const uint32_t two_byte_seq_type = kSeqStringTag | kTwoByteStringTag; | 3871 static const uint32_t two_byte_seq_type = kSeqStringTag | kTwoByteStringTag; |
| 3956 __ EmitSeqStringSetCharCheck(string, index, value, two_byte_seq_type); | 3872 __ EmitSeqStringSetCharCheck(string, index, value, two_byte_seq_type); |
| 3957 } | 3873 } |
| 3958 | 3874 |
| 3959 __ movw(FieldOperand(string, index, times_2, SeqTwoByteString::kHeaderSize), | 3875 __ movw(FieldOperand(string, index, times_2, SeqTwoByteString::kHeaderSize), |
| 3960 value); | 3876 value); |
| 3961 context()->Plug(rax); | 3877 context()->Plug(rax); |
| 3962 } | 3878 } |
| 3963 | 3879 |
| 3964 | 3880 |
| 3965 void FullCodeGenerator::EmitMathPow(CallRuntime* expr) { | |
| 3966 // Load the arguments on the stack and call the runtime function. | |
| 3967 ZoneList<Expression*>* args = expr->arguments(); | |
| 3968 DCHECK(args->length() == 2); | |
| 3969 VisitForStackValue(args->at(0)); | |
| 3970 VisitForStackValue(args->at(1)); | |
| 3971 MathPowStub stub(isolate(), MathPowStub::ON_STACK); | |
| 3972 __ CallStub(&stub); | |
| 3973 context()->Plug(rax); | |
| 3974 } | |
| 3975 | |
| 3976 | |
| 3977 void FullCodeGenerator::EmitSetValueOf(CallRuntime* expr) { | 3881 void FullCodeGenerator::EmitSetValueOf(CallRuntime* expr) { |
| 3978 ZoneList<Expression*>* args = expr->arguments(); | 3882 ZoneList<Expression*>* args = expr->arguments(); |
| 3979 DCHECK(args->length() == 2); | 3883 DCHECK(args->length() == 2); |
| 3980 | 3884 |
| 3981 VisitForStackValue(args->at(0)); // Load the object. | 3885 VisitForStackValue(args->at(0)); // Load the object. |
| 3982 VisitForAccumulatorValue(args->at(1)); // Load the value. | 3886 VisitForAccumulatorValue(args->at(1)); // Load the value. |
| 3983 __ Pop(rbx); // rax = value. rbx = object. | 3887 __ Pop(rbx); // rax = value. rbx = object. |
| 3984 | 3888 |
| 3985 Label done; | 3889 Label done; |
| 3986 // If the object is a smi, return the value. | 3890 // If the object is a smi, return the value. |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4134 VisitForStackValue(args->at(0)); | 4038 VisitForStackValue(args->at(0)); |
| 4135 VisitForAccumulatorValue(args->at(1)); | 4039 VisitForAccumulatorValue(args->at(1)); |
| 4136 | 4040 |
| 4137 __ Pop(rdx); | 4041 __ Pop(rdx); |
| 4138 StringAddStub stub(isolate(), STRING_ADD_CHECK_BOTH, NOT_TENURED); | 4042 StringAddStub stub(isolate(), STRING_ADD_CHECK_BOTH, NOT_TENURED); |
| 4139 __ CallStub(&stub); | 4043 __ CallStub(&stub); |
| 4140 context()->Plug(rax); | 4044 context()->Plug(rax); |
| 4141 } | 4045 } |
| 4142 | 4046 |
| 4143 | 4047 |
| 4144 void FullCodeGenerator::EmitStringCompare(CallRuntime* expr) { | |
| 4145 ZoneList<Expression*>* args = expr->arguments(); | |
| 4146 DCHECK_EQ(2, args->length()); | |
| 4147 | |
| 4148 VisitForStackValue(args->at(0)); | |
| 4149 VisitForStackValue(args->at(1)); | |
| 4150 | |
| 4151 StringCompareStub stub(isolate()); | |
| 4152 __ CallStub(&stub); | |
| 4153 context()->Plug(rax); | |
| 4154 } | |
| 4155 | |
| 4156 | |
| 4157 void FullCodeGenerator::EmitCallFunction(CallRuntime* expr) { | 4048 void FullCodeGenerator::EmitCallFunction(CallRuntime* expr) { |
| 4158 ZoneList<Expression*>* args = expr->arguments(); | 4049 ZoneList<Expression*>* args = expr->arguments(); |
| 4159 DCHECK(args->length() >= 2); | 4050 DCHECK(args->length() >= 2); |
| 4160 | 4051 |
| 4161 int arg_count = args->length() - 2; // 2 ~ receiver and function. | 4052 int arg_count = args->length() - 2; // 2 ~ receiver and function. |
| 4162 for (int i = 0; i < arg_count + 1; i++) { | 4053 for (int i = 0; i < arg_count + 1; i++) { |
| 4163 VisitForStackValue(args->at(i)); | 4054 VisitForStackValue(args->at(i)); |
| 4164 } | 4055 } |
| 4165 VisitForAccumulatorValue(args->last()); // Function. | 4056 VisitForAccumulatorValue(args->last()); // Function. |
| 4166 | 4057 |
| (...skipping 1298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5465 Assembler::target_address_at(call_target_address, | 5356 Assembler::target_address_at(call_target_address, |
| 5466 unoptimized_code)); | 5357 unoptimized_code)); |
| 5467 return OSR_AFTER_STACK_CHECK; | 5358 return OSR_AFTER_STACK_CHECK; |
| 5468 } | 5359 } |
| 5469 | 5360 |
| 5470 | 5361 |
| 5471 } // namespace internal | 5362 } // namespace internal |
| 5472 } // namespace v8 | 5363 } // namespace v8 |
| 5473 | 5364 |
| 5474 #endif // V8_TARGET_ARCH_X64 | 5365 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |