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

Unified Diff: src/parser.cc

Issue 8677008: Relax inlining limits for simple leaf functions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Save/restore node count in FunctionState, add comments. Created 9 years, 1 month 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
« src/hydrogen.cc ('K') | « src/objects-inl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index e19af1cd5cd3dd265633660544b675246588c17b..baa446d8a7b3defaa56b21aa460762f290288122 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -513,6 +513,14 @@ class Parser::FunctionState BASE_EMBEDDED {
void AddProperty() { expected_property_count_++; }
int expected_property_count() { return expected_property_count_; }
+ int ast_node_count() {
+ return parser_->isolate()->ast_node_count();
+ }
+
+ bool is_function_primitive() {
+ return parser_->isolate()->is_function_primitive();
+ }
+
private:
// Used to assign an index to each literal that needs materialization in
// the function. Includes regexp literals, and boilerplate for object and
@@ -534,6 +542,8 @@ class Parser::FunctionState BASE_EMBEDDED {
FunctionState* outer_function_state_;
Scope* outer_scope_;
unsigned saved_ast_node_id_;
+ int saved_ast_node_count_;
+ bool saved_is_function_primitive_;
};
@@ -548,10 +558,14 @@ Parser::FunctionState::FunctionState(Parser* parser,
parser_(parser),
outer_function_state_(parser->current_function_state_),
outer_scope_(parser->top_scope_),
- saved_ast_node_id_(isolate->ast_node_id()) {
+ saved_ast_node_id_(isolate->ast_node_id()),
+ saved_ast_node_count_(isolate->ast_node_count()),
+ saved_is_function_primitive_(isolate->is_function_primitive()) {
parser->top_scope_ = scope;
parser->current_function_state_ = this;
isolate->set_ast_node_id(AstNode::kDeclarationsId + 1);
+ isolate->set_ast_node_count(0);
+ isolate->set_is_function_primitive(true);
}
@@ -559,6 +573,8 @@ Parser::FunctionState::~FunctionState() {
parser_->top_scope_ = outer_scope_;
parser_->current_function_state_ = outer_function_state_;
parser_->isolate()->set_ast_node_id(saved_ast_node_id_);
+ parser_->isolate()->set_ast_node_count(saved_ast_node_count_);
+ parser_->isolate()->set_is_function_primitive(saved_is_function_primitive_);
}
@@ -682,7 +698,9 @@ FunctionLiteral* Parser::DoParseProgram(CompilationInfo* info,
function_state.this_property_assignments(),
0,
FunctionLiteral::ANONYMOUS_EXPRESSION,
- false); // Does not have duplicate parameters.
+ false, // Does not have duplicate parameters.
+ function_state.ast_node_count(),
+ function_state.is_function_primitive());
} else if (stack_overflow_) {
isolate()->StackOverflow();
}
@@ -2183,7 +2201,7 @@ Statement* Parser::ParseWithStatement(ZoneStringList* labels, bool* ok) {
stmt = ParseStatement(labels, CHECK_OK);
with_scope->set_end_position(scanner().location().end_pos);
}
- return new(zone()) WithStatement(expr, stmt);
+ return new(zone()) WithStatement(isolate(), expr, stmt);
}
@@ -2349,7 +2367,8 @@ TryStatement* Parser::ParseTryStatement(bool* ok) {
// If we have both, create an inner try/catch.
ASSERT(catch_scope != NULL && catch_variable != NULL);
int index = current_function_state_->NextHandlerIndex();
- TryCatchStatement* statement = new(zone()) TryCatchStatement(index,
+ TryCatchStatement* statement = new(zone()) TryCatchStatement(isolate(),
+ index,
try_block,
catch_scope,
catch_variable,
@@ -2365,7 +2384,8 @@ TryStatement* Parser::ParseTryStatement(bool* ok) {
ASSERT(finally_block == NULL);
ASSERT(catch_scope != NULL && catch_variable != NULL);
int index = current_function_state_->NextHandlerIndex();
- result = new(zone()) TryCatchStatement(index,
+ result = new(zone()) TryCatchStatement(isolate(),
+ index,
try_block,
catch_scope,
catch_variable,
@@ -2373,7 +2393,8 @@ TryStatement* Parser::ParseTryStatement(bool* ok) {
} else {
ASSERT(finally_block != NULL);
int index = current_function_state_->NextHandlerIndex();
- result = new(zone()) TryFinallyStatement(index,
+ result = new(zone()) TryFinallyStatement(isolate(),
+ index,
try_block,
finally_block);
// Combine the jump targets of the try block and the possible catch block.
@@ -3941,6 +3962,8 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> function_name,
bool only_simple_this_property_assignments;
Handle<FixedArray> this_property_assignments;
bool has_duplicate_parameters = false;
+ int ast_node_count;
+ bool is_function_primitive;
// Parse function body.
{ FunctionState function_state(this, scope, isolate());
top_scope_->SetScopeName(function_name);
@@ -4038,6 +4061,10 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> function_name,
top_scope_->SetStrictModeFlag(entry.strict_mode_flag());
only_simple_this_property_assignments = false;
this_property_assignments = isolate()->factory()->empty_fixed_array();
+ // Give up computing the node count and the "primitive" flag when
+ // parsing lazily.
+ ast_node_count = 0;
+ is_function_primitive = false;
Expect(Token::RBRACE, CHECK_OK);
}
}
@@ -4062,7 +4089,8 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> function_name,
only_simple_this_property_assignments =
function_state.only_simple_this_property_assignments();
this_property_assignments = function_state.this_property_assignments();
-
+ ast_node_count = function_state.ast_node_count();
+ is_function_primitive = function_state.is_function_primitive();
Expect(Token::RBRACE, CHECK_OK);
scope->set_end_position(scanner().location().end_pos);
}
@@ -4131,7 +4159,9 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> function_name,
this_property_assignments,
num_parameters,
type,
- has_duplicate_parameters);
+ has_duplicate_parameters,
+ ast_node_count,
+ is_function_primitive);
function_literal->set_function_token_position(function_token_position);
if (fni_ != NULL && should_infer_name) fni_->AddFunction(function_literal);
« src/hydrogen.cc ('K') | « src/objects-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698