Revision: 7543
Author: [email protected]
Date: Thu Apr 7 07:45:34 2011
Log: Restart AST node numbering when we enter a function.
BUG=
TEST=
Review URL: http://codereview.chromium.org/6691058
http://code.google.com/p/v8/source/detail?r=7543
Modified:
/branches/bleeding_edge/src/arm/full-codegen-arm.cc
/branches/bleeding_edge/src/ast.h
/branches/bleeding_edge/src/hydrogen.cc
/branches/bleeding_edge/src/ia32/full-codegen-ia32.cc
/branches/bleeding_edge/src/parser.cc
/branches/bleeding_edge/src/x64/full-codegen-x64.cc
=======================================
--- /branches/bleeding_edge/src/arm/full-codegen-arm.cc Thu Apr 7 07:42:37
2011
+++ /branches/bleeding_edge/src/arm/full-codegen-arm.cc Thu Apr 7 07:45:34
2011
@@ -245,7 +245,7 @@
}
{ Comment cmnt(masm_, "[ Stack check");
- PrepareForBailout(info->function(), NO_REGISTERS);
+ PrepareForBailoutForId(AstNode::kFunctionEntryId, NO_REGISTERS);
Label ok;
__ LoadRoot(ip, Heap::kStackLimitRootIndex);
__ cmp(sp, Operand(ip));
=======================================
--- /branches/bleeding_edge/src/ast.h Thu Apr 7 07:42:37 2011
+++ /branches/bleeding_edge/src/ast.h Thu Apr 7 07:45:34 2011
@@ -132,6 +132,7 @@
#undef DECLARE_TYPE_ENUM
static const int kNoNumber = -1;
+ static const int kFunctionEntryId = 2; // Using 0 could disguise errors.
AstNode() : id_(GetNextId()) {
Isolate* isolate = Isolate::Current();
@@ -1661,8 +1662,7 @@
int num_parameters,
int start_position,
int end_position,
- bool is_expression,
- bool contains_loops)
+ bool is_expression)
: name_(name),
scope_(scope),
body_(body),
@@ -1675,7 +1675,6 @@
start_position_(start_position),
end_position_(end_position),
is_expression_(is_expression),
- contains_loops_(contains_loops),
function_token_position_(RelocInfo::kNoPosition),
inferred_name_(HEAP->empty_string()),
pretenure_(false) { }
@@ -1690,7 +1689,6 @@
int start_position() const { return start_position_; }
int end_position() const { return end_position_; }
bool is_expression() const { return is_expression_; }
- bool contains_loops() const { return contains_loops_; }
bool strict_mode() const;
int materialized_literal_count() { return materialized_literal_count_; }
@@ -1730,7 +1728,6 @@
int start_position_;
int end_position_;
bool is_expression_;
- bool contains_loops_;
bool strict_mode_;
int function_token_position_;
Handle<String> inferred_name_;
=======================================
--- /branches/bleeding_edge/src/hydrogen.cc Thu Apr 7 02:51:25 2011
+++ /branches/bleeding_edge/src/hydrogen.cc Thu Apr 7 07:45:34 2011
@@ -582,7 +582,7 @@
phi_list_(NULL) {
start_environment_ =
new(zone()) HEnvironment(NULL, info->scope(), info->closure());
- start_environment_->set_ast_id(info->function()->id());
+ start_environment_->set_ast_id(AstNode::kFunctionEntryId);
entry_block_ = CreateBasicBlock();
entry_block_->SetInitialEnvironment(start_environment_);
}
@@ -2203,7 +2203,7 @@
HEnvironment* initial_env = environment()->CopyWithoutHistory();
HBasicBlock* body_entry = CreateBasicBlock(initial_env);
current_block()->Goto(body_entry);
- body_entry->SetJoinId(info()->function()->id());
+ body_entry->SetJoinId(AstNode::kFunctionEntryId);
set_current_block(body_entry);
VisitStatements(info()->function()->body());
if (HasStackOverflow()) return NULL;
@@ -5663,7 +5663,7 @@
inner->SetValueAt(local_base + i, undefined);
}
- inner->set_ast_id(function->id());
+ inner->set_ast_id(AstNode::kFunctionEntryId);
return inner;
}
=======================================
--- /branches/bleeding_edge/src/ia32/full-codegen-ia32.cc Thu Apr 7
07:42:37 2011
+++ /branches/bleeding_edge/src/ia32/full-codegen-ia32.cc Thu Apr 7
07:45:34 2011
@@ -231,7 +231,7 @@
}
{ Comment cmnt(masm_, "[ Stack check");
- PrepareForBailout(info->function(), NO_REGISTERS);
+ PrepareForBailoutForId(AstNode::kFunctionEntryId, NO_REGISTERS);
NearLabel ok;
ExternalReference stack_limit =
ExternalReference::address_of_stack_limit(isolate());
=======================================
--- /branches/bleeding_edge/src/parser.cc Thu Apr 7 07:42:37 2011
+++ /branches/bleeding_edge/src/parser.cc Thu Apr 7 07:45:34 2011
@@ -462,7 +462,7 @@
// Parser's scope stack. The constructor sets the parser's top scope
// to the incoming scope, and the destructor resets it.
//
-// Additionlaly, it stores transient information used during parsing.
+// Additionally, it stores transient information used during parsing.
// These scopes are not kept around after parsing or referenced by syntax
// trees so they can be stack-allocated and hence used by the pre-parser.
@@ -495,9 +495,6 @@
void AddProperty() { expected_property_count_++; }
int expected_property_count() { return expected_property_count_; }
-
- void AddLoop() { loop_count_++; }
- bool ContainsLoops() const { return loop_count_ > 0; }
private:
// Captures the number of literals that need materialization in the
@@ -513,15 +510,13 @@
bool only_simple_this_property_assignments_;
Handle<FixedArray> this_property_assignments_;
- // Captures the number of loops inside the scope.
- int loop_count_;
-
// Bookkeeping
Parser* parser_;
// Previous values
LexicalScope* lexical_scope_parent_;
Scope* previous_scope_;
int previous_with_nesting_level_;
+ unsigned previous_ast_node_id_;
};
@@ -530,14 +525,15 @@
expected_property_count_(0),
only_simple_this_property_assignments_(false),
this_property_assignments_(isolate->factory()->empty_fixed_array()),
- loop_count_(0),
parser_(parser),
lexical_scope_parent_(parser->lexical_scope_),
previous_scope_(parser->top_scope_),
- previous_with_nesting_level_(parser->with_nesting_level_) {
+ previous_with_nesting_level_(parser->with_nesting_level_),
+ previous_ast_node_id_(isolate->ast_node_id()) {
parser->top_scope_ = scope;
parser->lexical_scope_ = this;
parser->with_nesting_level_ = 0;
+ isolate->set_ast_node_id(AstNode::kRootAstId + 1);
}
@@ -546,6 +542,7 @@
parser_->top_scope_ = previous_scope_;
parser_->lexical_scope_ = lexical_scope_parent_;
parser_->with_nesting_level_ = previous_with_nesting_level_;
+ parser_->isolate()->set_ast_node_id(previous_ast_node_id_);
}
@@ -663,8 +660,7 @@
0,
0,
source->length(),
- false,
- lexical_scope.ContainsLoops());
+ false);
} else if (stack_overflow_) {
isolate()->StackOverflow();
}
@@ -2162,7 +2158,6 @@
// DoStatement ::
// 'do' Statement 'while' '(' Expression ')' ';'
- lexical_scope_->AddLoop();
DoWhileStatement* loop = new(zone()) DoWhileStatement(labels);
Target target(&this->target_stack_, loop);
@@ -2194,7 +2189,6 @@
// WhileStatement ::
// 'while' '(' Expression ')' Statement
- lexical_scope_->AddLoop();
WhileStatement* loop = new(zone()) WhileStatement(labels);
Target target(&this->target_stack_, loop);
@@ -2213,7 +2207,6 @@
// ForStatement ::
// 'for' '(' Expression? ';' Expression? ';' Expression? ')' Statement
- lexical_scope_->AddLoop();
Statement* init = NULL;
Expect(Token::FOR, CHECK_OK);
@@ -3530,16 +3523,22 @@
}
int num_parameters = 0;
+ Scope* scope = NewScope(top_scope_, Scope::FUNCTION_SCOPE,
inside_with());
+ ZoneList<Statement*>* body = new ZoneList<Statement*>(8);
+ int materialized_literal_count;
+ int expected_property_count;
+ int start_pos;
+ int end_pos;
+ bool only_simple_this_property_assignments;
+ Handle<FixedArray> this_property_assignments;
// Parse function body.
- { Scope* scope =
- NewScope(top_scope_, Scope::FUNCTION_SCOPE, inside_with());
- LexicalScope lexical_scope(this, scope, isolate());
+ { LexicalScope lexical_scope(this, scope, isolate());
top_scope_->SetScopeName(name);
// FormalParameterList ::
// '(' (Identifier)*[','] ')'
Expect(Token::LPAREN, CHECK_OK);
- int start_pos = scanner().location().beg_pos;
+ start_pos = scanner().location().beg_pos;
Scanner::Location name_loc = Scanner::NoLocation();
Scanner::Location dupe_loc = Scanner::NoLocation();
Scanner::Location reserved_loc = Scanner::NoLocation();
@@ -3576,7 +3575,6 @@
Expect(Token::RPAREN, CHECK_OK);
Expect(Token::LBRACE, CHECK_OK);
- ZoneList<Statement*>* body = new ZoneList<Statement*>(8);
// If we have a named function expression, we add a local variable
// declaration to the body of the function with the name of the
@@ -3604,11 +3602,6 @@
parenthesized_function_ = false; // The bit was set for this function
only.
int function_block_pos = scanner().location().beg_pos;
- int materialized_literal_count;
- int expected_property_count;
- int end_pos;
- bool only_simple_this_property_assignments;
- Handle<FixedArray> this_property_assignments;
if (is_lazily_compiled && pre_data() != NULL) {
FunctionEntry entry =
pre_data()->GetFunctionEntry(function_block_pos);
if (!entry.is_valid()) {
@@ -3683,25 +3676,24 @@
}
CheckOctalLiteral(start_pos, end_pos, CHECK_OK);
}
-
- FunctionLiteral* function_literal =
- new(zone()) FunctionLiteral(name,
- top_scope_,
- body,
- materialized_literal_count,
- expected_property_count,
- only_simple_this_property_assignments,
- this_property_assignments,
- num_parameters,
- start_pos,
- end_pos,
- function_name->length() > 0,
- lexical_scope.ContainsLoops());
- function_literal->set_function_token_position(function_token_position);
-
- if (fni_ != NULL && !is_named) fni_->AddFunction(function_literal);
- return function_literal;
- }
+ }
+
+ FunctionLiteral* function_literal =
+ new(zone()) FunctionLiteral(name,
+ scope,
+ body,
+ materialized_literal_count,
+ expected_property_count,
+ only_simple_this_property_assignments,
+ this_property_assignments,
+ num_parameters,
+ start_pos,
+ end_pos,
+ (function_name->length() > 0));
+ function_literal->set_function_token_position(function_token_position);
+
+ if (fni_ != NULL && !is_named) fni_->AddFunction(function_literal);
+ return function_literal;
}
=======================================
--- /branches/bleeding_edge/src/x64/full-codegen-x64.cc Thu Apr 7 07:42:37
2011
+++ /branches/bleeding_edge/src/x64/full-codegen-x64.cc Thu Apr 7 07:45:34
2011
@@ -232,7 +232,7 @@
}
{ Comment cmnt(masm_, "[ Stack check");
- PrepareForBailout(info->function(), NO_REGISTERS);
+ PrepareForBailoutForId(AstNode::kFunctionEntryId, NO_REGISTERS);
NearLabel ok;
__ CompareRoot(rsp, Heap::kStackLimitRootIndex);
__ j(above_equal, &ok);
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev