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/crankshaft/mips/lithium-mips.h" | 5 #include "src/crankshaft/mips/lithium-mips.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #if V8_TARGET_ARCH_MIPS | 9 #if V8_TARGET_ARCH_MIPS |
10 | 10 |
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 | 546 |
547 | 547 |
548 LInstruction* LChunkBuilder::DefineFixedDouble( | 548 LInstruction* LChunkBuilder::DefineFixedDouble( |
549 LTemplateResultInstruction<1>* instr, DoubleRegister reg) { | 549 LTemplateResultInstruction<1>* instr, DoubleRegister reg) { |
550 return Define(instr, ToUnallocated(reg)); | 550 return Define(instr, ToUnallocated(reg)); |
551 } | 551 } |
552 | 552 |
553 | 553 |
554 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { | 554 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { |
555 HEnvironment* hydrogen_env = current_block_->last_environment(); | 555 HEnvironment* hydrogen_env = current_block_->last_environment(); |
556 int argument_index_accumulator = 0; | 556 return LChunkBuilderBase::AssignEnvironment(instr, hydrogen_env); |
557 ZoneList<HValue*> objects_to_materialize(0, zone()); | |
558 instr->set_environment(CreateEnvironment(hydrogen_env, | |
559 &argument_index_accumulator, | |
560 &objects_to_materialize)); | |
561 return instr; | |
562 } | 557 } |
563 | 558 |
564 | 559 |
565 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, | 560 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, |
566 HInstruction* hinstr, | 561 HInstruction* hinstr, |
567 CanDeoptimize can_deoptimize) { | 562 CanDeoptimize can_deoptimize) { |
568 info()->MarkAsNonDeferredCalling(); | 563 info()->MarkAsNonDeferredCalling(); |
569 #ifdef DEBUG | 564 #ifdef DEBUG |
570 instr->VerifyCall(); | 565 instr->VerifyCall(); |
571 #endif | 566 #endif |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
880 | 875 |
881 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) { | 876 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) { |
882 instr = AssignPointerMap(instr); | 877 instr = AssignPointerMap(instr); |
883 } | 878 } |
884 if (FLAG_stress_environments && !instr->HasEnvironment()) { | 879 if (FLAG_stress_environments && !instr->HasEnvironment()) { |
885 instr = AssignEnvironment(instr); | 880 instr = AssignEnvironment(instr); |
886 } | 881 } |
887 chunk_->AddInstruction(instr, current_block_); | 882 chunk_->AddInstruction(instr, current_block_); |
888 | 883 |
889 if (instr->IsCall()) { | 884 if (instr->IsCall()) { |
| 885 HEnvironment* hydrogen_env = current_block_->last_environment(); |
890 HValue* hydrogen_value_for_lazy_bailout = hydrogen_val; | 886 HValue* hydrogen_value_for_lazy_bailout = hydrogen_val; |
891 if (hydrogen_val->HasObservableSideEffects()) { | 887 DCHECK_NOT_NULL(hydrogen_env); |
892 HSimulate* sim = HSimulate::cast(hydrogen_val->next()); | 888 if (instr->IsSyntacticTailCall()) { |
893 sim->ReplayEnvironment(current_block_->last_environment()); | 889 // If it was a syntactic tail call we need to drop the current frame and |
894 hydrogen_value_for_lazy_bailout = sim; | 890 // an arguments adaptor frame on top of it (if the latter is present). |
| 891 hydrogen_env = hydrogen_env->outer(); |
| 892 if (hydrogen_env != nullptr && |
| 893 hydrogen_env->frame_type() == ARGUMENTS_ADAPTOR) { |
| 894 hydrogen_env = hydrogen_env->outer(); |
| 895 } |
| 896 if (hydrogen_env != nullptr) { |
| 897 // Push return value on top of outer environment. |
| 898 hydrogen_env = hydrogen_env->Copy(); |
| 899 hydrogen_env->Push(hydrogen_val); |
| 900 } |
| 901 } else { |
| 902 if (hydrogen_val->HasObservableSideEffects()) { |
| 903 HSimulate* sim = HSimulate::cast(hydrogen_val->next()); |
| 904 sim->ReplayEnvironment(hydrogen_env); |
| 905 hydrogen_value_for_lazy_bailout = sim; |
| 906 } |
895 } | 907 } |
896 LInstruction* bailout = AssignEnvironment(new(zone()) LLazyBailout()); | 908 if (hydrogen_env != nullptr) { |
897 bailout->set_hydrogen_value(hydrogen_value_for_lazy_bailout); | 909 // The |hydrogen_env| can be null at this point only if we are generating |
898 chunk_->AddInstruction(bailout, current_block_); | 910 // a syntactic tail call from the outermost function but in this case |
| 911 // it would be a real tail call which will pop function's frame and |
| 912 // therefore this lazy bailout can be skipped. |
| 913 LInstruction* bailout = LChunkBuilderBase::AssignEnvironment( |
| 914 new (zone()) LLazyBailout(), hydrogen_env); |
| 915 bailout->set_hydrogen_value(hydrogen_value_for_lazy_bailout); |
| 916 chunk_->AddInstruction(bailout, current_block_); |
| 917 } |
899 } | 918 } |
900 } | 919 } |
901 | 920 |
902 | 921 |
903 LInstruction* LChunkBuilder::DoPrologue(HPrologue* instr) { | 922 LInstruction* LChunkBuilder::DoPrologue(HPrologue* instr) { |
904 LInstruction* result = new (zone()) LPrologue(); | 923 LInstruction* result = new (zone()) LPrologue(); |
905 if (info_->num_heap_slots() > 0) { | 924 if (info_->num_heap_slots() > 0) { |
906 result = MarkAsCall(result, instr); | 925 result = MarkAsCall(result, instr); |
907 } | 926 } |
908 return result; | 927 return result; |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1063 i < instr->OperandCount(); i++) { | 1082 i < instr->OperandCount(); i++) { |
1064 op = | 1083 op = |
1065 UseFixed(instr->OperandAt(i), | 1084 UseFixed(instr->OperandAt(i), |
1066 descriptor.GetRegisterParameter( | 1085 descriptor.GetRegisterParameter( |
1067 i - LCallWithDescriptor::kImplicitRegisterParameterCount)); | 1086 i - LCallWithDescriptor::kImplicitRegisterParameterCount)); |
1068 ops.Add(op, zone()); | 1087 ops.Add(op, zone()); |
1069 } | 1088 } |
1070 | 1089 |
1071 LCallWithDescriptor* result = new(zone()) LCallWithDescriptor( | 1090 LCallWithDescriptor* result = new(zone()) LCallWithDescriptor( |
1072 descriptor, ops, zone()); | 1091 descriptor, ops, zone()); |
| 1092 if (instr->syntactic_tail_call_mode() == TailCallMode::kAllow) { |
| 1093 result->MarkAsSyntacticTailCall(); |
| 1094 } |
1073 return MarkAsCall(DefineFixed(result, v0), instr); | 1095 return MarkAsCall(DefineFixed(result, v0), instr); |
1074 } | 1096 } |
1075 | 1097 |
1076 | 1098 |
1077 LInstruction* LChunkBuilder::DoInvokeFunction(HInvokeFunction* instr) { | 1099 LInstruction* LChunkBuilder::DoInvokeFunction(HInvokeFunction* instr) { |
1078 LOperand* context = UseFixed(instr->context(), cp); | 1100 LOperand* context = UseFixed(instr->context(), cp); |
1079 LOperand* function = UseFixed(instr->function(), a1); | 1101 LOperand* function = UseFixed(instr->function(), a1); |
1080 LInvokeFunction* result = new(zone()) LInvokeFunction(context, function); | 1102 LInvokeFunction* result = new(zone()) LInvokeFunction(context, function); |
| 1103 if (instr->syntactic_tail_call_mode() == TailCallMode::kAllow) { |
| 1104 result->MarkAsSyntacticTailCall(); |
| 1105 } |
1081 return MarkAsCall(DefineFixed(result, v0), instr, CANNOT_DEOPTIMIZE_EAGERLY); | 1106 return MarkAsCall(DefineFixed(result, v0), instr, CANNOT_DEOPTIMIZE_EAGERLY); |
1082 } | 1107 } |
1083 | 1108 |
1084 | 1109 |
1085 LInstruction* LChunkBuilder::DoUnaryMathOperation(HUnaryMathOperation* instr) { | 1110 LInstruction* LChunkBuilder::DoUnaryMathOperation(HUnaryMathOperation* instr) { |
1086 switch (instr->op()) { | 1111 switch (instr->op()) { |
1087 case kMathFloor: | 1112 case kMathFloor: |
1088 return DoMathFloor(instr); | 1113 return DoMathFloor(instr); |
1089 case kMathRound: | 1114 case kMathRound: |
1090 return DoMathRound(instr); | 1115 return DoMathRound(instr); |
(...skipping 1406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2497 | 2522 |
2498 LInstruction* LChunkBuilder::DoStoreFrameContext(HStoreFrameContext* instr) { | 2523 LInstruction* LChunkBuilder::DoStoreFrameContext(HStoreFrameContext* instr) { |
2499 LOperand* context = UseRegisterAtStart(instr->context()); | 2524 LOperand* context = UseRegisterAtStart(instr->context()); |
2500 return new(zone()) LStoreFrameContext(context); | 2525 return new(zone()) LStoreFrameContext(context); |
2501 } | 2526 } |
2502 | 2527 |
2503 } // namespace internal | 2528 } // namespace internal |
2504 } // namespace v8 | 2529 } // namespace v8 |
2505 | 2530 |
2506 #endif // V8_TARGET_ARCH_MIPS | 2531 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |