frame_->AssertIsSpilled();
for (int i = 0; i < scope()->num_parameters(); i++) {
Variable* par = scope()->parameter(i);
- Slot* slot = par->slot();
+ Slot* slot = par->AsSlot();
if (slot != NULL && slot->type() == Slot::CONTEXT) {
ASSERT(!scope()->is_global_scope()); // No params in global scope.
__ ldr(r1, frame_->ParameterAt(i));
// Initialize ThisFunction reference if present.
if (scope()->is_function_scope() && scope()->function() != NULL) {
frame_->EmitPushRoot(Heap::kTheHoleValueRootIndex);
- StoreToSlot(scope()->function()->slot(), NOT_CONST_INIT);
+ StoreToSlot(scope()->function()->AsSlot(), NOT_CONST_INIT);
}
// Initialize the function return target after the locals are set
frame_->EmitPush(r0);
}
- Variable* arguments = scope()->arguments()->var();
- Variable* shadow = scope()->arguments_shadow()->var();
- ASSERT(arguments != NULL && arguments->slot() != NULL);
- ASSERT(shadow != NULL && shadow->slot() != NULL);
+ Variable* arguments = scope()->arguments();
+ Variable* shadow = scope()->arguments_shadow();
+ ASSERT(arguments != NULL && arguments->AsSlot() != NULL);
+ ASSERT(shadow != NULL && shadow->AsSlot() != NULL);
JumpTarget done;
if (mode == LAZY_ARGUMENTS_ALLOCATION && !initial) {
// We have to skip storing into the arguments slot if it has
// already been written to. This can happen if the a function
// has a local variable named 'arguments'.
- LoadFromSlot(scope()->arguments()->var()->slot(), NOT_INSIDE_TYPEOF);
+ LoadFromSlot(scope()->arguments()->AsSlot(), NOT_INSIDE_TYPEOF);
Register arguments = frame_->PopToRegister();
__ LoadRoot(ip, Heap::kTheHoleValueRootIndex);
__ cmp(arguments, ip);
done.Branch(ne);
}
- StoreToSlot(arguments->slot(), NOT_CONST_INIT);
+ StoreToSlot(arguments->AsSlot(), NOT_CONST_INIT);
if (mode == LAZY_ARGUMENTS_ALLOCATION) done.Bind();
- StoreToSlot(shadow->slot(), NOT_CONST_INIT);
+ StoreToSlot(shadow->AsSlot(), NOT_CONST_INIT);
}
Property property(&global, &key, RelocInfo::kNoPosition);
Reference ref(this, &property);
ref.GetValue();
- } else if (variable != NULL && variable->slot() != NULL) {
+ } else if (variable != NULL && variable->AsSlot() != NULL) {
// For a variable that rewrites to a slot, we signal it is the immediate
// subexpression of a typeof.
- LoadFromSlotCheckForArguments(variable->slot(), INSIDE_TYPEOF);
+ LoadFromSlotCheckForArguments(variable->AsSlot(), INSIDE_TYPEOF);
} else {
// Anything else can be handled normally.
Load(expr);
LoadGlobal();
ref->set_type(Reference::NAMED);
} else {
- ASSERT(var->slot() != NULL);
+ ASSERT(var->AsSlot() != NULL);
ref->set_type(Reference::SLOT);
}
} else {
// Load the receiver and the existing arguments object onto the
// expression stack. Avoid allocating the arguments object here.
Load(receiver);
- LoadFromSlot(scope()->arguments()->var()->slot(), NOT_INSIDE_TYPEOF);
+ LoadFromSlot(scope()->arguments()->AsSlot(), NOT_INSIDE_TYPEOF);
// At this point the top two stack elements are probably in registers
// since they were just loaded. Ensure they are in regs and get the
Comment cmnt(masm_, "[ Declaration");
Variable* var = node->proxy()->var();
ASSERT(var != NULL); // must have been resolved
- Slot* slot = var->slot();
+ Slot* slot = var->AsSlot();
// If it was not possible to allocate the variable at compile time,
// we need to "declare" it at runtime to make sure it actually
// the bottom check of the loop condition.
TypeInfoCodeGenState type_info_scope(this,
node->is_fast_smi_loop() ?
- node->loop_variable()->slot() :
- NULL,
+ node->loop_variable()->AsSlot() :
+ NULL,
TypeInfo::Smi());
// If there is no update statement, label the top of the loop with the
// Store the caught exception in the catch variable.
Variable* catch_var = node->catch_var()->var();
- ASSERT(catch_var != NULL && catch_var->slot() != NULL);
- StoreToSlot(catch_var->slot(), NOT_CONST_INIT);
+ ASSERT(catch_var != NULL && catch_var->AsSlot() != NULL);
+ StoreToSlot(catch_var->AsSlot(), NOT_CONST_INIT);
// Remove the exception from the stack.
frame_->Drop();
} else if (slot->var()->mode() == Variable::DYNAMIC_LOCAL) {
frame_->SpillAll();
- Slot* potential_slot = slot->var()->local_if_not_shadowed()->slot();
+ Slot* potential_slot = slot->var()->local_if_not_shadowed()->AsSlot();
Expression* rewrite = slot->var()->local_if_not_shadowed()->rewrite();
if (potential_slot != NULL) {
// Generate fast case for locals that rewrite to slots.
// variables. Then load the argument from the arguments
// object using keyed load.
__ ldr(r0,
- ContextSlotOperandCheckExtensions(obj_proxy->var()->slot(),
+ ContextSlotOperandCheckExtensions(obj_proxy->var()->AsSlot(),
r1,
r2,
slow));
Comment cmnt(masm(), "[ Variable Assignment");
Variable* var = node->target()->AsVariableProxy()->AsVariable();
ASSERT(var != NULL);
- Slot* slot = var->slot();
+ Slot* slot = var->AsSlot();
ASSERT(slot != NULL);
// Evaluate the right-hand side.
// in generated code. If we succeed, there is no need to perform a
// context lookup in the runtime system.
JumpTarget done;
- if (var->slot() != NULL && var->mode() == Variable::DYNAMIC_GLOBAL) {
- ASSERT(var->slot()->type() == Slot::LOOKUP);
+ if (var->AsSlot() != NULL && var->mode() == Variable::DYNAMIC_GLOBAL) {
+ ASSERT(var->AsSlot()->type() == Slot::LOOKUP);
JumpTarget slow;
// Prepare the stack for the call to
// ResolvePossiblyDirectEvalNoLookup by pushing the loaded
// function, the first argument to the eval call and the
// receiver.
- LoadFromGlobalSlotCheckExtensions(var->slot(),
+ LoadFromGlobalSlotCheckExtensions(var->AsSlot(),
NOT_INSIDE_TYPEOF,
&slow);
frame_->EmitPush(r0);
__ ldr(cp, frame_->Context());
frame_->EmitPush(r0);
- } else if (var != NULL && var->slot() != NULL &&
- var->slot()->type() == Slot::LOOKUP) {
+ } else if (var != NULL && var->AsSlot() != NULL &&
+ var->AsSlot()->type() == Slot::LOOKUP) {
// ----------------------------------
// JavaScript examples:
//
// Generate fast case for loading functions from slots that
// correspond to local/global variables or arguments unless they
// are shadowed by eval-introduced bindings.
- EmitDynamicLoadFromSlotFastCase(var->slot(),
+ EmitDynamicLoadFromSlotFastCase(var->AsSlot(),
NOT_INSIDE_TYPEOF,
&slow,
&done);
frame_->EmitPush(r0);
} else if (variable != NULL) {
- Slot* slot = variable->slot();
+ Slot* slot = variable->AsSlot();
if (variable->is_global()) {
LoadGlobal();
frame_->EmitPush(Operand(variable->name()));
bool is_const = (var != NULL && var->mode() == Variable::CONST);
bool is_slot = (var != NULL && var->mode() == Variable::VAR);
- if (!is_const && is_slot && type_info(var->slot()).IsSmi()) {
+ if (!is_const && is_slot && type_info(var->AsSlot()).IsSmi()) {
// The type info declares that this variable is always a Smi. That
// means it is a Smi both before and after the increment/decrement.
// Lets make use of that to make a very minimal count.
switch (type_) {
case SLOT: {
Comment cmnt(masm, "[ Load from Slot");
- Slot* slot = expression_->AsVariableProxy()->AsVariable()->slot();
+ Slot* slot = expression_->AsVariableProxy()->AsVariable()->AsSlot();
ASSERT(slot != NULL);
DupIfPersist();
cgen_->LoadFromSlotCheckForArguments(slot, NOT_INSIDE_TYPEOF);
switch (type_) {
case SLOT: {
Comment cmnt(masm, "[ Store to Slot");
- Slot* slot = expression_->AsVariableProxy()->AsVariable()->slot();
+ Slot* slot = expression_->AsVariableProxy()->AsVariable()->AsSlot();
cgen_->StoreToSlot(slot, init_state);
set_unloaded();
break;
// Copy any necessary parameters into the context.
int num_parameters = scope()->num_parameters();
for (int i = 0; i < num_parameters; i++) {
- Slot* slot = scope()->parameter(i)->slot();
+ Slot* slot = scope()->parameter(i)->AsSlot();
if (slot != NULL && slot->type() == Slot::CONTEXT) {
int parameter_offset = StandardFrameConstants::kCallerSPOffset +
(num_parameters - 1 - i) * kPointerSize;
}
}
- Variable* arguments = scope()->arguments()->AsVariable();
+ Variable* arguments = scope()->arguments();
if (arguments != NULL) {
// Function uses arguments object.
Comment cmnt(masm_, "[ Allocate arguments object");
__ CallStub(&stub);
// Duplicate the value; move-to-slot operation might clobber registers.
__ mov(r3, r0);
- Move(arguments->slot(), r0, r1, r2);
- Slot* dot_arguments_slot =
- scope()->arguments_shadow()->AsVariable()->slot();
+ Move(arguments->AsSlot(), r0, r1, r2);
+ Slot* dot_arguments_slot = scope()->arguments_shadow()->AsSlot();
Move(dot_arguments_slot, r3, r1, r2);
}
FunctionLiteral* function) {
Comment cmnt(masm_, "[ Declaration");
ASSERT(variable != NULL); // Must have been resolved.
- Slot* slot = variable->slot();
+ Slot* slot = variable->AsSlot();
Property* prop = variable->AsProperty();
if (slot != NULL) {
EmitLoadGlobalSlotCheckExtensions(slot, typeof_state, slow);
__ jmp(done);
} else if (slot->var()->mode() == Variable::DYNAMIC_LOCAL) {
- Slot* potential_slot = slot->var()->local_if_not_shadowed()->slot();
+ Slot* potential_slot = slot->var()->local_if_not_shadowed()->AsSlot();
Expression* rewrite = slot->var()->local_if_not_shadowed()->rewrite();
if (potential_slot != NULL) {
// Generate fast case for locals that rewrite to slots.
// variables. Then load the argument from the arguments
// object using keyed load.
__ ldr(r1,
- ContextSlotOperandCheckExtensions(obj_proxy->var()->slot(),
+ ContextSlotOperandCheckExtensions(obj_proxy->var()->AsSlot(),
slow));
__ mov(r0, Operand(key_literal->handle()));
Handle<Code> ic(Builtins::builtin(Builtins::KeyedLoadIC_Initialize));
// Four cases: non-this global variables, lookup slots, all other
// types of slots, and parameters that rewrite to explicit property
// accesses on the arguments object.
- Slot* slot = var->slot();
+ Slot* slot = var->AsSlot();
Property* property = var->AsProperty();
if (var->is_global() && !var->is_this()) {
// Assert that the object is in a slot.
Variable* object_var = property->obj()->AsVariableProxy()->AsVariable();
ASSERT_NOT_NULL(object_var);
- Slot* object_slot = object_var->slot();
+ Slot* object_slot = object_var->AsSlot();
ASSERT_NOT_NULL(object_slot);
// Load the object.
// Left-hand sides that rewrite to explicit property accesses do not reach
// here.
ASSERT(var != NULL);
- ASSERT(var->is_global() || var->slot() != NULL);
+ ASSERT(var->is_global() || var->AsSlot() != NULL);
if (var->is_global()) {
ASSERT(!var->is_this());
// Perform the assignment for non-const variables and for initialization
// of const variables. Const assignments are simply skipped.
Label done;
- Slot* slot = var->slot();
+ Slot* slot = var->AsSlot();
switch (slot->type()) {
case Slot::PARAMETER:
case Slot::LOCAL:
__ ldr(r0, CodeGenerator::GlobalObject());
__ push(r0);
EmitCallWithIC(expr, var->name(), RelocInfo::CODE_TARGET_CONTEXT);
- } else if (var != NULL && var->slot() != NULL &&
- var->slot()->type() == Slot::LOOKUP) {
+ } else if (var != NULL && var->AsSlot() != NULL &&
+ var->AsSlot()->type() == Slot::LOOKUP) {
// Call to a lookup slot (dynamically introduced variable).
Label slow, done;
// Generate code for loading from variables potentially shadowed
// by eval-introduced variables.
- EmitDynamicLoadFromSlotFastCase(var->slot(),
+ EmitDynamicLoadFromSlotFastCase(var->AsSlot(),
NOT_INSIDE_TYPEOF,
&slow,
&done);
context()->Plug(true);
} else if (var != NULL &&
!var->is_global() &&
- var->slot() != NULL &&
- var->slot()->type() != Slot::LOOKUP) {
+ var->AsSlot() != NULL &&
+ var->AsSlot()->type() != Slot::LOOKUP) {
// Result of deleting non-global, non-dynamic variables is false.
// The subexpression does not have side effects.
context()->Plug(false);
EmitCallIC(ic, RelocInfo::CODE_TARGET);
context()->Plug(r0);
} else if (proxy != NULL &&
- proxy->var()->slot() != NULL &&
- proxy->var()->slot()->type() == Slot::LOOKUP) {
+ proxy->var()->AsSlot() != NULL &&
+ proxy->var()->AsSlot()->type() == Slot::LOOKUP) {
Label done, slow;
// Generate code for loading from variables potentially shadowed
// by eval-introduced variables.
- Slot* slot = proxy->var()->slot();
+ Slot* slot = proxy->var()->AsSlot();
EmitDynamicLoadFromSlotFastCase(slot, INSIDE_TYPEOF, &slow, &done);
__ bind(&slow);
}
+VariableProxy::VariableProxy(Variable* var)
+ : name_(var->name()),
+ var_(NULL), // Will be set by the call to BindTo.
+ is_this_(var->is_this()),
+ inside_with_(false),
+ is_trivial_(false) {
+ BindTo(var);
+}
+
+
VariableProxy::VariableProxy(Handle<String> name,
bool is_this,
bool inside_with)
class VariableProxy: public Expression {
public:
+ explicit VariableProxy(Variable* var);
+
virtual void Accept(AstVisitor* v);
// Type testing & conversion
}
Variable* AsVariable() {
- return this == NULL || var_ == NULL ? NULL : var_->AsVariable();
+ if (this == NULL || var_ == NULL) return NULL;
+ Expression* rewrite = var_->rewrite();
+ if (rewrite == NULL || rewrite->AsSlot() != NULL) return var_;
+ return NULL;
}
virtual bool IsValidLeftHandSide() {
for (int i = 0; i < length; i++) {
Declaration* node = declarations->at(i);
Variable* var = node->proxy()->var();
- Slot* slot = var->slot();
+ Slot* slot = var->AsSlot();
// If it was not possible to allocate the variable at compile
// time, we need to "declare" it at runtime to make sure it
for (int j = 0, i = 0; i < length; i++) {
Declaration* node = declarations->at(i);
Variable* var = node->proxy()->var();
- Slot* slot = var->slot();
+ Slot* slot = var->AsSlot();
if ((slot != NULL && slot->type() == Slot::LOOKUP) || !var->is_global()) {
// Skip - already processed.
int AssignedVariablesAnalyzer::BitIndex(Variable* var) {
ASSERT(var != NULL);
ASSERT(var->IsStackAllocated());
- Slot* slot = var->slot();
+ Slot* slot = var->AsSlot();
if (slot->type() == Slot::PARAMETER) {
return slot->index();
} else {
for (int i = 0; i < length; i++) {
Declaration* decl = declarations->at(i);
Variable* var = decl->proxy()->var();
- Slot* slot = var->slot();
+ Slot* slot = var->AsSlot();
// If it was not possible to allocate the variable at compile
// time, we need to "declare" it at runtime to make sure it
for (int j = 0, i = 0; i < length; i++) {
Declaration* decl = declarations->at(i);
Variable* var = decl->proxy()->var();
- Slot* slot = var->slot();
+ Slot* slot = var->AsSlot();
if ((slot == NULL || slot->type() != Slot::LOOKUP) && var->is_global()) {
array->set(j++, *(var->name()));
// The catch variable is *always* a variable proxy for a local variable.
Variable* catch_var = stmt->catch_var()->AsVariableProxy()->AsVariable();
ASSERT_NOT_NULL(catch_var);
- Slot* variable_slot = catch_var->slot();
+ Slot* variable_slot = catch_var->AsSlot();
ASSERT_NOT_NULL(variable_slot);
ASSERT_EQ(Slot::LOCAL, variable_slot->type());
StoreToFrameField(SlotOffset(variable_slot), result_register());
// the function.
for (int i = 0; i < scope()->num_parameters(); i++) {
Variable* par = scope()->parameter(i);
- Slot* slot = par->slot();
+ Slot* slot = par->AsSlot();
if (slot != NULL && slot->type() == Slot::CONTEXT) {
// The use of SlotOperand below is safe in unspilled code
// because the slot is guaranteed to be a context slot.
// Initialize ThisFunction reference if present.
if (scope()->is_function_scope() && scope()->function() != NULL) {
frame_->Push(Factory::the_hole_value());
- StoreToSlot(scope()->function()->slot(), NOT_CONST_INIT);
+ StoreToSlot(scope()->function()->AsSlot(), NOT_CONST_INIT);
}
Property property(&global, &key, RelocInfo::kNoPosition);
Reference ref(this, &property);
ref.GetValue();
- } else if (variable != NULL && variable->slot() != NULL) {
+ } else if (variable != NULL && variable->AsSlot() != NULL) {
// For a variable that rewrites to a slot, we signal it is the immediate
// subexpression of a typeof.
- LoadFromSlotCheckForArguments(variable->slot(), INSIDE_TYPEOF);
+ LoadFromSlotCheckForArguments(variable->AsSlot(), INSIDE_TYPEOF);
} else {
// Anything else can be handled normally.
Load(expr);
frame_->Push(&result);
}
- Variable* arguments = scope()->arguments()->var();
- Variable* shadow = scope()->arguments_shadow()->var();
- ASSERT(arguments != NULL && arguments->slot() != NULL);
- ASSERT(shadow != NULL && shadow->slot() != NULL);
+ Variable* arguments = scope()->arguments();
+ Variable* shadow = scope()->arguments_shadow();
+ ASSERT(arguments != NULL && arguments->AsSlot() != NULL);
+ ASSERT(shadow != NULL && shadow->AsSlot() != NULL);
JumpTarget done;
bool skip_arguments = false;
if (mode == LAZY_ARGUMENTS_ALLOCATION && !initial) {
// We have to skip storing into the arguments slot if it has
// already been written to. This can happen if the a function
// has a local variable named 'arguments'.
- LoadFromSlot(arguments->slot(), NOT_INSIDE_TYPEOF);
+ LoadFromSlot(arguments->AsSlot(), NOT_INSIDE_TYPEOF);
Result probe = frame_->Pop();
if (probe.is_constant()) {
// We have to skip updating the arguments object if it has
}
}
if (!skip_arguments) {
- StoreToSlot(arguments->slot(), NOT_CONST_INIT);
+ StoreToSlot(arguments->AsSlot(), NOT_CONST_INIT);
if (mode == LAZY_ARGUMENTS_ALLOCATION) done.Bind();
}
- StoreToSlot(shadow->slot(), NOT_CONST_INIT);
+ StoreToSlot(shadow->AsSlot(), NOT_CONST_INIT);
return frame_->Pop();
}
LoadGlobal();
ref->set_type(Reference::NAMED);
} else {
- ASSERT(var->slot() != NULL);
+ ASSERT(var->AsSlot() != NULL);
ref->set_type(Reference::SLOT);
}
} else {
// Load the receiver and the existing arguments object onto the
// expression stack. Avoid allocating the arguments object here.
Load(receiver);
- LoadFromSlot(scope()->arguments()->var()->slot(), NOT_INSIDE_TYPEOF);
+ LoadFromSlot(scope()->arguments()->AsSlot(), NOT_INSIDE_TYPEOF);
// Emit the source position information after having loaded the
// receiver and the arguments.
Comment cmnt(masm_, "[ Declaration");
Variable* var = node->proxy()->var();
ASSERT(var != NULL); // must have been resolved
- Slot* slot = var->slot();
+ Slot* slot = var->AsSlot();
// If it was not possible to allocate the variable at compile time,
// we need to "declare" it at runtime to make sure it actually
// the bottom check of the loop condition.
if (node->is_fast_smi_loop()) {
// Set number type of the loop variable to smi.
- SetTypeForStackSlot(node->loop_variable()->slot(), TypeInfo::Smi());
+ SetTypeForStackSlot(node->loop_variable()->AsSlot(), TypeInfo::Smi());
}
Visit(node->body());
// expression if we are in a fast smi loop condition.
if (node->is_fast_smi_loop() && has_valid_frame()) {
// Set number type of the loop variable to smi.
- SetTypeForStackSlot(node->loop_variable()->slot(), TypeInfo::Smi());
+ SetTypeForStackSlot(node->loop_variable()->AsSlot(), TypeInfo::Smi());
}
// Based on the condition analysis, compile the backward jump as
// Store the caught exception in the catch variable.
Variable* catch_var = node->catch_var()->var();
- ASSERT(catch_var != NULL && catch_var->slot() != NULL);
- StoreToSlot(catch_var->slot(), NOT_CONST_INIT);
+ ASSERT(catch_var != NULL && catch_var->AsSlot() != NULL);
+ StoreToSlot(catch_var->AsSlot(), NOT_CONST_INIT);
// Remove the exception from the stack.
frame_->Drop();
done->Jump(result);
} else if (slot->var()->mode() == Variable::DYNAMIC_LOCAL) {
- Slot* potential_slot = slot->var()->local_if_not_shadowed()->slot();
+ Slot* potential_slot = slot->var()->local_if_not_shadowed()->AsSlot();
Expression* rewrite = slot->var()->local_if_not_shadowed()->rewrite();
if (potential_slot != NULL) {
// Generate fast case for locals that rewrite to slots.
Result arguments = allocator()->Allocate();
ASSERT(arguments.is_valid());
__ mov(arguments.reg(),
- ContextSlotOperandCheckExtensions(obj_proxy->var()->slot(),
+ ContextSlotOperandCheckExtensions(obj_proxy->var()->AsSlot(),
arguments,
slow));
frame_->Push(&arguments);
Comment cmnt(masm(), "[ Variable Assignment");
Variable* var = node->target()->AsVariableProxy()->AsVariable();
ASSERT(var != NULL);
- Slot* slot = var->slot();
+ Slot* slot = var->AsSlot();
ASSERT(slot != NULL);
// Evaluate the right-hand side.
// in generated code. If we succeed, there is no need to perform a
// context lookup in the runtime system.
JumpTarget done;
- if (var->slot() != NULL && var->mode() == Variable::DYNAMIC_GLOBAL) {
- ASSERT(var->slot()->type() == Slot::LOOKUP);
+ if (var->AsSlot() != NULL && var->mode() == Variable::DYNAMIC_GLOBAL) {
+ ASSERT(var->AsSlot()->type() == Slot::LOOKUP);
JumpTarget slow;
// Prepare the stack for the call to
// ResolvePossiblyDirectEvalNoLookup by pushing the loaded
// function, the first argument to the eval call and the
// receiver.
- Result fun = LoadFromGlobalSlotCheckExtensions(var->slot(),
+ Result fun = LoadFromGlobalSlotCheckExtensions(var->AsSlot(),
NOT_INSIDE_TYPEOF,
&slow);
frame_->Push(&fun);
frame_->RestoreContextRegister();
frame_->Push(&result);
- } else if (var != NULL && var->slot() != NULL &&
- var->slot()->type() == Slot::LOOKUP) {
+ } else if (var != NULL && var->AsSlot() != NULL &&
+ var->AsSlot()->type() == Slot::LOOKUP) {
// ----------------------------------
// JavaScript examples:
//
// Generate fast case for loading functions from slots that
// correspond to local/global variables or arguments unless they
// are shadowed by eval-introduced bindings.
- EmitDynamicLoadFromSlotFastCase(var->slot(),
+ EmitDynamicLoadFromSlotFastCase(var->AsSlot(),
NOT_INSIDE_TYPEOF,
&function,
&slow,
Variable* variable = node->expression()->AsVariableProxy()->AsVariable();
if (variable != NULL) {
- Slot* slot = variable->slot();
+ Slot* slot = variable->AsSlot();
if (variable->is_global()) {
LoadGlobal();
frame_->Push(variable->name());
switch (type_) {
case SLOT: {
Comment cmnt(masm, "[ Load from Slot");
- Slot* slot = expression_->AsVariableProxy()->AsVariable()->slot();
+ Slot* slot = expression_->AsVariableProxy()->AsVariable()->AsSlot();
ASSERT(slot != NULL);
cgen_->LoadFromSlotCheckForArguments(slot, NOT_INSIDE_TYPEOF);
if (!persist_after_get_) set_unloaded();
return;
}
- Slot* slot = expression_->AsVariableProxy()->AsVariable()->slot();
+ Slot* slot = expression_->AsVariableProxy()->AsVariable()->AsSlot();
ASSERT(slot != NULL);
if (slot->type() == Slot::LOOKUP ||
slot->type() == Slot::CONTEXT ||
switch (type_) {
case SLOT: {
Comment cmnt(masm, "[ Store to Slot");
- Slot* slot = expression_->AsVariableProxy()->AsVariable()->slot();
+ Slot* slot = expression_->AsVariableProxy()->AsVariable()->AsSlot();
ASSERT(slot != NULL);
cgen_->StoreToSlot(slot, init_state);
set_unloaded();
// Copy parameters into context if necessary.
int num_parameters = scope()->num_parameters();
for (int i = 0; i < num_parameters; i++) {
- Slot* slot = scope()->parameter(i)->slot();
+ Slot* slot = scope()->parameter(i)->AsSlot();
if (slot != NULL && slot->type() == Slot::CONTEXT) {
int parameter_offset = StandardFrameConstants::kCallerSPOffset +
(num_parameters - 1 - i) * kPointerSize;
}
}
- Variable* arguments = scope()->arguments()->AsVariable();
+ Variable* arguments = scope()->arguments();
if (arguments != NULL) {
// Function uses arguments object.
Comment cmnt(masm_, "[ Allocate arguments object");
ArgumentsAccessStub stub(ArgumentsAccessStub::NEW_OBJECT);
__ CallStub(&stub);
__ mov(ecx, eax); // Duplicate result.
- Move(arguments->slot(), eax, ebx, edx);
- Slot* dot_arguments_slot =
- scope()->arguments_shadow()->AsVariable()->slot();
+ Move(arguments->AsSlot(), eax, ebx, edx);
+ Slot* dot_arguments_slot = scope()->arguments_shadow()->AsSlot();
Move(dot_arguments_slot, ecx, ebx, edx);
}
FunctionLiteral* function) {
Comment cmnt(masm_, "[ Declaration");
ASSERT(variable != NULL); // Must have been resolved.
- Slot* slot = variable->slot();
+ Slot* slot = variable->AsSlot();
Property* prop = variable->AsProperty();
if (slot != NULL) {
switch (slot->type()) {
EmitLoadGlobalSlotCheckExtensions(slot, typeof_state, slow);
__ jmp(done);
} else if (slot->var()->mode() == Variable::DYNAMIC_LOCAL) {
- Slot* potential_slot = slot->var()->local_if_not_shadowed()->slot();
+ Slot* potential_slot = slot->var()->local_if_not_shadowed()->AsSlot();
Expression* rewrite = slot->var()->local_if_not_shadowed()->rewrite();
if (potential_slot != NULL) {
// Generate fast case for locals that rewrite to slots.
// variables. Then load the argument from the arguments
// object using keyed load.
__ mov(edx,
- ContextSlotOperandCheckExtensions(obj_proxy->var()->slot(),
+ ContextSlotOperandCheckExtensions(obj_proxy->var()->AsSlot(),
slow));
__ mov(eax, Immediate(key_literal->handle()));
Handle<Code> ic(Builtins::builtin(Builtins::KeyedLoadIC_Initialize));
// Four cases: non-this global variables, lookup slots, all other
// types of slots, and parameters that rewrite to explicit property
// accesses on the arguments object.
- Slot* slot = var->slot();
+ Slot* slot = var->AsSlot();
Property* property = var->AsProperty();
if (var->is_global() && !var->is_this()) {
// Assert that the object is in a slot.
Variable* object_var = property->obj()->AsVariableProxy()->AsVariable();
ASSERT_NOT_NULL(object_var);
- Slot* object_slot = object_var->slot();
+ Slot* object_slot = object_var->AsSlot();
ASSERT_NOT_NULL(object_slot);
// Load the object.
// Left-hand sides that rewrite to explicit property accesses do not reach
// here.
ASSERT(var != NULL);
- ASSERT(var->is_global() || var->slot() != NULL);
+ ASSERT(var->is_global() || var->AsSlot() != NULL);
if (var->is_global()) {
ASSERT(!var->is_this());
// Perform the assignment for non-const variables and for initialization
// of const variables. Const assignments are simply skipped.
Label done;
- Slot* slot = var->slot();
+ Slot* slot = var->AsSlot();
switch (slot->type()) {
case Slot::PARAMETER:
case Slot::LOCAL:
// Push global object as receiver for the call IC.
__ push(CodeGenerator::GlobalObject());
EmitCallWithIC(expr, var->name(), RelocInfo::CODE_TARGET_CONTEXT);
- } else if (var != NULL && var->slot() != NULL &&
- var->slot()->type() == Slot::LOOKUP) {
+ } else if (var != NULL && var->AsSlot() != NULL &&
+ var->AsSlot()->type() == Slot::LOOKUP) {
// Call to a lookup slot (dynamically introduced variable).
Label slow, done;
// Generate code for loading from variables potentially shadowed
// by eval-introduced variables.
- EmitDynamicLoadFromSlotFastCase(var->slot(),
+ EmitDynamicLoadFromSlotFastCase(var->AsSlot(),
NOT_INSIDE_TYPEOF,
&slow,
&done);
context()->Plug(true);
} else if (var != NULL &&
!var->is_global() &&
- var->slot() != NULL &&
- var->slot()->type() != Slot::LOOKUP) {
+ var->AsSlot() != NULL &&
+ var->AsSlot()->type() != Slot::LOOKUP) {
// Result of deleting non-global, non-dynamic variables is false.
// The subexpression does not have side effects.
context()->Plug(false);
EmitCallIC(ic, RelocInfo::CODE_TARGET);
context()->Plug(eax);
} else if (proxy != NULL &&
- proxy->var()->slot() != NULL &&
- proxy->var()->slot()->type() == Slot::LOOKUP) {
+ proxy->var()->AsSlot() != NULL &&
+ proxy->var()->AsSlot()->type() == Slot::LOOKUP) {
Label done, slow;
// Generate code for loading from variables potentially shadowed
// by eval-introduced variables.
- Slot* slot = proxy->var()->slot();
+ Slot* slot = proxy->var()->AsSlot();
EmitDynamicLoadFromSlotFastCase(slot, INSIDE_TYPEOF, &slow, &done);
__ bind(&slow);
VariableProxy* proxy = expr->AsVariableProxy();
if (proxy != NULL) {
- Slot* slot = proxy->var()->slot();
+ Slot* slot = proxy->var()->AsSlot();
if (slot->type() == Slot::LOCAL) {
PushLocalAt(slot->index());
return;
int j = 0;
for (int i = 0; i < list.length(); i++) {
Variable* var1 = list[i];
- Slot* slot = var1->slot();
+ Slot* slot = var1->AsSlot();
if (slot != NULL && slot->type() == Slot::CONTEXT) {
if (j != i) {
list[j] = var1;
for (int k = 1; k < j; k++) {
int l = k;
for (int m = k + 1; m < j; m++) {
- if (list[l]->slot()->index() > list[m]->slot()->index()) {
+ if (list[l]->AsSlot()->index() > list[m]->AsSlot()->index()) {
l = m;
}
}
SetElement(scope_info_list, scope_info_length, list[i]->name());
scope_info_length++;
SetElement(scope_info_list, scope_info_length,
- Handle<Smi>(Smi::FromInt(list[i]->slot()->index())));
+ Handle<Smi>(Smi::FromInt(list[i]->AsSlot()->index())));
scope_info_length++;
}
SetElement(scope_info_list, scope_info_length,
Variable* rvar = rvar_proxy->AsVariable();
if (lvar != NULL && rvar != NULL) {
if (lvar->mode() == Variable::VAR && rvar->mode() == Variable::VAR) {
- Slot* lslot = lvar->slot();
- Slot* rslot = rvar->slot();
+ Slot* lslot = lvar->AsSlot();
+ Slot* rslot = rvar->AsSlot();
if (lslot->type() == rslot->type() &&
(lslot->type() == Slot::PARAMETER ||
lslot->type() == Slot::LOCAL) &&
static int CompareLocal(Variable* const* v, Variable* const* w) {
- Slot* s = (*v)->slot();
- Slot* t = (*w)->slot();
+ Slot* s = (*v)->AsSlot();
+ Slot* t = (*w)->AsSlot();
// We may have rewritten parameters (that are in the arguments object)
// and which may have a NULL slot... - find a better solution...
int x = (s != NULL ? s->index() : 0);
for (int i = 0; i < locals.length(); i++) {
Variable* var = locals[i];
if (var->is_used()) {
- Slot* slot = var->slot();
+ Slot* slot = var->AsSlot();
if (slot != NULL) {
switch (slot->type()) {
case Slot::PARAMETER:
if (scope->num_heap_slots() > 0) {
// Add user-defined slots.
for (int i = 0; i < heap_locals.length(); i++) {
- ASSERT(heap_locals[i]->slot()->index() - Context::MIN_CONTEXT_SLOTS ==
+ ASSERT(heap_locals[i]->AsSlot()->index() - Context::MIN_CONTEXT_SLOTS ==
context_slots_.length());
- ASSERT(heap_locals[i]->slot()->index() - Context::MIN_CONTEXT_SLOTS ==
+ ASSERT(heap_locals[i]->AsSlot()->index() - Context::MIN_CONTEXT_SLOTS ==
context_modes_.length());
context_slots_.Add(heap_locals[i]->name());
context_modes_.Add(heap_locals[i]->mode());
Variable* var = scope->function();
if (var != NULL &&
var->is_used() &&
- var->slot()->type() == Slot::CONTEXT) {
+ var->AsSlot()->type() == Slot::CONTEXT) {
function_name_ = var->name();
// Note that we must not find the function name in the context slot
// list - instead it must be handled separately in the
// Contexts::Lookup() function. Thus record an empty symbol here so we
// get the correct number of context slots.
- ASSERT(var->slot()->index() - Context::MIN_CONTEXT_SLOTS ==
+ ASSERT(var->AsSlot()->index() - Context::MIN_CONTEXT_SLOTS ==
context_slots_.length());
- ASSERT(var->slot()->index() - Context::MIN_CONTEXT_SLOTS ==
+ ASSERT(var->AsSlot()->index() - Context::MIN_CONTEXT_SLOTS ==
context_modes_.length());
context_slots_.Add(Factory::empty_symbol());
context_modes_.Add(Variable::INTERNAL);
// We are using 'arguments'. Tell the code generator that is needs to
// allocate the arguments object by setting 'arguments_'.
- arguments_ = new VariableProxy(Factory::arguments_symbol(), false, false);
- arguments_->BindTo(arguments);
+ arguments_ = arguments;
// We also need the '.arguments' shadow variable. Declare it and create
// and bind the corresponding proxy. It's ok to declare it only now
// NewTemporary() because the mode needs to be INTERNAL since this
// variable may be allocated in the heap-allocated context (temporaries
// are never allocated in the context).
- Variable* arguments_shadow =
- new Variable(this, Factory::arguments_shadow_symbol(),
- Variable::INTERNAL, true, Variable::ARGUMENTS);
- arguments_shadow_ =
- new VariableProxy(Factory::arguments_shadow_symbol(), false, false);
- arguments_shadow_->BindTo(arguments_shadow);
- temps_.Add(arguments_shadow);
+ arguments_shadow_ = new Variable(this,
+ Factory::arguments_shadow_symbol(),
+ Variable::INTERNAL,
+ true,
+ Variable::ARGUMENTS);
+ arguments_shadow_->set_is_used(true);
+ temps_.Add(arguments_shadow_);
// Allocate the parameters by rewriting them into '.arguments[i]' accesses.
for (int i = 0; i < params_.length(); i++) {
// It is ok to set this only now, because arguments is a local
// variable that is allocated after the parameters have been
// allocated.
- arguments_shadow->is_accessed_from_inner_scope_ = true;
+ arguments_shadow_->is_accessed_from_inner_scope_ = true;
}
var->rewrite_ =
- new Property(arguments_shadow_,
- new Literal(Handle<Object>(Smi::FromInt(i))),
- RelocInfo::kNoPosition,
- Property::SYNTHETIC);
- if (var->is_used()) arguments_shadow->set_is_used(true);
+ new Property(new VariableProxy(arguments_shadow_),
+ new Literal(Handle<Object>(Smi::FromInt(i))),
+ RelocInfo::kNoPosition,
+ Property::SYNTHETIC);
}
}
if (MustAllocate(var)) {
if (MustAllocateInContext(var)) {
ASSERT(var->rewrite_ == NULL ||
- (var->slot() != NULL && var->slot()->type() == Slot::CONTEXT));
+ (var->AsSlot() != NULL &&
+ var->AsSlot()->type() == Slot::CONTEXT));
if (var->rewrite_ == NULL) {
// Only set the heap allocation if the parameter has not
// been allocated yet.
}
} else {
ASSERT(var->rewrite_ == NULL ||
- (var->slot() != NULL &&
- var->slot()->type() == Slot::PARAMETER));
+ (var->AsSlot() != NULL &&
+ var->AsSlot()->type() == Slot::PARAMETER));
// Set the parameter index always, even if the parameter
// was seen before! (We need to access the actual parameter
// supplied for the last occurrence of a multiply declared
ASSERT(var->scope() == this);
ASSERT(var->rewrite_ == NULL ||
(!var->IsVariable(Factory::result_symbol())) ||
- (var->slot() == NULL || var->slot()->type() != Slot::LOCAL));
+ (var->AsSlot() == NULL || var->AsSlot()->type() != Slot::LOCAL));
if (var->rewrite_ == NULL && MustAllocate(var)) {
if (MustAllocateInContext(var)) {
AllocateHeapSlot(var);
// The local variable 'arguments' if we need to allocate it; NULL otherwise.
// If arguments() exist, arguments_shadow() exists, too.
- VariableProxy* arguments() const { return arguments_; }
+ Variable* arguments() const { return arguments_; }
// The '.arguments' shadow variable if we need to allocate it; NULL otherwise.
// If arguments_shadow() exist, arguments() exists, too.
- VariableProxy* arguments_shadow() const { return arguments_shadow_; }
+ Variable* arguments_shadow() const { return arguments_shadow_; }
// Declarations list.
ZoneList<Declaration*>* declarations() { return &decls_; }
// Function variable, if any; function scopes only.
Variable* function_;
// Convenience variable; function scopes only.
- VariableProxy* arguments_;
+ Variable* arguments_;
// Convenience variable; function scopes only.
- VariableProxy* arguments_shadow_;
+ Variable* arguments_shadow_;
// Illegal redeclaration.
Expression* illegal_redecl_;
}
-Property* Variable::AsProperty() {
+Property* Variable::AsProperty() const {
return rewrite_ == NULL ? NULL : rewrite_->AsProperty();
}
-Variable* Variable::AsVariable() {
- return rewrite_ == NULL || rewrite_->AsSlot() != NULL ? this : NULL;
-}
-
-
-Slot* Variable::slot() const {
- return rewrite_ != NULL ? rewrite_->AsSlot() : NULL;
+Slot* Variable::AsSlot() const {
+ return rewrite_ == NULL ? NULL : rewrite_->AsSlot();
}
bool Variable::IsStackAllocated() const {
- Slot* s = slot();
- return s != NULL && s->IsStackAllocated();
+ Slot* slot = AsSlot();
+ return slot != NULL && slot->IsStackAllocated();
}
static const char* Mode2String(Mode mode);
// Type testing & conversion
- Property* AsProperty();
- Variable* AsVariable();
+ Property* AsProperty() const;
+ Slot* AsSlot() const;
+
bool IsValidLeftHandSide() { return is_valid_LHS_; }
// The source code for an eval() call may refer to a variable that is
}
Expression* rewrite() const { return rewrite_; }
- Slot* slot() const;
StaticType* type() { return &type_; }
// the function.
for (int i = 0; i < scope()->num_parameters(); i++) {
Variable* par = scope()->parameter(i);
- Slot* slot = par->slot();
+ Slot* slot = par->AsSlot();
if (slot != NULL && slot->type() == Slot::CONTEXT) {
// The use of SlotOperand below is safe in unspilled code
// because the slot is guaranteed to be a context slot.
// Initialize ThisFunction reference if present.
if (scope()->is_function_scope() && scope()->function() != NULL) {
frame_->Push(Factory::the_hole_value());
- StoreToSlot(scope()->function()->slot(), NOT_CONST_INIT);
+ StoreToSlot(scope()->function()->AsSlot(), NOT_CONST_INIT);
}
// Initialize the function return target after the locals are set
Property property(&global, &key, RelocInfo::kNoPosition);
Reference ref(this, &property);
ref.GetValue();
- } else if (variable != NULL && variable->slot() != NULL) {
+ } else if (variable != NULL && variable->AsSlot() != NULL) {
// For a variable that rewrites to a slot, we signal it is the immediate
// subexpression of a typeof.
- LoadFromSlotCheckForArguments(variable->slot(), INSIDE_TYPEOF);
+ LoadFromSlotCheckForArguments(variable->AsSlot(), INSIDE_TYPEOF);
} else {
// Anything else can be handled normally.
Load(expr);
frame_->Push(&result);
}
- Variable* arguments = scope()->arguments()->var();
- Variable* shadow = scope()->arguments_shadow()->var();
- ASSERT(arguments != NULL && arguments->slot() != NULL);
- ASSERT(shadow != NULL && shadow->slot() != NULL);
+ Variable* arguments = scope()->arguments();
+ Variable* shadow = scope()->arguments_shadow();
+ ASSERT(arguments != NULL && arguments->AsSlot() != NULL);
+ ASSERT(shadow != NULL && shadow->AsSlot() != NULL);
JumpTarget done;
bool skip_arguments = false;
if (mode == LAZY_ARGUMENTS_ALLOCATION && !initial) {
// We have to skip storing into the arguments slot if it has
// already been written to. This can happen if the a function
// has a local variable named 'arguments'.
- LoadFromSlot(arguments->slot(), NOT_INSIDE_TYPEOF);
+ LoadFromSlot(arguments->AsSlot(), NOT_INSIDE_TYPEOF);
Result probe = frame_->Pop();
if (probe.is_constant()) {
// We have to skip updating the arguments object if it has
}
}
if (!skip_arguments) {
- StoreToSlot(arguments->slot(), NOT_CONST_INIT);
+ StoreToSlot(arguments->AsSlot(), NOT_CONST_INIT);
if (mode == LAZY_ARGUMENTS_ALLOCATION) done.Bind();
}
- StoreToSlot(shadow->slot(), NOT_CONST_INIT);
+ StoreToSlot(shadow->AsSlot(), NOT_CONST_INIT);
return frame_->Pop();
}
LoadGlobal();
ref->set_type(Reference::NAMED);
} else {
- ASSERT(var->slot() != NULL);
+ ASSERT(var->AsSlot() != NULL);
ref->set_type(Reference::SLOT);
}
} else {
// Load the receiver and the existing arguments object onto the
// expression stack. Avoid allocating the arguments object here.
Load(receiver);
- LoadFromSlot(scope()->arguments()->var()->slot(), NOT_INSIDE_TYPEOF);
+ LoadFromSlot(scope()->arguments()->AsSlot(), NOT_INSIDE_TYPEOF);
// Emit the source position information after having loaded the
// receiver and the arguments.
Comment cmnt(masm_, "[ Declaration");
Variable* var = node->proxy()->var();
ASSERT(var != NULL); // must have been resolved
- Slot* slot = var->slot();
+ Slot* slot = var->AsSlot();
// If it was not possible to allocate the variable at compile time,
// we need to "declare" it at runtime to make sure it actually
// Set number type of the loop variable to smi.
CheckStack(); // TODO(1222600): ignore if body contains calls.
- SetTypeForStackSlot(loop_var->slot(), TypeInfo::Smi());
+ SetTypeForStackSlot(loop_var->AsSlot(), TypeInfo::Smi());
Visit(node->body());
if (node->continue_target()->is_linked()) {
if (has_valid_frame()) {
CodeForStatementPosition(node);
- Slot* loop_var_slot = loop_var->slot();
+ Slot* loop_var_slot = loop_var->AsSlot();
if (loop_var_slot->type() == Slot::LOCAL) {
frame_->TakeLocalAt(loop_var_slot->index());
} else {
// Store the caught exception in the catch variable.
Variable* catch_var = node->catch_var()->var();
- ASSERT(catch_var != NULL && catch_var->slot() != NULL);
- StoreToSlot(catch_var->slot(), NOT_CONST_INIT);
+ ASSERT(catch_var != NULL && catch_var->AsSlot() != NULL);
+ StoreToSlot(catch_var->AsSlot(), NOT_CONST_INIT);
// Remove the exception from the stack.
frame_->Drop();
done->Jump(result);
} else if (slot->var()->mode() == Variable::DYNAMIC_LOCAL) {
- Slot* potential_slot = slot->var()->local_if_not_shadowed()->slot();
+ Slot* potential_slot = slot->var()->local_if_not_shadowed()->AsSlot();
Expression* rewrite = slot->var()->local_if_not_shadowed()->rewrite();
if (potential_slot != NULL) {
// Generate fast case for locals that rewrite to slots.
Result arguments = allocator()->Allocate();
ASSERT(arguments.is_valid());
__ movq(arguments.reg(),
- ContextSlotOperandCheckExtensions(obj_proxy->var()->slot(),
+ ContextSlotOperandCheckExtensions(obj_proxy->var()->AsSlot(),
arguments,
slow));
frame_->Push(&arguments);
Comment cmnt(masm(), "[ Variable Assignment");
Variable* var = node->target()->AsVariableProxy()->AsVariable();
ASSERT(var != NULL);
- Slot* slot = var->slot();
+ Slot* slot = var->AsSlot();
ASSERT(slot != NULL);
// Evaluate the right-hand side.
// in generated code. If we succeed, there is no need to perform a
// context lookup in the runtime system.
JumpTarget done;
- if (var->slot() != NULL && var->mode() == Variable::DYNAMIC_GLOBAL) {
- ASSERT(var->slot()->type() == Slot::LOOKUP);
+ if (var->AsSlot() != NULL && var->mode() == Variable::DYNAMIC_GLOBAL) {
+ ASSERT(var->AsSlot()->type() == Slot::LOOKUP);
JumpTarget slow;
// Prepare the stack for the call to
// ResolvePossiblyDirectEvalNoLookup by pushing the loaded
// function, the first argument to the eval call and the
// receiver.
- Result fun = LoadFromGlobalSlotCheckExtensions(var->slot(),
+ Result fun = LoadFromGlobalSlotCheckExtensions(var->AsSlot(),
NOT_INSIDE_TYPEOF,
&slow);
frame_->Push(&fun);
// Replace the function on the stack with the result.
frame_->Push(&result);
- } else if (var != NULL && var->slot() != NULL &&
- var->slot()->type() == Slot::LOOKUP) {
+ } else if (var != NULL && var->AsSlot() != NULL &&
+ var->AsSlot()->type() == Slot::LOOKUP) {
// ----------------------------------
// JavaScript examples:
//
// Generate fast case for loading functions from slots that
// correspond to local/global variables or arguments unless they
// are shadowed by eval-introduced bindings.
- EmitDynamicLoadFromSlotFastCase(var->slot(),
+ EmitDynamicLoadFromSlotFastCase(var->AsSlot(),
NOT_INSIDE_TYPEOF,
&function,
&slow,
Variable* variable = node->expression()->AsVariableProxy()->AsVariable();
if (variable != NULL) {
- Slot* slot = variable->slot();
+ Slot* slot = variable->AsSlot();
if (variable->is_global()) {
LoadGlobal();
frame_->Push(variable->name());
switch (type_) {
case SLOT: {
Comment cmnt(masm, "[ Load from Slot");
- Slot* slot = expression_->AsVariableProxy()->AsVariable()->slot();
+ Slot* slot = expression_->AsVariableProxy()->AsVariable()->AsSlot();
ASSERT(slot != NULL);
cgen_->LoadFromSlotCheckForArguments(slot, NOT_INSIDE_TYPEOF);
break;
return;
}
- Slot* slot = expression_->AsVariableProxy()->AsVariable()->slot();
+ Slot* slot = expression_->AsVariableProxy()->AsVariable()->AsSlot();
ASSERT(slot != NULL);
if (slot->type() == Slot::LOOKUP ||
slot->type() == Slot::CONTEXT ||
switch (type_) {
case SLOT: {
Comment cmnt(masm, "[ Store to Slot");
- Slot* slot = expression_->AsVariableProxy()->AsVariable()->slot();
+ Slot* slot = expression_->AsVariableProxy()->AsVariable()->AsSlot();
ASSERT(slot != NULL);
cgen_->StoreToSlot(slot, init_state);
set_unloaded();
// Copy any necessary parameters into the context.
int num_parameters = scope()->num_parameters();
for (int i = 0; i < num_parameters; i++) {
- Slot* slot = scope()->parameter(i)->slot();
+ Slot* slot = scope()->parameter(i)->AsSlot();
if (slot != NULL && slot->type() == Slot::CONTEXT) {
int parameter_offset = StandardFrameConstants::kCallerSPOffset +
(num_parameters - 1 - i) * kPointerSize;
}
// Possibly allocate an arguments object.
- Variable* arguments = scope()->arguments()->AsVariable();
+ Variable* arguments = scope()->arguments();
if (arguments != NULL) {
// Arguments object must be allocated after the context object, in
// case the "arguments" or ".arguments" variables are in the context.
__ CallStub(&stub);
// Store new arguments object in both "arguments" and ".arguments" slots.
__ movq(rcx, rax);
- Move(arguments->slot(), rax, rbx, rdx);
- Slot* dot_arguments_slot =
- scope()->arguments_shadow()->AsVariable()->slot();
+ Move(arguments->AsSlot(), rax, rbx, rdx);
+ Slot* dot_arguments_slot = scope()->arguments_shadow()->AsSlot();
Move(dot_arguments_slot, rcx, rbx, rdx);
}
FunctionLiteral* function) {
Comment cmnt(masm_, "[ Declaration");
ASSERT(variable != NULL); // Must have been resolved.
- Slot* slot = variable->slot();
+ Slot* slot = variable->AsSlot();
Property* prop = variable->AsProperty();
if (slot != NULL) {
EmitLoadGlobalSlotCheckExtensions(slot, typeof_state, slow);
__ jmp(done);
} else if (slot->var()->mode() == Variable::DYNAMIC_LOCAL) {
- Slot* potential_slot = slot->var()->local_if_not_shadowed()->slot();
+ Slot* potential_slot = slot->var()->local_if_not_shadowed()->AsSlot();
Expression* rewrite = slot->var()->local_if_not_shadowed()->rewrite();
if (potential_slot != NULL) {
// Generate fast case for locals that rewrite to slots.
// variables. Then load the argument from the arguments
// object using keyed load.
__ movq(rdx,
- ContextSlotOperandCheckExtensions(obj_proxy->var()->slot(),
+ ContextSlotOperandCheckExtensions(obj_proxy->var()->AsSlot(),
slow));
__ Move(rax, key_literal->handle());
Handle<Code> ic(Builtins::builtin(Builtins::KeyedLoadIC_Initialize));
// Four cases: non-this global variables, lookup slots, all other
// types of slots, and parameters that rewrite to explicit property
// accesses on the arguments object.
- Slot* slot = var->slot();
+ Slot* slot = var->AsSlot();
Property* property = var->AsProperty();
if (var->is_global() && !var->is_this()) {
// Assert that the object is in a slot.
Variable* object_var = property->obj()->AsVariableProxy()->AsVariable();
ASSERT_NOT_NULL(object_var);
- Slot* object_slot = object_var->slot();
+ Slot* object_slot = object_var->AsSlot();
ASSERT_NOT_NULL(object_slot);
// Load the object.
// Left-hand sides that rewrite to explicit property accesses do not reach
// here.
ASSERT(var != NULL);
- ASSERT(var->is_global() || var->slot() != NULL);
+ ASSERT(var->is_global() || var->AsSlot() != NULL);
if (var->is_global()) {
ASSERT(!var->is_this());
// Perform the assignment for non-const variables and for initialization
// of const variables. Const assignments are simply skipped.
Label done;
- Slot* slot = var->slot();
+ Slot* slot = var->AsSlot();
switch (slot->type()) {
case Slot::PARAMETER:
case Slot::LOCAL:
// Push global object as receiver for the call IC lookup.
__ push(CodeGenerator::GlobalObject());
EmitCallWithIC(expr, var->name(), RelocInfo::CODE_TARGET_CONTEXT);
- } else if (var != NULL && var->slot() != NULL &&
- var->slot()->type() == Slot::LOOKUP) {
+ } else if (var != NULL && var->AsSlot() != NULL &&
+ var->AsSlot()->type() == Slot::LOOKUP) {
// Call to a lookup slot (dynamically introduced variable).
Label slow, done;
// Generate code for loading from variables potentially shadowed
// by eval-introduced variables.
- EmitDynamicLoadFromSlotFastCase(var->slot(),
+ EmitDynamicLoadFromSlotFastCase(var->AsSlot(),
NOT_INSIDE_TYPEOF,
&slow,
&done);
context()->Plug(true);
} else if (var != NULL &&
!var->is_global() &&
- var->slot() != NULL &&
- var->slot()->type() != Slot::LOOKUP) {
+ var->AsSlot() != NULL &&
+ var->AsSlot()->type() != Slot::LOOKUP) {
// Result of deleting non-global, non-dynamic variables is false.
// The subexpression does not have side effects.
context()->Plug(false);
EmitCallIC(ic, RelocInfo::CODE_TARGET);
context()->Plug(rax);
} else if (proxy != NULL &&
- proxy->var()->slot() != NULL &&
- proxy->var()->slot()->type() == Slot::LOOKUP) {
+ proxy->var()->AsSlot() != NULL &&
+ proxy->var()->AsSlot()->type() == Slot::LOOKUP) {
Label done, slow;
// Generate code for loading from variables potentially shadowed
// by eval-introduced variables.
- Slot* slot = proxy->var()->slot();
+ Slot* slot = proxy->var()->AsSlot();
EmitDynamicLoadFromSlotFastCase(slot, INSIDE_TYPEOF, &slow, &done);
__ bind(&slow);
VariableProxy* proxy = expr->AsVariableProxy();
if (proxy != NULL) {
- Slot* slot = proxy->var()->slot();
+ Slot* slot = proxy->var()->AsSlot();
if (slot->type() == Slot::LOCAL) {
PushLocalAt(slot->index());
return;