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 {
namespace internal {
SwitchStatement::SwitchStatement(ZoneStringList* labels)
: BreakableStatement(labels, TARGET_FOR_ANONYMOUS),
SwitchStatement::SwitchStatement(Isolate* isolate,
ZoneStringList* labels)
: BreakableStatement(isolate, labels, TARGET_FOR_ANONYMOUS),
tag_(NULL), cases_(NULL) {
}
Block::Block(ZoneStringList* labels, int capacity, bool is_initializer_block)
: BreakableStatement(labels, TARGET_FOR_NAMED_ONLY),
Block::Block(Isolate* isolate,
ZoneStringList* labels,
int capacity,
bool is_initializer_block)
: BreakableStatement(isolate, labels, TARGET_FOR_NAMED_ONLY),
statements_(capacity),
is_initializer_block_(is_initializer_block) {
}
BreakableStatement::BreakableStatement(ZoneStringList* labels, Type type)
BreakableStatement::BreakableStatement(Isolate* isolate,
ZoneStringList* labels,
Type type)
: labels_(labels),
type_(type),
entry_id_(GetNextId()),
exit_id_(GetNextId()) {
entry_id_(GetNextId(isolate)),
exit_id_(GetNextId(isolate)) {
ASSERT(labels == NULL || labels->length() > 0);
}
IterationStatement::IterationStatement(ZoneStringList* labels)
: BreakableStatement(labels, TARGET_FOR_ANONYMOUS),
IterationStatement::IterationStatement(Isolate* isolate, ZoneStringList* labels)
: BreakableStatement(isolate, labels, TARGET_FOR_ANONYMOUS),
body_(NULL),
continue_target_(),
osr_entry_id_(GetNextId()) {
osr_entry_id_(GetNextId(isolate)) {
}
DoWhileStatement::DoWhileStatement(ZoneStringList* labels)
: IterationStatement(labels),
DoWhileStatement::DoWhileStatement(Isolate* isolate, ZoneStringList* labels)
: IterationStatement(isolate, labels),
cond_(NULL),
condition_position_(-1),
continue_id_(GetNextId()),
back_edge_id_(GetNextId()) {
continue_id_(GetNextId(isolate)),
back_edge_id_(GetNextId(isolate)) {
}
WhileStatement::WhileStatement(ZoneStringList* labels)
: IterationStatement(labels),
WhileStatement::WhileStatement(Isolate* isolate, ZoneStringList* labels)
: IterationStatement(isolate, labels),
cond_(NULL),
may_have_function_literal_(true),
body_id_(GetNextId()) {
body_id_(GetNextId(isolate)) {
}
ForStatement::ForStatement(ZoneStringList* labels)
: IterationStatement(labels),
ForStatement::ForStatement(Isolate* isolate, ZoneStringList* labels)
: IterationStatement(isolate, labels),
init_(NULL),
cond_(NULL),
next_(NULL),
may_have_function_literal_(true),
loop_variable_(NULL),
continue_id_(GetNextId()),
body_id_(GetNextId()) {
continue_id_(GetNextId(isolate)),
body_id_(GetNextId(isolate)) {
}
ForInStatement::ForInStatement(ZoneStringList* labels)
: IterationStatement(labels), each_(NULL), enumerable_(NULL),
assignment_id_(GetNextId()) {
ForInStatement::ForInStatement(Isolate* isolate, ZoneStringList* labels)
: IterationStatement(isolate, labels),
each_(NULL),
enumerable_(NULL),
assignment_id_(GetNextId(isolate)) {
}
......
......@@ -37,11 +37,11 @@ namespace v8 {
namespace internal {
AstSentinels::AstSentinels()
: this_proxy_(true),
identifier_proxy_(false),
valid_left_hand_side_sentinel_(),
this_property_(&this_proxy_, NULL, 0),
call_sentinel_(NULL, NULL, 0) {
: this_proxy_(Isolate::Current(), true),
identifier_proxy_(Isolate::Current(), false),
valid_left_hand_side_sentinel_(Isolate::Current()),
this_property_(Isolate::Current(), &this_proxy_, NULL, 0),
call_sentinel_(Isolate::Current(), NULL, NULL, 0) {
}
......@@ -72,8 +72,9 @@ CountOperation* ExpressionStatement::StatementAsCountOperation() {
}
VariableProxy::VariableProxy(Variable* var)
: name_(var->name()),
VariableProxy::VariableProxy(Isolate* isolate, Variable* var)
: Expression(isolate),
name_(var->name()),
var_(NULL), // Will be set by the call to BindTo.
is_this_(var->is_this()),
inside_with_(false),
......@@ -83,11 +84,13 @@ VariableProxy::VariableProxy(Variable* var)
}
VariableProxy::VariableProxy(Handle<String> name,
VariableProxy::VariableProxy(Isolate* isolate,
Handle<String> name,
bool is_this,
bool inside_with,
int position)
: name_(name),
: Expression(isolate),
name_(name),
var_(NULL),
is_this_(is_this),
inside_with_(inside_with),
......@@ -98,8 +101,9 @@ VariableProxy::VariableProxy(Handle<String> name,
}
VariableProxy::VariableProxy(bool is_this)
: var_(NULL),
VariableProxy::VariableProxy(Isolate* isolate, bool is_this)
: Expression(isolate),
var_(NULL),
is_this_(is_this),
inside_with_(false),
is_trivial_(false) {
......@@ -120,17 +124,19 @@ void VariableProxy::BindTo(Variable* var) {
}
Assignment::Assignment(Token::Value op,
Assignment::Assignment(Isolate* isolate,
Token::Value op,
Expression* target,
Expression* value,
int pos)
: op_(op),
: Expression(isolate),
op_(op),
target_(target),
value_(value),
pos_(pos),
binary_operation_(NULL),
compound_load_id_(kNoNumber),
assignment_id_(GetNextId()),
assignment_id_(GetNextId(isolate)),
block_start_(false),
block_end_(false),
is_monomorphic_(false),
......@@ -138,8 +144,12 @@ Assignment::Assignment(Token::Value op,
ASSERT(Token::IsAssignmentOp(op));
if (is_compound()) {
binary_operation_ =
new(ZONE) BinaryOperation(binary_op(), target, value, pos + 1);
compound_load_id_ = GetNextId();
new(isolate->zone()) BinaryOperation(isolate,
binary_op(),
target,
value,
pos + 1);
compound_load_id_ = GetNextId(isolate);
}
}
......@@ -186,8 +196,9 @@ ObjectLiteral::Property::Property(Literal* key, Expression* value) {
ObjectLiteral::Property::Property(bool is_getter, FunctionLiteral* value) {
Isolate* isolate = Isolate::Current();
emit_store_ = true;
key_ = new(ZONE) Literal(value->name());
key_ = new(isolate->zone()) Literal(isolate, value->name());
value_ = value;
kind_ = is_getter ? GETTER : SETTER;
}
......@@ -1190,15 +1201,16 @@ RegExpAlternative::RegExpAlternative(ZoneList<RegExpTree*>* nodes)
}
CaseClause::CaseClause(Expression* label,
CaseClause::CaseClause(Isolate* isolate,
Expression* label,
ZoneList<Statement*>* statements,
int pos)
: label_(label),
statements_(statements),
position_(pos),
compare_type_(NONE),
compare_id_(AstNode::GetNextId()),
entry_id_(AstNode::GetNextId()) {
compare_id_(AstNode::GetNextId(isolate)),
entry_id_(AstNode::GetNextId(isolate)) {
}
} } // namespace v8::internal
......@@ -169,9 +169,11 @@ class AstNode: public ZoneObject {
static void ResetIds() { Isolate::Current()->set_ast_node_id(0); }
protected:
static unsigned GetNextId() { return ReserveIdRange(1); }
static unsigned ReserveIdRange(int n) {
Isolate* isolate = Isolate::Current();
static unsigned GetNextId(Isolate* isolate) {
return ReserveIdRange(isolate, 1);
}
static unsigned ReserveIdRange(Isolate* isolate, int n) {
unsigned tmp = isolate->ast_node_id();
isolate->set_ast_node_id(tmp + n);
return tmp;
......@@ -219,7 +221,9 @@ class Expression: public AstNode {
kTest
};
Expression() : id_(GetNextId()), test_id_(GetNextId()) {}
explicit Expression(Isolate* isolate)
: id_(GetNextId(isolate)),
test_id_(GetNextId(isolate)) {}
virtual int position() const {
UNREACHABLE();
......@@ -286,6 +290,7 @@ class Expression: public AstNode {
*/
class ValidLeftHandSideSentinel: public Expression {
public:
explicit ValidLeftHandSideSentinel(Isolate* isolate) : Expression(isolate) {}
virtual bool IsValidLeftHandSide() { return true; }
virtual void Accept(AstVisitor* v) { UNREACHABLE(); }
virtual bool IsInlineable() const;
......@@ -317,7 +322,7 @@ class BreakableStatement: public Statement {
int ExitId() const { return exit_id_; }
protected:
inline BreakableStatement(ZoneStringList* labels, Type type);
BreakableStatement(Isolate* isolate, ZoneStringList* labels, Type type);
private:
ZoneStringList* labels_;
......@@ -330,7 +335,10 @@ class BreakableStatement: public Statement {
class Block: public BreakableStatement {
public:
inline Block(ZoneStringList* labels, int capacity, bool is_initializer_block);
inline Block(Isolate* isolate,
ZoneStringList* labels,
int capacity,
bool is_initializer_block);
DECLARE_NODE_TYPE(Block)
......@@ -398,7 +406,7 @@ class IterationStatement: public BreakableStatement {
Label* continue_target() { return &continue_target_; }
protected:
explicit inline IterationStatement(ZoneStringList* labels);
inline IterationStatement(Isolate* isolate, ZoneStringList* labels);
void Initialize(Statement* body) {
body_ = body;
......@@ -413,7 +421,7 @@ class IterationStatement: public BreakableStatement {
class DoWhileStatement: public IterationStatement {
public:
explicit inline DoWhileStatement(ZoneStringList* labels);
inline DoWhileStatement(Isolate* isolate, ZoneStringList* labels);
DECLARE_NODE_TYPE(DoWhileStatement)
......@@ -446,7 +454,7 @@ class DoWhileStatement: public IterationStatement {
class WhileStatement: public IterationStatement {
public:
explicit inline WhileStatement(ZoneStringList* labels);
inline WhileStatement(Isolate* isolate, ZoneStringList* labels);
DECLARE_NODE_TYPE(WhileStatement)
......@@ -479,7 +487,7 @@ class WhileStatement: public IterationStatement {
class ForStatement: public IterationStatement {
public:
explicit inline ForStatement(ZoneStringList* labels);
inline ForStatement(Isolate* isolate, ZoneStringList* labels);
DECLARE_NODE_TYPE(ForStatement)
......@@ -528,7 +536,7 @@ class ForStatement: public IterationStatement {
class ForInStatement: public IterationStatement {
public:
explicit inline ForInStatement(ZoneStringList* labels);
inline ForInStatement(Isolate* isolate, ZoneStringList* labels);
DECLARE_NODE_TYPE(ForInStatement)
......@@ -645,7 +653,10 @@ class ExitContextStatement: public Statement {
class CaseClause: public ZoneObject {
public:
CaseClause(Expression* label, ZoneList<Statement*>* statements, int pos);
CaseClause(Isolate* isolate,
Expression* label,
ZoneList<Statement*>* statements,
int pos);
bool is_default() const { return label_ == NULL; }
Expression* label() const {
......@@ -680,7 +691,7 @@ class CaseClause: public ZoneObject {
class SwitchStatement: public BreakableStatement {
public:
explicit inline SwitchStatement(ZoneStringList* labels);
inline SwitchStatement(Isolate* isolate, ZoneStringList* labels);
DECLARE_NODE_TYPE(SwitchStatement)
......@@ -706,15 +717,16 @@ class SwitchStatement: public BreakableStatement {
// given if-statement has a then- or an else-part containing code.
class IfStatement: public Statement {
public:
IfStatement(Expression* condition,
IfStatement(Isolate* isolate,
Expression* condition,
Statement* then_statement,
Statement* else_statement)
: condition_(condition),
then_statement_(then_statement),
else_statement_(else_statement),
if_id_(GetNextId()),
then_id_(GetNextId()),
else_id_(GetNextId()) {
if_id_(GetNextId(isolate)),
then_id_(GetNextId(isolate)),
else_id_(GetNextId(isolate)) {
}
DECLARE_NODE_TYPE(IfStatement)
......@@ -843,7 +855,8 @@ class EmptyStatement: public Statement {
class Literal: public Expression {
public:
explicit Literal(Handle<Object> handle) : handle_(handle) { }
Literal(Isolate* isolate, Handle<Object> handle)
: Expression(isolate), handle_(handle) { }
DECLARE_NODE_TYPE(Literal)
......@@ -896,8 +909,14 @@ class Literal: public Expression {
// Base class for literals that needs space in the corresponding JSFunction.
class MaterializedLiteral: public Expression {
public:
explicit MaterializedLiteral(int literal_index, bool is_simple, int depth)
: literal_index_(literal_index), is_simple_(is_simple), depth_(depth) {}
MaterializedLiteral(Isolate* isolate,
int literal_index,
bool is_simple,
int depth)
: Expression(isolate),
literal_index_(literal_index),
is_simple_(is_simple),
depth_(depth) {}
virtual MaterializedLiteral* AsMaterializedLiteral() { return this; }
......@@ -953,14 +972,15 @@ class ObjectLiteral: public MaterializedLiteral {
bool emit_store_;
};
ObjectLiteral(Handle<FixedArray> constant_properties,
ObjectLiteral(Isolate* isolate,
Handle<FixedArray> constant_properties,
ZoneList<Property*>* properties,
int literal_index,
bool is_simple,
bool fast_elements,
int depth,
bool has_function)
: MaterializedLiteral(literal_index, is_simple, depth),
: MaterializedLiteral(isolate, literal_index, is_simple, depth),
constant_properties_(constant_properties),
properties_(properties),
fast_elements_(fast_elements),
......@@ -999,10 +1019,11 @@ class ObjectLiteral: public MaterializedLiteral {
// Node for capturing a regexp literal.
class RegExpLiteral: public MaterializedLiteral {
public:
RegExpLiteral(Handle<String> pattern,
RegExpLiteral(Isolate* isolate,
Handle<String> pattern,
Handle<String> flags,
int literal_index)
: MaterializedLiteral(literal_index, false, 1),
: MaterializedLiteral(isolate, literal_index, false, 1),
pattern_(pattern),
flags_(flags) {}
......@@ -1020,15 +1041,16 @@ class RegExpLiteral: public MaterializedLiteral {
// for minimizing the work when constructing it at runtime.
class ArrayLiteral: public MaterializedLiteral {
public:
ArrayLiteral(Handle<FixedArray> constant_elements,
ArrayLiteral(Isolate* isolate,
Handle<FixedArray> constant_elements,
ZoneList<Expression*>* values,
int literal_index,
bool is_simple,
int depth)
: MaterializedLiteral(literal_index, is_simple, depth),
: MaterializedLiteral(isolate, literal_index, is_simple, depth),
constant_elements_(constant_elements),
values_(values),
first_element_id_(ReserveIdRange(values->length())) {}
first_element_id_(ReserveIdRange(isolate, values->length())) {}
DECLARE_NODE_TYPE(ArrayLiteral)
......@@ -1047,7 +1069,7 @@ class ArrayLiteral: public MaterializedLiteral {
class VariableProxy: public Expression {
public:
explicit VariableProxy(Variable* var);
VariableProxy(Isolate* isolate, Variable* var);
DECLARE_NODE_TYPE(VariableProxy)
......@@ -1094,11 +1116,12 @@ class VariableProxy: public Expression {
bool is_trivial_;
int position_;
VariableProxy(Handle<String> name,
VariableProxy(Isolate* isolate,
Handle<String> name,
bool is_this,
bool inside_with,
int position = RelocInfo::kNoPosition);
explicit VariableProxy(bool is_this);
VariableProxy(Isolate* isolate, bool is_this);
friend class Scope;
};
......@@ -1109,7 +1132,8 @@ class VariableProxySentinel: public VariableProxy {
virtual bool IsValidLeftHandSide() { return !is_this(); }
private:
explicit VariableProxySentinel(bool is_this) : VariableProxy(is_this) { }
VariableProxySentinel(Isolate* isolate, bool is_this)
: VariableProxy(isolate, is_this) { }
friend class AstSentinels;
};
......@@ -1139,8 +1163,8 @@ class Slot: public Expression {
LOOKUP
};
Slot(Variable* var, Type type, int index)
: var_(var), type_(type), index_(index) {
Slot(Isolate* isolate, Variable* var, Type type, int index)
: Expression(isolate), var_(var), type_(type), index_(index) {
ASSERT(var != NULL);
}
......@@ -1171,8 +1195,13 @@ class Property: public Expression {
// properties should use the global object as receiver, not the base object
// of the resolved Reference.
enum Type { NORMAL, SYNTHETIC };
Property(Expression* obj, Expression* key, int pos, Type type = NORMAL)
: obj_(obj),
Property(Isolate* isolate,
Expression* obj,
Expression* key,
int pos,
Type type = NORMAL)
: Expression(isolate),
obj_(obj),
key_(key),
pos_(pos),
type_(type),
......@@ -1224,14 +1253,18 @@ class Property: public Expression {
class Call: public Expression {
public:
Call(Expression* expression, ZoneList<Expression*>* arguments, int pos)
: expression_(expression),
Call(Isolate* isolate,
Expression* expression,
ZoneList<Expression*>* arguments,
int pos)
: Expression(isolate),
expression_(expression),
arguments_(arguments),
pos_(pos),
is_monomorphic_(false),
check_type_(RECEIVER_MAP_CHECK),
receiver_types_(NULL),
return_id_(GetNextId()) {
return_id_(GetNextId(isolate)) {
}
DECLARE_NODE_TYPE(Call)
......@@ -1310,8 +1343,14 @@ class AstSentinels {
class CallNew: public Expression {
public:
CallNew(Expression* expression, ZoneList<Expression*>* arguments, int pos)
: expression_(expression), arguments_(arguments), pos_(pos) { }
CallNew(Isolate* isolate,
Expression* expression,
ZoneList<Expression*>* arguments,
int pos)
: Expression(isolate),
expression_(expression),
arguments_(arguments),
pos_(pos) { }
DECLARE_NODE_TYPE(CallNew)
......@@ -1334,10 +1373,14 @@ class CallNew: public Expression {
// implemented in JavaScript (see "v8natives.js").
class CallRuntime: public Expression {
public:
CallRuntime(Handle<String> name,
CallRuntime(Isolate* isolate,
Handle<String> name,
const Runtime::Function* function,
ZoneList<Expression*>* arguments)
: name_(name), function_(function), arguments_(arguments) { }
: Expression(isolate),
name_(name),
function_(function),
arguments_(arguments) { }
DECLARE_NODE_TYPE(CallRuntime)
......@@ -1357,8 +1400,11 @@ class CallRuntime: public Expression {
class UnaryOperation: public Expression {
public:
UnaryOperation(Token::Value op, Expression* expression, int pos)
: op_(op), expression_(expression), pos_(pos) {
UnaryOperation(Isolate* isolate,
Token::Value op,
Expression* expression,
int pos)
: Expression(isolate), op_(op), expression_(expression), pos_(pos) {
ASSERT(Token::IsUnaryOp(op));
}
......@@ -1381,14 +1427,15 @@ class UnaryOperation: public Expression {
class BinaryOperation: public Expression {
public:
BinaryOperation(Token::Value op,
BinaryOperation(Isolate* isolate,
Token::Value op,
Expression* left,
Expression* right,
int pos)
: op_(op), left_(left), right_(right), pos_(pos) {
: Expression(isolate), op_(op), left_(left), right_(right), pos_(pos) {
ASSERT(Token::IsBinaryOp(op));
right_id_ = (op == Token::AND || op == Token::OR)
? static_cast<int>(GetNextId())
? static_cast<int>(GetNextId(isolate))
: AstNode::kNoNumber;
}
......@@ -1419,13 +1466,18 @@ class BinaryOperation: public Expression {
class CountOperation: public Expression {
public:
CountOperation(Token::Value op, bool is_prefix, Expression* expr, int pos)
: op_(op),
CountOperation(Isolate* isolate,
Token::Value op,
bool is_prefix,
Expression* expr,
int pos)
: Expression(isolate),
op_(op),
is_prefix_(is_prefix),
expression_(expr),
pos_(pos),
assignment_id_(GetNextId()),
count_id_(GetNextId()),
assignment_id_(GetNextId(isolate)),
count_id_(GetNextId(isolate)),
receiver_types_(NULL) { }
DECLARE_NODE_TYPE(CountOperation)
......@@ -1471,11 +1523,17 @@ class CountOperation: public Expression {
class CompareOperation: public Expression {
public:
CompareOperation(Token::Value op,
CompareOperation(Isolate* isolate,
Token::Value op,
Expression* left,
Expression* right,
int pos)
: op_(op), left_(left), right_(right), pos_(pos), compare_type_(NONE) {
: Expression(isolate),
op_(op),
left_(left),
right_(right),
pos_(pos),
compare_type_(NONE) {
ASSERT(Token::IsCompareOp(op));
}
......@@ -1510,8 +1568,8 @@ class CompareOperation: public Expression {
class CompareToNull: public Expression {
public:
CompareToNull(bool is_strict, Expression* expression)
: is_strict_(is_strict), expression_(expression) { }
CompareToNull(Isolate* isolate, bool is_strict, Expression* expression)
: Expression(isolate), is_strict_(is_strict), expression_(expression) { }
DECLARE_NODE_TYPE(CompareToNull)
......@@ -1529,18 +1587,20 @@ class CompareToNull: public Expression {
class Conditional: public Expression {
public:
Conditional(Expression* condition,
Conditional(Isolate* isolate,
Expression* condition,
Expression* then_expression,
Expression* else_expression,
int then_expression_position,
int else_expression_position)
: condition_(condition),
: Expression(isolate),
condition_(condition),
then_expression_(then_expression),
else_expression_(else_expression),
then_expression_position_(then_expression_position),
else_expression_position_(else_expression_position),
then_id_(GetNextId()),
else_id_(GetNextId()) {
then_id_(GetNextId(isolate)),
else_id_(GetNextId(isolate)) {
}
DECLARE_NODE_TYPE(Conditional)
......@@ -1570,7 +1630,11 @@ class Conditional: public Expression {
class Assignment: public Expression {
public:
Assignment(Token::Value op, Expression* target, Expression* value, int pos);
Assignment(Isolate* isolate,
Token::Value op,
Expression* target,
Expression* value,
int pos);
DECLARE_NODE_TYPE(Assignment)
......@@ -1630,8 +1694,8 @@ class Assignment: public Expression {
class Throw: public Expression {
public:
Throw(Expression* exception, int pos)
: exception_(exception), pos_(pos) {}
Throw(Isolate* isolate, Expression* exception, int pos)
: Expression(isolate), exception_(exception), pos_(pos) {}
DECLARE_NODE_TYPE(Throw)
......@@ -1647,7 +1711,8 @@ class Throw: public Expression {
class FunctionLiteral: public Expression {
public:
FunctionLiteral(Handle<String> name,
FunctionLiteral(Isolate* isolate,
Handle<String> name,
Scope* scope,
ZoneList<Statement*>* body,
int materialized_literal_count,
......@@ -1659,7 +1724,8 @@ class FunctionLiteral: public Expression {
int end_position,
bool is_expression,
bool has_duplicate_parameters)
: name_(name),
: Expression(isolate),
name_(name),
scope_(scope),
body_(body),
materialized_literal_count_(materialized_literal_count),
......@@ -1738,9 +1804,10 @@ class FunctionLiteral: public Expression {
class SharedFunctionInfoLiteral: public Expression {
public:
explicit SharedFunctionInfoLiteral(
SharedFunctionInfoLiteral(
Isolate* isolate,
Handle<SharedFunctionInfo> shared_function_info)
: shared_function_info_(shared_function_info) { }
: Expression(isolate), shared_function_info_(shared_function_info) { }
DECLARE_NODE_TYPE(SharedFunctionInfoLiteral)
......@@ -1756,6 +1823,7 @@ class SharedFunctionInfoLiteral: public Expression {
class ThisFunction: public Expression {
public:
explicit ThisFunction(Isolate* isolate) : Expression(isolate) {}
DECLARE_NODE_TYPE(ThisFunction)
virtual bool IsInlineable() const;
};
......
......@@ -648,6 +648,7 @@ FunctionLiteral* Parser::DoParseProgram(Handle<String> source,
}
if (ok) {
result = new(zone()) FunctionLiteral(
isolate(),
no_name,
top_scope_,
body,
......@@ -1262,7 +1263,7 @@ Statement* Parser::ParseStatement(ZoneStringList* labels, bool* ok) {
// one must take great care not to treat it as a
// fall-through. It is much easier just to wrap the entire
// try-statement in a statement block and put the labels there
Block* result = new(zone()) Block(labels, 1, false);
Block* result = new(zone()) Block(isolate(), labels, 1, false);
Target target(&this->target_stack_, result);
TryStatement* statement = ParseTryStatement(CHECK_OK);
if (statement) {
......@@ -1453,10 +1454,10 @@ Statement* Parser::ParseNativeDeclaration(bool* ok) {
// introduced dynamically when we meet their declarations, whereas
// other functions are setup when entering the surrounding scope.
SharedFunctionInfoLiteral* lit =
new(zone()) SharedFunctionInfoLiteral(shared);
new(zone()) SharedFunctionInfoLiteral(isolate(), shared);
VariableProxy* var = Declare(name, Variable::VAR, NULL, true, CHECK_OK);
return new(zone()) ExpressionStatement(new(zone()) Assignment(
Token::INIT_VAR, var, lit, RelocInfo::kNoPosition));
isolate(), Token::INIT_VAR, var, lit, RelocInfo::kNoPosition));
}
......@@ -1489,7 +1490,7 @@ Block* Parser::ParseBlock(ZoneStringList* labels, bool* ok) {
// (ECMA-262, 3rd, 12.2)
//
// Construct block expecting 16 statements.
Block* result = new(zone()) Block(labels, 16, false);
Block* result = new(zone()) Block(isolate(), labels, 16, false);
Target target(&this->target_stack_, result);
Expect(Token::LBRACE, CHECK_OK);
InitializationBlockFinder block_finder(top_scope_, target_stack_);
......@@ -1564,7 +1565,7 @@ Block* Parser::ParseVariableDeclarations(bool accept_IN,
// is inside an initializer block, it is ignored.
//
// Create new block with one expected declaration.
Block* block = new(zone()) Block(NULL, 1, true);
Block* block = new(zone()) Block(isolate(), NULL, 1, true);
int nvars = 0; // the number of variables declared
Handle<String> name;
do {
......@@ -1676,7 +1677,7 @@ Block* Parser::ParseVariableDeclarations(bool accept_IN,
// Compute the arguments for the runtime call.
ZoneList<Expression*>* arguments = new(zone()) ZoneList<Expression*>(3);
// We have at least 1 parameter.
arguments->Add(new(zone()) Literal(name));
arguments->Add(NewLiteral(name));
CallRuntime* initialize;
if (is_const) {
......@@ -1689,6 +1690,7 @@ Block* Parser::ParseVariableDeclarations(bool accept_IN,
// the number of arguments (1 or 2).
initialize =
new(zone()) CallRuntime(
isolate(),
isolate()->factory()->InitializeConstGlobal_symbol(),
Runtime::FunctionForId(Runtime::kInitializeConstGlobal),
arguments);
......@@ -1715,6 +1717,7 @@ Block* Parser::ParseVariableDeclarations(bool accept_IN,
// the number of arguments (2 or 3).
initialize =
new(zone()) CallRuntime(
isolate(),
isolate()->factory()->InitializeVarGlobal_symbol(),
Runtime::FunctionForId(Runtime::kInitializeVarGlobal),
arguments);
......@@ -1739,7 +1742,7 @@ Block* Parser::ParseVariableDeclarations(bool accept_IN,
VariableProxy* proxy =
initialization_scope->NewUnresolved(name, in_with);
Assignment* assignment =
new(zone()) Assignment(op, proxy, value, position);
new(zone()) Assignment(isolate(), op, proxy, value, position);
if (block) {
block->AddStatement(new(zone()) ExpressionStatement(assignment));
}
......@@ -1842,7 +1845,8 @@ IfStatement* Parser::ParseIfStatement(ZoneStringList* labels, bool* ok) {
} else {
else_statement = EmptyStatement();
}
return new(zone()) IfStatement(condition, then_statement, else_statement);
return new(zone()) IfStatement(
isolate(), condition, then_statement, else_statement);
}
......@@ -1961,17 +1965,17 @@ Block* Parser::WithHelper(Expression* obj, ZoneStringList* labels, bool* ok) {
// Create resulting block with two statements.
// 1: Evaluate the with expression.
// 2: The try-finally block evaluating the body.
Block* result = new(zone()) Block(NULL, 2, false);
Block* result = new(zone()) Block(isolate(), NULL, 2, false);
if (result != NULL) {
result->AddStatement(new(zone()) EnterWithContextStatement(obj));
// Create body block.
Block* body = new(zone()) Block(NULL, 1, false);
Block* body = new(zone()) Block(isolate(), NULL, 1, false);
body->AddStatement(stat);
// Create exit block.
Block* exit = new(zone()) Block(NULL, 1, false);
Block* exit = new(zone()) Block(isolate(), NULL, 1, false);
exit->AddStatement(new(zone()) ExitContextStatement());
// Return a try-finally statement.
......@@ -2032,7 +2036,7 @@ CaseClause* Parser::ParseCaseClause(bool* default_seen_ptr, bool* ok) {
statements->Add(stat);
}
return new(zone()) CaseClause(label, statements, pos);
return new(zone()) CaseClause(isolate(), label, statements, pos);
}
......@@ -2041,7 +2045,7 @@ SwitchStatement* Parser::ParseSwitchStatement(ZoneStringList* labels,
// SwitchStatement ::
// 'switch' '(' Expression ')' '{' CaseClause* '}'
SwitchStatement* statement = new(zone()) SwitchStatement(labels);
SwitchStatement* statement = new(zone()) SwitchStatement(isolate(), labels);
Target target(&this->target_stack_, statement);
Expect(Token::SWITCH, CHECK_OK);
......@@ -2077,7 +2081,8 @@ Statement* Parser::ParseThrowStatement(bool* ok) {
Expression* exception = ParseExpression(true, CHECK_OK);
ExpectSemicolon(CHECK_OK);
return new(zone()) ExpressionStatement(new(zone()) Throw(exception, pos));
return new(zone()) ExpressionStatement(
new(zone()) Throw(isolate(), exception, pos));
}
......@@ -2156,7 +2161,7 @@ TryStatement* Parser::ParseTryStatement(bool* ok) {
}
// Create exit block.
Block* inner_finally = new(zone()) Block(NULL, 1, false);
Block* inner_finally = new(zone()) Block(isolate(), NULL, 1, false);
inner_finally->AddStatement(new(zone()) ExitContextStatement());
// Create a try/finally statement.
......@@ -2164,7 +2169,7 @@ TryStatement* Parser::ParseTryStatement(bool* ok) {
new(zone()) TryFinallyStatement(inner_body, inner_finally);
inner_try_finally->set_escaping_targets(inner_collector.targets());
catch_block = new(zone()) Block(NULL, 1, false);
catch_block = new(zone()) Block(isolate(), NULL, 1, false);
catch_block->AddStatement(inner_try_finally);
} else {
Expect(Token::LBRACE, CHECK_OK);
......@@ -2193,7 +2198,7 @@ TryStatement* Parser::ParseTryStatement(bool* ok) {
catch_variable,
catch_block);
statement->set_escaping_targets(try_collector.targets());
try_block = new(zone()) Block(NULL, 1, false);
try_block = new(zone()) Block(isolate(), NULL, 1, false);
try_block->AddStatement(statement);
catch_block = NULL; // Clear to indicate it's been handled.
}
......@@ -2224,7 +2229,7 @@ DoWhileStatement* Parser::ParseDoWhileStatement(ZoneStringList* labels,
// DoStatement ::
// 'do' Statement 'while' '(' Expression ')' ';'
DoWhileStatement* loop = new(zone()) DoWhileStatement(labels);
DoWhileStatement* loop = new(zone()) DoWhileStatement(isolate(), labels);
Target target(&this->target_stack_, loop);
Expect(Token::DO, CHECK_OK);
......@@ -2255,7 +2260,7 @@ WhileStatement* Parser::ParseWhileStatement(ZoneStringList* labels, bool* ok) {
// WhileStatement ::
// 'while' '(' Expression ')' Statement
WhileStatement* loop = new(zone()) WhileStatement(labels);
WhileStatement* loop = new(zone()) WhileStatement(isolate(), labels);
Target target(&this->target_stack_, loop);
Expect(Token::WHILE, CHECK_OK);
......@@ -2285,7 +2290,7 @@ Statement* Parser::ParseForStatement(ZoneStringList* labels, bool* ok) {
if (peek() == Token::IN && !name.is_null()) {
VariableProxy* each = top_scope_->NewUnresolved(name, inside_with());
ForInStatement* loop = new(zone()) ForInStatement(labels);
ForInStatement* loop = new(zone()) ForInStatement(isolate(), labels);
Target target(&this->target_stack_, loop);
Expect(Token::IN, CHECK_OK);
......@@ -2294,7 +2299,7 @@ Statement* Parser::ParseForStatement(ZoneStringList* labels, bool* ok) {
Statement* body = ParseStatement(NULL, CHECK_OK);
loop->Initialize(each, enumerable, body);
Block* result = new(zone()) Block(NULL, 2, false);
Block* result = new(zone()) Block(isolate(), NULL, 2, false);
result->AddStatement(variable_statement);
result->AddStatement(loop);
// Parsed for-in loop w/ variable/const declaration.
......@@ -2315,7 +2320,7 @@ Statement* Parser::ParseForStatement(ZoneStringList* labels, bool* ok) {
isolate()->factory()->invalid_lhs_in_for_in_symbol();
expression = NewThrowReferenceError(type);
}
ForInStatement* loop = new(zone()) ForInStatement(labels);
ForInStatement* loop = new(zone()) ForInStatement(isolate(), labels);
Target target(&this->target_stack_, loop);
Expect(Token::IN, CHECK_OK);
......@@ -2334,7 +2339,7 @@ Statement* Parser::ParseForStatement(ZoneStringList* labels, bool* ok) {
}
// Standard 'for' loop
ForStatement* loop = new(zone()) ForStatement(labels);
ForStatement* loop = new(zone()) ForStatement(isolate(), labels);
Target target(&this->target_stack_, loop);
// Parsed initializer at this point.
......@@ -2370,7 +2375,8 @@ Expression* Parser::ParseExpression(bool accept_IN, bool* ok) {
Expect(Token::COMMA, CHECK_OK);
int position = scanner().location().beg_pos;
Expression* right = ParseAssignmentExpression(accept_IN, CHECK_OK);
result = new(zone()) BinaryOperation(Token::COMMA, result, right, position);
result = new(zone()) BinaryOperation(
isolate(), Token::COMMA, result, right, position);
}
return result;
}
......@@ -2442,7 +2448,7 @@ Expression* Parser::ParseAssignmentExpression(bool accept_IN, bool* ok) {
fni_->Leave();
}
return new(zone()) Assignment(op, expression, right, pos);
return new(zone()) Assignment(isolate(), op, expression, right, pos);
}
......@@ -2464,8 +2470,8 @@ Expression* Parser::ParseConditionalExpression(bool accept_IN, bool* ok) {
Expect(Token::COLON, CHECK_OK);
int right_position = scanner().peek_location().beg_pos;
Expression* right = ParseAssignmentExpression(accept_IN, CHECK_OK);
return new(zone()) Conditional(expression, left, right,
left_position, right_position);
return new(zone()) Conditional(
isolate(), expression, left, right, left_position, right_position);
}
......@@ -2552,12 +2558,12 @@ Expression* Parser::ParseBinaryExpression(int prec, bool accept_IN, bool* ok) {
x = NewCompareNode(cmp, x, y, position);
if (cmp != op) {
// The comparison was negated - add a NOT.
x = new(zone()) UnaryOperation(Token::NOT, x, position);
x = new(zone()) UnaryOperation(isolate(), Token::NOT, x, position);
}
} else {
// We have a "normal" binary operation.
x = new(zone()) BinaryOperation(op, x, y, position);
x = new(zone()) BinaryOperation(isolate(), op, x, y, position);
}
}
}
......@@ -2574,15 +2580,15 @@ Expression* Parser::NewCompareNode(Token::Value op,
bool is_strict = (op == Token::EQ_STRICT);
Literal* x_literal = x->AsLiteral();
if (x_literal != NULL && x_literal->IsNull()) {
return new(zone()) CompareToNull(is_strict, y);
return new(zone()) CompareToNull(isolate(), is_strict, y);
}
Literal* y_literal = y->AsLiteral();
if (y_literal != NULL && y_literal->IsNull()) {
return new(zone()) CompareToNull(is_strict, x);
return new(zone()) CompareToNull(isolate(), is_strict, x);
}
}
return new(zone()) CompareOperation(op, x, y, position);
return new(zone()) CompareOperation(isolate(), op, x, y, position);
}
......@@ -2611,7 +2617,7 @@ Expression* Parser::ParseUnaryExpression(bool* ok) {
// Convert the literal to a boolean condition and negate it.
bool condition = literal->ToBoolean()->IsTrue();
Handle<Object> result(isolate()->heap()->ToBoolean(!condition));
return new(zone()) Literal(result);
return NewLiteral(result);
} else if (literal->IsNumber()) {
// Compute some expressions involving only number literals.
double value = literal->Number();
......@@ -2638,7 +2644,7 @@ Expression* Parser::ParseUnaryExpression(bool* ok) {
}
}
return new(zone()) UnaryOperation(op, expression, position);
return new(zone()) UnaryOperation(isolate(), op, expression, position);
} else if (Token::IsCountOp(op)) {
op = Next();
......@@ -2659,7 +2665,8 @@ Expression* Parser::ParseUnaryExpression(bool* ok) {
}
int position = scanner().location().beg_pos;
return new(zone()) CountOperation(op,
return new(zone()) CountOperation(isolate(),
op,
true /* prefix */,
expression,
position);
......@@ -2695,7 +2702,8 @@ Expression* Parser::ParsePostfixExpression(bool* ok) {
Token::Value next = Next();
int position = scanner().location().beg_pos;
expression =
new(zone()) CountOperation(next,
new(zone()) CountOperation(isolate(),
next,
false /* postfix */,
expression,
position);
......@@ -2721,7 +2729,7 @@ Expression* Parser::ParseLeftHandSideExpression(bool* ok) {
Consume(Token::LBRACK);
int pos = scanner().location().beg_pos;
Expression* index = ParseExpression(true, CHECK_OK);
result = new(zone()) Property(result, index, pos);
result = new(zone()) Property(isolate(), result, index, pos);
Expect(Token::RBRACK, CHECK_OK);
break;
}
......@@ -2759,7 +2767,10 @@ Expression* Parser::ParseLeftHandSideExpression(bool* ok) {
Consume(Token::PERIOD);
int pos = scanner().location().beg_pos;
Handle<String> name = ParseIdentifierName(CHECK_OK);
result = new(zone()) Property(result, new(zone()) Literal(name), pos);
result = new(zone()) Property(isolate(),
result,
NewLiteral(name),
pos);
if (fni_ != NULL) fni_->PushLiteralName(name);
break;
}
......@@ -2795,7 +2806,8 @@ Expression* Parser::ParseNewPrefix(PositionStack* stack, bool* ok) {
if (!stack->is_empty()) {
int last = stack->pop();
result = new(zone()) CallNew(result,
result = new(zone()) CallNew(isolate(),
result,
new(zone()) ZoneList<Expression*>(0),
last);
}
......@@ -2843,7 +2855,7 @@ Expression* Parser::ParseMemberWithNewPrefixesExpression(PositionStack* stack,
Consume(Token::LBRACK);
int pos = scanner().location().beg_pos;
Expression* index = ParseExpression(true, CHECK_OK);
result = new(zone()) Property(result, index, pos);
result = new(zone()) Property(isolate(), result, index, pos);
if (fni_ != NULL) {
if (index->IsPropertyName()) {
fni_->PushLiteralName(index->AsLiteral()->AsPropertyName());
......@@ -2859,7 +2871,10 @@ Expression* Parser::ParseMemberWithNewPrefixesExpression(PositionStack* stack,
Consume(Token::PERIOD);
int pos = scanner().location().beg_pos;
Handle<String> name = ParseIdentifierName(CHECK_OK);
result = new(zone()) Property(result, new(zone()) Literal(name), pos);
result = new(zone()) Property(isolate(),
result,
NewLiteral(name),
pos);
if (fni_ != NULL) fni_->PushLiteralName(name);
break;
}
......@@ -2868,7 +2883,7 @@ Expression* Parser::ParseMemberWithNewPrefixesExpression(PositionStack* stack,
// Consume one of the new prefixes (already parsed).
ZoneList<Expression*>* args = ParseArguments(CHECK_OK);
int last = stack->pop();
result = new(zone()) CallNew(result, args, last);
result = new(zone()) CallNew(isolate(), result, args, last);
break;
}
default:
......@@ -2952,23 +2967,26 @@ Expression* Parser::ParsePrimaryExpression(bool* ok) {
switch (peek()) {
case Token::THIS: {
Consume(Token::THIS);
result = new(zone()) VariableProxy(top_scope_->receiver());
result = new(zone()) VariableProxy(isolate(), top_scope_->receiver());
break;
}
case Token::NULL_LITERAL:
Consume(Token::NULL_LITERAL);
result = new(zone()) Literal(isolate()->factory()->null_value());
result = new(zone()) Literal(
isolate(), isolate()->factory()->null_value());
break;
case Token::TRUE_LITERAL:
Consume(Token::TRUE_LITERAL);
result = new(zone()) Literal(isolate()->factory()->true_value());
result = new(zone()) Literal(
isolate(), isolate()->factory()->true_value());
break;
case Token::FALSE_LITERAL:
Consume(Token::FALSE_LITERAL);
result = new(zone()) Literal(isolate()->factory()->false_value());
result = new(zone()) Literal(
isolate(), isolate()->factory()->false_value());
break;
case Token::IDENTIFIER:
......@@ -2994,7 +3012,7 @@ Expression* Parser::ParsePrimaryExpression(bool* ok) {
case Token::STRING: {
Consume(Token::STRING);
Handle<String> symbol = GetSymbol(CHECK_OK);
result = new(zone()) Literal(symbol);
result = NewLiteral(symbol);
if (fni_ != NULL) fni_->PushLiteralName(symbol);
break;
}
......@@ -3121,8 +3139,8 @@ Expression* Parser::ParseArrayLiteral(bool* ok) {
literals->set_map(isolate()->heap()->fixed_cow_array_map());
}
return new(zone()) ArrayLiteral(literals, values,
literal_index, is_simple, depth);
return new(zone()) ArrayLiteral(
isolate(), literals, values, literal_index, is_simple, depth);
}
......@@ -3467,7 +3485,7 @@ Expression* Parser::ParseObjectLiteral(bool* ok) {
}
// Failed to parse as get/set property, so it's just a property
// called "get" or "set".
key = new(zone()) Literal(id);
key = NewLiteral(id);
break;
}
case Token::STRING: {
......@@ -3479,7 +3497,7 @@ Expression* Parser::ParseObjectLiteral(bool* ok) {
key = NewNumberLiteral(index);
break;
}
key = new(zone()) Literal(string);
key = NewLiteral(string);
break;
}
case Token::NUMBER: {
......@@ -3495,7 +3513,7 @@ Expression* Parser::ParseObjectLiteral(bool* ok) {
if (Token::IsKeyword(next)) {
Consume(next);
Handle<String> string = GetSymbol(CHECK_OK);
key = new(zone()) Literal(string);
key = NewLiteral(string);
} else {
// Unexpected token.
Token::Value next = Next();
......@@ -3548,7 +3566,8 @@ Expression* Parser::ParseObjectLiteral(bool* ok) {
&is_simple,
&fast_elements,
&depth);
return new(zone()) ObjectLiteral(constant_properties,
return new(zone()) ObjectLiteral(isolate(),
constant_properties,
properties,
literal_index,
is_simple,
......@@ -3573,7 +3592,8 @@ Expression* Parser::ParseRegExpLiteral(bool seen_equal, bool* ok) {
Handle<String> js_flags = NextLiteralString(TENURED);
Next();
return new(zone()) RegExpLiteral(js_pattern, js_flags, literal_index);
return new(zone()) RegExpLiteral(
isolate(), js_pattern, js_flags, literal_index);
}
......@@ -3690,8 +3710,10 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> var_name,
top_scope_->NewUnresolved(function_name, inside_with());
fproxy->BindTo(fvar);
body->Add(new(zone()) ExpressionStatement(
new(zone()) Assignment(Token::INIT_CONST, fproxy,
new(zone()) ThisFunction(),
new(zone()) Assignment(isolate(),
Token::INIT_CONST,
fproxy,
new(zone()) ThisFunction(isolate()),
RelocInfo::kNoPosition)));
}
......@@ -3782,7 +3804,8 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> var_name,
}
FunctionLiteral* function_literal =
new(zone()) FunctionLiteral(name,
new(zone()) FunctionLiteral(isolate(),
name,
scope,
body,
materialized_literal_count,
......@@ -3843,7 +3866,7 @@ Expression* Parser::ParseV8Intrinsic(bool* ok) {
}
// We have a valid intrinsics call or a call to a builtin.
return new(zone()) CallRuntime(name, function, args);
return new(zone()) CallRuntime(isolate(), name, function, args);
}
......@@ -3899,12 +3922,12 @@ void Parser::ExpectSemicolon(bool* ok) {
Literal* Parser::GetLiteralUndefined() {
return new(zone()) Literal(isolate()->factory()->undefined_value());
return NewLiteral(isolate()->factory()->undefined_value());
}
Literal* Parser::GetLiteralTheHole() {
return new(zone()) Literal(isolate()->factory()->the_hole_value());
return NewLiteral(isolate()->factory()->the_hole_value());
}
......@@ -4060,7 +4083,7 @@ void Parser::RegisterTargetUse(Label* target, Target* stop) {
Literal* Parser::NewNumberLiteral(double number) {
return new(zone()) Literal(isolate()->factory()->NewNumber(number, TENURED));
return NewLiteral(isolate()->factory()->NewNumber(number, TENURED));
}
......@@ -4107,9 +4130,14 @@ Expression* Parser::NewThrowError(Handle<String> constructor,
TENURED);
ZoneList<Expression*>* args = new(zone()) ZoneList<Expression*>(2);
args->Add(new(zone()) Literal(type));
args->Add(new(zone()) Literal(array));
return new(zone()) Throw(new(zone()) CallRuntime(constructor, NULL, args),
args->Add(NewLiteral(type));
args->Add(NewLiteral(array));
CallRuntime* call_constructor = new(zone()) CallRuntime(isolate(),
constructor,
NULL,
args);
return new(zone()) Throw(isolate(),
call_constructor,
scanner().location().beg_pos);
}
......
......@@ -668,9 +668,12 @@ class Parser {
Expression* NewCall(Expression* expression,
ZoneList<Expression*>* arguments,
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.
Literal* NewNumberLiteral(double value);
......
......@@ -67,8 +67,11 @@ class Processor: public AstVisitor {
Expression* SetResult(Expression* value) {
result_assigned_ = true;
Zone* zone = isolate()->zone();
VariableProxy* result_proxy = new(zone) VariableProxy(result_);
return new(zone) Assignment(Token::ASSIGN, result_proxy, value,
VariableProxy* result_proxy = new(zone) VariableProxy(isolate(), result_);
return new(zone) Assignment(isolate(),
Token::ASSIGN,
result_proxy,
value,
RelocInfo::kNoPosition);
}
......@@ -230,8 +233,9 @@ bool Rewriter::Rewrite(CompilationInfo* info) {
if (processor.HasStackOverflow()) return false;
if (processor.result_assigned()) {
Zone* zone = info->isolate()->zone();
VariableProxy* result_proxy = new(zone) VariableProxy(result);
Isolate* isolate = info->isolate();
Zone* zone = isolate->zone();
VariableProxy* result_proxy = new(zone) VariableProxy(isolate, result);
body->Add(new(zone) ReturnStatement(result_proxy));
}
}
......
......@@ -304,7 +304,7 @@ void Scope::Initialize(bool inside_with) {
Variable::VAR,
false,
Variable::THIS);
var->set_rewrite(new(isolate_->zone()) Slot(var, Slot::PARAMETER, -1));
var->set_rewrite(NewSlot(var, Slot::PARAMETER, -1));
receiver_ = var;
}
......@@ -350,7 +350,7 @@ Variable* Scope::LocalLookup(Handle<String> name) {
Variable* var =
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;
}
......@@ -407,8 +407,8 @@ VariableProxy* Scope::NewUnresolved(Handle<String> name,
// the same name because they may be removed selectively via
// RemoveUnresolved().
ASSERT(!already_resolved());
VariableProxy* proxy =
new(isolate_->zone()) VariableProxy(name, false, inside_with, position);
VariableProxy* proxy = new(isolate_->zone()) VariableProxy(
isolate_, name, false, inside_with, position);
unresolved_.Add(proxy);
return proxy;
}
......@@ -708,7 +708,7 @@ Variable* Scope::NonLocal(Handle<String> name, Variable::Mode mode) {
// Declare a new non-local.
var = map->Declare(NULL, name, mode, true, Variable::NORMAL);
// 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;
}
......@@ -964,14 +964,12 @@ bool Scope::HasArgumentsParameter() {
void Scope::AllocateStackSlot(Variable* var) {
var->set_rewrite(
new(isolate_->zone()) Slot(var, Slot::LOCAL, num_stack_slots_++));
var->set_rewrite(NewSlot(var, Slot::LOCAL, num_stack_slots_++));
}
void Scope::AllocateHeapSlot(Variable* var) {
var->set_rewrite(
new(isolate_->zone()) Slot(var, Slot::CONTEXT, num_heap_slots_++));
var->set_rewrite(NewSlot(var, Slot::CONTEXT, num_heap_slots_++));
}
......@@ -1024,7 +1022,7 @@ void Scope::AllocateParameterLocals() {
} else {
ASSERT(var->rewrite() == NULL || var->IsParameter());
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 {
// Construct a catch scope with a binding for the 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) {
if (inner_scope != NULL) {
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