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

Side by Side Diff: src/crankshaft/arm64/lithium-arm64.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/arm64/lithium-arm64.h ('k') | src/crankshaft/hydrogen.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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/arm64/lithium-arm64.h" 5 #include "src/crankshaft/arm64/lithium-arm64.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "src/crankshaft/arm64/lithium-codegen-arm64.h" 9 #include "src/crankshaft/arm64/lithium-codegen-arm64.h"
10 #include "src/crankshaft/hydrogen-osr.h" 10 #include "src/crankshaft/hydrogen-osr.h"
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 708
709 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) { 709 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) {
710 instr = AssignPointerMap(instr); 710 instr = AssignPointerMap(instr);
711 } 711 }
712 if (FLAG_stress_environments && !instr->HasEnvironment()) { 712 if (FLAG_stress_environments && !instr->HasEnvironment()) {
713 instr = AssignEnvironment(instr); 713 instr = AssignEnvironment(instr);
714 } 714 }
715 chunk_->AddInstruction(instr, current_block_); 715 chunk_->AddInstruction(instr, current_block_);
716 716
717 if (instr->IsCall()) { 717 if (instr->IsCall()) {
718 HEnvironment* hydrogen_env = current_block_->last_environment();
718 HValue* hydrogen_value_for_lazy_bailout = hydrogen_val; 719 HValue* hydrogen_value_for_lazy_bailout = hydrogen_val;
719 if (hydrogen_val->HasObservableSideEffects()) { 720 DCHECK_NOT_NULL(hydrogen_env);
720 HSimulate* sim = HSimulate::cast(hydrogen_val->next()); 721 if (instr->IsSyntacticTailCall()) {
721 sim->ReplayEnvironment(current_block_->last_environment()); 722 // If it was a syntactic tail call we need to drop the current frame and
722 hydrogen_value_for_lazy_bailout = sim; 723 // an arguments adaptor frame on top of it (if the latter is present).
724 hydrogen_env = hydrogen_env->outer();
725 if (hydrogen_env != nullptr &&
726 hydrogen_env->frame_type() == ARGUMENTS_ADAPTOR) {
727 hydrogen_env = hydrogen_env->outer();
728 }
729 if (hydrogen_env != nullptr) {
730 // Push return value on top of outer environment.
731 hydrogen_env = hydrogen_env->Copy();
732 hydrogen_env->Push(hydrogen_val);
733 }
734 } else {
735 if (hydrogen_val->HasObservableSideEffects()) {
736 HSimulate* sim = HSimulate::cast(hydrogen_val->next());
737 sim->ReplayEnvironment(hydrogen_env);
738 hydrogen_value_for_lazy_bailout = sim;
739 }
723 } 740 }
724 LInstruction* bailout = AssignEnvironment(new(zone()) LLazyBailout()); 741 if (hydrogen_env != nullptr) {
725 bailout->set_hydrogen_value(hydrogen_value_for_lazy_bailout); 742 // The |hydrogen_env| can be null at this point only if we are generating
726 chunk_->AddInstruction(bailout, current_block_); 743 // a syntactic tail call from the outermost function but in this case
744 // it would be a real tail call which will pop function's frame and
745 // therefore this lazy bailout can be skipped.
746 LInstruction* bailout = LChunkBuilderBase::AssignEnvironment(
747 new (zone()) LLazyBailout(), hydrogen_env);
748 bailout->set_hydrogen_value(hydrogen_value_for_lazy_bailout);
749 chunk_->AddInstruction(bailout, current_block_);
750 }
727 } 751 }
728 } 752 }
729 753
730 754
731 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { 755 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) {
732 HEnvironment* hydrogen_env = current_block_->last_environment(); 756 HEnvironment* hydrogen_env = current_block_->last_environment();
733 int argument_index_accumulator = 0; 757 return LChunkBuilderBase::AssignEnvironment(instr, hydrogen_env);
734 ZoneList<HValue*> objects_to_materialize(0, zone());
735 instr->set_environment(CreateEnvironment(hydrogen_env,
736 &argument_index_accumulator,
737 &objects_to_materialize));
738 return instr;
739 } 758 }
740 759
741 760
742 LInstruction* LChunkBuilder::DoPrologue(HPrologue* instr) { 761 LInstruction* LChunkBuilder::DoPrologue(HPrologue* instr) {
743 LInstruction* result = new (zone()) LPrologue(); 762 LInstruction* result = new (zone()) LPrologue();
744 if (info_->num_heap_slots() > 0) { 763 if (info_->num_heap_slots() > 0) {
745 result = MarkAsCall(result, instr); 764 result = MarkAsCall(result, instr);
746 } 765 }
747 return result; 766 return result;
748 } 767 }
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
1011 op = 1030 op =
1012 UseFixed(instr->OperandAt(i), 1031 UseFixed(instr->OperandAt(i),
1013 descriptor.GetRegisterParameter( 1032 descriptor.GetRegisterParameter(
1014 i - LCallWithDescriptor::kImplicitRegisterParameterCount)); 1033 i - LCallWithDescriptor::kImplicitRegisterParameterCount));
1015 ops.Add(op, zone()); 1034 ops.Add(op, zone());
1016 } 1035 }
1017 1036
1018 LCallWithDescriptor* result = new(zone()) LCallWithDescriptor(descriptor, 1037 LCallWithDescriptor* result = new(zone()) LCallWithDescriptor(descriptor,
1019 ops, 1038 ops,
1020 zone()); 1039 zone());
1040 if (instr->syntactic_tail_call_mode() == TailCallMode::kAllow) {
1041 result->MarkAsSyntacticTailCall();
1042 }
1021 return MarkAsCall(DefineFixed(result, x0), instr); 1043 return MarkAsCall(DefineFixed(result, x0), instr);
1022 } 1044 }
1023 1045
1024 1046
1025 LInstruction* LChunkBuilder::DoCallNewArray(HCallNewArray* instr) { 1047 LInstruction* LChunkBuilder::DoCallNewArray(HCallNewArray* instr) {
1026 LOperand* context = UseFixed(instr->context(), cp); 1048 LOperand* context = UseFixed(instr->context(), cp);
1027 // The call to ArrayConstructCode will expect the constructor to be in x1. 1049 // The call to ArrayConstructCode will expect the constructor to be in x1.
1028 LOperand* constructor = UseFixed(instr->constructor(), x1); 1050 LOperand* constructor = UseFixed(instr->constructor(), x1);
1029 LCallNewArray* result = new(zone()) LCallNewArray(context, constructor); 1051 LCallNewArray* result = new(zone()) LCallNewArray(context, constructor);
1030 return MarkAsCall(DefineFixed(result, x0), instr); 1052 return MarkAsCall(DefineFixed(result, x0), instr);
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
1503 LHasInPrototypeChainAndBranch(object, prototype, scratch1, scratch2); 1525 LHasInPrototypeChainAndBranch(object, prototype, scratch1, scratch2);
1504 return AssignEnvironment(result); 1526 return AssignEnvironment(result);
1505 } 1527 }
1506 1528
1507 1529
1508 LInstruction* LChunkBuilder::DoInvokeFunction(HInvokeFunction* instr) { 1530 LInstruction* LChunkBuilder::DoInvokeFunction(HInvokeFunction* instr) {
1509 LOperand* context = UseFixed(instr->context(), cp); 1531 LOperand* context = UseFixed(instr->context(), cp);
1510 // The function is required (by MacroAssembler::InvokeFunction) to be in x1. 1532 // The function is required (by MacroAssembler::InvokeFunction) to be in x1.
1511 LOperand* function = UseFixed(instr->function(), x1); 1533 LOperand* function = UseFixed(instr->function(), x1);
1512 LInvokeFunction* result = new(zone()) LInvokeFunction(context, function); 1534 LInvokeFunction* result = new(zone()) LInvokeFunction(context, function);
1535 if (instr->syntactic_tail_call_mode() == TailCallMode::kAllow) {
1536 result->MarkAsSyntacticTailCall();
1537 }
1513 return MarkAsCall(DefineFixed(result, x0), instr, CANNOT_DEOPTIMIZE_EAGERLY); 1538 return MarkAsCall(DefineFixed(result, x0), instr, CANNOT_DEOPTIMIZE_EAGERLY);
1514 } 1539 }
1515 1540
1516 1541
1517 LInstruction* LChunkBuilder::DoIsStringAndBranch(HIsStringAndBranch* instr) { 1542 LInstruction* LChunkBuilder::DoIsStringAndBranch(HIsStringAndBranch* instr) {
1518 DCHECK(instr->value()->representation().IsTagged()); 1543 DCHECK(instr->value()->representation().IsTagged());
1519 LOperand* value = UseRegisterAtStart(instr->value()); 1544 LOperand* value = UseRegisterAtStart(instr->value());
1520 LOperand* temp = TempRegister(); 1545 LOperand* temp = TempRegister();
1521 return new(zone()) LIsStringAndBranch(value, temp); 1546 return new(zone()) LIsStringAndBranch(value, temp);
1522 } 1547 }
(...skipping 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after
2640 2665
2641 2666
2642 LInstruction* LChunkBuilder::DoStoreFrameContext(HStoreFrameContext* instr) { 2667 LInstruction* LChunkBuilder::DoStoreFrameContext(HStoreFrameContext* instr) {
2643 LOperand* context = UseRegisterAtStart(instr->context()); 2668 LOperand* context = UseRegisterAtStart(instr->context());
2644 return new(zone()) LStoreFrameContext(context); 2669 return new(zone()) LStoreFrameContext(context);
2645 } 2670 }
2646 2671
2647 2672
2648 } // namespace internal 2673 } // namespace internal
2649 } // namespace v8 2674 } // namespace v8
OLDNEW
« no previous file with comments | « src/crankshaft/arm64/lithium-arm64.h ('k') | src/crankshaft/hydrogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698