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/x87/lithium-x87.h" | 5 #include "src/crankshaft/x87/lithium-x87.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #if V8_TARGET_ARCH_X87 | 9 #if V8_TARGET_ARCH_X87 |
10 | 10 |
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 | 588 |
589 | 589 |
590 LInstruction* LChunkBuilder::DefineFixed(LTemplateResultInstruction<1>* instr, | 590 LInstruction* LChunkBuilder::DefineFixed(LTemplateResultInstruction<1>* instr, |
591 X87Register reg) { | 591 X87Register reg) { |
592 return Define(instr, ToUnallocated(reg)); | 592 return Define(instr, ToUnallocated(reg)); |
593 } | 593 } |
594 | 594 |
595 | 595 |
596 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { | 596 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { |
597 HEnvironment* hydrogen_env = current_block_->last_environment(); | 597 HEnvironment* hydrogen_env = current_block_->last_environment(); |
598 int argument_index_accumulator = 0; | 598 return LChunkBuilderBase::AssignEnvironment(instr, hydrogen_env); |
599 ZoneList<HValue*> objects_to_materialize(0, zone()); | |
600 instr->set_environment(CreateEnvironment(hydrogen_env, | |
601 &argument_index_accumulator, | |
602 &objects_to_materialize)); | |
603 return instr; | |
604 } | 599 } |
605 | 600 |
606 | 601 |
607 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, | 602 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, |
608 HInstruction* hinstr, | 603 HInstruction* hinstr, |
609 CanDeoptimize can_deoptimize) { | 604 CanDeoptimize can_deoptimize) { |
610 info()->MarkAsNonDeferredCalling(); | 605 info()->MarkAsNonDeferredCalling(); |
611 | 606 |
612 #ifdef DEBUG | 607 #ifdef DEBUG |
613 instr->VerifyCall(); | 608 instr->VerifyCall(); |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 // (not in the stack slot), we need to allow the goto gaps to keep one | 913 // (not in the stack slot), we need to allow the goto gaps to keep one |
919 // x87 register alive. To ensure all other values are still spilled, we | 914 // x87 register alive. To ensure all other values are still spilled, we |
920 // insert a fpu register barrier right before. | 915 // insert a fpu register barrier right before. |
921 LClobberDoubles* clobber = new(zone()) LClobberDoubles(isolate()); | 916 LClobberDoubles* clobber = new(zone()) LClobberDoubles(isolate()); |
922 clobber->set_hydrogen_value(hydrogen_val); | 917 clobber->set_hydrogen_value(hydrogen_val); |
923 chunk_->AddInstruction(clobber, current_block_); | 918 chunk_->AddInstruction(clobber, current_block_); |
924 } | 919 } |
925 chunk_->AddInstruction(instr, current_block_); | 920 chunk_->AddInstruction(instr, current_block_); |
926 | 921 |
927 if (instr->IsCall()) { | 922 if (instr->IsCall()) { |
| 923 HEnvironment* hydrogen_env = current_block_->last_environment(); |
928 HValue* hydrogen_value_for_lazy_bailout = hydrogen_val; | 924 HValue* hydrogen_value_for_lazy_bailout = hydrogen_val; |
929 if (hydrogen_val->HasObservableSideEffects()) { | 925 DCHECK_NOT_NULL(hydrogen_env); |
930 HSimulate* sim = HSimulate::cast(hydrogen_val->next()); | 926 if (instr->IsSyntacticTailCall()) { |
931 sim->ReplayEnvironment(current_block_->last_environment()); | 927 // If it was a syntactic tail call we need to drop the current frame and |
932 hydrogen_value_for_lazy_bailout = sim; | 928 // an arguments adaptor frame on top of it (if the latter is present). |
| 929 hydrogen_env = hydrogen_env->outer(); |
| 930 if (hydrogen_env != nullptr && |
| 931 hydrogen_env->frame_type() == ARGUMENTS_ADAPTOR) { |
| 932 hydrogen_env = hydrogen_env->outer(); |
| 933 } |
| 934 if (hydrogen_env != nullptr) { |
| 935 // Push return value on top of outer environment. |
| 936 hydrogen_env = hydrogen_env->Copy(); |
| 937 hydrogen_env->Push(hydrogen_val); |
| 938 } |
| 939 } else { |
| 940 if (hydrogen_val->HasObservableSideEffects()) { |
| 941 HSimulate* sim = HSimulate::cast(hydrogen_val->next()); |
| 942 sim->ReplayEnvironment(hydrogen_env); |
| 943 hydrogen_value_for_lazy_bailout = sim; |
| 944 } |
933 } | 945 } |
934 LInstruction* bailout = AssignEnvironment(new(zone()) LLazyBailout()); | 946 if (hydrogen_env != nullptr) { |
935 bailout->set_hydrogen_value(hydrogen_value_for_lazy_bailout); | 947 // The |hydrogen_env| can be null at this point only if we are generating |
936 chunk_->AddInstruction(bailout, current_block_); | 948 // a syntactic tail call from the outermost function but in this case |
| 949 // it would be a real tail call which will pop function's frame and |
| 950 // therefore this lazy bailout can be skipped. |
| 951 LInstruction* bailout = LChunkBuilderBase::AssignEnvironment( |
| 952 new (zone()) LLazyBailout(), hydrogen_env); |
| 953 bailout->set_hydrogen_value(hydrogen_value_for_lazy_bailout); |
| 954 chunk_->AddInstruction(bailout, current_block_); |
| 955 } |
937 } | 956 } |
938 } | 957 } |
939 | 958 |
940 | 959 |
941 LInstruction* LChunkBuilder::DoPrologue(HPrologue* instr) { | 960 LInstruction* LChunkBuilder::DoPrologue(HPrologue* instr) { |
942 LInstruction* result = new (zone()) LPrologue(); | 961 LInstruction* result = new (zone()) LPrologue(); |
943 if (info_->num_heap_slots() > 0) { | 962 if (info_->num_heap_slots() > 0) { |
944 result = MarkAsCall(result, instr); | 963 result = MarkAsCall(result, instr); |
945 } | 964 } |
946 return result; | 965 return result; |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1109 i < instr->OperandCount(); i++) { | 1128 i < instr->OperandCount(); i++) { |
1110 op = | 1129 op = |
1111 UseFixed(instr->OperandAt(i), | 1130 UseFixed(instr->OperandAt(i), |
1112 descriptor.GetRegisterParameter( | 1131 descriptor.GetRegisterParameter( |
1113 i - LCallWithDescriptor::kImplicitRegisterParameterCount)); | 1132 i - LCallWithDescriptor::kImplicitRegisterParameterCount)); |
1114 ops.Add(op, zone()); | 1133 ops.Add(op, zone()); |
1115 } | 1134 } |
1116 | 1135 |
1117 LCallWithDescriptor* result = new(zone()) LCallWithDescriptor( | 1136 LCallWithDescriptor* result = new(zone()) LCallWithDescriptor( |
1118 descriptor, ops, zone()); | 1137 descriptor, ops, zone()); |
| 1138 if (instr->syntactic_tail_call_mode() == TailCallMode::kAllow) { |
| 1139 result->MarkAsSyntacticTailCall(); |
| 1140 } |
1119 return MarkAsCall(DefineFixed(result, eax), instr, CANNOT_DEOPTIMIZE_EAGERLY); | 1141 return MarkAsCall(DefineFixed(result, eax), instr, CANNOT_DEOPTIMIZE_EAGERLY); |
1120 } | 1142 } |
1121 | 1143 |
1122 | 1144 |
1123 LInstruction* LChunkBuilder::DoInvokeFunction(HInvokeFunction* instr) { | 1145 LInstruction* LChunkBuilder::DoInvokeFunction(HInvokeFunction* instr) { |
1124 LOperand* context = UseFixed(instr->context(), esi); | 1146 LOperand* context = UseFixed(instr->context(), esi); |
1125 LOperand* function = UseFixed(instr->function(), edi); | 1147 LOperand* function = UseFixed(instr->function(), edi); |
1126 LInvokeFunction* result = new(zone()) LInvokeFunction(context, function); | 1148 LInvokeFunction* result = new(zone()) LInvokeFunction(context, function); |
| 1149 if (instr->syntactic_tail_call_mode() == TailCallMode::kAllow) { |
| 1150 result->MarkAsSyntacticTailCall(); |
| 1151 } |
1127 return MarkAsCall(DefineFixed(result, eax), instr, CANNOT_DEOPTIMIZE_EAGERLY); | 1152 return MarkAsCall(DefineFixed(result, eax), instr, CANNOT_DEOPTIMIZE_EAGERLY); |
1128 } | 1153 } |
1129 | 1154 |
1130 | 1155 |
1131 LInstruction* LChunkBuilder::DoUnaryMathOperation(HUnaryMathOperation* instr) { | 1156 LInstruction* LChunkBuilder::DoUnaryMathOperation(HUnaryMathOperation* instr) { |
1132 switch (instr->op()) { | 1157 switch (instr->op()) { |
1133 case kMathFloor: return DoMathFloor(instr); | 1158 case kMathFloor: return DoMathFloor(instr); |
1134 case kMathRound: return DoMathRound(instr); | 1159 case kMathRound: return DoMathRound(instr); |
1135 case kMathFround: return DoMathFround(instr); | 1160 case kMathFround: return DoMathFround(instr); |
1136 case kMathAbs: return DoMathAbs(instr); | 1161 case kMathAbs: return DoMathAbs(instr); |
(...skipping 1463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2600 LInstruction* LChunkBuilder::DoStoreFrameContext(HStoreFrameContext* instr) { | 2625 LInstruction* LChunkBuilder::DoStoreFrameContext(HStoreFrameContext* instr) { |
2601 LOperand* context = UseRegisterAtStart(instr->context()); | 2626 LOperand* context = UseRegisterAtStart(instr->context()); |
2602 return new(zone()) LStoreFrameContext(context); | 2627 return new(zone()) LStoreFrameContext(context); |
2603 } | 2628 } |
2604 | 2629 |
2605 | 2630 |
2606 } // namespace internal | 2631 } // namespace internal |
2607 } // namespace v8 | 2632 } // namespace v8 |
2608 | 2633 |
2609 #endif // V8_TARGET_ARCH_X87 | 2634 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |