Commit bfd7c719 authored by vitalyr@chromium.org's avatar vitalyr@chromium.org

Pass isolate to AST ID functions.

R=ager@chromium.org

Review URL: http://codereview.chromium.org/7399023

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8678 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 7ac9dfcc
...@@ -37,68 +37,76 @@ namespace v8 { ...@@ -37,68 +37,76 @@ namespace v8 {
namespace internal { namespace internal {
SwitchStatement::SwitchStatement(ZoneStringList* labels) SwitchStatement::SwitchStatement(Isolate* isolate,
: BreakableStatement(labels, TARGET_FOR_ANONYMOUS), ZoneStringList* labels)
: BreakableStatement(isolate, labels, TARGET_FOR_ANONYMOUS),
tag_(NULL), cases_(NULL) { tag_(NULL), cases_(NULL) {
} }
Block::Block(ZoneStringList* labels, int capacity, bool is_initializer_block) Block::Block(Isolate* isolate,
: BreakableStatement(labels, TARGET_FOR_NAMED_ONLY), ZoneStringList* labels,
int capacity,
bool is_initializer_block)
: BreakableStatement(isolate, labels, TARGET_FOR_NAMED_ONLY),
statements_(capacity), statements_(capacity),
is_initializer_block_(is_initializer_block) { is_initializer_block_(is_initializer_block) {
} }
BreakableStatement::BreakableStatement(ZoneStringList* labels, Type type) BreakableStatement::BreakableStatement(Isolate* isolate,
ZoneStringList* labels,
Type type)
: labels_(labels), : labels_(labels),
type_(type), type_(type),
entry_id_(GetNextId()), entry_id_(GetNextId(isolate)),
exit_id_(GetNextId()) { exit_id_(GetNextId(isolate)) {
ASSERT(labels == NULL || labels->length() > 0); ASSERT(labels == NULL || labels->length() > 0);
} }
IterationStatement::IterationStatement(ZoneStringList* labels) IterationStatement::IterationStatement(Isolate* isolate, ZoneStringList* labels)
: BreakableStatement(labels, TARGET_FOR_ANONYMOUS), : BreakableStatement(isolate, labels, TARGET_FOR_ANONYMOUS),
body_(NULL), body_(NULL),
continue_target_(), continue_target_(),
osr_entry_id_(GetNextId()) { osr_entry_id_(GetNextId(isolate)) {
} }
DoWhileStatement::DoWhileStatement(ZoneStringList* labels) DoWhileStatement::DoWhileStatement(Isolate* isolate, ZoneStringList* labels)
: IterationStatement(labels), : IterationStatement(isolate, labels),
cond_(NULL), cond_(NULL),
condition_position_(-1), condition_position_(-1),
continue_id_(GetNextId()), continue_id_(GetNextId(isolate)),
back_edge_id_(GetNextId()) { back_edge_id_(GetNextId(isolate)) {
} }
WhileStatement::WhileStatement(ZoneStringList* labels) WhileStatement::WhileStatement(Isolate* isolate, ZoneStringList* labels)
: IterationStatement(labels), : IterationStatement(isolate, labels),
cond_(NULL), cond_(NULL),
may_have_function_literal_(true), may_have_function_literal_(true),
body_id_(GetNextId()) { body_id_(GetNextId(isolate)) {
} }
ForStatement::ForStatement(ZoneStringList* labels) ForStatement::ForStatement(Isolate* isolate, ZoneStringList* labels)
: IterationStatement(labels), : IterationStatement(isolate, labels),
init_(NULL), init_(NULL),
cond_(NULL), cond_(NULL),
next_(NULL), next_(NULL),
may_have_function_literal_(true), may_have_function_literal_(true),
loop_variable_(NULL), loop_variable_(NULL),
continue_id_(GetNextId()), continue_id_(GetNextId(isolate)),
body_id_(GetNextId()) { body_id_(GetNextId(isolate)) {
} }
ForInStatement::ForInStatement(ZoneStringList* labels) ForInStatement::ForInStatement(Isolate* isolate, ZoneStringList* labels)
: IterationStatement(labels), each_(NULL), enumerable_(NULL), : IterationStatement(isolate, labels),
assignment_id_(GetNextId()) { each_(NULL),
enumerable_(NULL),
assignment_id_(GetNextId(isolate)) {
} }
......
...@@ -37,11 +37,11 @@ namespace v8 { ...@@ -37,11 +37,11 @@ namespace v8 {
namespace internal { namespace internal {
AstSentinels::AstSentinels() AstSentinels::AstSentinels()
: this_proxy_(true), : this_proxy_(Isolate::Current(), true),
identifier_proxy_(false), identifier_proxy_(Isolate::Current(), false),
valid_left_hand_side_sentinel_(), valid_left_hand_side_sentinel_(Isolate::Current()),
this_property_(&this_proxy_, NULL, 0), this_property_(Isolate::Current(), &this_proxy_, NULL, 0),
call_sentinel_(NULL, NULL, 0) { call_sentinel_(Isolate::Current(), NULL, NULL, 0) {
} }
...@@ -72,8 +72,9 @@ CountOperation* ExpressionStatement::StatementAsCountOperation() { ...@@ -72,8 +72,9 @@ CountOperation* ExpressionStatement::StatementAsCountOperation() {
} }
VariableProxy::VariableProxy(Variable* var) VariableProxy::VariableProxy(Isolate* isolate, Variable* var)
: name_(var->name()), : Expression(isolate),
name_(var->name()),
var_(NULL), // Will be set by the call to BindTo. var_(NULL), // Will be set by the call to BindTo.
is_this_(var->is_this()), is_this_(var->is_this()),
inside_with_(false), inside_with_(false),
...@@ -83,26 +84,29 @@ VariableProxy::VariableProxy(Variable* var) ...@@ -83,26 +84,29 @@ VariableProxy::VariableProxy(Variable* var)
} }
VariableProxy::VariableProxy(Handle<String> name, VariableProxy::VariableProxy(Isolate* isolate,
Handle<String> name,
bool is_this, bool is_this,
bool inside_with, bool inside_with,
int position) int position)
: name_(name), : Expression(isolate),
var_(NULL), name_(name),
is_this_(is_this), var_(NULL),
inside_with_(inside_with), is_this_(is_this),
is_trivial_(false), inside_with_(inside_with),
position_(position) { is_trivial_(false),
position_(position) {
// Names must be canonicalized for fast equality checks. // Names must be canonicalized for fast equality checks.
ASSERT(name->IsSymbol()); ASSERT(name->IsSymbol());
} }
VariableProxy::VariableProxy(bool is_this) VariableProxy::VariableProxy(Isolate* isolate, bool is_this)
: var_(NULL), : Expression(isolate),
is_this_(is_this), var_(NULL),
inside_with_(false), is_this_(is_this),
is_trivial_(false) { inside_with_(false),
is_trivial_(false) {
} }
...@@ -120,17 +124,19 @@ void VariableProxy::BindTo(Variable* var) { ...@@ -120,17 +124,19 @@ void VariableProxy::BindTo(Variable* var) {
} }
Assignment::Assignment(Token::Value op, Assignment::Assignment(Isolate* isolate,
Token::Value op,
Expression* target, Expression* target,
Expression* value, Expression* value,
int pos) int pos)
: op_(op), : Expression(isolate),
op_(op),
target_(target), target_(target),
value_(value), value_(value),
pos_(pos), pos_(pos),
binary_operation_(NULL), binary_operation_(NULL),
compound_load_id_(kNoNumber), compound_load_id_(kNoNumber),
assignment_id_(GetNextId()), assignment_id_(GetNextId(isolate)),
block_start_(false), block_start_(false),
block_end_(false), block_end_(false),
is_monomorphic_(false), is_monomorphic_(false),
...@@ -138,8 +144,12 @@ Assignment::Assignment(Token::Value op, ...@@ -138,8 +144,12 @@ Assignment::Assignment(Token::Value op,
ASSERT(Token::IsAssignmentOp(op)); ASSERT(Token::IsAssignmentOp(op));
if (is_compound()) { if (is_compound()) {
binary_operation_ = binary_operation_ =
new(ZONE) BinaryOperation(binary_op(), target, value, pos + 1); new(isolate->zone()) BinaryOperation(isolate,
compound_load_id_ = GetNextId(); binary_op(),
target,
value,
pos + 1);
compound_load_id_ = GetNextId(isolate);
} }
} }
...@@ -186,8 +196,9 @@ ObjectLiteral::Property::Property(Literal* key, Expression* value) { ...@@ -186,8 +196,9 @@ ObjectLiteral::Property::Property(Literal* key, Expression* value) {
ObjectLiteral::Property::Property(bool is_getter, FunctionLiteral* value) { ObjectLiteral::Property::Property(bool is_getter, FunctionLiteral* value) {
Isolate* isolate = Isolate::Current();
emit_store_ = true; emit_store_ = true;
key_ = new(ZONE) Literal(value->name()); key_ = new(isolate->zone()) Literal(isolate, value->name());
value_ = value; value_ = value;
kind_ = is_getter ? GETTER : SETTER; kind_ = is_getter ? GETTER : SETTER;
} }
...@@ -1190,15 +1201,16 @@ RegExpAlternative::RegExpAlternative(ZoneList<RegExpTree*>* nodes) ...@@ -1190,15 +1201,16 @@ RegExpAlternative::RegExpAlternative(ZoneList<RegExpTree*>* nodes)
} }
CaseClause::CaseClause(Expression* label, CaseClause::CaseClause(Isolate* isolate,
Expression* label,
ZoneList<Statement*>* statements, ZoneList<Statement*>* statements,
int pos) int pos)
: label_(label), : label_(label),
statements_(statements), statements_(statements),
position_(pos), position_(pos),
compare_type_(NONE), compare_type_(NONE),
compare_id_(AstNode::GetNextId()), compare_id_(AstNode::GetNextId(isolate)),
entry_id_(AstNode::GetNextId()) { entry_id_(AstNode::GetNextId(isolate)) {
} }
} } // namespace v8::internal } } // namespace v8::internal
This diff is collapsed.
This diff is collapsed.
...@@ -668,9 +668,12 @@ class Parser { ...@@ -668,9 +668,12 @@ class Parser {
Expression* NewCall(Expression* expression, Expression* NewCall(Expression* expression,
ZoneList<Expression*>* arguments, ZoneList<Expression*>* arguments,
int pos) { int pos) {
return new(zone()) Call(expression, arguments, pos); return new(zone()) Call(isolate(), expression, arguments, pos);
} }
inline Literal* NewLiteral(Handle<Object> handle) {
return new(zone()) Literal(isolate(), handle);
}
// Create a number literal. // Create a number literal.
Literal* NewNumberLiteral(double value); Literal* NewNumberLiteral(double value);
......
...@@ -67,8 +67,11 @@ class Processor: public AstVisitor { ...@@ -67,8 +67,11 @@ class Processor: public AstVisitor {
Expression* SetResult(Expression* value) { Expression* SetResult(Expression* value) {
result_assigned_ = true; result_assigned_ = true;
Zone* zone = isolate()->zone(); Zone* zone = isolate()->zone();
VariableProxy* result_proxy = new(zone) VariableProxy(result_); VariableProxy* result_proxy = new(zone) VariableProxy(isolate(), result_);
return new(zone) Assignment(Token::ASSIGN, result_proxy, value, return new(zone) Assignment(isolate(),
Token::ASSIGN,
result_proxy,
value,
RelocInfo::kNoPosition); RelocInfo::kNoPosition);
} }
...@@ -230,8 +233,9 @@ bool Rewriter::Rewrite(CompilationInfo* info) { ...@@ -230,8 +233,9 @@ bool Rewriter::Rewrite(CompilationInfo* info) {
if (processor.HasStackOverflow()) return false; if (processor.HasStackOverflow()) return false;
if (processor.result_assigned()) { if (processor.result_assigned()) {
Zone* zone = info->isolate()->zone(); Isolate* isolate = info->isolate();
VariableProxy* result_proxy = new(zone) VariableProxy(result); Zone* zone = isolate->zone();
VariableProxy* result_proxy = new(zone) VariableProxy(isolate, result);
body->Add(new(zone) ReturnStatement(result_proxy)); body->Add(new(zone) ReturnStatement(result_proxy));
} }
} }
......
...@@ -304,7 +304,7 @@ void Scope::Initialize(bool inside_with) { ...@@ -304,7 +304,7 @@ void Scope::Initialize(bool inside_with) {
Variable::VAR, Variable::VAR,
false, false,
Variable::THIS); Variable::THIS);
var->set_rewrite(new(isolate_->zone()) Slot(var, Slot::PARAMETER, -1)); var->set_rewrite(NewSlot(var, Slot::PARAMETER, -1));
receiver_ = var; receiver_ = var;
} }
...@@ -350,7 +350,7 @@ Variable* Scope::LocalLookup(Handle<String> name) { ...@@ -350,7 +350,7 @@ Variable* Scope::LocalLookup(Handle<String> name) {
Variable* var = Variable* var =
variables_.Declare(this, name, mode, true, Variable::NORMAL); variables_.Declare(this, name, mode, true, Variable::NORMAL);
var->set_rewrite(new(isolate_->zone()) Slot(var, Slot::CONTEXT, index)); var->set_rewrite(NewSlot(var, Slot::CONTEXT, index));
return var; return var;
} }
...@@ -407,8 +407,8 @@ VariableProxy* Scope::NewUnresolved(Handle<String> name, ...@@ -407,8 +407,8 @@ VariableProxy* Scope::NewUnresolved(Handle<String> name,
// the same name because they may be removed selectively via // the same name because they may be removed selectively via
// RemoveUnresolved(). // RemoveUnresolved().
ASSERT(!already_resolved()); ASSERT(!already_resolved());
VariableProxy* proxy = VariableProxy* proxy = new(isolate_->zone()) VariableProxy(
new(isolate_->zone()) VariableProxy(name, false, inside_with, position); isolate_, name, false, inside_with, position);
unresolved_.Add(proxy); unresolved_.Add(proxy);
return proxy; return proxy;
} }
...@@ -708,7 +708,7 @@ Variable* Scope::NonLocal(Handle<String> name, Variable::Mode mode) { ...@@ -708,7 +708,7 @@ Variable* Scope::NonLocal(Handle<String> name, Variable::Mode mode) {
// Declare a new non-local. // Declare a new non-local.
var = map->Declare(NULL, name, mode, true, Variable::NORMAL); var = map->Declare(NULL, name, mode, true, Variable::NORMAL);
// Allocate it by giving it a dynamic lookup. // Allocate it by giving it a dynamic lookup.
var->set_rewrite(new(isolate_->zone()) Slot(var, Slot::LOOKUP, -1)); var->set_rewrite(NewSlot(var, Slot::LOOKUP, -1));
} }
return var; return var;
} }
...@@ -964,14 +964,12 @@ bool Scope::HasArgumentsParameter() { ...@@ -964,14 +964,12 @@ bool Scope::HasArgumentsParameter() {
void Scope::AllocateStackSlot(Variable* var) { void Scope::AllocateStackSlot(Variable* var) {
var->set_rewrite( var->set_rewrite(NewSlot(var, Slot::LOCAL, num_stack_slots_++));
new(isolate_->zone()) Slot(var, Slot::LOCAL, num_stack_slots_++));
} }
void Scope::AllocateHeapSlot(Variable* var) { void Scope::AllocateHeapSlot(Variable* var) {
var->set_rewrite( var->set_rewrite(NewSlot(var, Slot::CONTEXT, num_heap_slots_++));
new(isolate_->zone()) Slot(var, Slot::CONTEXT, num_heap_slots_++));
} }
...@@ -1024,7 +1022,7 @@ void Scope::AllocateParameterLocals() { ...@@ -1024,7 +1022,7 @@ void Scope::AllocateParameterLocals() {
} else { } else {
ASSERT(var->rewrite() == NULL || var->IsParameter()); ASSERT(var->rewrite() == NULL || var->IsParameter());
if (var->rewrite() == NULL) { if (var->rewrite() == NULL) {
var->set_rewrite(new(isolate_->zone()) Slot(var, Slot::PARAMETER, i)); var->set_rewrite(NewSlot(var, Slot::PARAMETER, i));
} }
} }
} }
......
...@@ -425,6 +425,10 @@ class Scope: public ZoneObject { ...@@ -425,6 +425,10 @@ class Scope: public ZoneObject {
// Construct a catch scope with a binding for the name. // Construct a catch scope with a binding for the name.
Scope(Scope* inner_scope, Handle<String> catch_variable_name); Scope(Scope* inner_scope, Handle<String> catch_variable_name);
inline Slot* NewSlot(Variable* var, Slot::Type type, int index) {
return new(isolate_->zone()) Slot(isolate_, var, type, index);
}
void AddInnerScope(Scope* inner_scope) { void AddInnerScope(Scope* inner_scope) {
if (inner_scope != NULL) { if (inner_scope != NULL) {
inner_scopes_.Add(inner_scope); inner_scopes_.Add(inner_scope);
......
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