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

Side by Side Diff: src/crankshaft/arm/lithium-arm.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/arm/lithium-arm.h ('k') | src/crankshaft/arm64/lithium-arm64.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/arm/lithium-arm.h" 5 #include "src/crankshaft/arm/lithium-arm.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "src/crankshaft/arm/lithium-codegen-arm.h" 9 #include "src/crankshaft/arm/lithium-codegen-arm.h"
10 #include "src/crankshaft/hydrogen-osr.h" 10 #include "src/crankshaft/hydrogen-osr.h"
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 539
540 540
541 LInstruction* LChunkBuilder::DefineFixedDouble( 541 LInstruction* LChunkBuilder::DefineFixedDouble(
542 LTemplateResultInstruction<1>* instr, DoubleRegister reg) { 542 LTemplateResultInstruction<1>* instr, DoubleRegister reg) {
543 return Define(instr, ToUnallocated(reg)); 543 return Define(instr, ToUnallocated(reg));
544 } 544 }
545 545
546 546
547 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { 547 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) {
548 HEnvironment* hydrogen_env = current_block_->last_environment(); 548 HEnvironment* hydrogen_env = current_block_->last_environment();
549 int argument_index_accumulator = 0; 549 return LChunkBuilderBase::AssignEnvironment(instr, hydrogen_env);
550 ZoneList<HValue*> objects_to_materialize(0, zone());
551 instr->set_environment(CreateEnvironment(hydrogen_env,
552 &argument_index_accumulator,
553 &objects_to_materialize));
554 return instr;
555 } 550 }
556 551
557 552
558 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, 553 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr,
559 HInstruction* hinstr, 554 HInstruction* hinstr,
560 CanDeoptimize can_deoptimize) { 555 CanDeoptimize can_deoptimize) {
561 info()->MarkAsNonDeferredCalling(); 556 info()->MarkAsNonDeferredCalling();
562 #ifdef DEBUG 557 #ifdef DEBUG
563 instr->VerifyCall(); 558 instr->VerifyCall();
564 #endif 559 #endif
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 865
871 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) { 866 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) {
872 instr = AssignPointerMap(instr); 867 instr = AssignPointerMap(instr);
873 } 868 }
874 if (FLAG_stress_environments && !instr->HasEnvironment()) { 869 if (FLAG_stress_environments && !instr->HasEnvironment()) {
875 instr = AssignEnvironment(instr); 870 instr = AssignEnvironment(instr);
876 } 871 }
877 chunk_->AddInstruction(instr, current_block_); 872 chunk_->AddInstruction(instr, current_block_);
878 873
879 if (instr->IsCall()) { 874 if (instr->IsCall()) {
875 HEnvironment* hydrogen_env = current_block_->last_environment();
880 HValue* hydrogen_value_for_lazy_bailout = hydrogen_val; 876 HValue* hydrogen_value_for_lazy_bailout = hydrogen_val;
881 if (hydrogen_val->HasObservableSideEffects()) { 877 DCHECK_NOT_NULL(hydrogen_env);
882 HSimulate* sim = HSimulate::cast(hydrogen_val->next()); 878 if (instr->IsSyntacticTailCall()) {
883 sim->ReplayEnvironment(current_block_->last_environment()); 879 // If it was a syntactic tail call we need to drop the current frame and
884 hydrogen_value_for_lazy_bailout = sim; 880 // an arguments adaptor frame on top of it (if the latter is present).
881 hydrogen_env = hydrogen_env->outer();
882 if (hydrogen_env != nullptr &&
883 hydrogen_env->frame_type() == ARGUMENTS_ADAPTOR) {
884 hydrogen_env = hydrogen_env->outer();
885 }
886 if (hydrogen_env != nullptr) {
887 // Push return value on top of outer environment.
888 hydrogen_env = hydrogen_env->Copy();
889 hydrogen_env->Push(hydrogen_val);
890 }
891 } else {
892 if (hydrogen_val->HasObservableSideEffects()) {
893 HSimulate* sim = HSimulate::cast(hydrogen_val->next());
894 sim->ReplayEnvironment(hydrogen_env);
895 hydrogen_value_for_lazy_bailout = sim;
896 }
885 } 897 }
886 LInstruction* bailout = AssignEnvironment(new(zone()) LLazyBailout()); 898 if (hydrogen_env != nullptr) {
887 bailout->set_hydrogen_value(hydrogen_value_for_lazy_bailout); 899 // The |hydrogen_env| can be null at this point only if we are generating
888 chunk_->AddInstruction(bailout, current_block_); 900 // a syntactic tail call from the outermost function but in this case
901 // it would be a real tail call which will pop function's frame and
902 // therefore this lazy bailout can be skipped.
903 LInstruction* bailout = LChunkBuilderBase::AssignEnvironment(
904 new (zone()) LLazyBailout(), hydrogen_env);
905 bailout->set_hydrogen_value(hydrogen_value_for_lazy_bailout);
906 chunk_->AddInstruction(bailout, current_block_);
907 }
889 } 908 }
890 } 909 }
891 910
892 911
893 LInstruction* LChunkBuilder::DoPrologue(HPrologue* instr) { 912 LInstruction* LChunkBuilder::DoPrologue(HPrologue* instr) {
894 LInstruction* result = new (zone()) LPrologue(); 913 LInstruction* result = new (zone()) LPrologue();
895 if (info_->num_heap_slots() > 0) { 914 if (info_->num_heap_slots() > 0) {
896 result = MarkAsCall(result, instr); 915 result = MarkAsCall(result, instr);
897 } 916 }
898 return result; 917 return result;
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1058 i < instr->OperandCount(); i++) { 1077 i < instr->OperandCount(); i++) {
1059 op = 1078 op =
1060 UseFixed(instr->OperandAt(i), 1079 UseFixed(instr->OperandAt(i),
1061 descriptor.GetRegisterParameter( 1080 descriptor.GetRegisterParameter(
1062 i - LCallWithDescriptor::kImplicitRegisterParameterCount)); 1081 i - LCallWithDescriptor::kImplicitRegisterParameterCount));
1063 ops.Add(op, zone()); 1082 ops.Add(op, zone());
1064 } 1083 }
1065 1084
1066 LCallWithDescriptor* result = new(zone()) LCallWithDescriptor( 1085 LCallWithDescriptor* result = new(zone()) LCallWithDescriptor(
1067 descriptor, ops, zone()); 1086 descriptor, ops, zone());
1087 if (instr->syntactic_tail_call_mode() == TailCallMode::kAllow) {
1088 result->MarkAsSyntacticTailCall();
1089 }
1068 return MarkAsCall(DefineFixed(result, r0), instr); 1090 return MarkAsCall(DefineFixed(result, r0), instr);
1069 } 1091 }
1070 1092
1071 1093
1072 LInstruction* LChunkBuilder::DoInvokeFunction(HInvokeFunction* instr) { 1094 LInstruction* LChunkBuilder::DoInvokeFunction(HInvokeFunction* instr) {
1073 LOperand* context = UseFixed(instr->context(), cp); 1095 LOperand* context = UseFixed(instr->context(), cp);
1074 LOperand* function = UseFixed(instr->function(), r1); 1096 LOperand* function = UseFixed(instr->function(), r1);
1075 LInvokeFunction* result = new(zone()) LInvokeFunction(context, function); 1097 LInvokeFunction* result = new(zone()) LInvokeFunction(context, function);
1098 if (instr->syntactic_tail_call_mode() == TailCallMode::kAllow) {
1099 result->MarkAsSyntacticTailCall();
1100 }
1076 return MarkAsCall(DefineFixed(result, r0), instr, CANNOT_DEOPTIMIZE_EAGERLY); 1101 return MarkAsCall(DefineFixed(result, r0), instr, CANNOT_DEOPTIMIZE_EAGERLY);
1077 } 1102 }
1078 1103
1079 1104
1080 LInstruction* LChunkBuilder::DoUnaryMathOperation(HUnaryMathOperation* instr) { 1105 LInstruction* LChunkBuilder::DoUnaryMathOperation(HUnaryMathOperation* instr) {
1081 switch (instr->op()) { 1106 switch (instr->op()) {
1082 case kMathFloor: 1107 case kMathFloor:
1083 return DoMathFloor(instr); 1108 return DoMathFloor(instr);
1084 case kMathRound: 1109 case kMathRound:
1085 return DoMathRound(instr); 1110 return DoMathRound(instr);
(...skipping 1461 matching lines...) Expand 10 before | Expand all | Expand 10 after
2547 } 2572 }
2548 2573
2549 2574
2550 LInstruction* LChunkBuilder::DoStoreFrameContext(HStoreFrameContext* instr) { 2575 LInstruction* LChunkBuilder::DoStoreFrameContext(HStoreFrameContext* instr) {
2551 LOperand* context = UseRegisterAtStart(instr->context()); 2576 LOperand* context = UseRegisterAtStart(instr->context());
2552 return new(zone()) LStoreFrameContext(context); 2577 return new(zone()) LStoreFrameContext(context);
2553 } 2578 }
2554 2579
2555 } // namespace internal 2580 } // namespace internal
2556 } // namespace v8 2581 } // namespace v8
OLDNEW
« no previous file with comments | « src/crankshaft/arm/lithium-arm.h ('k') | src/crankshaft/arm64/lithium-arm64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698