Change the list of statements that are inlineable into a black-list.

Before we had a white-list of things that we allow inside inlined functions.

This way we can enable new constructs one-by-one.
Review URL: http://codereview.chromium.org/6825042

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7585 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent a932441a
...@@ -349,6 +349,138 @@ BinaryOperation::BinaryOperation(Assignment* assignment) { ...@@ -349,6 +349,138 @@ BinaryOperation::BinaryOperation(Assignment* assignment) {
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Inlining support // Inlining support
bool Declaration::IsInlineable() const {
UNREACHABLE();
return false;
}
bool TargetCollector::IsInlineable() const {
UNREACHABLE();
return false;
}
bool Slot::IsInlineable() const {
UNREACHABLE();
return false;
}
bool ForStatement::IsInlineable() const {
return false;
}
bool WhileStatement::IsInlineable() const {
return false;
}
bool DoWhileStatement::IsInlineable() const {
return false;
}
bool ForInStatement::IsInlineable() const {
return false;
}
bool ContinueStatement::IsInlineable() const {
return false;
}
bool BreakStatement::IsInlineable() const {
return false;
}
bool WithEnterStatement::IsInlineable() const {
return false;
}
bool WithExitStatement::IsInlineable() const {
return false;
}
bool SwitchStatement::IsInlineable() const {
return false;
}
bool TryStatement::IsInlineable() const {
return false;
}
bool TryCatchStatement::IsInlineable() const {
return false;
}
bool TryFinallyStatement::IsInlineable() const {
return false;
}
bool CatchExtensionObject::IsInlineable() const {
return false;
}
bool DebuggerStatement::IsInlineable() const {
return false;
}
bool Throw::IsInlineable() const {
// TODO(1143): Make functions containing throw inlineable.
return false;
}
bool MaterializedLiteral::IsInlineable() const {
// TODO(1322): Allow materialized literals.
return false;
}
bool FunctionLiteral::IsInlineable() const {
// TODO(1322): Allow materialized literals.
return false;
}
bool ThisFunction::IsInlineable() const {
return false;
}
bool SharedFunctionInfoLiteral::IsInlineable() const {
return false;
}
bool ValidLeftHandSideSentinel::IsInlineable() const {
UNREACHABLE();
return false;
}
bool EmptyStatement::IsInlineable() const {
return true;
}
bool Literal::IsInlineable() const {
return true;
}
bool Block::IsInlineable() const { bool Block::IsInlineable() const {
const int count = statements_.length(); const int count = statements_.length();
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
...@@ -364,8 +496,9 @@ bool ExpressionStatement::IsInlineable() const { ...@@ -364,8 +496,9 @@ bool ExpressionStatement::IsInlineable() const {
bool IfStatement::IsInlineable() const { bool IfStatement::IsInlineable() const {
return condition()->IsInlineable() && then_statement()->IsInlineable() && return condition()->IsInlineable()
else_statement()->IsInlineable(); && then_statement()->IsInlineable()
&& else_statement()->IsInlineable();
} }
......
...@@ -159,7 +159,7 @@ class AstNode: public ZoneObject { ...@@ -159,7 +159,7 @@ class AstNode: public ZoneObject {
virtual Slot* AsSlot() { return NULL; } virtual Slot* AsSlot() { return NULL; }
// True if the node is simple enough for us to inline calls containing it. // True if the node is simple enough for us to inline calls containing it.
virtual bool IsInlineable() const { return false; } virtual bool IsInlineable() const = 0;
static int Count() { return Isolate::Current()->ast_node_count(); } static int Count() { return Isolate::Current()->ast_node_count(); }
static void ResetIds() { Isolate::Current()->set_ast_node_id(0); } static void ResetIds() { Isolate::Current()->set_ast_node_id(0); }
...@@ -291,6 +291,7 @@ class ValidLeftHandSideSentinel: public Expression { ...@@ -291,6 +291,7 @@ class ValidLeftHandSideSentinel: public Expression {
public: public:
virtual bool IsValidLeftHandSide() { return true; } virtual bool IsValidLeftHandSide() { return true; }
virtual void Accept(AstVisitor* v) { UNREACHABLE(); } virtual void Accept(AstVisitor* v) { UNREACHABLE(); }
virtual bool IsInlineable() const;
}; };
...@@ -375,6 +376,7 @@ class Declaration: public AstNode { ...@@ -375,6 +376,7 @@ class Declaration: public AstNode {
VariableProxy* proxy() const { return proxy_; } VariableProxy* proxy() const { return proxy_; }
Variable::Mode mode() const { return mode_; } Variable::Mode mode() const { return mode_; }
FunctionLiteral* fun() const { return fun_; } // may be NULL FunctionLiteral* fun() const { return fun_; } // may be NULL
virtual bool IsInlineable() const;
private: private:
VariableProxy* proxy_; VariableProxy* proxy_;
...@@ -433,6 +435,8 @@ class DoWhileStatement: public IterationStatement { ...@@ -433,6 +435,8 @@ class DoWhileStatement: public IterationStatement {
virtual int ContinueId() const { return continue_id_; } virtual int ContinueId() const { return continue_id_; }
int BackEdgeId() const { return back_edge_id_; } int BackEdgeId() const { return back_edge_id_; }
virtual bool IsInlineable() const;
private: private:
Expression* cond_; Expression* cond_;
int condition_position_; int condition_position_;
...@@ -459,6 +463,7 @@ class WhileStatement: public IterationStatement { ...@@ -459,6 +463,7 @@ class WhileStatement: public IterationStatement {
void set_may_have_function_literal(bool value) { void set_may_have_function_literal(bool value) {
may_have_function_literal_ = value; may_have_function_literal_ = value;
} }
virtual bool IsInlineable() const;
// Bailout support. // Bailout support.
virtual int ContinueId() const { return EntryId(); } virtual int ContinueId() const { return EntryId(); }
...@@ -506,6 +511,7 @@ class ForStatement: public IterationStatement { ...@@ -506,6 +511,7 @@ class ForStatement: public IterationStatement {
bool is_fast_smi_loop() { return loop_variable_ != NULL; } bool is_fast_smi_loop() { return loop_variable_ != NULL; }
Variable* loop_variable() { return loop_variable_; } Variable* loop_variable() { return loop_variable_; }
void set_loop_variable(Variable* var) { loop_variable_ = var; } void set_loop_variable(Variable* var) { loop_variable_ = var; }
virtual bool IsInlineable() const;
private: private:
Statement* init_; Statement* init_;
...@@ -533,6 +539,7 @@ class ForInStatement: public IterationStatement { ...@@ -533,6 +539,7 @@ class ForInStatement: public IterationStatement {
Expression* each() const { return each_; } Expression* each() const { return each_; }
Expression* enumerable() const { return enumerable_; } Expression* enumerable() const { return enumerable_; }
virtual bool IsInlineable() const;
// Bailout support. // Bailout support.
int AssignmentId() const { return assignment_id_; } int AssignmentId() const { return assignment_id_; }
...@@ -573,6 +580,7 @@ class ContinueStatement: public Statement { ...@@ -573,6 +580,7 @@ class ContinueStatement: public Statement {
DECLARE_NODE_TYPE(ContinueStatement) DECLARE_NODE_TYPE(ContinueStatement)
IterationStatement* target() const { return target_; } IterationStatement* target() const { return target_; }
virtual bool IsInlineable() const;
private: private:
IterationStatement* target_; IterationStatement* target_;
...@@ -587,6 +595,7 @@ class BreakStatement: public Statement { ...@@ -587,6 +595,7 @@ class BreakStatement: public Statement {
DECLARE_NODE_TYPE(BreakStatement) DECLARE_NODE_TYPE(BreakStatement)
BreakableStatement* target() const { return target_; } BreakableStatement* target() const { return target_; }
virtual bool IsInlineable() const;
private: private:
BreakableStatement* target_; BreakableStatement* target_;
...@@ -618,6 +627,7 @@ class WithEnterStatement: public Statement { ...@@ -618,6 +627,7 @@ class WithEnterStatement: public Statement {
Expression* expression() const { return expression_; } Expression* expression() const { return expression_; }
bool is_catch_block() const { return is_catch_block_; } bool is_catch_block() const { return is_catch_block_; }
virtual bool IsInlineable() const;
private: private:
Expression* expression_; Expression* expression_;
...@@ -629,6 +639,8 @@ class WithExitStatement: public Statement { ...@@ -629,6 +639,8 @@ class WithExitStatement: public Statement {
public: public:
WithExitStatement() { } WithExitStatement() { }
virtual bool IsInlineable() const;
DECLARE_NODE_TYPE(WithExitStatement) DECLARE_NODE_TYPE(WithExitStatement)
}; };
...@@ -679,6 +691,7 @@ class SwitchStatement: public BreakableStatement { ...@@ -679,6 +691,7 @@ class SwitchStatement: public BreakableStatement {
Expression* tag() const { return tag_; } Expression* tag() const { return tag_; }
ZoneList<CaseClause*>* cases() const { return cases_; } ZoneList<CaseClause*>* cases() const { return cases_; }
virtual bool IsInlineable() const;
private: private:
Expression* tag_; Expression* tag_;
...@@ -744,6 +757,7 @@ class TargetCollector: public AstNode { ...@@ -744,6 +757,7 @@ class TargetCollector: public AstNode {
virtual TargetCollector* AsTargetCollector() { return this; } virtual TargetCollector* AsTargetCollector() { return this; }
ZoneList<Label*>* targets() { return targets_; } ZoneList<Label*>* targets() { return targets_; }
virtual bool IsInlineable() const;
private: private:
ZoneList<Label*>* targets_; ZoneList<Label*>* targets_;
...@@ -761,6 +775,7 @@ class TryStatement: public Statement { ...@@ -761,6 +775,7 @@ class TryStatement: public Statement {
Block* try_block() const { return try_block_; } Block* try_block() const { return try_block_; }
ZoneList<Label*>* escaping_targets() const { return escaping_targets_; } ZoneList<Label*>* escaping_targets() const { return escaping_targets_; }
virtual bool IsInlineable() const;
private: private:
Block* try_block_; Block* try_block_;
...@@ -782,6 +797,7 @@ class TryCatchStatement: public TryStatement { ...@@ -782,6 +797,7 @@ class TryCatchStatement: public TryStatement {
VariableProxy* catch_var() const { return catch_var_; } VariableProxy* catch_var() const { return catch_var_; }
Block* catch_block() const { return catch_block_; } Block* catch_block() const { return catch_block_; }
virtual bool IsInlineable() const;
private: private:
VariableProxy* catch_var_; VariableProxy* catch_var_;
...@@ -798,6 +814,7 @@ class TryFinallyStatement: public TryStatement { ...@@ -798,6 +814,7 @@ class TryFinallyStatement: public TryStatement {
DECLARE_NODE_TYPE(TryFinallyStatement) DECLARE_NODE_TYPE(TryFinallyStatement)
Block* finally_block() const { return finally_block_; } Block* finally_block() const { return finally_block_; }
virtual bool IsInlineable() const;
private: private:
Block* finally_block_; Block* finally_block_;
...@@ -807,6 +824,7 @@ class TryFinallyStatement: public TryStatement { ...@@ -807,6 +824,7 @@ class TryFinallyStatement: public TryStatement {
class DebuggerStatement: public Statement { class DebuggerStatement: public Statement {
public: public:
DECLARE_NODE_TYPE(DebuggerStatement) DECLARE_NODE_TYPE(DebuggerStatement)
virtual bool IsInlineable() const;
}; };
...@@ -814,7 +832,7 @@ class EmptyStatement: public Statement { ...@@ -814,7 +832,7 @@ class EmptyStatement: public Statement {
public: public:
DECLARE_NODE_TYPE(EmptyStatement) DECLARE_NODE_TYPE(EmptyStatement)
virtual bool IsInlineable() const { return true; } virtual bool IsInlineable() const;
}; };
...@@ -825,7 +843,6 @@ class Literal: public Expression { ...@@ -825,7 +843,6 @@ class Literal: public Expression {
DECLARE_NODE_TYPE(Literal) DECLARE_NODE_TYPE(Literal)
virtual bool IsTrivial() { return true; } virtual bool IsTrivial() { return true; }
virtual bool IsInlineable() const { return true; }
virtual bool IsSmiLiteral() { return handle_->IsSmi(); } virtual bool IsSmiLiteral() { return handle_->IsSmi(); }
// Check if this literal is identical to the other literal. // Check if this literal is identical to the other literal.
...@@ -864,6 +881,7 @@ class Literal: public Expression { ...@@ -864,6 +881,7 @@ class Literal: public Expression {
} }
Handle<Object> handle() const { return handle_; } Handle<Object> handle() const { return handle_; }
virtual bool IsInlineable() const;
private: private:
Handle<Object> handle_; Handle<Object> handle_;
...@@ -885,6 +903,7 @@ class MaterializedLiteral: public Expression { ...@@ -885,6 +903,7 @@ class MaterializedLiteral: public Expression {
bool is_simple() const { return is_simple_; } bool is_simple() const { return is_simple_; }
int depth() const { return depth_; } int depth() const { return depth_; }
virtual bool IsInlineable() const;
private: private:
int literal_index_; int literal_index_;
...@@ -1034,6 +1053,7 @@ class CatchExtensionObject: public Expression { ...@@ -1034,6 +1053,7 @@ class CatchExtensionObject: public Expression {
Literal* key() const { return key_; } Literal* key() const { return key_; }
VariableProxy* value() const { return value_; } VariableProxy* value() const { return value_; }
virtual bool IsInlineable() const;
private: private:
Literal* key_; Literal* key_;
...@@ -1160,6 +1180,7 @@ class Slot: public Expression { ...@@ -1160,6 +1180,7 @@ class Slot: public Expression {
Type type() const { return type_; } Type type() const { return type_; }
int index() const { return index_; } int index() const { return index_; }
bool is_arguments() const { return var_->is_arguments(); } bool is_arguments() const { return var_->is_arguments(); }
virtual bool IsInlineable() const;
private: private:
Variable* var_; Variable* var_;
...@@ -1643,6 +1664,7 @@ class Throw: public Expression { ...@@ -1643,6 +1664,7 @@ class Throw: public Expression {
Expression* exception() const { return exception_; } Expression* exception() const { return exception_; }
virtual int position() const { return pos_; } virtual int position() const { return pos_; }
virtual bool IsInlineable() const;
private: private:
Expression* exception_; Expression* exception_;
...@@ -1715,6 +1737,7 @@ class FunctionLiteral: public Expression { ...@@ -1715,6 +1737,7 @@ class FunctionLiteral: public Expression {
bool pretenure() { return pretenure_; } bool pretenure() { return pretenure_; }
void set_pretenure(bool value) { pretenure_ = value; } void set_pretenure(bool value) { pretenure_ = value; }
virtual bool IsInlineable() const;
private: private:
Handle<String> name_; Handle<String> name_;
...@@ -1745,6 +1768,7 @@ class SharedFunctionInfoLiteral: public Expression { ...@@ -1745,6 +1768,7 @@ class SharedFunctionInfoLiteral: public Expression {
Handle<SharedFunctionInfo> shared_function_info() const { Handle<SharedFunctionInfo> shared_function_info() const {
return shared_function_info_; return shared_function_info_;
} }
virtual bool IsInlineable() const;
private: private:
Handle<SharedFunctionInfo> shared_function_info_; Handle<SharedFunctionInfo> shared_function_info_;
...@@ -1754,6 +1778,7 @@ class SharedFunctionInfoLiteral: public Expression { ...@@ -1754,6 +1778,7 @@ class SharedFunctionInfoLiteral: public Expression {
class ThisFunction: public Expression { class ThisFunction: public Expression {
public: public:
DECLARE_NODE_TYPE(ThisFunction) DECLARE_NODE_TYPE(ThisFunction)
virtual bool IsInlineable() const;
}; };
......
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