Commit 89984f72 authored by jarin@chromium.org's avatar jarin@chromium.org

Refactor building of lazy bailouts in AstGraphBuilder.

BUG=
R=mstarzinger@chromium.org

Review URL: https://codereview.chromium.org/464033002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23096 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 0a35d53f
This diff is collapsed.
...@@ -171,8 +171,18 @@ class AstGraphBuilder : public StructuredGraphBuilder, public AstVisitor { ...@@ -171,8 +171,18 @@ class AstGraphBuilder : public StructuredGraphBuilder, public AstVisitor {
// Dispatched from VisitForInStatement. // Dispatched from VisitForInStatement.
void VisitForInAssignment(Expression* expr, Node* value); void VisitForInAssignment(Expression* expr, Node* value);
void BuildLazyBailout(Node* node, BailoutId ast_id); // Flag that describes how to combine the current environment with
void BuildLazyBailoutWithPushedNode(Node* node, BailoutId ast_id); // the output of a node to obtain a framestate for lazy bailout.
enum OutputFrameStateCombine {
PUSH_OUTPUT, // Push the output on the expression stack.
IGNORE_OUTPUT // Use the frame state as-is.
};
// Builds deoptimization for a given node.
void PrepareFrameState(Node* node, BailoutId ast_id,
OutputFrameStateCombine combine = IGNORE_OUTPUT);
OutputFrameStateCombine StateCombineFromAstContext();
DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); DEFINE_AST_VISITOR_SUBCLASS_MEMBERS();
DISALLOW_COPY_AND_ASSIGN(AstGraphBuilder); DISALLOW_COPY_AND_ASSIGN(AstGraphBuilder);
...@@ -282,10 +292,15 @@ class AstGraphBuilder::AstContext BASE_EMBEDDED { ...@@ -282,10 +292,15 @@ class AstGraphBuilder::AstContext BASE_EMBEDDED {
bool IsValue() const { return kind_ == Expression::kValue; } bool IsValue() const { return kind_ == Expression::kValue; }
bool IsTest() const { return kind_ == Expression::kTest; } bool IsTest() const { return kind_ == Expression::kTest; }
// Determines how to combine the frame state with the value
// that is about to be plugged into this AstContext.
AstGraphBuilder::OutputFrameStateCombine GetStateCombine() {
return IsEffect() ? IGNORE_OUTPUT : PUSH_OUTPUT;
}
// Plug a node into this expression context. Call this function in tail // Plug a node into this expression context. Call this function in tail
// position in the Visit functions for expressions. // position in the Visit functions for expressions.
virtual void ProduceValue(Node* value) = 0; virtual void ProduceValue(Node* value) = 0;
virtual void ProduceValueWithLazyBailout(Node* value) = 0;
// Unplugs a node from this expression context. Call this to retrieve the // Unplugs a node from this expression context. Call this to retrieve the
// result of another Visit function that already plugged the context. // result of another Visit function that already plugged the context.
...@@ -295,8 +310,7 @@ class AstGraphBuilder::AstContext BASE_EMBEDDED { ...@@ -295,8 +310,7 @@ class AstGraphBuilder::AstContext BASE_EMBEDDED {
void ReplaceValue() { ProduceValue(ConsumeValue()); } void ReplaceValue() { ProduceValue(ConsumeValue()); }
protected: protected:
AstContext(AstGraphBuilder* owner, Expression::Context kind, AstContext(AstGraphBuilder* owner, Expression::Context kind);
BailoutId bailout_id);
virtual ~AstContext(); virtual ~AstContext();
AstGraphBuilder* owner() const { return owner_; } AstGraphBuilder* owner() const { return owner_; }
...@@ -308,8 +322,6 @@ class AstGraphBuilder::AstContext BASE_EMBEDDED { ...@@ -308,8 +322,6 @@ class AstGraphBuilder::AstContext BASE_EMBEDDED {
int original_height_; int original_height_;
#endif #endif
BailoutId bailout_id_;
private: private:
Expression::Context kind_; Expression::Context kind_;
AstGraphBuilder* owner_; AstGraphBuilder* owner_;
...@@ -320,11 +332,10 @@ class AstGraphBuilder::AstContext BASE_EMBEDDED { ...@@ -320,11 +332,10 @@ class AstGraphBuilder::AstContext BASE_EMBEDDED {
// Context to evaluate expression for its side effects only. // Context to evaluate expression for its side effects only.
class AstGraphBuilder::AstEffectContext V8_FINAL : public AstContext { class AstGraphBuilder::AstEffectContext V8_FINAL : public AstContext {
public: public:
explicit AstEffectContext(AstGraphBuilder* owner, BailoutId bailout_id) explicit AstEffectContext(AstGraphBuilder* owner)
: AstContext(owner, Expression::kEffect, bailout_id) {} : AstContext(owner, Expression::kEffect) {}
virtual ~AstEffectContext(); virtual ~AstEffectContext();
virtual void ProduceValue(Node* value) V8_OVERRIDE; virtual void ProduceValue(Node* value) V8_OVERRIDE;
virtual void ProduceValueWithLazyBailout(Node* value) V8_OVERRIDE;
virtual Node* ConsumeValue() V8_OVERRIDE; virtual Node* ConsumeValue() V8_OVERRIDE;
}; };
...@@ -332,11 +343,10 @@ class AstGraphBuilder::AstEffectContext V8_FINAL : public AstContext { ...@@ -332,11 +343,10 @@ class AstGraphBuilder::AstEffectContext V8_FINAL : public AstContext {
// Context to evaluate expression for its value (and side effects). // Context to evaluate expression for its value (and side effects).
class AstGraphBuilder::AstValueContext V8_FINAL : public AstContext { class AstGraphBuilder::AstValueContext V8_FINAL : public AstContext {
public: public:
explicit AstValueContext(AstGraphBuilder* owner, BailoutId bailout_id) explicit AstValueContext(AstGraphBuilder* owner)
: AstContext(owner, Expression::kValue, bailout_id) {} : AstContext(owner, Expression::kValue) {}
virtual ~AstValueContext(); virtual ~AstValueContext();
virtual void ProduceValue(Node* value) V8_OVERRIDE; virtual void ProduceValue(Node* value) V8_OVERRIDE;
virtual void ProduceValueWithLazyBailout(Node* value) V8_OVERRIDE;
virtual Node* ConsumeValue() V8_OVERRIDE; virtual Node* ConsumeValue() V8_OVERRIDE;
}; };
...@@ -344,11 +354,10 @@ class AstGraphBuilder::AstValueContext V8_FINAL : public AstContext { ...@@ -344,11 +354,10 @@ class AstGraphBuilder::AstValueContext V8_FINAL : public AstContext {
// Context to evaluate expression for a condition value (and side effects). // Context to evaluate expression for a condition value (and side effects).
class AstGraphBuilder::AstTestContext V8_FINAL : public AstContext { class AstGraphBuilder::AstTestContext V8_FINAL : public AstContext {
public: public:
explicit AstTestContext(AstGraphBuilder* owner, BailoutId bailout_id) explicit AstTestContext(AstGraphBuilder* owner)
: AstContext(owner, Expression::kTest, bailout_id) {} : AstContext(owner, Expression::kTest) {}
virtual ~AstTestContext(); virtual ~AstTestContext();
virtual void ProduceValue(Node* value) V8_OVERRIDE; virtual void ProduceValue(Node* value) V8_OVERRIDE;
virtual void ProduceValueWithLazyBailout(Node* value) V8_OVERRIDE;
virtual Node* ConsumeValue() V8_OVERRIDE; virtual Node* ConsumeValue() V8_OVERRIDE;
}; };
......
...@@ -30,6 +30,8 @@ StructuredGraphBuilder::StructuredGraphBuilder(Graph* graph, ...@@ -30,6 +30,8 @@ StructuredGraphBuilder::StructuredGraphBuilder(Graph* graph,
Node* StructuredGraphBuilder::MakeNode(Operator* op, int value_input_count, Node* StructuredGraphBuilder::MakeNode(Operator* op, int value_input_count,
Node** value_inputs) { Node** value_inputs) {
DCHECK(op->InputCount() == value_input_count);
bool has_context = OperatorProperties::HasContextInput(op); bool has_context = OperatorProperties::HasContextInput(op);
bool has_control = OperatorProperties::GetControlInputCount(op) == 1; bool has_control = OperatorProperties::GetControlInputCount(op) == 1;
bool has_effect = OperatorProperties::GetEffectInputCount(op) == 1; bool has_effect = OperatorProperties::GetEffectInputCount(op) == 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment