OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_PPC | 7 #if V8_TARGET_ARCH_PPC |
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 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 int32_t sp_delta = arg_count * kPointerSize; | 490 int32_t sp_delta = arg_count * kPointerSize; |
491 SetReturnPosition(function()); | 491 SetReturnPosition(function()); |
492 int no_frame_start = __ LeaveFrame(StackFrame::JAVA_SCRIPT, sp_delta); | 492 int no_frame_start = __ LeaveFrame(StackFrame::JAVA_SCRIPT, sp_delta); |
493 __ blr(); | 493 __ blr(); |
494 info_->AddNoFrameRange(no_frame_start, masm_->pc_offset()); | 494 info_->AddNoFrameRange(no_frame_start, masm_->pc_offset()); |
495 } | 495 } |
496 } | 496 } |
497 } | 497 } |
498 | 498 |
499 | 499 |
500 void FullCodeGenerator::EffectContext::Plug(Variable* var) const { | |
501 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | |
502 } | |
503 | |
504 | |
505 void FullCodeGenerator::AccumulatorValueContext::Plug(Variable* var) const { | |
506 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | |
507 codegen()->GetVar(result_register(), var); | |
508 } | |
509 | |
510 | |
511 void FullCodeGenerator::StackValueContext::Plug(Variable* var) const { | 500 void FullCodeGenerator::StackValueContext::Plug(Variable* var) const { |
512 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | 501 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); |
513 codegen()->GetVar(result_register(), var); | 502 codegen()->GetVar(result_register(), var); |
514 __ push(result_register()); | 503 __ push(result_register()); |
515 } | 504 } |
516 | 505 |
517 | 506 |
518 void FullCodeGenerator::TestContext::Plug(Variable* var) const { | |
519 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | |
520 // For simplicity we always test the accumulator register. | |
521 codegen()->GetVar(result_register(), var); | |
522 codegen()->PrepareForBailoutBeforeSplit(condition(), false, NULL, NULL); | |
523 codegen()->DoTest(this); | |
524 } | |
525 | |
526 | |
527 void FullCodeGenerator::EffectContext::Plug(Heap::RootListIndex index) const {} | 507 void FullCodeGenerator::EffectContext::Plug(Heap::RootListIndex index) const {} |
528 | 508 |
529 | 509 |
530 void FullCodeGenerator::AccumulatorValueContext::Plug( | 510 void FullCodeGenerator::AccumulatorValueContext::Plug( |
531 Heap::RootListIndex index) const { | 511 Heap::RootListIndex index) const { |
532 __ LoadRoot(result_register(), index); | 512 __ LoadRoot(result_register(), index); |
533 } | 513 } |
534 | 514 |
535 | 515 |
536 void FullCodeGenerator::StackValueContext::Plug( | 516 void FullCodeGenerator::StackValueContext::Plug( |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 } | 646 } |
667 | 647 |
668 | 648 |
669 void FullCodeGenerator::TestContext::Plug(Label* materialize_true, | 649 void FullCodeGenerator::TestContext::Plug(Label* materialize_true, |
670 Label* materialize_false) const { | 650 Label* materialize_false) const { |
671 DCHECK(materialize_true == true_label_); | 651 DCHECK(materialize_true == true_label_); |
672 DCHECK(materialize_false == false_label_); | 652 DCHECK(materialize_false == false_label_); |
673 } | 653 } |
674 | 654 |
675 | 655 |
676 void FullCodeGenerator::EffectContext::Plug(bool flag) const {} | |
677 | |
678 | |
679 void FullCodeGenerator::AccumulatorValueContext::Plug(bool flag) const { | 656 void FullCodeGenerator::AccumulatorValueContext::Plug(bool flag) const { |
680 Heap::RootListIndex value_root_index = | 657 Heap::RootListIndex value_root_index = |
681 flag ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex; | 658 flag ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex; |
682 __ LoadRoot(result_register(), value_root_index); | 659 __ LoadRoot(result_register(), value_root_index); |
683 } | 660 } |
684 | 661 |
685 | 662 |
686 void FullCodeGenerator::StackValueContext::Plug(bool flag) const { | 663 void FullCodeGenerator::StackValueContext::Plug(bool flag) const { |
687 Heap::RootListIndex value_root_index = | 664 Heap::RootListIndex value_root_index = |
688 flag ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex; | 665 flag ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex; |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
920 __ Push(cp, r5, r4); | 897 __ Push(cp, r5, r4); |
921 // Push initial value for function declaration. | 898 // Push initial value for function declaration. |
922 VisitForStackValue(declaration->fun()); | 899 VisitForStackValue(declaration->fun()); |
923 __ CallRuntime(Runtime::kDeclareLookupSlot, 4); | 900 __ CallRuntime(Runtime::kDeclareLookupSlot, 4); |
924 break; | 901 break; |
925 } | 902 } |
926 } | 903 } |
927 } | 904 } |
928 | 905 |
929 | 906 |
930 void FullCodeGenerator::VisitImportDeclaration(ImportDeclaration* declaration) { | |
931 VariableProxy* proxy = declaration->proxy(); | |
932 Variable* variable = proxy->var(); | |
933 switch (variable->location()) { | |
934 case VariableLocation::GLOBAL: | |
935 case VariableLocation::UNALLOCATED: | |
936 // TODO(rossberg) | |
937 break; | |
938 | |
939 case VariableLocation::CONTEXT: { | |
940 Comment cmnt(masm_, "[ ImportDeclaration"); | |
941 EmitDebugCheckDeclarationContext(variable); | |
942 // TODO(rossberg) | |
943 break; | |
944 } | |
945 | |
946 case VariableLocation::PARAMETER: | |
947 case VariableLocation::LOCAL: | |
948 case VariableLocation::LOOKUP: | |
949 UNREACHABLE(); | |
950 } | |
951 } | |
952 | |
953 | |
954 void FullCodeGenerator::VisitExportDeclaration(ExportDeclaration* declaration) { | |
955 // TODO(rossberg) | |
956 } | |
957 | |
958 | |
959 void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) { | 907 void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) { |
960 // Call the runtime to declare the globals. | 908 // Call the runtime to declare the globals. |
961 // The context is the first argument. | 909 // The context is the first argument. |
962 __ mov(r4, Operand(pairs)); | 910 __ mov(r4, Operand(pairs)); |
963 __ LoadSmiLiteral(r3, Smi::FromInt(DeclareGlobalsFlags())); | 911 __ LoadSmiLiteral(r3, Smi::FromInt(DeclareGlobalsFlags())); |
964 __ Push(cp, r4, r3); | 912 __ Push(cp, r4, r3); |
965 __ CallRuntime(Runtime::kDeclareGlobals, 3); | 913 __ CallRuntime(Runtime::kDeclareGlobals, 3); |
966 // Return value is ignored. | 914 // Return value is ignored. |
967 } | 915 } |
968 | 916 |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1281 __ mov(r3, Operand(info)); | 1229 __ mov(r3, Operand(info)); |
1282 __ LoadRoot( | 1230 __ LoadRoot( |
1283 r4, pretenure ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex); | 1231 r4, pretenure ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex); |
1284 __ Push(cp, r3, r4); | 1232 __ Push(cp, r3, r4); |
1285 __ CallRuntime(Runtime::kNewClosure, 3); | 1233 __ CallRuntime(Runtime::kNewClosure, 3); |
1286 } | 1234 } |
1287 context()->Plug(r3); | 1235 context()->Plug(r3); |
1288 } | 1236 } |
1289 | 1237 |
1290 | 1238 |
1291 void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) { | |
1292 Comment cmnt(masm_, "[ VariableProxy"); | |
1293 EmitVariableLoad(expr); | |
1294 } | |
1295 | |
1296 | |
1297 void FullCodeGenerator::EmitSetHomeObjectIfNeeded(Expression* initializer, | 1239 void FullCodeGenerator::EmitSetHomeObjectIfNeeded(Expression* initializer, |
1298 int offset, | 1240 int offset, |
1299 FeedbackVectorICSlot slot) { | 1241 FeedbackVectorICSlot slot) { |
1300 if (NeedsHomeObject(initializer)) { | 1242 if (NeedsHomeObject(initializer)) { |
1301 __ LoadP(StoreDescriptor::ReceiverRegister(), MemOperand(sp)); | 1243 __ LoadP(StoreDescriptor::ReceiverRegister(), MemOperand(sp)); |
1302 __ mov(StoreDescriptor::NameRegister(), | 1244 __ mov(StoreDescriptor::NameRegister(), |
1303 Operand(isolate()->factory()->home_object_symbol())); | 1245 Operand(isolate()->factory()->home_object_symbol())); |
1304 __ LoadP(StoreDescriptor::ValueRegister(), | 1246 __ LoadP(StoreDescriptor::ValueRegister(), |
1305 MemOperand(sp, offset * kPointerSize)); | 1247 MemOperand(sp, offset * kPointerSize)); |
1306 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); | 1248 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); |
(...skipping 2600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3907 __ bind(&null); | 3849 __ bind(&null); |
3908 __ LoadRoot(r3, Heap::kNullValueRootIndex); | 3850 __ LoadRoot(r3, Heap::kNullValueRootIndex); |
3909 | 3851 |
3910 // All done. | 3852 // All done. |
3911 __ bind(&done); | 3853 __ bind(&done); |
3912 | 3854 |
3913 context()->Plug(r3); | 3855 context()->Plug(r3); |
3914 } | 3856 } |
3915 | 3857 |
3916 | 3858 |
3917 void FullCodeGenerator::EmitSubString(CallRuntime* expr) { | |
3918 // Load the arguments on the stack and call the stub. | |
3919 SubStringStub stub(isolate()); | |
3920 ZoneList<Expression*>* args = expr->arguments(); | |
3921 DCHECK(args->length() == 3); | |
3922 VisitForStackValue(args->at(0)); | |
3923 VisitForStackValue(args->at(1)); | |
3924 VisitForStackValue(args->at(2)); | |
3925 __ CallStub(&stub); | |
3926 context()->Plug(r3); | |
3927 } | |
3928 | |
3929 | |
3930 void FullCodeGenerator::EmitRegExpExec(CallRuntime* expr) { | |
3931 // Load the arguments on the stack and call the stub. | |
3932 RegExpExecStub stub(isolate()); | |
3933 ZoneList<Expression*>* args = expr->arguments(); | |
3934 DCHECK(args->length() == 4); | |
3935 VisitForStackValue(args->at(0)); | |
3936 VisitForStackValue(args->at(1)); | |
3937 VisitForStackValue(args->at(2)); | |
3938 VisitForStackValue(args->at(3)); | |
3939 __ CallStub(&stub); | |
3940 context()->Plug(r3); | |
3941 } | |
3942 | |
3943 | |
3944 void FullCodeGenerator::EmitValueOf(CallRuntime* expr) { | 3859 void FullCodeGenerator::EmitValueOf(CallRuntime* expr) { |
3945 ZoneList<Expression*>* args = expr->arguments(); | 3860 ZoneList<Expression*>* args = expr->arguments(); |
3946 DCHECK(args->length() == 1); | 3861 DCHECK(args->length() == 1); |
3947 VisitForAccumulatorValue(args->at(0)); // Load the object. | 3862 VisitForAccumulatorValue(args->at(0)); // Load the object. |
3948 | 3863 |
3949 Label done; | 3864 Label done; |
3950 // If the object is a smi return the object. | 3865 // If the object is a smi return the object. |
3951 __ JumpIfSmi(r3, &done); | 3866 __ JumpIfSmi(r3, &done); |
3952 // If the object is not a value type, return the object. | 3867 // If the object is not a value type, return the object. |
3953 __ CompareObjectType(r3, r4, r4, JS_VALUE_TYPE); | 3868 __ CompareObjectType(r3, r4, r4, JS_VALUE_TYPE); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4079 } | 3994 } |
4080 | 3995 |
4081 __ SmiUntag(value); | 3996 __ SmiUntag(value); |
4082 __ addi(ip, string, Operand(SeqTwoByteString::kHeaderSize - kHeapObjectTag)); | 3997 __ addi(ip, string, Operand(SeqTwoByteString::kHeaderSize - kHeapObjectTag)); |
4083 __ SmiToShortArrayOffset(r0, index); | 3998 __ SmiToShortArrayOffset(r0, index); |
4084 __ sthx(value, MemOperand(ip, r0)); | 3999 __ sthx(value, MemOperand(ip, r0)); |
4085 context()->Plug(string); | 4000 context()->Plug(string); |
4086 } | 4001 } |
4087 | 4002 |
4088 | 4003 |
4089 void FullCodeGenerator::EmitMathPow(CallRuntime* expr) { | |
4090 // Load the arguments on the stack and call the runtime function. | |
4091 ZoneList<Expression*>* args = expr->arguments(); | |
4092 DCHECK(args->length() == 2); | |
4093 VisitForStackValue(args->at(0)); | |
4094 VisitForStackValue(args->at(1)); | |
4095 MathPowStub stub(isolate(), MathPowStub::ON_STACK); | |
4096 __ CallStub(&stub); | |
4097 context()->Plug(r3); | |
4098 } | |
4099 | |
4100 | |
4101 void FullCodeGenerator::EmitSetValueOf(CallRuntime* expr) { | 4004 void FullCodeGenerator::EmitSetValueOf(CallRuntime* expr) { |
4102 ZoneList<Expression*>* args = expr->arguments(); | 4005 ZoneList<Expression*>* args = expr->arguments(); |
4103 DCHECK(args->length() == 2); | 4006 DCHECK(args->length() == 2); |
4104 VisitForStackValue(args->at(0)); // Load the object. | 4007 VisitForStackValue(args->at(0)); // Load the object. |
4105 VisitForAccumulatorValue(args->at(1)); // Load the value. | 4008 VisitForAccumulatorValue(args->at(1)); // Load the value. |
4106 __ pop(r4); // r3 = value. r4 = object. | 4009 __ pop(r4); // r3 = value. r4 = object. |
4107 | 4010 |
4108 Label done; | 4011 Label done; |
4109 // If the object is a smi, return the value. | 4012 // If the object is a smi, return the value. |
4110 __ JumpIfSmi(r4, &done); | 4013 __ JumpIfSmi(r4, &done); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4245 VisitForStackValue(args->at(0)); | 4148 VisitForStackValue(args->at(0)); |
4246 VisitForAccumulatorValue(args->at(1)); | 4149 VisitForAccumulatorValue(args->at(1)); |
4247 | 4150 |
4248 __ pop(r4); | 4151 __ pop(r4); |
4249 StringAddStub stub(isolate(), STRING_ADD_CHECK_BOTH, NOT_TENURED); | 4152 StringAddStub stub(isolate(), STRING_ADD_CHECK_BOTH, NOT_TENURED); |
4250 __ CallStub(&stub); | 4153 __ CallStub(&stub); |
4251 context()->Plug(r3); | 4154 context()->Plug(r3); |
4252 } | 4155 } |
4253 | 4156 |
4254 | 4157 |
4255 void FullCodeGenerator::EmitStringCompare(CallRuntime* expr) { | |
4256 ZoneList<Expression*>* args = expr->arguments(); | |
4257 DCHECK_EQ(2, args->length()); | |
4258 VisitForStackValue(args->at(0)); | |
4259 VisitForStackValue(args->at(1)); | |
4260 | |
4261 StringCompareStub stub(isolate()); | |
4262 __ CallStub(&stub); | |
4263 context()->Plug(r3); | |
4264 } | |
4265 | |
4266 | |
4267 void FullCodeGenerator::EmitCallFunction(CallRuntime* expr) { | 4158 void FullCodeGenerator::EmitCallFunction(CallRuntime* expr) { |
4268 ZoneList<Expression*>* args = expr->arguments(); | 4159 ZoneList<Expression*>* args = expr->arguments(); |
4269 DCHECK(args->length() >= 2); | 4160 DCHECK(args->length() >= 2); |
4270 | 4161 |
4271 int arg_count = args->length() - 2; // 2 ~ receiver and function. | 4162 int arg_count = args->length() - 2; // 2 ~ receiver and function. |
4272 for (int i = 0; i < arg_count + 1; i++) { | 4163 for (int i = 0; i < arg_count + 1; i++) { |
4273 VisitForStackValue(args->at(i)); | 4164 VisitForStackValue(args->at(i)); |
4274 } | 4165 } |
4275 VisitForAccumulatorValue(args->last()); // Function. | 4166 VisitForAccumulatorValue(args->last()); // Function. |
4276 | 4167 |
(...skipping 1249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5526 return ON_STACK_REPLACEMENT; | 5417 return ON_STACK_REPLACEMENT; |
5527 } | 5418 } |
5528 | 5419 |
5529 DCHECK(interrupt_address == | 5420 DCHECK(interrupt_address == |
5530 isolate->builtins()->OsrAfterStackCheck()->entry()); | 5421 isolate->builtins()->OsrAfterStackCheck()->entry()); |
5531 return OSR_AFTER_STACK_CHECK; | 5422 return OSR_AFTER_STACK_CHECK; |
5532 } | 5423 } |
5533 } // namespace internal | 5424 } // namespace internal |
5534 } // namespace v8 | 5425 } // namespace v8 |
5535 #endif // V8_TARGET_ARCH_PPC | 5426 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |