| 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/x64/lithium-x64.h" | 5 #include "src/crankshaft/x64/lithium-x64.h" |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 | 8 |
| 9 #if V8_TARGET_ARCH_X64 | 9 #if V8_TARGET_ARCH_X64 |
| 10 | 10 |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 | 574 |
| 575 LInstruction* LChunkBuilder::DefineFixedDouble( | 575 LInstruction* LChunkBuilder::DefineFixedDouble( |
| 576 LTemplateResultInstruction<1>* instr, | 576 LTemplateResultInstruction<1>* instr, |
| 577 XMMRegister reg) { | 577 XMMRegister reg) { |
| 578 return Define(instr, ToUnallocated(reg)); | 578 return Define(instr, ToUnallocated(reg)); |
| 579 } | 579 } |
| 580 | 580 |
| 581 | 581 |
| 582 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { | 582 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { |
| 583 HEnvironment* hydrogen_env = current_block_->last_environment(); | 583 HEnvironment* hydrogen_env = current_block_->last_environment(); |
| 584 int argument_index_accumulator = 0; | 584 return LChunkBuilderBase::AssignEnvironment(instr, hydrogen_env); |
| 585 ZoneList<HValue*> objects_to_materialize(0, zone()); | |
| 586 instr->set_environment(CreateEnvironment( | |
| 587 hydrogen_env, &argument_index_accumulator, &objects_to_materialize)); | |
| 588 return instr; | |
| 589 } | 585 } |
| 590 | 586 |
| 591 | 587 |
| 592 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, | 588 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, |
| 593 HInstruction* hinstr, | 589 HInstruction* hinstr, |
| 594 CanDeoptimize can_deoptimize) { | 590 CanDeoptimize can_deoptimize) { |
| 595 info()->MarkAsNonDeferredCalling(); | 591 info()->MarkAsNonDeferredCalling(); |
| 596 | 592 |
| 597 #ifdef DEBUG | 593 #ifdef DEBUG |
| 598 instr->VerifyCall(); | 594 instr->VerifyCall(); |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 | 890 |
| 895 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) { | 891 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) { |
| 896 instr = AssignPointerMap(instr); | 892 instr = AssignPointerMap(instr); |
| 897 } | 893 } |
| 898 if (FLAG_stress_environments && !instr->HasEnvironment()) { | 894 if (FLAG_stress_environments && !instr->HasEnvironment()) { |
| 899 instr = AssignEnvironment(instr); | 895 instr = AssignEnvironment(instr); |
| 900 } | 896 } |
| 901 chunk_->AddInstruction(instr, current_block_); | 897 chunk_->AddInstruction(instr, current_block_); |
| 902 | 898 |
| 903 if (instr->IsCall()) { | 899 if (instr->IsCall()) { |
| 900 HEnvironment* hydrogen_env = current_block_->last_environment(); |
| 904 HValue* hydrogen_value_for_lazy_bailout = hydrogen_val; | 901 HValue* hydrogen_value_for_lazy_bailout = hydrogen_val; |
| 905 if (hydrogen_val->HasObservableSideEffects()) { | 902 DCHECK_NOT_NULL(hydrogen_env); |
| 906 HSimulate* sim = HSimulate::cast(hydrogen_val->next()); | 903 if (instr->IsSyntacticTailCall()) { |
| 907 sim->ReplayEnvironment(current_block_->last_environment()); | 904 // If it was a syntactic tail call we need to drop the current frame and |
| 908 hydrogen_value_for_lazy_bailout = sim; | 905 // an arguments adaptor frame on top of it (if the latter is present). |
| 906 hydrogen_env = hydrogen_env->outer(); |
| 907 if (hydrogen_env != nullptr && |
| 908 hydrogen_env->frame_type() == ARGUMENTS_ADAPTOR) { |
| 909 hydrogen_env = hydrogen_env->outer(); |
| 910 } |
| 911 if (hydrogen_env != nullptr) { |
| 912 // Push return value on top of outer environment. |
| 913 hydrogen_env = hydrogen_env->Copy(); |
| 914 hydrogen_env->Push(hydrogen_val); |
| 915 } |
| 916 } else { |
| 917 if (hydrogen_val->HasObservableSideEffects()) { |
| 918 HSimulate* sim = HSimulate::cast(hydrogen_val->next()); |
| 919 sim->ReplayEnvironment(hydrogen_env); |
| 920 hydrogen_value_for_lazy_bailout = sim; |
| 921 } |
| 909 } | 922 } |
| 910 LInstruction* bailout = AssignEnvironment(new(zone()) LLazyBailout()); | 923 if (hydrogen_env != nullptr) { |
| 911 bailout->set_hydrogen_value(hydrogen_value_for_lazy_bailout); | 924 // The |hydrogen_env| can be null at this point only if we are generating |
| 912 chunk_->AddInstruction(bailout, current_block_); | 925 // a syntactic tail call from the outermost function but in this case |
| 926 // it would be a real tail call which will pop function's frame and |
| 927 // therefore this lazy bailout can be skipped. |
| 928 LInstruction* bailout = LChunkBuilderBase::AssignEnvironment( |
| 929 new (zone()) LLazyBailout(), hydrogen_env); |
| 930 bailout->set_hydrogen_value(hydrogen_value_for_lazy_bailout); |
| 931 chunk_->AddInstruction(bailout, current_block_); |
| 932 } |
| 913 } | 933 } |
| 914 } | 934 } |
| 915 | 935 |
| 916 | 936 |
| 917 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { | 937 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { |
| 918 return new(zone()) LGoto(instr->FirstSuccessor()); | 938 return new(zone()) LGoto(instr->FirstSuccessor()); |
| 919 } | 939 } |
| 920 | 940 |
| 921 | 941 |
| 922 LInstruction* LChunkBuilder::DoPrologue(HPrologue* instr) { | 942 LInstruction* LChunkBuilder::DoPrologue(HPrologue* instr) { |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1080 i < instr->OperandCount(); i++) { | 1100 i < instr->OperandCount(); i++) { |
| 1081 op = | 1101 op = |
| 1082 UseFixed(instr->OperandAt(i), | 1102 UseFixed(instr->OperandAt(i), |
| 1083 descriptor.GetRegisterParameter( | 1103 descriptor.GetRegisterParameter( |
| 1084 i - LCallWithDescriptor::kImplicitRegisterParameterCount)); | 1104 i - LCallWithDescriptor::kImplicitRegisterParameterCount)); |
| 1085 ops.Add(op, zone()); | 1105 ops.Add(op, zone()); |
| 1086 } | 1106 } |
| 1087 | 1107 |
| 1088 LCallWithDescriptor* result = new(zone()) LCallWithDescriptor( | 1108 LCallWithDescriptor* result = new(zone()) LCallWithDescriptor( |
| 1089 descriptor, ops, zone()); | 1109 descriptor, ops, zone()); |
| 1110 if (instr->syntactic_tail_call_mode() == TailCallMode::kAllow) { |
| 1111 result->MarkAsSyntacticTailCall(); |
| 1112 } |
| 1090 return MarkAsCall(DefineFixed(result, rax), instr); | 1113 return MarkAsCall(DefineFixed(result, rax), instr); |
| 1091 } | 1114 } |
| 1092 | 1115 |
| 1093 | 1116 |
| 1094 LInstruction* LChunkBuilder::DoInvokeFunction(HInvokeFunction* instr) { | 1117 LInstruction* LChunkBuilder::DoInvokeFunction(HInvokeFunction* instr) { |
| 1095 LOperand* context = UseFixed(instr->context(), rsi); | 1118 LOperand* context = UseFixed(instr->context(), rsi); |
| 1096 LOperand* function = UseFixed(instr->function(), rdi); | 1119 LOperand* function = UseFixed(instr->function(), rdi); |
| 1097 LInvokeFunction* result = new(zone()) LInvokeFunction(context, function); | 1120 LInvokeFunction* result = new(zone()) LInvokeFunction(context, function); |
| 1121 if (instr->syntactic_tail_call_mode() == TailCallMode::kAllow) { |
| 1122 result->MarkAsSyntacticTailCall(); |
| 1123 } |
| 1098 return MarkAsCall(DefineFixed(result, rax), instr, CANNOT_DEOPTIMIZE_EAGERLY); | 1124 return MarkAsCall(DefineFixed(result, rax), instr, CANNOT_DEOPTIMIZE_EAGERLY); |
| 1099 } | 1125 } |
| 1100 | 1126 |
| 1101 | 1127 |
| 1102 LInstruction* LChunkBuilder::DoUnaryMathOperation(HUnaryMathOperation* instr) { | 1128 LInstruction* LChunkBuilder::DoUnaryMathOperation(HUnaryMathOperation* instr) { |
| 1103 switch (instr->op()) { | 1129 switch (instr->op()) { |
| 1104 case kMathFloor: | 1130 case kMathFloor: |
| 1105 return DoMathFloor(instr); | 1131 return DoMathFloor(instr); |
| 1106 case kMathRound: | 1132 case kMathRound: |
| 1107 return DoMathRound(instr); | 1133 return DoMathRound(instr); |
| (...skipping 1497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2605 LInstruction* LChunkBuilder::DoStoreFrameContext(HStoreFrameContext* instr) { | 2631 LInstruction* LChunkBuilder::DoStoreFrameContext(HStoreFrameContext* instr) { |
| 2606 LOperand* context = UseRegisterAtStart(instr->context()); | 2632 LOperand* context = UseRegisterAtStart(instr->context()); |
| 2607 return new(zone()) LStoreFrameContext(context); | 2633 return new(zone()) LStoreFrameContext(context); |
| 2608 } | 2634 } |
| 2609 | 2635 |
| 2610 | 2636 |
| 2611 } // namespace internal | 2637 } // namespace internal |
| 2612 } // namespace v8 | 2638 } // namespace v8 |
| 2613 | 2639 |
| 2614 #endif // V8_TARGET_ARCH_X64 | 2640 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |