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

Side by Side Diff: src/hydrogen.cc

Issue 23710070: Allow control intructions to have side effects. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: extend test Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « src/arm/lithium-codegen-arm.cc ('k') | src/hydrogen-instructions.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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 2637 matching lines...) Expand 10 before | Expand all | Expand 10 after
2648 ASSERT(!instr->IsControlInstruction()); 2648 ASSERT(!instr->IsControlInstruction());
2649 owner()->AddInstruction(instr); 2649 owner()->AddInstruction(instr);
2650 if (instr->HasObservableSideEffects()) { 2650 if (instr->HasObservableSideEffects()) {
2651 owner()->Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); 2651 owner()->Add<HSimulate>(ast_id, REMOVABLE_SIMULATE);
2652 } 2652 }
2653 } 2653 }
2654 2654
2655 2655
2656 void EffectContext::ReturnControl(HControlInstruction* instr, 2656 void EffectContext::ReturnControl(HControlInstruction* instr,
2657 BailoutId ast_id) { 2657 BailoutId ast_id) {
2658 ASSERT(!instr->HasObservableSideEffects());
2659 HBasicBlock* empty_true = owner()->graph()->CreateBasicBlock(); 2658 HBasicBlock* empty_true = owner()->graph()->CreateBasicBlock();
2660 HBasicBlock* empty_false = owner()->graph()->CreateBasicBlock(); 2659 HBasicBlock* empty_false = owner()->graph()->CreateBasicBlock();
2661 instr->SetSuccessorAt(0, empty_true); 2660 instr->SetSuccessorAt(0, empty_true);
2662 instr->SetSuccessorAt(1, empty_false); 2661 instr->SetSuccessorAt(1, empty_false);
2663 owner()->current_block()->Finish(instr); 2662 owner()->current_block()->Finish(instr);
2664 HBasicBlock* join = owner()->CreateJoin(empty_true, empty_false, ast_id); 2663 HBasicBlock* join = owner()->CreateJoin(empty_true, empty_false, ast_id);
2665 owner()->set_current_block(join); 2664 owner()->set_current_block(join);
2666 } 2665 }
2667 2666
2668 2667
(...skipping 20 matching lines...) Expand all
2689 } 2688 }
2690 owner()->AddInstruction(instr); 2689 owner()->AddInstruction(instr);
2691 owner()->Push(instr); 2690 owner()->Push(instr);
2692 if (instr->HasObservableSideEffects()) { 2691 if (instr->HasObservableSideEffects()) {
2693 owner()->Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); 2692 owner()->Add<HSimulate>(ast_id, REMOVABLE_SIMULATE);
2694 } 2693 }
2695 } 2694 }
2696 2695
2697 2696
2698 void ValueContext::ReturnControl(HControlInstruction* instr, BailoutId ast_id) { 2697 void ValueContext::ReturnControl(HControlInstruction* instr, BailoutId ast_id) {
2699 ASSERT(!instr->HasObservableSideEffects());
2700 if (!arguments_allowed() && instr->CheckFlag(HValue::kIsArguments)) { 2698 if (!arguments_allowed() && instr->CheckFlag(HValue::kIsArguments)) {
2701 return owner()->Bailout(kBadValueContextForArgumentsObjectValue); 2699 return owner()->Bailout(kBadValueContextForArgumentsObjectValue);
2702 } 2700 }
2703 HBasicBlock* materialize_false = owner()->graph()->CreateBasicBlock(); 2701 HBasicBlock* materialize_false = owner()->graph()->CreateBasicBlock();
2704 HBasicBlock* materialize_true = owner()->graph()->CreateBasicBlock(); 2702 HBasicBlock* materialize_true = owner()->graph()->CreateBasicBlock();
2705 instr->SetSuccessorAt(0, materialize_true); 2703 instr->SetSuccessorAt(0, materialize_true);
2706 instr->SetSuccessorAt(1, materialize_false); 2704 instr->SetSuccessorAt(1, materialize_false);
2707 owner()->current_block()->Finish(instr); 2705 owner()->current_block()->Finish(instr);
2708 owner()->set_current_block(materialize_true); 2706 owner()->set_current_block(materialize_true);
2709 owner()->Push(owner()->graph()->GetConstantTrue()); 2707 owner()->Push(owner()->graph()->GetConstantTrue());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2747 if (instr->HasObservableSideEffects()) { 2745 if (instr->HasObservableSideEffects()) {
2748 builder->Push(instr); 2746 builder->Push(instr);
2749 builder->Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); 2747 builder->Add<HSimulate>(ast_id, REMOVABLE_SIMULATE);
2750 builder->Pop(); 2748 builder->Pop();
2751 } 2749 }
2752 BuildBranch(instr); 2750 BuildBranch(instr);
2753 } 2751 }
2754 2752
2755 2753
2756 void TestContext::ReturnControl(HControlInstruction* instr, BailoutId ast_id) { 2754 void TestContext::ReturnControl(HControlInstruction* instr, BailoutId ast_id) {
2757 ASSERT(!instr->HasObservableSideEffects()); 2755 // We can ignore ObservableSideEffects here since both HGoto instructions
2756 // insert a different Simulate, thus we will directly deoptimize into the
2757 // correct branch.
2758 HBasicBlock* empty_true = owner()->graph()->CreateBasicBlock(); 2758 HBasicBlock* empty_true = owner()->graph()->CreateBasicBlock();
2759 HBasicBlock* empty_false = owner()->graph()->CreateBasicBlock(); 2759 HBasicBlock* empty_false = owner()->graph()->CreateBasicBlock();
2760 instr->SetSuccessorAt(0, empty_true); 2760 instr->SetSuccessorAt(0, empty_true);
2761 instr->SetSuccessorAt(1, empty_false); 2761 instr->SetSuccessorAt(1, empty_false);
2762 owner()->current_block()->Finish(instr); 2762 owner()->current_block()->Finish(instr);
2763 empty_true->Goto(if_true(), owner()->function_state()); 2763 empty_true->Goto(if_true(), owner()->function_state());
2764 empty_false->Goto(if_false(), owner()->function_state()); 2764 empty_false->Goto(if_false(), owner()->function_state());
2765 owner()->set_current_block(NULL); 2765 owner()->set_current_block(NULL);
2766 } 2766 }
2767 2767
(...skipping 5426 matching lines...) Expand 10 before | Expand all | Expand 10 after
8194 BuildCheckHeapObject(left); 8194 BuildCheckHeapObject(left);
8195 AddInstruction(HCheckInstanceType::NewIsInternalizedString(left, zone())); 8195 AddInstruction(HCheckInstanceType::NewIsInternalizedString(left, zone()));
8196 BuildCheckHeapObject(right); 8196 BuildCheckHeapObject(right);
8197 AddInstruction(HCheckInstanceType::NewIsInternalizedString(right, zone())); 8197 AddInstruction(HCheckInstanceType::NewIsInternalizedString(right, zone()));
8198 HCompareObjectEqAndBranch* result = 8198 HCompareObjectEqAndBranch* result =
8199 New<HCompareObjectEqAndBranch>(left, right); 8199 New<HCompareObjectEqAndBranch>(left, right);
8200 result->set_position(expr->position()); 8200 result->set_position(expr->position());
8201 return ast_context()->ReturnControl(result, expr->id()); 8201 return ast_context()->ReturnControl(result, expr->id());
8202 } else { 8202 } else {
8203 if (combined_rep.IsTagged() || combined_rep.IsNone()) { 8203 if (combined_rep.IsTagged() || combined_rep.IsNone()) {
8204 HCompareGeneric* result = 8204 HCompareGenericAndBranch* result =
8205 new(zone()) HCompareGeneric(context, left, right, op); 8205 New<HCompareGenericAndBranch>(left, right, op);
8206 result->set_observed_input_representation(1, left_rep); 8206 result->set_observed_input_representation(left_rep, right_rep);
8207 result->set_observed_input_representation(2, right_rep);
8208 result->set_position(expr->position()); 8207 result->set_position(expr->position());
8209 return ast_context()->ReturnInstruction(result, expr->id()); 8208 return ast_context()->ReturnControl(result, expr->id());
8210 } else { 8209 } else {
8211 HCompareNumericAndBranch* result = 8210 HCompareNumericAndBranch* result =
8212 New<HCompareNumericAndBranch>(left, right, op); 8211 New<HCompareNumericAndBranch>(left, right, op);
8213 result->set_observed_input_representation(left_rep, right_rep); 8212 result->set_observed_input_representation(left_rep, right_rep);
8214 result->set_position(expr->position()); 8213 result->set_position(expr->position());
8215 return ast_context()->ReturnControl(result, expr->id()); 8214 return ast_context()->ReturnControl(result, expr->id());
8216 } 8215 }
8217 } 8216 }
8218 } 8217 }
8219 8218
(...skipping 1554 matching lines...) Expand 10 before | Expand all | Expand 10 after
9774 if (ShouldProduceTraceOutput()) { 9773 if (ShouldProduceTraceOutput()) {
9775 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 9774 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
9776 } 9775 }
9777 9776
9778 #ifdef DEBUG 9777 #ifdef DEBUG
9779 graph_->Verify(false); // No full verify. 9778 graph_->Verify(false); // No full verify.
9780 #endif 9779 #endif
9781 } 9780 }
9782 9781
9783 } } // namespace v8::internal 9782 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/lithium-codegen-arm.cc ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698