Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(374)

Side by Side Diff: src/crankshaft/ia32/lithium-ia32.cc

Issue 1780043004: [crankshaft] Fixing ES6 tail call elimination. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebasing Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/crankshaft/ia32/lithium-ia32.h ('k') | src/crankshaft/lithium.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/ia32/lithium-ia32.h" 5 #include "src/crankshaft/ia32/lithium-ia32.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 8
9 #if V8_TARGET_ARCH_IA32 9 #if V8_TARGET_ARCH_IA32
10 10
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 583
584 LInstruction* LChunkBuilder::DefineFixedDouble( 584 LInstruction* LChunkBuilder::DefineFixedDouble(
585 LTemplateResultInstruction<1>* instr, 585 LTemplateResultInstruction<1>* instr,
586 XMMRegister reg) { 586 XMMRegister reg) {
587 return Define(instr, ToUnallocated(reg)); 587 return Define(instr, ToUnallocated(reg));
588 } 588 }
589 589
590 590
591 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { 591 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) {
592 HEnvironment* hydrogen_env = current_block_->last_environment(); 592 HEnvironment* hydrogen_env = current_block_->last_environment();
593 int argument_index_accumulator = 0; 593 return LChunkBuilderBase::AssignEnvironment(instr, hydrogen_env);
594 ZoneList<HValue*> objects_to_materialize(0, zone());
595 instr->set_environment(CreateEnvironment(
596 hydrogen_env, &argument_index_accumulator, &objects_to_materialize));
597 return instr;
598 } 594 }
599 595
600 596
601 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, 597 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr,
602 HInstruction* hinstr, 598 HInstruction* hinstr,
603 CanDeoptimize can_deoptimize) { 599 CanDeoptimize can_deoptimize) {
604 info()->MarkAsNonDeferredCalling(); 600 info()->MarkAsNonDeferredCalling();
605 601
606 #ifdef DEBUG 602 #ifdef DEBUG
607 instr->VerifyCall(); 603 instr->VerifyCall();
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
902 898
903 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) { 899 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) {
904 instr = AssignPointerMap(instr); 900 instr = AssignPointerMap(instr);
905 } 901 }
906 if (FLAG_stress_environments && !instr->HasEnvironment()) { 902 if (FLAG_stress_environments && !instr->HasEnvironment()) {
907 instr = AssignEnvironment(instr); 903 instr = AssignEnvironment(instr);
908 } 904 }
909 chunk_->AddInstruction(instr, current_block_); 905 chunk_->AddInstruction(instr, current_block_);
910 906
911 if (instr->IsCall()) { 907 if (instr->IsCall()) {
908 HEnvironment* hydrogen_env = current_block_->last_environment();
912 HValue* hydrogen_value_for_lazy_bailout = hydrogen_val; 909 HValue* hydrogen_value_for_lazy_bailout = hydrogen_val;
913 if (hydrogen_val->HasObservableSideEffects()) { 910 DCHECK_NOT_NULL(hydrogen_env);
914 HSimulate* sim = HSimulate::cast(hydrogen_val->next()); 911 if (instr->IsSyntacticTailCall()) {
915 sim->ReplayEnvironment(current_block_->last_environment()); 912 // If it was a syntactic tail call we need to drop the current frame and
916 hydrogen_value_for_lazy_bailout = sim; 913 // an arguments adaptor frame on top of it (if the latter is present).
914 hydrogen_env = hydrogen_env->outer();
915 if (hydrogen_env != nullptr &&
916 hydrogen_env->frame_type() == ARGUMENTS_ADAPTOR) {
917 hydrogen_env = hydrogen_env->outer();
918 }
919 if (hydrogen_env != nullptr) {
920 // Push return value on top of outer environment.
921 hydrogen_env = hydrogen_env->Copy();
922 hydrogen_env->Push(hydrogen_val);
923 }
924 } else {
925 if (hydrogen_val->HasObservableSideEffects()) {
926 HSimulate* sim = HSimulate::cast(hydrogen_val->next());
927 sim->ReplayEnvironment(hydrogen_env);
928 hydrogen_value_for_lazy_bailout = sim;
929 }
917 } 930 }
918 LInstruction* bailout = AssignEnvironment(new(zone()) LLazyBailout()); 931 if (hydrogen_env != nullptr) {
919 bailout->set_hydrogen_value(hydrogen_value_for_lazy_bailout); 932 // The |hydrogen_env| can be null at this point only if we are generating
920 chunk_->AddInstruction(bailout, current_block_); 933 // a syntactic tail call from the outermost function but in this case
934 // it would be a real tail call which will pop function's frame and
935 // therefore this lazy bailout can be skipped.
936 LInstruction* bailout = LChunkBuilderBase::AssignEnvironment(
937 new (zone()) LLazyBailout(), hydrogen_env);
938 bailout->set_hydrogen_value(hydrogen_value_for_lazy_bailout);
939 chunk_->AddInstruction(bailout, current_block_);
940 }
921 } 941 }
922 } 942 }
923 943
924 944
925 LInstruction* LChunkBuilder::DoPrologue(HPrologue* instr) { 945 LInstruction* LChunkBuilder::DoPrologue(HPrologue* instr) {
926 LInstruction* result = new (zone()) LPrologue(); 946 LInstruction* result = new (zone()) LPrologue();
927 if (info_->num_heap_slots() > 0) { 947 if (info_->num_heap_slots() > 0) {
928 result = MarkAsCall(result, instr); 948 result = MarkAsCall(result, instr);
929 } 949 }
930 return result; 950 return result;
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 i < instr->OperandCount(); i++) { 1111 i < instr->OperandCount(); i++) {
1092 op = 1112 op =
1093 UseFixed(instr->OperandAt(i), 1113 UseFixed(instr->OperandAt(i),
1094 descriptor.GetRegisterParameter( 1114 descriptor.GetRegisterParameter(
1095 i - LCallWithDescriptor::kImplicitRegisterParameterCount)); 1115 i - LCallWithDescriptor::kImplicitRegisterParameterCount));
1096 ops.Add(op, zone()); 1116 ops.Add(op, zone());
1097 } 1117 }
1098 1118
1099 LCallWithDescriptor* result = new(zone()) LCallWithDescriptor( 1119 LCallWithDescriptor* result = new(zone()) LCallWithDescriptor(
1100 descriptor, ops, zone()); 1120 descriptor, ops, zone());
1121 if (instr->syntactic_tail_call_mode() == TailCallMode::kAllow) {
1122 result->MarkAsSyntacticTailCall();
1123 }
1101 return MarkAsCall(DefineFixed(result, eax), instr, CANNOT_DEOPTIMIZE_EAGERLY); 1124 return MarkAsCall(DefineFixed(result, eax), instr, CANNOT_DEOPTIMIZE_EAGERLY);
1102 } 1125 }
1103 1126
1104 1127
1105 LInstruction* LChunkBuilder::DoInvokeFunction(HInvokeFunction* instr) { 1128 LInstruction* LChunkBuilder::DoInvokeFunction(HInvokeFunction* instr) {
1106 LOperand* context = UseFixed(instr->context(), esi); 1129 LOperand* context = UseFixed(instr->context(), esi);
1107 LOperand* function = UseFixed(instr->function(), edi); 1130 LOperand* function = UseFixed(instr->function(), edi);
1108 LInvokeFunction* result = new(zone()) LInvokeFunction(context, function); 1131 LInvokeFunction* result = new(zone()) LInvokeFunction(context, function);
1132 if (instr->syntactic_tail_call_mode() == TailCallMode::kAllow) {
1133 result->MarkAsSyntacticTailCall();
1134 }
1109 return MarkAsCall(DefineFixed(result, eax), instr, CANNOT_DEOPTIMIZE_EAGERLY); 1135 return MarkAsCall(DefineFixed(result, eax), instr, CANNOT_DEOPTIMIZE_EAGERLY);
1110 } 1136 }
1111 1137
1112 1138
1113 LInstruction* LChunkBuilder::DoUnaryMathOperation(HUnaryMathOperation* instr) { 1139 LInstruction* LChunkBuilder::DoUnaryMathOperation(HUnaryMathOperation* instr) {
1114 switch (instr->op()) { 1140 switch (instr->op()) {
1115 case kMathFloor: 1141 case kMathFloor:
1116 return DoMathFloor(instr); 1142 return DoMathFloor(instr);
1117 case kMathRound: 1143 case kMathRound:
1118 return DoMathRound(instr); 1144 return DoMathRound(instr);
(...skipping 1483 matching lines...) Expand 10 before | Expand all | Expand 10 after
2602 LInstruction* LChunkBuilder::DoStoreFrameContext(HStoreFrameContext* instr) { 2628 LInstruction* LChunkBuilder::DoStoreFrameContext(HStoreFrameContext* instr) {
2603 LOperand* context = UseRegisterAtStart(instr->context()); 2629 LOperand* context = UseRegisterAtStart(instr->context());
2604 return new(zone()) LStoreFrameContext(context); 2630 return new(zone()) LStoreFrameContext(context);
2605 } 2631 }
2606 2632
2607 2633
2608 } // namespace internal 2634 } // namespace internal
2609 } // namespace v8 2635 } // namespace v8
2610 2636
2611 #endif // V8_TARGET_ARCH_IA32 2637 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/crankshaft/ia32/lithium-ia32.h ('k') | src/crankshaft/lithium.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698