| 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_MIPS64 | 7 #if V8_TARGET_ARCH_MIPS64 |
| 8 | 8 |
| 9 // Note on Mips implementation: | 9 // Note on Mips implementation: |
| 10 // | 10 // |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 int no_frame_start = masm_->pc_offset(); | 493 int no_frame_start = masm_->pc_offset(); |
| 494 masm_->MultiPop(static_cast<RegList>(fp.bit() | ra.bit())); | 494 masm_->MultiPop(static_cast<RegList>(fp.bit() | ra.bit())); |
| 495 masm_->Daddu(sp, sp, Operand(sp_delta)); | 495 masm_->Daddu(sp, sp, Operand(sp_delta)); |
| 496 masm_->Jump(ra); | 496 masm_->Jump(ra); |
| 497 info_->AddNoFrameRange(no_frame_start, masm_->pc_offset()); | 497 info_->AddNoFrameRange(no_frame_start, masm_->pc_offset()); |
| 498 } | 498 } |
| 499 } | 499 } |
| 500 } | 500 } |
| 501 | 501 |
| 502 | 502 |
| 503 void FullCodeGenerator::EffectContext::Plug(Variable* var) const { | |
| 504 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | |
| 505 } | |
| 506 | |
| 507 | |
| 508 void FullCodeGenerator::AccumulatorValueContext::Plug(Variable* var) const { | |
| 509 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | |
| 510 codegen()->GetVar(result_register(), var); | |
| 511 } | |
| 512 | |
| 513 | |
| 514 void FullCodeGenerator::StackValueContext::Plug(Variable* var) const { | 503 void FullCodeGenerator::StackValueContext::Plug(Variable* var) const { |
| 515 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | 504 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); |
| 516 codegen()->GetVar(result_register(), var); | 505 codegen()->GetVar(result_register(), var); |
| 517 __ push(result_register()); | 506 __ push(result_register()); |
| 518 } | 507 } |
| 519 | 508 |
| 520 | 509 |
| 521 void FullCodeGenerator::TestContext::Plug(Variable* var) const { | |
| 522 // For simplicity we always test the accumulator register. | |
| 523 codegen()->GetVar(result_register(), var); | |
| 524 codegen()->PrepareForBailoutBeforeSplit(condition(), false, NULL, NULL); | |
| 525 codegen()->DoTest(this); | |
| 526 } | |
| 527 | |
| 528 | |
| 529 void FullCodeGenerator::EffectContext::Plug(Heap::RootListIndex index) const { | 510 void FullCodeGenerator::EffectContext::Plug(Heap::RootListIndex index) const { |
| 530 } | 511 } |
| 531 | 512 |
| 532 | 513 |
| 533 void FullCodeGenerator::AccumulatorValueContext::Plug( | 514 void FullCodeGenerator::AccumulatorValueContext::Plug( |
| 534 Heap::RootListIndex index) const { | 515 Heap::RootListIndex index) const { |
| 535 __ LoadRoot(result_register(), index); | 516 __ LoadRoot(result_register(), index); |
| 536 } | 517 } |
| 537 | 518 |
| 538 | 519 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 } | 660 } |
| 680 | 661 |
| 681 | 662 |
| 682 void FullCodeGenerator::TestContext::Plug(Label* materialize_true, | 663 void FullCodeGenerator::TestContext::Plug(Label* materialize_true, |
| 683 Label* materialize_false) const { | 664 Label* materialize_false) const { |
| 684 DCHECK(materialize_true == true_label_); | 665 DCHECK(materialize_true == true_label_); |
| 685 DCHECK(materialize_false == false_label_); | 666 DCHECK(materialize_false == false_label_); |
| 686 } | 667 } |
| 687 | 668 |
| 688 | 669 |
| 689 void FullCodeGenerator::EffectContext::Plug(bool flag) const { | |
| 690 } | |
| 691 | |
| 692 | |
| 693 void FullCodeGenerator::AccumulatorValueContext::Plug(bool flag) const { | 670 void FullCodeGenerator::AccumulatorValueContext::Plug(bool flag) const { |
| 694 Heap::RootListIndex value_root_index = | 671 Heap::RootListIndex value_root_index = |
| 695 flag ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex; | 672 flag ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex; |
| 696 __ LoadRoot(result_register(), value_root_index); | 673 __ LoadRoot(result_register(), value_root_index); |
| 697 } | 674 } |
| 698 | 675 |
| 699 | 676 |
| 700 void FullCodeGenerator::StackValueContext::Plug(bool flag) const { | 677 void FullCodeGenerator::StackValueContext::Plug(bool flag) const { |
| 701 Heap::RootListIndex value_root_index = | 678 Heap::RootListIndex value_root_index = |
| 702 flag ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex; | 679 flag ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex; |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 955 __ Push(cp, a2, a1); | 932 __ Push(cp, a2, a1); |
| 956 // Push initial value for function declaration. | 933 // Push initial value for function declaration. |
| 957 VisitForStackValue(declaration->fun()); | 934 VisitForStackValue(declaration->fun()); |
| 958 __ CallRuntime(Runtime::kDeclareLookupSlot, 4); | 935 __ CallRuntime(Runtime::kDeclareLookupSlot, 4); |
| 959 break; | 936 break; |
| 960 } | 937 } |
| 961 } | 938 } |
| 962 } | 939 } |
| 963 | 940 |
| 964 | 941 |
| 965 void FullCodeGenerator::VisitImportDeclaration(ImportDeclaration* declaration) { | |
| 966 VariableProxy* proxy = declaration->proxy(); | |
| 967 Variable* variable = proxy->var(); | |
| 968 switch (variable->location()) { | |
| 969 case VariableLocation::GLOBAL: | |
| 970 case VariableLocation::UNALLOCATED: | |
| 971 // TODO(rossberg) | |
| 972 break; | |
| 973 | |
| 974 case VariableLocation::CONTEXT: { | |
| 975 Comment cmnt(masm_, "[ ImportDeclaration"); | |
| 976 EmitDebugCheckDeclarationContext(variable); | |
| 977 // TODO(rossberg) | |
| 978 break; | |
| 979 } | |
| 980 | |
| 981 case VariableLocation::PARAMETER: | |
| 982 case VariableLocation::LOCAL: | |
| 983 case VariableLocation::LOOKUP: | |
| 984 UNREACHABLE(); | |
| 985 } | |
| 986 } | |
| 987 | |
| 988 | |
| 989 void FullCodeGenerator::VisitExportDeclaration(ExportDeclaration* declaration) { | |
| 990 // TODO(rossberg) | |
| 991 } | |
| 992 | |
| 993 | |
| 994 void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) { | 942 void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) { |
| 995 // Call the runtime to declare the globals. | 943 // Call the runtime to declare the globals. |
| 996 // The context is the first argument. | 944 // The context is the first argument. |
| 997 __ li(a1, Operand(pairs)); | 945 __ li(a1, Operand(pairs)); |
| 998 __ li(a0, Operand(Smi::FromInt(DeclareGlobalsFlags()))); | 946 __ li(a0, Operand(Smi::FromInt(DeclareGlobalsFlags()))); |
| 999 __ Push(cp, a1, a0); | 947 __ Push(cp, a1, a0); |
| 1000 __ CallRuntime(Runtime::kDeclareGlobals, 3); | 948 __ CallRuntime(Runtime::kDeclareGlobals, 3); |
| 1001 // Return value is ignored. | 949 // Return value is ignored. |
| 1002 } | 950 } |
| 1003 | 951 |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1309 __ li(a0, Operand(info)); | 1257 __ li(a0, Operand(info)); |
| 1310 __ LoadRoot(a1, pretenure ? Heap::kTrueValueRootIndex | 1258 __ LoadRoot(a1, pretenure ? Heap::kTrueValueRootIndex |
| 1311 : Heap::kFalseValueRootIndex); | 1259 : Heap::kFalseValueRootIndex); |
| 1312 __ Push(cp, a0, a1); | 1260 __ Push(cp, a0, a1); |
| 1313 __ CallRuntime(Runtime::kNewClosure, 3); | 1261 __ CallRuntime(Runtime::kNewClosure, 3); |
| 1314 } | 1262 } |
| 1315 context()->Plug(v0); | 1263 context()->Plug(v0); |
| 1316 } | 1264 } |
| 1317 | 1265 |
| 1318 | 1266 |
| 1319 void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) { | |
| 1320 Comment cmnt(masm_, "[ VariableProxy"); | |
| 1321 EmitVariableLoad(expr); | |
| 1322 } | |
| 1323 | |
| 1324 | |
| 1325 void FullCodeGenerator::EmitSetHomeObjectIfNeeded(Expression* initializer, | 1267 void FullCodeGenerator::EmitSetHomeObjectIfNeeded(Expression* initializer, |
| 1326 int offset, | 1268 int offset, |
| 1327 FeedbackVectorICSlot slot) { | 1269 FeedbackVectorICSlot slot) { |
| 1328 if (NeedsHomeObject(initializer)) { | 1270 if (NeedsHomeObject(initializer)) { |
| 1329 __ ld(StoreDescriptor::ReceiverRegister(), MemOperand(sp)); | 1271 __ ld(StoreDescriptor::ReceiverRegister(), MemOperand(sp)); |
| 1330 __ li(StoreDescriptor::NameRegister(), | 1272 __ li(StoreDescriptor::NameRegister(), |
| 1331 Operand(isolate()->factory()->home_object_symbol())); | 1273 Operand(isolate()->factory()->home_object_symbol())); |
| 1332 __ ld(StoreDescriptor::ValueRegister(), | 1274 __ ld(StoreDescriptor::ValueRegister(), |
| 1333 MemOperand(sp, offset * kPointerSize)); | 1275 MemOperand(sp, offset * kPointerSize)); |
| 1334 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); | 1276 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); |
| (...skipping 2552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3887 __ bind(&null); | 3829 __ bind(&null); |
| 3888 __ LoadRoot(v0, Heap::kNullValueRootIndex); | 3830 __ LoadRoot(v0, Heap::kNullValueRootIndex); |
| 3889 | 3831 |
| 3890 // All done. | 3832 // All done. |
| 3891 __ bind(&done); | 3833 __ bind(&done); |
| 3892 | 3834 |
| 3893 context()->Plug(v0); | 3835 context()->Plug(v0); |
| 3894 } | 3836 } |
| 3895 | 3837 |
| 3896 | 3838 |
| 3897 void FullCodeGenerator::EmitSubString(CallRuntime* expr) { | |
| 3898 // Load the arguments on the stack and call the stub. | |
| 3899 SubStringStub stub(isolate()); | |
| 3900 ZoneList<Expression*>* args = expr->arguments(); | |
| 3901 DCHECK(args->length() == 3); | |
| 3902 VisitForStackValue(args->at(0)); | |
| 3903 VisitForStackValue(args->at(1)); | |
| 3904 VisitForStackValue(args->at(2)); | |
| 3905 __ CallStub(&stub); | |
| 3906 context()->Plug(v0); | |
| 3907 } | |
| 3908 | |
| 3909 | |
| 3910 void FullCodeGenerator::EmitRegExpExec(CallRuntime* expr) { | |
| 3911 // Load the arguments on the stack and call the stub. | |
| 3912 RegExpExecStub stub(isolate()); | |
| 3913 ZoneList<Expression*>* args = expr->arguments(); | |
| 3914 DCHECK(args->length() == 4); | |
| 3915 VisitForStackValue(args->at(0)); | |
| 3916 VisitForStackValue(args->at(1)); | |
| 3917 VisitForStackValue(args->at(2)); | |
| 3918 VisitForStackValue(args->at(3)); | |
| 3919 __ CallStub(&stub); | |
| 3920 context()->Plug(v0); | |
| 3921 } | |
| 3922 | |
| 3923 | |
| 3924 void FullCodeGenerator::EmitValueOf(CallRuntime* expr) { | 3839 void FullCodeGenerator::EmitValueOf(CallRuntime* expr) { |
| 3925 ZoneList<Expression*>* args = expr->arguments(); | 3840 ZoneList<Expression*>* args = expr->arguments(); |
| 3926 DCHECK(args->length() == 1); | 3841 DCHECK(args->length() == 1); |
| 3927 | 3842 |
| 3928 VisitForAccumulatorValue(args->at(0)); // Load the object. | 3843 VisitForAccumulatorValue(args->at(0)); // Load the object. |
| 3929 | 3844 |
| 3930 Label done; | 3845 Label done; |
| 3931 // If the object is a smi return the object. | 3846 // If the object is a smi return the object. |
| 3932 __ JumpIfSmi(v0, &done); | 3847 __ JumpIfSmi(v0, &done); |
| 3933 // If the object is not a value type, return the object. | 3848 // If the object is not a value type, return the object. |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4070 string, | 3985 string, |
| 4071 Operand(SeqTwoByteString::kHeaderSize - kHeapObjectTag)); | 3986 Operand(SeqTwoByteString::kHeaderSize - kHeapObjectTag)); |
| 4072 __ dsra(index, index, 32 - 1); | 3987 __ dsra(index, index, 32 - 1); |
| 4073 __ Daddu(at, at, index); | 3988 __ Daddu(at, at, index); |
| 4074 STATIC_ASSERT(kSmiTagSize == 1 && kSmiTag == 0); | 3989 STATIC_ASSERT(kSmiTagSize == 1 && kSmiTag == 0); |
| 4075 __ sh(value, MemOperand(at)); | 3990 __ sh(value, MemOperand(at)); |
| 4076 context()->Plug(string); | 3991 context()->Plug(string); |
| 4077 } | 3992 } |
| 4078 | 3993 |
| 4079 | 3994 |
| 4080 void FullCodeGenerator::EmitMathPow(CallRuntime* expr) { | |
| 4081 // Load the arguments on the stack and call the runtime function. | |
| 4082 ZoneList<Expression*>* args = expr->arguments(); | |
| 4083 DCHECK(args->length() == 2); | |
| 4084 VisitForStackValue(args->at(0)); | |
| 4085 VisitForStackValue(args->at(1)); | |
| 4086 MathPowStub stub(isolate(), MathPowStub::ON_STACK); | |
| 4087 __ CallStub(&stub); | |
| 4088 context()->Plug(v0); | |
| 4089 } | |
| 4090 | |
| 4091 | |
| 4092 void FullCodeGenerator::EmitSetValueOf(CallRuntime* expr) { | 3995 void FullCodeGenerator::EmitSetValueOf(CallRuntime* expr) { |
| 4093 ZoneList<Expression*>* args = expr->arguments(); | 3996 ZoneList<Expression*>* args = expr->arguments(); |
| 4094 DCHECK(args->length() == 2); | 3997 DCHECK(args->length() == 2); |
| 4095 | 3998 |
| 4096 VisitForStackValue(args->at(0)); // Load the object. | 3999 VisitForStackValue(args->at(0)); // Load the object. |
| 4097 VisitForAccumulatorValue(args->at(1)); // Load the value. | 4000 VisitForAccumulatorValue(args->at(1)); // Load the value. |
| 4098 __ pop(a1); // v0 = value. a1 = object. | 4001 __ pop(a1); // v0 = value. a1 = object. |
| 4099 | 4002 |
| 4100 Label done; | 4003 Label done; |
| 4101 // If the object is a smi, return the value. | 4004 // If the object is a smi, return the value. |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4254 VisitForAccumulatorValue(args->at(1)); | 4157 VisitForAccumulatorValue(args->at(1)); |
| 4255 | 4158 |
| 4256 __ pop(a1); | 4159 __ pop(a1); |
| 4257 __ mov(a0, result_register()); // StringAddStub requires args in a0, a1. | 4160 __ mov(a0, result_register()); // StringAddStub requires args in a0, a1. |
| 4258 StringAddStub stub(isolate(), STRING_ADD_CHECK_BOTH, NOT_TENURED); | 4161 StringAddStub stub(isolate(), STRING_ADD_CHECK_BOTH, NOT_TENURED); |
| 4259 __ CallStub(&stub); | 4162 __ CallStub(&stub); |
| 4260 context()->Plug(v0); | 4163 context()->Plug(v0); |
| 4261 } | 4164 } |
| 4262 | 4165 |
| 4263 | 4166 |
| 4264 void FullCodeGenerator::EmitStringCompare(CallRuntime* expr) { | |
| 4265 ZoneList<Expression*>* args = expr->arguments(); | |
| 4266 DCHECK_EQ(2, args->length()); | |
| 4267 | |
| 4268 VisitForStackValue(args->at(0)); | |
| 4269 VisitForStackValue(args->at(1)); | |
| 4270 | |
| 4271 StringCompareStub stub(isolate()); | |
| 4272 __ CallStub(&stub); | |
| 4273 context()->Plug(v0); | |
| 4274 } | |
| 4275 | |
| 4276 | |
| 4277 void FullCodeGenerator::EmitCallFunction(CallRuntime* expr) { | 4167 void FullCodeGenerator::EmitCallFunction(CallRuntime* expr) { |
| 4278 ZoneList<Expression*>* args = expr->arguments(); | 4168 ZoneList<Expression*>* args = expr->arguments(); |
| 4279 DCHECK(args->length() >= 2); | 4169 DCHECK(args->length() >= 2); |
| 4280 | 4170 |
| 4281 int arg_count = args->length() - 2; // 2 ~ receiver and function. | 4171 int arg_count = args->length() - 2; // 2 ~ receiver and function. |
| 4282 for (int i = 0; i < arg_count + 1; i++) { | 4172 for (int i = 0; i < arg_count + 1; i++) { |
| 4283 VisitForStackValue(args->at(i)); | 4173 VisitForStackValue(args->at(i)); |
| 4284 } | 4174 } |
| 4285 VisitForAccumulatorValue(args->last()); // Function. | 4175 VisitForAccumulatorValue(args->last()); // Function. |
| 4286 | 4176 |
| (...skipping 1254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5541 reinterpret_cast<uint64_t>( | 5431 reinterpret_cast<uint64_t>( |
| 5542 isolate->builtins()->OsrAfterStackCheck()->entry())); | 5432 isolate->builtins()->OsrAfterStackCheck()->entry())); |
| 5543 return OSR_AFTER_STACK_CHECK; | 5433 return OSR_AFTER_STACK_CHECK; |
| 5544 } | 5434 } |
| 5545 | 5435 |
| 5546 | 5436 |
| 5547 } // namespace internal | 5437 } // namespace internal |
| 5548 } // namespace v8 | 5438 } // namespace v8 |
| 5549 | 5439 |
| 5550 #endif // V8_TARGET_ARCH_MIPS64 | 5440 #endif // V8_TARGET_ARCH_MIPS64 |
| OLD | NEW |