| Index: src/ast.h
|
| diff --git a/src/ast.h b/src/ast.h
|
| index c2d9412a90b227e59885504ed79effd08ad8dcdc..fc05b0b514ba3b5590d8456b381b9c56baac2348 100644
|
| --- a/src/ast.h
|
| +++ b/src/ast.h
|
| @@ -138,8 +138,6 @@ class AstNode: public ZoneObject {
|
|
|
| // Override ZoneObject's new to count allocated AST nodes.
|
| void* operator new(size_t size, Zone* zone) {
|
| - Isolate* isolate = zone->isolate();
|
| - isolate->set_ast_node_count(isolate->ast_node_count() + 1);
|
| return zone->New(static_cast<int>(size));
|
| }
|
|
|
| @@ -165,9 +163,9 @@ class AstNode: public ZoneObject {
|
| virtual MaterializedLiteral* AsMaterializedLiteral() { return NULL; }
|
|
|
| // True if the node is simple enough for us to inline calls containing it.
|
| - virtual bool IsInlineable() const = 0;
|
| + // The 'function' argument is the function node that contains this node.
|
| + virtual bool IsInlineable(FunctionLiteral* function) const = 0;
|
|
|
| - static int Count() { return Isolate::Current()->ast_node_count(); }
|
| static void ResetIds() { Isolate::Current()->set_ast_node_id(0); }
|
|
|
| protected:
|
| @@ -368,7 +366,7 @@ class Block: public BreakableStatement {
|
|
|
| DECLARE_NODE_TYPE(Block)
|
|
|
| - virtual bool IsInlineable() const;
|
| + virtual bool IsInlineable(FunctionLiteral* function) const;
|
|
|
| void AddStatement(Statement* statement) { statements_.Add(statement); }
|
|
|
| @@ -408,7 +406,7 @@ class Declaration: public AstNode {
|
| VariableProxy* proxy() const { return proxy_; }
|
| VariableMode mode() const { return mode_; }
|
| FunctionLiteral* fun() const { return fun_; } // may be NULL
|
| - virtual bool IsInlineable() const;
|
| + virtual bool IsInlineable(FunctionLiteral* function) const;
|
| Scope* scope() const { return scope_; }
|
|
|
| private:
|
| @@ -440,8 +438,7 @@ class IterationStatement: public BreakableStatement {
|
| IterationStatement(Isolate* isolate, ZoneStringList* labels)
|
| : BreakableStatement(isolate, labels, TARGET_FOR_ANONYMOUS),
|
| body_(NULL),
|
| - osr_entry_id_(GetNextId(isolate)) {
|
| - }
|
| + osr_entry_id_(GetNextId(isolate)) { }
|
|
|
| void Initialize(Statement* body) {
|
| body_ = body;
|
| @@ -461,8 +458,7 @@ class DoWhileStatement: public IterationStatement {
|
| cond_(NULL),
|
| condition_position_(-1),
|
| continue_id_(GetNextId(isolate)),
|
| - back_edge_id_(GetNextId(isolate)) {
|
| - }
|
| + back_edge_id_(GetNextId(isolate)) { }
|
|
|
| DECLARE_NODE_TYPE(DoWhileStatement)
|
|
|
| @@ -483,7 +479,7 @@ class DoWhileStatement: public IterationStatement {
|
| virtual int StackCheckId() const { return back_edge_id_; }
|
| int BackEdgeId() const { return back_edge_id_; }
|
|
|
| - virtual bool IsInlineable() const;
|
| + virtual bool IsInlineable(FunctionLiteral* function) const;
|
|
|
| private:
|
| Expression* cond_;
|
| @@ -499,8 +495,7 @@ class WhileStatement: public IterationStatement {
|
| : IterationStatement(isolate, labels),
|
| cond_(NULL),
|
| may_have_function_literal_(true),
|
| - body_id_(GetNextId(isolate)) {
|
| - }
|
| + body_id_(GetNextId(isolate)) { }
|
|
|
| DECLARE_NODE_TYPE(WhileStatement)
|
|
|
| @@ -516,7 +511,7 @@ class WhileStatement: public IterationStatement {
|
| void set_may_have_function_literal(bool value) {
|
| may_have_function_literal_ = value;
|
| }
|
| - virtual bool IsInlineable() const;
|
| + virtual bool IsInlineable(FunctionLiteral* function) const;
|
|
|
| // Bailout support.
|
| virtual int ContinueId() const { return EntryId(); }
|
| @@ -575,7 +570,7 @@ class ForStatement: public IterationStatement {
|
| bool is_fast_smi_loop() { return loop_variable_ != NULL; }
|
| Variable* loop_variable() { return loop_variable_; }
|
| void set_loop_variable(Variable* var) { loop_variable_ = var; }
|
| - virtual bool IsInlineable() const;
|
| + virtual bool IsInlineable(FunctionLiteral* function) const;
|
|
|
| private:
|
| Statement* init_;
|
| @@ -595,8 +590,7 @@ class ForInStatement: public IterationStatement {
|
| : IterationStatement(isolate, labels),
|
| each_(NULL),
|
| enumerable_(NULL),
|
| - assignment_id_(GetNextId(isolate)) {
|
| - }
|
| + assignment_id_(GetNextId(isolate)) { }
|
|
|
| DECLARE_NODE_TYPE(ForInStatement)
|
|
|
| @@ -608,7 +602,7 @@ class ForInStatement: public IterationStatement {
|
|
|
| Expression* each() const { return each_; }
|
| Expression* enumerable() const { return enumerable_; }
|
| - virtual bool IsInlineable() const;
|
| + virtual bool IsInlineable(FunctionLiteral* function) const;
|
|
|
| // Bailout support.
|
| int AssignmentId() const { return assignment_id_; }
|
| @@ -629,7 +623,7 @@ class ExpressionStatement: public Statement {
|
|
|
| DECLARE_NODE_TYPE(ExpressionStatement)
|
|
|
| - virtual bool IsInlineable() const;
|
| + virtual bool IsInlineable(FunctionLiteral* function) const;
|
|
|
| void set_expression(Expression* e) { expression_ = e; }
|
| Expression* expression() const { return expression_; }
|
| @@ -647,7 +641,7 @@ class ContinueStatement: public Statement {
|
| DECLARE_NODE_TYPE(ContinueStatement)
|
|
|
| IterationStatement* target() const { return target_; }
|
| - virtual bool IsInlineable() const;
|
| + virtual bool IsInlineable(FunctionLiteral* function) const;
|
|
|
| private:
|
| IterationStatement* target_;
|
| @@ -662,7 +656,7 @@ class BreakStatement: public Statement {
|
| DECLARE_NODE_TYPE(BreakStatement)
|
|
|
| BreakableStatement* target() const { return target_; }
|
| - virtual bool IsInlineable() const;
|
| + virtual bool IsInlineable(FunctionLiteral* function) const;
|
|
|
| private:
|
| BreakableStatement* target_;
|
| @@ -677,7 +671,7 @@ class ReturnStatement: public Statement {
|
| DECLARE_NODE_TYPE(ReturnStatement)
|
|
|
| Expression* expression() const { return expression_; }
|
| - virtual bool IsInlineable() const;
|
| + virtual bool IsInlineable(FunctionLiteral* function) const;
|
|
|
| private:
|
| Expression* expression_;
|
| @@ -694,7 +688,7 @@ class WithStatement: public Statement {
|
| Expression* expression() const { return expression_; }
|
| Statement* statement() const { return statement_; }
|
|
|
| - virtual bool IsInlineable() const;
|
| + virtual bool IsInlineable(FunctionLiteral* function) const;
|
|
|
| private:
|
| Expression* expression_;
|
| @@ -753,8 +747,7 @@ class SwitchStatement: public BreakableStatement {
|
| SwitchStatement(Isolate* isolate, ZoneStringList* labels)
|
| : BreakableStatement(isolate, labels, TARGET_FOR_ANONYMOUS),
|
| tag_(NULL),
|
| - cases_(NULL) {
|
| - }
|
| + cases_(NULL) { }
|
|
|
|
|
| DECLARE_NODE_TYPE(SwitchStatement)
|
| @@ -766,7 +759,7 @@ class SwitchStatement: public BreakableStatement {
|
|
|
| Expression* tag() const { return tag_; }
|
| ZoneList<CaseClause*>* cases() const { return cases_; }
|
| - virtual bool IsInlineable() const;
|
| + virtual bool IsInlineable(FunctionLiteral* function) const;
|
|
|
| private:
|
| Expression* tag_;
|
| @@ -790,12 +783,11 @@ class IfStatement: public Statement {
|
| else_statement_(else_statement),
|
| if_id_(GetNextId(isolate)),
|
| then_id_(GetNextId(isolate)),
|
| - else_id_(GetNextId(isolate)) {
|
| - }
|
| + else_id_(GetNextId(isolate)) { }
|
|
|
| DECLARE_NODE_TYPE(IfStatement)
|
|
|
| - virtual bool IsInlineable() const;
|
| + virtual bool IsInlineable(FunctionLiteral* function) const;
|
|
|
| bool HasThenStatement() const { return !then_statement()->IsEmpty(); }
|
| bool HasElseStatement() const { return !else_statement()->IsEmpty(); }
|
| @@ -834,7 +826,7 @@ class TargetCollector: public AstNode {
|
| virtual TargetCollector* AsTargetCollector() { return this; }
|
|
|
| ZoneList<Label*>* targets() { return &targets_; }
|
| - virtual bool IsInlineable() const;
|
| + virtual bool IsInlineable(FunctionLiteral* function) const;
|
|
|
| private:
|
| ZoneList<Label*> targets_;
|
| @@ -846,8 +838,7 @@ class TryStatement: public Statement {
|
| explicit TryStatement(int index, Block* try_block)
|
| : index_(index),
|
| try_block_(try_block),
|
| - escaping_targets_(NULL) {
|
| - }
|
| + escaping_targets_(NULL) { }
|
|
|
| void set_escaping_targets(ZoneList<Label*>* targets) {
|
| escaping_targets_ = targets;
|
| @@ -856,7 +847,7 @@ class TryStatement: public Statement {
|
| int index() const { return index_; }
|
| Block* try_block() const { return try_block_; }
|
| ZoneList<Label*>* escaping_targets() const { return escaping_targets_; }
|
| - virtual bool IsInlineable() const;
|
| + virtual bool IsInlineable(FunctionLiteral* function) const;
|
|
|
| private:
|
| // Unique (per-function) index of this handler. This is not an AST ID.
|
| @@ -877,15 +868,14 @@ class TryCatchStatement: public TryStatement {
|
| : TryStatement(index, try_block),
|
| scope_(scope),
|
| variable_(variable),
|
| - catch_block_(catch_block) {
|
| - }
|
| + catch_block_(catch_block) { }
|
|
|
| DECLARE_NODE_TYPE(TryCatchStatement)
|
|
|
| Scope* scope() { return scope_; }
|
| Variable* variable() { return variable_; }
|
| Block* catch_block() const { return catch_block_; }
|
| - virtual bool IsInlineable() const;
|
| + virtual bool IsInlineable(FunctionLiteral* function) const;
|
|
|
| private:
|
| Scope* scope_;
|
| @@ -896,14 +886,16 @@ class TryCatchStatement: public TryStatement {
|
|
|
| class TryFinallyStatement: public TryStatement {
|
| public:
|
| - TryFinallyStatement(int index, Block* try_block, Block* finally_block)
|
| + TryFinallyStatement(int index,
|
| + Block* try_block,
|
| + Block* finally_block)
|
| : TryStatement(index, try_block),
|
| finally_block_(finally_block) { }
|
|
|
| DECLARE_NODE_TYPE(TryFinallyStatement)
|
|
|
| Block* finally_block() const { return finally_block_; }
|
| - virtual bool IsInlineable() const;
|
| + virtual bool IsInlineable(FunctionLiteral* function) const;
|
|
|
| private:
|
| Block* finally_block_;
|
| @@ -913,7 +905,7 @@ class TryFinallyStatement: public TryStatement {
|
| class DebuggerStatement: public Statement {
|
| public:
|
| DECLARE_NODE_TYPE(DebuggerStatement)
|
| - virtual bool IsInlineable() const;
|
| + virtual bool IsInlineable(FunctionLiteral* function) const;
|
| };
|
|
|
|
|
| @@ -921,7 +913,7 @@ class EmptyStatement: public Statement {
|
| public:
|
| DECLARE_NODE_TYPE(EmptyStatement)
|
|
|
| - virtual bool IsInlineable() const;
|
| + virtual bool IsInlineable(FunctionLiteral* function) const;
|
| };
|
|
|
|
|
| @@ -968,7 +960,7 @@ class Literal: public Expression {
|
| }
|
|
|
| Handle<Object> handle() const { return handle_; }
|
| - virtual bool IsInlineable() const;
|
| + virtual bool IsInlineable(FunctionLiteral* function) const;
|
|
|
| private:
|
| Handle<Object> handle_;
|
| @@ -996,7 +988,7 @@ class MaterializedLiteral: public Expression {
|
| bool is_simple() const { return is_simple_; }
|
|
|
| int depth() const { return depth_; }
|
| - virtual bool IsInlineable() const;
|
| + virtual bool IsInlineable(FunctionLiteral* function) const;
|
|
|
| private:
|
| int literal_index_;
|
| @@ -1146,7 +1138,7 @@ class VariableProxy: public Expression {
|
| return var_ == NULL ? true : var_->IsValidLeftHandSide();
|
| }
|
|
|
| - virtual bool IsInlineable() const;
|
| + virtual bool IsInlineable(FunctionLiteral* function) const;
|
|
|
| bool IsVariable(Handle<String> n) {
|
| return !is_this() && name().is_identical_to(n);
|
| @@ -1199,7 +1191,7 @@ class Property: public Expression {
|
| DECLARE_NODE_TYPE(Property)
|
|
|
| virtual bool IsValidLeftHandSide() { return true; }
|
| - virtual bool IsInlineable() const;
|
| + virtual bool IsInlineable(FunctionLiteral* function) const;
|
|
|
| Expression* obj() const { return obj_; }
|
| Expression* key() const { return key_; }
|
| @@ -1241,12 +1233,11 @@ class Call: public Expression {
|
| pos_(pos),
|
| is_monomorphic_(false),
|
| check_type_(RECEIVER_MAP_CHECK),
|
| - return_id_(GetNextId(isolate)) {
|
| - }
|
| + return_id_(GetNextId(isolate)) { }
|
|
|
| DECLARE_NODE_TYPE(Call)
|
|
|
| - virtual bool IsInlineable() const;
|
| + virtual bool IsInlineable(FunctionLiteral* function) const;
|
|
|
| Expression* expression() const { return expression_; }
|
| ZoneList<Expression*>* arguments() const { return arguments_; }
|
| @@ -1301,7 +1292,7 @@ class CallNew: public Expression {
|
|
|
| DECLARE_NODE_TYPE(CallNew)
|
|
|
| - virtual bool IsInlineable() const;
|
| + virtual bool IsInlineable(FunctionLiteral* function) const;
|
|
|
| Expression* expression() const { return expression_; }
|
| ZoneList<Expression*>* arguments() const { return arguments_; }
|
| @@ -1331,7 +1322,7 @@ class CallRuntime: public Expression {
|
|
|
| DECLARE_NODE_TYPE(CallRuntime)
|
|
|
| - virtual bool IsInlineable() const;
|
| + virtual bool IsInlineable(FunctionLiteral* function) const;
|
|
|
| Handle<String> name() const { return name_; }
|
| const Runtime::Function* function() const { return function_; }
|
| @@ -1366,7 +1357,7 @@ class UnaryOperation: public Expression {
|
|
|
| DECLARE_NODE_TYPE(UnaryOperation)
|
|
|
| - virtual bool IsInlineable() const;
|
| + virtual bool IsInlineable(FunctionLiteral* function) const;
|
|
|
| virtual bool ResultOverwriteAllowed();
|
|
|
| @@ -1405,7 +1396,7 @@ class BinaryOperation: public Expression {
|
|
|
| DECLARE_NODE_TYPE(BinaryOperation)
|
|
|
| - virtual bool IsInlineable() const;
|
| + virtual bool IsInlineable(FunctionLiteral* function) const;
|
|
|
| virtual bool ResultOverwriteAllowed();
|
|
|
| @@ -1458,7 +1449,7 @@ class CountOperation: public Expression {
|
|
|
| virtual void MarkAsStatement() { is_prefix_ = true; }
|
|
|
| - virtual bool IsInlineable() const;
|
| + virtual bool IsInlineable(FunctionLiteral* function) const;
|
|
|
| void RecordTypeFeedback(TypeFeedbackOracle* oracle);
|
| virtual bool IsMonomorphic() { return is_monomorphic_; }
|
| @@ -1503,7 +1494,7 @@ class CompareOperation: public Expression {
|
| Expression* right() const { return right_; }
|
| virtual int position() const { return pos_; }
|
|
|
| - virtual bool IsInlineable() const;
|
| + virtual bool IsInlineable(FunctionLiteral* function) const;
|
|
|
| // Type feedback information.
|
| void RecordTypeFeedback(TypeFeedbackOracle* oracle);
|
| @@ -1546,7 +1537,7 @@ class Conditional: public Expression {
|
|
|
| DECLARE_NODE_TYPE(Conditional)
|
|
|
| - virtual bool IsInlineable() const;
|
| + virtual bool IsInlineable(FunctionLiteral* function) const;
|
|
|
| Expression* condition() const { return condition_; }
|
| Expression* then_expression() const { return then_expression_; }
|
| @@ -1579,7 +1570,7 @@ class Assignment: public Expression {
|
|
|
| DECLARE_NODE_TYPE(Assignment)
|
|
|
| - virtual bool IsInlineable() const;
|
| + virtual bool IsInlineable(FunctionLiteral* function) const;
|
|
|
| Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; }
|
|
|
| @@ -1638,7 +1629,7 @@ class Throw: public Expression {
|
|
|
| Expression* exception() const { return exception_; }
|
| virtual int position() const { return pos_; }
|
| - virtual bool IsInlineable() const;
|
| + virtual bool IsInlineable(FunctionLiteral* function) const;
|
|
|
| private:
|
| Expression* exception_;
|
| @@ -1676,7 +1667,10 @@ class FunctionLiteral: public Expression {
|
| expected_property_count_(expected_property_count),
|
| handler_count_(handler_count),
|
| parameter_count_(parameter_count),
|
| - function_token_position_(RelocInfo::kNoPosition) {
|
| + function_token_position_(RelocInfo::kNoPosition),
|
| + is_function_inlineable_(false),
|
| + is_function_primitive_(false),
|
| + ast_node_count_(0) {
|
| bitfield_ =
|
| HasOnlySimpleThisPropertyAssignments::encode(
|
| has_only_simple_this_property_assignments) |
|
| @@ -1725,12 +1719,28 @@ class FunctionLiteral: public Expression {
|
|
|
| bool pretenure() { return Pretenure::decode(bitfield_); }
|
| void set_pretenure() { bitfield_ |= Pretenure::encode(true); }
|
| - virtual bool IsInlineable() const;
|
| + virtual bool IsInlineable(FunctionLiteral* function) const;
|
|
|
| bool has_duplicate_parameters() {
|
| return HasDuplicateParameters::decode(bitfield_);
|
| }
|
|
|
| + void ComputeAstNodeCountAndInlineableFlags();
|
| +
|
| + bool is_function_inlineable() { return is_function_inlineable_; }
|
| +
|
| + bool is_function_primitive() { return is_function_primitive_; }
|
| +
|
| + void mark_as_not_primitive() {
|
| + is_function_primitive_ = false;
|
| + }
|
| +
|
| + int ast_node_count() { return ast_node_count_; }
|
| +
|
| + void increment_ast_node_count() {
|
| + ast_node_count_++;
|
| + }
|
| +
|
| private:
|
| Handle<String> name_;
|
| Scope* scope_;
|
| @@ -1744,6 +1754,10 @@ class FunctionLiteral: public Expression {
|
| int parameter_count_;
|
| int function_token_position_;
|
|
|
| + bool is_function_inlineable_;
|
| + bool is_function_primitive_;
|
| + int ast_node_count_;
|
| +
|
| unsigned bitfield_;
|
| class HasOnlySimpleThisPropertyAssignments: public BitField<bool, 0, 1> {};
|
| class IsExpression: public BitField<bool, 1, 1> {};
|
| @@ -1765,7 +1779,7 @@ class SharedFunctionInfoLiteral: public Expression {
|
| Handle<SharedFunctionInfo> shared_function_info() const {
|
| return shared_function_info_;
|
| }
|
| - virtual bool IsInlineable() const;
|
| + virtual bool IsInlineable(FunctionLiteral* function) const;
|
|
|
| private:
|
| Handle<SharedFunctionInfo> shared_function_info_;
|
| @@ -1774,9 +1788,9 @@ class SharedFunctionInfoLiteral: public Expression {
|
|
|
| class ThisFunction: public Expression {
|
| public:
|
| - explicit ThisFunction(Isolate* isolate) : Expression(isolate) {}
|
| + explicit ThisFunction(Isolate* isolate) : Expression(isolate) { }
|
| DECLARE_NODE_TYPE(ThisFunction)
|
| - virtual bool IsInlineable() const;
|
| + virtual bool IsInlineable(FunctionLiteral* function) const;
|
| };
|
|
|
|
|
|
|