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

Unified Diff: src/hydrogen.h

Issue 19528003: Unify SoftDeoptimize and Deoptimize hydrogen instructions (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/code-stubs-hydrogen.cc ('k') | src/hydrogen.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen.h
diff --git a/src/hydrogen.h b/src/hydrogen.h
index 797b444078d5e838157c77e207a956a4b3d056db..ed1eaf1a21e95a9cc25a9a3f72c2d00491cc46f9 100644
--- a/src/hydrogen.h
+++ b/src/hydrogen.h
@@ -137,17 +137,15 @@ class HBasicBlock: public ZoneObject {
}
int PredecessorIndexOf(HBasicBlock* predecessor) const;
- void AddSimulate(BailoutId ast_id,
- RemovableSimulate removable = FIXED_SIMULATE) {
- AddInstruction(CreateSimulate(ast_id, removable));
+ HSimulate* AddSimulate(BailoutId ast_id,
+ RemovableSimulate removable = FIXED_SIMULATE) {
+ HSimulate* instr = CreateSimulate(ast_id, removable);
+ AddInstruction(instr);
+ return instr;
}
void AssignCommonDominator(HBasicBlock* other);
void AssignLoopSuccessorDominators();
- void FinishExitWithDeoptimization(HDeoptimize::UseEnvironment has_uses) {
- FinishExit(CreateDeoptimize(has_uses));
- }
-
// Add the inlined function exit sequence, adding an HLeaveInlined
// instruction and updating the bailout environment.
void AddLeaveInlined(HValue* return_value, FunctionState* state);
@@ -182,11 +180,12 @@ class HBasicBlock: public ZoneObject {
#endif
private:
+ friend class HGraphBuilder;
+
void RegisterPredecessor(HBasicBlock* pred);
void AddDominatedBlock(HBasicBlock* block);
HSimulate* CreateSimulate(BailoutId ast_id, RemovableSimulate removable);
- HDeoptimize* CreateDeoptimize(HDeoptimize::UseEnvironment has_uses);
int block_id_;
HGraph* graph_;
@@ -1023,11 +1022,6 @@ class HGraphBuilder {
new(zone()) I(p1, p2, p3, p4, p5, p6, p7, p8)));
}
- void AddSimulate(BailoutId id,
- RemovableSimulate removable = FIXED_SIMULATE);
-
- HReturn* AddReturn(HValue* value);
-
void IncrementInNoSideEffectsScope() {
no_side_effects_scope_count_++;
}
@@ -1118,12 +1112,7 @@ class HGraphBuilder {
HValue* AddLoadJSBuiltin(Builtins::JavaScript builtin, HValue* context);
- enum SoftDeoptimizeMode {
- MUST_EMIT_SOFT_DEOPT,
- CAN_OMIT_SOFT_DEOPT
- };
-
- void AddSoftDeoptimize(SoftDeoptimizeMode mode = CAN_OMIT_SOFT_DEOPT);
+ void FinishExitWithHardDeoptimization(HBasicBlock* continuation);
class IfBuilder {
public:
@@ -1228,7 +1217,6 @@ class HGraphBuilder {
void ElseDeopt() {
Else();
Deopt();
- End();
}
void Return(HValue* value);
@@ -1241,6 +1229,8 @@ class HGraphBuilder {
HGraphBuilder* builder_;
int position_;
bool finished_ : 1;
+ bool deopt_then_ : 1;
+ bool deopt_else_ : 1;
bool did_then_ : 1;
bool did_else_ : 1;
bool did_and_ : 1;
@@ -1422,12 +1412,68 @@ class HGraphBuilder {
private:
HGraphBuilder();
+
+ void PadEnvironmentForContinuation(HBasicBlock* from,
+ HBasicBlock* continuation);
+
CompilationInfo* info_;
HGraph* graph_;
HBasicBlock* current_block_;
int no_side_effects_scope_count_;
};
+
+template<>
+inline HDeoptimize* HGraphBuilder::Add(Deoptimizer::BailoutType type) {
+ if (type == Deoptimizer::SOFT) {
+ isolate()->counters()->soft_deopts_requested()->Increment();
+ if (FLAG_always_opt) return NULL;
+ }
+ if (current_block()->IsDeoptimizing()) return NULL;
+ HDeoptimize* instr = new(zone()) HDeoptimize(type);
+ AddInstruction(instr);
+ if (type == Deoptimizer::SOFT) {
+ isolate()->counters()->soft_deopts_inserted()->Increment();
+ graph()->set_has_soft_deoptimize(true);
+ }
+ current_block()->MarkAsDeoptimizing();
+ return instr;
+}
+
+
+template<>
+inline HSimulate* HGraphBuilder::Add(BailoutId id,
+ RemovableSimulate removable) {
+ HSimulate* instr = current_block()->CreateSimulate(id, removable);
+ AddInstruction(instr);
+ return instr;
+}
+
+
+template<>
+inline HSimulate* HGraphBuilder::Add(BailoutId id) {
+ return Add<HSimulate>(id, FIXED_SIMULATE);
+}
+
+
+template<>
+inline HReturn* HGraphBuilder::Add(HValue* value) {
+ HValue* context = environment()->LookupContext();
+ int num_parameters = graph()->info()->num_parameters();
+ HValue* params = Add<HConstant>(num_parameters);
+ HReturn* return_instruction = new(graph()->zone())
+ HReturn(value, context, params);
+ current_block()->FinishExit(return_instruction);
+ return return_instruction;
+}
+
+
+template<>
+inline HReturn* HGraphBuilder::Add(HConstant* p1) {
+ return Add<HReturn>(static_cast<HValue*>(p1));
+}
+
+
class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor {
public:
// A class encapsulating (lazily-allocated) break and continue blocks for
« no previous file with comments | « src/code-stubs-hydrogen.cc ('k') | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698