Remove code handling parameters rewritten to properties (aka synthetic properties).

After merging the new arguments branch, there is no need for this code anymore.

TEST=all tests pass
Review URL: http://codereview.chromium.org/7753030

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9031 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
fschneider@chromium.org 2011-08-29 07:07:39 +00:00
parent cd3588d582
commit a58b9ba90b
6 changed files with 300 additions and 586 deletions

View File

@ -47,7 +47,6 @@ namespace internal {
static unsigned GetPropertyId(Property* property) { static unsigned GetPropertyId(Property* property) {
if (property->is_synthetic()) return AstNode::kNoNumber;
return property->id(); return property->id();
} }
@ -694,104 +693,73 @@ void FullCodeGenerator::EmitDeclaration(Variable* variable,
Comment cmnt(masm_, "[ Declaration"); Comment cmnt(masm_, "[ Declaration");
ASSERT(variable != NULL); // Must have been resolved. ASSERT(variable != NULL); // Must have been resolved.
Slot* slot = variable->AsSlot(); Slot* slot = variable->AsSlot();
Property* prop = variable->AsProperty(); ASSERT(slot != NULL);
switch (slot->type()) {
if (slot != NULL) { case Slot::PARAMETER:
switch (slot->type()) { case Slot::LOCAL:
case Slot::PARAMETER: if (mode == Variable::CONST) {
case Slot::LOCAL: __ LoadRoot(ip, Heap::kTheHoleValueRootIndex);
if (mode == Variable::CONST) { __ str(ip, MemOperand(fp, SlotOffset(slot)));
__ LoadRoot(ip, Heap::kTheHoleValueRootIndex); } else if (function != NULL) {
__ str(ip, MemOperand(fp, SlotOffset(slot))); VisitForAccumulatorValue(function);
} else if (function != NULL) { __ str(result_register(), MemOperand(fp, SlotOffset(slot)));
VisitForAccumulatorValue(function);
__ str(result_register(), MemOperand(fp, SlotOffset(slot)));
}
break;
case Slot::CONTEXT:
// We bypass the general EmitSlotSearch because we know more about
// this specific context.
// The variable in the decl always resides in the current function
// context.
ASSERT_EQ(0, scope()->ContextChainLength(variable->scope()));
if (FLAG_debug_code) {
// Check that we're not inside a with or catch context.
__ ldr(r1, FieldMemOperand(cp, HeapObject::kMapOffset));
__ CompareRoot(r1, Heap::kWithContextMapRootIndex);
__ Check(ne, "Declaration in with context.");
__ CompareRoot(r1, Heap::kCatchContextMapRootIndex);
__ Check(ne, "Declaration in catch context.");
}
if (mode == Variable::CONST) {
__ LoadRoot(ip, Heap::kTheHoleValueRootIndex);
__ str(ip, ContextOperand(cp, slot->index()));
// No write barrier since the_hole_value is in old space.
} else if (function != NULL) {
VisitForAccumulatorValue(function);
__ str(result_register(), ContextOperand(cp, slot->index()));
int offset = Context::SlotOffset(slot->index());
// We know that we have written a function, which is not a smi.
__ mov(r1, Operand(cp));
__ RecordWrite(r1, Operand(offset), r2, result_register());
}
break;
case Slot::LOOKUP: {
__ mov(r2, Operand(variable->name()));
// Declaration nodes are always introduced in one of two modes.
ASSERT(mode == Variable::VAR ||
mode == Variable::CONST ||
mode == Variable::LET);
PropertyAttributes attr = (mode == Variable::CONST) ? READ_ONLY : NONE;
__ mov(r1, Operand(Smi::FromInt(attr)));
// Push initial value, if any.
// Note: For variables we must not push an initial value (such as
// 'undefined') because we may have a (legal) redeclaration and we
// must not destroy the current value.
if (mode == Variable::CONST) {
__ LoadRoot(r0, Heap::kTheHoleValueRootIndex);
__ Push(cp, r2, r1, r0);
} else if (function != NULL) {
__ Push(cp, r2, r1);
// Push initial value for function declaration.
VisitForStackValue(function);
} else {
__ mov(r0, Operand(Smi::FromInt(0))); // No initial value!
__ Push(cp, r2, r1, r0);
}
__ CallRuntime(Runtime::kDeclareContextSlot, 4);
break;
} }
} break;
} else if (prop != NULL) { case Slot::CONTEXT:
// A const declaration aliasing a parameter is an illegal redeclaration. // We bypass the general EmitSlotSearch because we know more about
ASSERT(mode != Variable::CONST); // this specific context.
if (function != NULL) {
// We are declaring a function that rewrites to a property. // The variable in the decl always resides in the current function
// Use (keyed) IC to set the initial value. We cannot visit the // context.
// rewrite because it's shared and we risk recording duplicate AST ASSERT_EQ(0, scope()->ContextChainLength(variable->scope()));
// IDs for bailouts from optimized code. if (FLAG_debug_code) {
ASSERT(prop->obj()->AsVariableProxy() != NULL); // Check that we're not inside a with or catch context.
{ AccumulatorValueContext for_object(this); __ ldr(r1, FieldMemOperand(cp, HeapObject::kMapOffset));
EmitVariableLoad(prop->obj()->AsVariableProxy()); __ CompareRoot(r1, Heap::kWithContextMapRootIndex);
__ Check(ne, "Declaration in with context.");
__ CompareRoot(r1, Heap::kCatchContextMapRootIndex);
__ Check(ne, "Declaration in catch context.");
} }
if (mode == Variable::CONST) {
__ LoadRoot(ip, Heap::kTheHoleValueRootIndex);
__ str(ip, ContextOperand(cp, slot->index()));
// No write barrier since the_hole_value is in old space.
} else if (function != NULL) {
VisitForAccumulatorValue(function);
__ str(result_register(), ContextOperand(cp, slot->index()));
int offset = Context::SlotOffset(slot->index());
// We know that we have written a function, which is not a smi.
__ mov(r1, Operand(cp));
__ RecordWrite(r1, Operand(offset), r2, result_register());
}
break;
__ push(r0); case Slot::LOOKUP: {
VisitForAccumulatorValue(function); __ mov(r2, Operand(variable->name()));
__ pop(r2); // Declaration nodes are always introduced in one of two modes.
ASSERT(mode == Variable::VAR ||
ASSERT(prop->key()->AsLiteral() != NULL && mode == Variable::CONST ||
prop->key()->AsLiteral()->handle()->IsSmi()); mode == Variable::LET);
__ mov(r1, Operand(prop->key()->AsLiteral()->handle())); PropertyAttributes attr = (mode == Variable::CONST) ? READ_ONLY : NONE;
__ mov(r1, Operand(Smi::FromInt(attr)));
Handle<Code> ic = is_strict_mode() // Push initial value, if any.
? isolate()->builtins()->KeyedStoreIC_Initialize_Strict() // Note: For variables we must not push an initial value (such as
: isolate()->builtins()->KeyedStoreIC_Initialize(); // 'undefined') because we may have a (legal) redeclaration and we
__ Call(ic); // must not destroy the current value.
// Value in r0 is ignored (declarations are statements). if (mode == Variable::CONST) {
__ LoadRoot(r0, Heap::kTheHoleValueRootIndex);
__ Push(cp, r2, r1, r0);
} else if (function != NULL) {
__ Push(cp, r2, r1);
// Push initial value for function declaration.
VisitForStackValue(function);
} else {
__ mov(r0, Operand(Smi::FromInt(0))); // No initial value!
__ Push(cp, r2, r1, r0);
}
__ CallRuntime(Runtime::kDeclareContextSlot, 4);
break;
} }
} }
} }
@ -2272,36 +2240,10 @@ void FullCodeGenerator::VisitCall(Call* expr) {
EmitCallWithIC(expr, key->handle(), RelocInfo::CODE_TARGET); EmitCallWithIC(expr, key->handle(), RelocInfo::CODE_TARGET);
} else { } else {
// Call to a keyed property. // Call to a keyed property.
// For a synthetic property use keyed load IC followed by function call, { PreservePositionScope scope(masm()->positions_recorder());
// for a regular property use EmitKeyedCallWithIC. VisitForStackValue(prop->obj());
if (prop->is_synthetic()) {
// Do not visit the object and key subexpressions (they are shared
// by all occurrences of the same rewritten parameter).
ASSERT(prop->obj()->AsVariableProxy() != NULL);
ASSERT(prop->obj()->AsVariableProxy()->var()->AsSlot() != NULL);
Slot* slot = prop->obj()->AsVariableProxy()->var()->AsSlot();
MemOperand operand = EmitSlotSearch(slot, r1);
__ ldr(r1, operand);
ASSERT(prop->key()->AsLiteral() != NULL);
ASSERT(prop->key()->AsLiteral()->handle()->IsSmi());
__ mov(r0, Operand(prop->key()->AsLiteral()->handle()));
// Record source code position for IC call.
SetSourcePosition(prop->position());
Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize();
__ Call(ic, RelocInfo::CODE_TARGET, GetPropertyId(prop));
__ ldr(r1, GlobalObjectOperand());
__ ldr(r1, FieldMemOperand(r1, GlobalObject::kGlobalReceiverOffset));
__ Push(r0, r1); // Function, receiver.
EmitCallWithStub(expr, NO_CALL_FUNCTION_FLAGS);
} else {
{ PreservePositionScope scope(masm()->positions_recorder());
VisitForStackValue(prop->obj());
}
EmitKeyedCallWithIC(expr, prop->key());
} }
EmitKeyedCallWithIC(expr, prop->key());
} }
} else { } else {
{ PreservePositionScope scope(masm()->positions_recorder()); { PreservePositionScope scope(masm()->positions_recorder());
@ -3631,18 +3573,12 @@ void FullCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) {
Variable* var = expr->expression()->AsVariableProxy()->AsVariable(); Variable* var = expr->expression()->AsVariableProxy()->AsVariable();
if (prop != NULL) { if (prop != NULL) {
if (prop->is_synthetic()) { VisitForStackValue(prop->obj());
// Result of deleting parameters is false, even when they rewrite VisitForStackValue(prop->key());
// to accesses on the arguments object. __ mov(r1, Operand(Smi::FromInt(strict_mode_flag())));
context()->Plug(false); __ push(r1);
} else { __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION);
VisitForStackValue(prop->obj()); context()->Plug(r0);
VisitForStackValue(prop->key());
__ mov(r1, Operand(Smi::FromInt(strict_mode_flag())));
__ push(r1);
__ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION);
context()->Plug(r0);
}
} else if (var != NULL) { } else if (var != NULL) {
// Delete of an unqualified identifier is disallowed in strict mode // Delete of an unqualified identifier is disallowed in strict mode
// but "delete this" is. // but "delete this" is.

View File

@ -1231,21 +1231,14 @@ class Slot: public Expression {
class Property: public Expression { class Property: public Expression {
public: public:
// Synthetic properties are property lookups introduced by the system,
// to objects that aren't visible to the user. Function calls to synthetic
// properties should use the global object as receiver, not the base object
// of the resolved Reference.
enum Type { NORMAL, SYNTHETIC };
Property(Isolate* isolate, Property(Isolate* isolate,
Expression* obj, Expression* obj,
Expression* key, Expression* key,
int pos, int pos)
Type type = NORMAL)
: Expression(isolate), : Expression(isolate),
obj_(obj), obj_(obj),
key_(key), key_(key),
pos_(pos), pos_(pos),
type_(type),
is_monomorphic_(false), is_monomorphic_(false),
is_array_length_(false), is_array_length_(false),
is_string_length_(false), is_string_length_(false),
@ -1260,7 +1253,6 @@ class Property: public Expression {
Expression* obj() const { return obj_; } Expression* obj() const { return obj_; }
Expression* key() const { return key_; } Expression* key() const { return key_; }
virtual int position() const { return pos_; } virtual int position() const { return pos_; }
bool is_synthetic() const { return type_ == SYNTHETIC; }
bool IsStringLength() const { return is_string_length_; } bool IsStringLength() const { return is_string_length_; }
bool IsStringAccess() const { return is_string_access_; } bool IsStringAccess() const { return is_string_access_; }
@ -1276,7 +1268,6 @@ class Property: public Expression {
Expression* obj_; Expression* obj_;
Expression* key_; Expression* key_;
int pos_; int pos_;
Type type_;
SmallMapList receiver_types_; SmallMapList receiver_types_;
bool is_monomorphic_ : 1; bool is_monomorphic_ : 1;

View File

@ -5074,19 +5074,13 @@ void HGraphBuilder::VisitDelete(UnaryOperation* expr) {
// The subexpression does not have side effects. // The subexpression does not have side effects.
return ast_context()->ReturnValue(graph()->GetConstantFalse()); return ast_context()->ReturnValue(graph()->GetConstantFalse());
} else if (prop != NULL) { } else if (prop != NULL) {
if (prop->is_synthetic()) { CHECK_ALIVE(VisitForValue(prop->obj()));
// Result of deleting parameters is false, even when they rewrite CHECK_ALIVE(VisitForValue(prop->key()));
// to accesses on the arguments object. HValue* key = Pop();
return ast_context()->ReturnValue(graph()->GetConstantFalse()); HValue* obj = Pop();
} else { HValue* context = environment()->LookupContext();
CHECK_ALIVE(VisitForValue(prop->obj())); HDeleteProperty* instr = new(zone()) HDeleteProperty(context, obj, key);
CHECK_ALIVE(VisitForValue(prop->key())); return ast_context()->ReturnInstruction(instr, expr->id());
HValue* key = Pop();
HValue* obj = Pop();
HValue* context = environment()->LookupContext();
HDeleteProperty* instr = new(zone()) HDeleteProperty(context, obj, key);
return ast_context()->ReturnInstruction(instr, expr->id());
}
} else if (var->is_global()) { } else if (var->is_global()) {
Bailout("delete with global variable"); Bailout("delete with global variable");
} else { } else {

View File

@ -46,7 +46,6 @@ namespace internal {
static unsigned GetPropertyId(Property* property) { static unsigned GetPropertyId(Property* property) {
if (property->is_synthetic()) return AstNode::kNoNumber;
return property->id(); return property->id();
} }
@ -690,105 +689,73 @@ void FullCodeGenerator::EmitDeclaration(Variable* variable,
Comment cmnt(masm_, "[ Declaration"); Comment cmnt(masm_, "[ Declaration");
ASSERT(variable != NULL); // Must have been resolved. ASSERT(variable != NULL); // Must have been resolved.
Slot* slot = variable->AsSlot(); Slot* slot = variable->AsSlot();
Property* prop = variable->AsProperty(); ASSERT(slot != NULL);
switch (slot->type()) {
if (slot != NULL) { case Slot::PARAMETER:
switch (slot->type()) { case Slot::LOCAL:
case Slot::PARAMETER: if (mode == Variable::CONST) {
case Slot::LOCAL: __ mov(Operand(ebp, SlotOffset(slot)),
if (mode == Variable::CONST) { Immediate(isolate()->factory()->the_hole_value()));
__ mov(Operand(ebp, SlotOffset(slot)), } else if (function != NULL) {
Immediate(isolate()->factory()->the_hole_value())); VisitForAccumulatorValue(function);
} else if (function != NULL) { __ mov(Operand(ebp, SlotOffset(slot)), result_register());
VisitForAccumulatorValue(function);
__ mov(Operand(ebp, SlotOffset(slot)), result_register());
}
break;
case Slot::CONTEXT:
// We bypass the general EmitSlotSearch because we know more about
// this specific context.
// The variable in the decl always resides in the current function
// context.
ASSERT_EQ(0, scope()->ContextChainLength(variable->scope()));
if (FLAG_debug_code) {
// Check that we're not inside a with or catch context.
__ mov(ebx, FieldOperand(esi, HeapObject::kMapOffset));
__ cmp(ebx, isolate()->factory()->with_context_map());
__ Check(not_equal, "Declaration in with context.");
__ cmp(ebx, isolate()->factory()->catch_context_map());
__ Check(not_equal, "Declaration in catch context.");
}
if (mode == Variable::CONST) {
__ mov(ContextOperand(esi, slot->index()),
Immediate(isolate()->factory()->the_hole_value()));
// No write barrier since the hole value is in old space.
} else if (function != NULL) {
VisitForAccumulatorValue(function);
__ mov(ContextOperand(esi, slot->index()), result_register());
int offset = Context::SlotOffset(slot->index());
__ mov(ebx, esi);
__ RecordWrite(ebx, offset, result_register(), ecx);
}
break;
case Slot::LOOKUP: {
__ push(esi);
__ push(Immediate(variable->name()));
// Declaration nodes are always introduced in one of two modes.
ASSERT(mode == Variable::VAR ||
mode == Variable::CONST ||
mode == Variable::LET);
PropertyAttributes attr = (mode == Variable::CONST) ? READ_ONLY : NONE;
__ push(Immediate(Smi::FromInt(attr)));
// Push initial value, if any.
// Note: For variables we must not push an initial value (such as
// 'undefined') because we may have a (legal) redeclaration and we
// must not destroy the current value.
increment_stack_height(3);
if (mode == Variable::CONST) {
__ push(Immediate(isolate()->factory()->the_hole_value()));
increment_stack_height();
} else if (function != NULL) {
VisitForStackValue(function);
} else {
__ push(Immediate(Smi::FromInt(0))); // No initial value!
increment_stack_height();
}
__ CallRuntime(Runtime::kDeclareContextSlot, 4);
decrement_stack_height(4);
break;
} }
} break;
} else if (prop != NULL) { case Slot::CONTEXT:
// A const declaration aliasing a parameter is an illegal redeclaration. // We bypass the general EmitSlotSearch because we know more about
ASSERT(mode != Variable::CONST); // this specific context.
if (function != NULL) {
// We are declaring a function that rewrites to a property. // The variable in the decl always resides in the current function
// Use (keyed) IC to set the initial value. We cannot visit the // context.
// rewrite because it's shared and we risk recording duplicate AST ASSERT_EQ(0, scope()->ContextChainLength(variable->scope()));
// IDs for bailouts from optimized code. if (FLAG_debug_code) {
ASSERT(prop->obj()->AsVariableProxy() != NULL); // Check that we're not inside a with or catch context.
{ AccumulatorValueContext for_object(this); __ mov(ebx, FieldOperand(esi, HeapObject::kMapOffset));
EmitVariableLoad(prop->obj()->AsVariableProxy()); __ cmp(ebx, isolate()->factory()->with_context_map());
__ Check(not_equal, "Declaration in with context.");
__ cmp(ebx, isolate()->factory()->catch_context_map());
__ Check(not_equal, "Declaration in catch context.");
} }
if (mode == Variable::CONST) {
__ mov(ContextOperand(esi, slot->index()),
Immediate(isolate()->factory()->the_hole_value()));
// No write barrier since the hole value is in old space.
} else if (function != NULL) {
VisitForAccumulatorValue(function);
__ mov(ContextOperand(esi, slot->index()), result_register());
int offset = Context::SlotOffset(slot->index());
__ mov(ebx, esi);
__ RecordWrite(ebx, offset, result_register(), ecx);
}
break;
__ push(eax); case Slot::LOOKUP: {
increment_stack_height(); __ push(esi);
VisitForAccumulatorValue(function); __ push(Immediate(variable->name()));
__ pop(edx); // Declaration nodes are always introduced in one of two modes.
decrement_stack_height(); ASSERT(mode == Variable::VAR ||
mode == Variable::CONST ||
ASSERT(prop->key()->AsLiteral() != NULL && mode == Variable::LET);
prop->key()->AsLiteral()->handle()->IsSmi()); PropertyAttributes attr = (mode == Variable::CONST) ? READ_ONLY : NONE;
__ SafeSet(ecx, Immediate(prop->key()->AsLiteral()->handle())); __ push(Immediate(Smi::FromInt(attr)));
// Push initial value, if any.
Handle<Code> ic = is_strict_mode() // Note: For variables we must not push an initial value (such as
? isolate()->builtins()->KeyedStoreIC_Initialize_Strict() // 'undefined') because we may have a (legal) redeclaration and we
: isolate()->builtins()->KeyedStoreIC_Initialize(); // must not destroy the current value.
__ call(ic); increment_stack_height(3);
if (mode == Variable::CONST) {
__ push(Immediate(isolate()->factory()->the_hole_value()));
increment_stack_height();
} else if (function != NULL) {
VisitForStackValue(function);
} else {
__ push(Immediate(Smi::FromInt(0))); // No initial value!
increment_stack_height();
}
__ CallRuntime(Runtime::kDeclareContextSlot, 4);
decrement_stack_height(4);
break;
} }
} }
} }
@ -1824,21 +1791,11 @@ void FullCodeGenerator::EmitAssignment(Expression* expr, int bailout_ast_id) {
case KEYED_PROPERTY: { case KEYED_PROPERTY: {
__ push(eax); // Preserve value. __ push(eax); // Preserve value.
increment_stack_height(); increment_stack_height();
if (prop->is_synthetic()) { VisitForStackValue(prop->obj());
ASSERT(prop->obj()->AsVariableProxy() != NULL); VisitForAccumulatorValue(prop->key());
ASSERT(prop->key()->AsLiteral() != NULL); __ mov(ecx, eax);
{ AccumulatorValueContext for_object(this); __ pop(edx);
EmitVariableLoad(prop->obj()->AsVariableProxy()); decrement_stack_height();
}
__ mov(edx, eax);
__ SafeSet(ecx, Immediate(prop->key()->AsLiteral()->handle()));
} else {
VisitForStackValue(prop->obj());
VisitForAccumulatorValue(prop->key());
__ mov(ecx, eax);
__ pop(edx);
decrement_stack_height();
}
__ pop(eax); // Restore value. __ pop(eax); // Restore value.
decrement_stack_height(); decrement_stack_height();
Handle<Code> ic = is_strict_mode() Handle<Code> ic = is_strict_mode()
@ -2275,40 +2232,10 @@ void FullCodeGenerator::VisitCall(Call* expr) {
EmitCallWithIC(expr, key->handle(), RelocInfo::CODE_TARGET); EmitCallWithIC(expr, key->handle(), RelocInfo::CODE_TARGET);
} else { } else {
// Call to a keyed property. // Call to a keyed property.
// For a synthetic property use keyed load IC followed by function call, { PreservePositionScope scope(masm()->positions_recorder());
// for a regular property use EmitKeyedCallWithIC. VisitForStackValue(prop->obj());
if (prop->is_synthetic()) {
// Do not visit the object and key subexpressions (they are shared
// by all occurrences of the same rewritten parameter).
ASSERT(prop->obj()->AsVariableProxy() != NULL);
ASSERT(prop->obj()->AsVariableProxy()->var()->AsSlot() != NULL);
Slot* slot = prop->obj()->AsVariableProxy()->var()->AsSlot();
MemOperand operand = EmitSlotSearch(slot, edx);
__ mov(edx, operand);
ASSERT(prop->key()->AsLiteral() != NULL);
ASSERT(prop->key()->AsLiteral()->handle()->IsSmi());
__ mov(eax, prop->key()->AsLiteral()->handle());
// Record source code position for IC call.
SetSourcePosition(prop->position());
Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize();
__ call(ic, RelocInfo::CODE_TARGET, GetPropertyId(prop));
// Push result (function).
__ push(eax);
increment_stack_height();
// Push Global receiver.
__ mov(ecx, GlobalObjectOperand());
__ push(FieldOperand(ecx, GlobalObject::kGlobalReceiverOffset));
increment_stack_height();
EmitCallWithStub(expr, NO_CALL_FUNCTION_FLAGS);
} else {
{ PreservePositionScope scope(masm()->positions_recorder());
VisitForStackValue(prop->obj());
}
EmitKeyedCallWithIC(expr, prop->key());
} }
EmitKeyedCallWithIC(expr, prop->key());
} }
} else { } else {
{ PreservePositionScope scope(masm()->positions_recorder()); { PreservePositionScope scope(masm()->positions_recorder());
@ -3688,18 +3615,12 @@ void FullCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) {
Variable* var = expr->expression()->AsVariableProxy()->AsVariable(); Variable* var = expr->expression()->AsVariableProxy()->AsVariable();
if (prop != NULL) { if (prop != NULL) {
if (prop->is_synthetic()) { VisitForStackValue(prop->obj());
// Result of deleting parameters is false, even when they rewrite VisitForStackValue(prop->key());
// to accesses on the arguments object. __ push(Immediate(Smi::FromInt(strict_mode_flag())));
context()->Plug(false); __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION);
} else { decrement_stack_height(2);
VisitForStackValue(prop->obj()); context()->Plug(eax);
VisitForStackValue(prop->key());
__ push(Immediate(Smi::FromInt(strict_mode_flag())));
__ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION);
decrement_stack_height(2);
context()->Plug(eax);
}
} else if (var != NULL) { } else if (var != NULL) {
// Delete of an unqualified identifier is disallowed in strict mode // Delete of an unqualified identifier is disallowed in strict mode
// but "delete this" is. // but "delete this" is.

View File

@ -55,7 +55,6 @@ namespace internal {
static unsigned GetPropertyId(Property* property) { static unsigned GetPropertyId(Property* property) {
if (property->is_synthetic()) return AstNode::kNoNumber;
return property->id(); return property->id();
} }
@ -697,109 +696,77 @@ void FullCodeGenerator::EmitDeclaration(Variable* variable,
Comment cmnt(masm_, "[ Declaration"); Comment cmnt(masm_, "[ Declaration");
ASSERT(variable != NULL); // Must have been resolved. ASSERT(variable != NULL); // Must have been resolved.
Slot* slot = variable->AsSlot(); Slot* slot = variable->AsSlot();
Property* prop = variable->AsProperty(); ASSERT(slot != NULL);
switch (slot->type()) {
if (slot != NULL) { case Slot::PARAMETER:
switch (slot->type()) { case Slot::LOCAL:
case Slot::PARAMETER: if (mode == Variable::CONST) {
case Slot::LOCAL: __ LoadRoot(t0, Heap::kTheHoleValueRootIndex);
if (mode == Variable::CONST) { __ sw(t0, MemOperand(fp, SlotOffset(slot)));
__ LoadRoot(t0, Heap::kTheHoleValueRootIndex); } else if (function != NULL) {
__ sw(t0, MemOperand(fp, SlotOffset(slot))); VisitForAccumulatorValue(function);
} else if (function != NULL) { __ sw(result_register(), MemOperand(fp, SlotOffset(slot)));
VisitForAccumulatorValue(function);
__ sw(result_register(), MemOperand(fp, SlotOffset(slot)));
}
break;
case Slot::CONTEXT:
// We bypass the general EmitSlotSearch because we know more about
// this specific context.
// The variable in the decl always resides in the current function
// context.
ASSERT_EQ(0, scope()->ContextChainLength(variable->scope()));
if (FLAG_debug_code) {
// Check that we're not inside a with or catch context.
__ lw(a1, FieldMemOperand(cp, HeapObject::kMapOffset));
__ LoadRoot(t0, Heap::kWithContextMapRootIndex);
__ Check(ne, "Declaration in with context.",
a1, Operand(t0));
__ LoadRoot(t0, Heap::kCatchContextMapRootIndex);
__ Check(ne, "Declaration in catch context.",
a1, Operand(t0));
}
if (mode == Variable::CONST) {
__ LoadRoot(at, Heap::kTheHoleValueRootIndex);
__ sw(at, ContextOperand(cp, slot->index()));
// No write barrier since the_hole_value is in old space.
} else if (function != NULL) {
VisitForAccumulatorValue(function);
__ sw(result_register(), ContextOperand(cp, slot->index()));
int offset = Context::SlotOffset(slot->index());
// We know that we have written a function, which is not a smi.
__ mov(a1, cp);
__ RecordWrite(a1, Operand(offset), a2, result_register());
}
break;
case Slot::LOOKUP: {
__ li(a2, Operand(variable->name()));
// Declaration nodes are always introduced in one of two modes.
ASSERT(mode == Variable::VAR ||
mode == Variable::CONST ||
mode == Variable::LET);
PropertyAttributes attr = (mode == Variable::CONST) ? READ_ONLY : NONE;
__ li(a1, Operand(Smi::FromInt(attr)));
// Push initial value, if any.
// Note: For variables we must not push an initial value (such as
// 'undefined') because we may have a (legal) redeclaration and we
// must not destroy the current value.
if (mode == Variable::CONST) {
__ LoadRoot(a0, Heap::kTheHoleValueRootIndex);
__ Push(cp, a2, a1, a0);
} else if (function != NULL) {
__ Push(cp, a2, a1);
// Push initial value for function declaration.
VisitForStackValue(function);
} else {
ASSERT(Smi::FromInt(0) == 0);
// No initial value!
__ mov(a0, zero_reg); // Operand(Smi::FromInt(0)));
__ Push(cp, a2, a1, a0);
}
__ CallRuntime(Runtime::kDeclareContextSlot, 4);
break;
} }
} break;
} else if (prop != NULL) { case Slot::CONTEXT:
// A const declaration aliasing a parameter is an illegal redeclaration. // We bypass the general EmitSlotSearch because we know more about
ASSERT(mode != Variable::CONST); // this specific context.
if (function != NULL) {
// We are declaring a function that rewrites to a property. // The variable in the decl always resides in the current function
// Use (keyed) IC to set the initial value. We cannot visit the // context.
// rewrite because it's shared and we risk recording duplicate AST ASSERT_EQ(0, scope()->ContextChainLength(variable->scope()));
// IDs for bailouts from optimized code. if (FLAG_debug_code) {
ASSERT(prop->obj()->AsVariableProxy() != NULL); // Check that we're not inside a with or catch context.
{ AccumulatorValueContext for_object(this); __ lw(a1, FieldMemOperand(cp, HeapObject::kMapOffset));
EmitVariableLoad(prop->obj()->AsVariableProxy()); __ LoadRoot(t0, Heap::kWithContextMapRootIndex);
__ Check(ne, "Declaration in with context.",
a1, Operand(t0));
__ LoadRoot(t0, Heap::kCatchContextMapRootIndex);
__ Check(ne, "Declaration in catch context.",
a1, Operand(t0));
} }
if (mode == Variable::CONST) {
__ LoadRoot(at, Heap::kTheHoleValueRootIndex);
__ sw(at, ContextOperand(cp, slot->index()));
// No write barrier since the_hole_value is in old space.
} else if (function != NULL) {
VisitForAccumulatorValue(function);
__ sw(result_register(), ContextOperand(cp, slot->index()));
int offset = Context::SlotOffset(slot->index());
// We know that we have written a function, which is not a smi.
__ mov(a1, cp);
__ RecordWrite(a1, Operand(offset), a2, result_register());
}
break;
__ push(result_register()); case Slot::LOOKUP: {
VisitForAccumulatorValue(function); __ li(a2, Operand(variable->name()));
__ mov(a0, result_register()); // Declaration nodes are always introduced in one of two modes.
__ pop(a2); ASSERT(mode == Variable::VAR ||
mode == Variable::CONST ||
ASSERT(prop->key()->AsLiteral() != NULL && mode == Variable::LET);
prop->key()->AsLiteral()->handle()->IsSmi()); PropertyAttributes attr = (mode == Variable::CONST) ? READ_ONLY : NONE;
__ li(a1, Operand(prop->key()->AsLiteral()->handle())); __ li(a1, Operand(Smi::FromInt(attr)));
// Push initial value, if any.
Handle<Code> ic = is_strict_mode() // Note: For variables we must not push an initial value (such as
? isolate()->builtins()->KeyedStoreIC_Initialize_Strict() // 'undefined') because we may have a (legal) redeclaration and we
: isolate()->builtins()->KeyedStoreIC_Initialize(); // must not destroy the current value.
__ Call(ic); if (mode == Variable::CONST) {
// Value in v0 is ignored (declarations are statements). __ LoadRoot(a0, Heap::kTheHoleValueRootIndex);
__ Push(cp, a2, a1, a0);
} else if (function != NULL) {
__ Push(cp, a2, a1);
// Push initial value for function declaration.
VisitForStackValue(function);
} else {
ASSERT(Smi::FromInt(0) == 0);
// No initial value!
__ mov(a0, zero_reg); // Operand(Smi::FromInt(0)));
__ Push(cp, a2, a1, a0);
}
__ CallRuntime(Runtime::kDeclareContextSlot, 4);
break;
} }
} }
} }
@ -2286,36 +2253,10 @@ void FullCodeGenerator::VisitCall(Call* expr) {
EmitCallWithIC(expr, key->handle(), RelocInfo::CODE_TARGET); EmitCallWithIC(expr, key->handle(), RelocInfo::CODE_TARGET);
} else { } else {
// Call to a keyed property. // Call to a keyed property.
// For a synthetic property use keyed load IC followed by function call, { PreservePositionScope scope(masm()->positions_recorder());
// for a regular property use EmitKeyedCallWithIC. VisitForStackValue(prop->obj());
if (prop->is_synthetic()) {
// Do not visit the object and key subexpressions (they are shared
// by all occurrences of the same rewritten parameter).
ASSERT(prop->obj()->AsVariableProxy() != NULL);
ASSERT(prop->obj()->AsVariableProxy()->var()->AsSlot() != NULL);
Slot* slot = prop->obj()->AsVariableProxy()->var()->AsSlot();
MemOperand operand = EmitSlotSearch(slot, a1);
__ lw(a1, operand);
ASSERT(prop->key()->AsLiteral() != NULL);
ASSERT(prop->key()->AsLiteral()->handle()->IsSmi());
__ li(a0, Operand(prop->key()->AsLiteral()->handle()));
// Record source code position for IC call.
SetSourcePosition(prop->position());
Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize();
__ Call(ic, RelocInfo::CODE_TARGET, GetPropertyId(prop));
__ lw(a1, GlobalObjectOperand());
__ lw(a1, FieldMemOperand(a1, GlobalObject::kGlobalReceiverOffset));
__ Push(v0, a1); // Function, receiver.
EmitCallWithStub(expr, NO_CALL_FUNCTION_FLAGS);
} else {
{ PreservePositionScope scope(masm()->positions_recorder());
VisitForStackValue(prop->obj());
}
EmitKeyedCallWithIC(expr, prop->key());
} }
EmitKeyedCallWithIC(expr, prop->key());
} }
} else { } else {
{ PreservePositionScope scope(masm()->positions_recorder()); { PreservePositionScope scope(masm()->positions_recorder());
@ -3653,18 +3594,12 @@ void FullCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) {
Variable* var = expr->expression()->AsVariableProxy()->AsVariable(); Variable* var = expr->expression()->AsVariableProxy()->AsVariable();
if (prop != NULL) { if (prop != NULL) {
if (prop->is_synthetic()) { VisitForStackValue(prop->obj());
// Result of deleting parameters is false, even when they rewrite VisitForStackValue(prop->key());
// to accesses on the arguments object. __ li(a1, Operand(Smi::FromInt(strict_mode_flag())));
context()->Plug(false); __ push(a1);
} else { __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION);
VisitForStackValue(prop->obj()); context()->Plug(v0);
VisitForStackValue(prop->key());
__ li(a1, Operand(Smi::FromInt(strict_mode_flag())));
__ push(a1);
__ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION);
context()->Plug(v0);
}
} else if (var != NULL) { } else if (var != NULL) {
// Delete of an unqualified identifier is disallowed in strict mode // Delete of an unqualified identifier is disallowed in strict mode
// but "delete this" is. // but "delete this" is.

View File

@ -45,7 +45,6 @@ namespace internal {
static unsigned GetPropertyId(Property* property) { static unsigned GetPropertyId(Property* property) {
if (property->is_synthetic()) return AstNode::kNoNumber;
return property->id(); return property->id();
} }
@ -665,97 +664,69 @@ void FullCodeGenerator::EmitDeclaration(Variable* variable,
Comment cmnt(masm_, "[ Declaration"); Comment cmnt(masm_, "[ Declaration");
ASSERT(variable != NULL); // Must have been resolved. ASSERT(variable != NULL); // Must have been resolved.
Slot* slot = variable->AsSlot(); Slot* slot = variable->AsSlot();
Property* prop = variable->AsProperty(); ASSERT(slot != NULL);
switch (slot->type()) {
if (slot != NULL) { case Slot::PARAMETER:
switch (slot->type()) { case Slot::LOCAL:
case Slot::PARAMETER: if (mode == Variable::CONST) {
case Slot::LOCAL: __ LoadRoot(kScratchRegister, Heap::kTheHoleValueRootIndex);
if (mode == Variable::CONST) { __ movq(Operand(rbp, SlotOffset(slot)), kScratchRegister);
__ LoadRoot(kScratchRegister, Heap::kTheHoleValueRootIndex); } else if (function != NULL) {
__ movq(Operand(rbp, SlotOffset(slot)), kScratchRegister); VisitForAccumulatorValue(function);
} else if (function != NULL) { __ movq(Operand(rbp, SlotOffset(slot)), result_register());
VisitForAccumulatorValue(function);
__ movq(Operand(rbp, SlotOffset(slot)), result_register());
}
break;
case Slot::CONTEXT:
// We bypass the general EmitSlotSearch because we know more about
// this specific context.
// The variable in the decl always resides in the current function
// context.
ASSERT_EQ(0, scope()->ContextChainLength(variable->scope()));
if (FLAG_debug_code) {
// Check that we're not inside a with or catch context.
__ movq(rbx, FieldOperand(rsi, HeapObject::kMapOffset));
__ CompareRoot(rbx, Heap::kWithContextMapRootIndex);
__ Check(not_equal, "Declaration in with context.");
__ CompareRoot(rbx, Heap::kCatchContextMapRootIndex);
__ Check(not_equal, "Declaration in catch context.");
}
if (mode == Variable::CONST) {
__ LoadRoot(kScratchRegister, Heap::kTheHoleValueRootIndex);
__ movq(ContextOperand(rsi, slot->index()), kScratchRegister);
// No write barrier since the hole value is in old space.
} else if (function != NULL) {
VisitForAccumulatorValue(function);
__ movq(ContextOperand(rsi, slot->index()), result_register());
int offset = Context::SlotOffset(slot->index());
__ movq(rbx, rsi);
__ RecordWrite(rbx, offset, result_register(), rcx);
}
break;
case Slot::LOOKUP: {
__ push(rsi);
__ Push(variable->name());
// Declaration nodes are always introduced in one of two modes.
ASSERT(mode == Variable::VAR ||
mode == Variable::CONST ||
mode == Variable::LET);
PropertyAttributes attr = (mode == Variable::CONST) ? READ_ONLY : NONE;
__ Push(Smi::FromInt(attr));
// Push initial value, if any.
// Note: For variables we must not push an initial value (such as
// 'undefined') because we may have a (legal) redeclaration and we
// must not destroy the current value.
if (mode == Variable::CONST) {
__ PushRoot(Heap::kTheHoleValueRootIndex);
} else if (function != NULL) {
VisitForStackValue(function);
} else {
__ Push(Smi::FromInt(0)); // no initial value!
}
__ CallRuntime(Runtime::kDeclareContextSlot, 4);
break;
} }
} break;
} else if (prop != NULL) { case Slot::CONTEXT:
// A const declaration aliasing a parameter is an illegal redeclaration. // We bypass the general EmitSlotSearch because we know more about
ASSERT(mode != Variable::CONST); // this specific context.
if (function != NULL) {
// We are declaring a function that rewrites to a property. // The variable in the decl always resides in the current function
// Use (keyed) IC to set the initial value. We cannot visit the // context.
// rewrite because it's shared and we risk recording duplicate AST ASSERT_EQ(0, scope()->ContextChainLength(variable->scope()));
// IDs for bailouts from optimized code. if (FLAG_debug_code) {
ASSERT(prop->obj()->AsVariableProxy() != NULL); // Check that we're not inside a with or catch context.
{ AccumulatorValueContext for_object(this); __ movq(rbx, FieldOperand(rsi, HeapObject::kMapOffset));
EmitVariableLoad(prop->obj()->AsVariableProxy()); __ CompareRoot(rbx, Heap::kWithContextMapRootIndex);
__ Check(not_equal, "Declaration in with context.");
__ CompareRoot(rbx, Heap::kCatchContextMapRootIndex);
__ Check(not_equal, "Declaration in catch context.");
} }
__ push(rax); if (mode == Variable::CONST) {
VisitForAccumulatorValue(function); __ LoadRoot(kScratchRegister, Heap::kTheHoleValueRootIndex);
__ pop(rdx); __ movq(ContextOperand(rsi, slot->index()), kScratchRegister);
ASSERT(prop->key()->AsLiteral() != NULL && // No write barrier since the hole value is in old space.
prop->key()->AsLiteral()->handle()->IsSmi()); } else if (function != NULL) {
__ Move(rcx, prop->key()->AsLiteral()->handle()); VisitForAccumulatorValue(function);
__ movq(ContextOperand(rsi, slot->index()), result_register());
int offset = Context::SlotOffset(slot->index());
__ movq(rbx, rsi);
__ RecordWrite(rbx, offset, result_register(), rcx);
}
break;
Handle<Code> ic = is_strict_mode() case Slot::LOOKUP: {
? isolate()->builtins()->KeyedStoreIC_Initialize_Strict() __ push(rsi);
: isolate()->builtins()->KeyedStoreIC_Initialize(); __ Push(variable->name());
__ call(ic); // Declaration nodes are always introduced in one of two modes.
ASSERT(mode == Variable::VAR ||
mode == Variable::CONST ||
mode == Variable::LET);
PropertyAttributes attr = (mode == Variable::CONST) ? READ_ONLY : NONE;
__ Push(Smi::FromInt(attr));
// Push initial value, if any.
// Note: For variables we must not push an initial value (such as
// 'undefined') because we may have a (legal) redeclaration and we
// must not destroy the current value.
if (mode == Variable::CONST) {
__ PushRoot(Heap::kTheHoleValueRootIndex);
} else if (function != NULL) {
VisitForStackValue(function);
} else {
__ Push(Smi::FromInt(0)); // no initial value!
}
__ CallRuntime(Runtime::kDeclareContextSlot, 4);
break;
} }
} }
} }
@ -2169,38 +2140,10 @@ void FullCodeGenerator::VisitCall(Call* expr) {
EmitCallWithIC(expr, key->handle(), RelocInfo::CODE_TARGET); EmitCallWithIC(expr, key->handle(), RelocInfo::CODE_TARGET);
} else { } else {
// Call to a keyed property. // Call to a keyed property.
// For a synthetic property use keyed load IC followed by function call, { PreservePositionScope scope(masm()->positions_recorder());
// for a regular property use EmitKeyedCallWithIC. VisitForStackValue(prop->obj());
if (prop->is_synthetic()) {
// Do not visit the object and key subexpressions (they are shared
// by all occurrences of the same rewritten parameter).
ASSERT(prop->obj()->AsVariableProxy() != NULL);
ASSERT(prop->obj()->AsVariableProxy()->var()->AsSlot() != NULL);
Slot* slot = prop->obj()->AsVariableProxy()->var()->AsSlot();
MemOperand operand = EmitSlotSearch(slot, rdx);
__ movq(rdx, operand);
ASSERT(prop->key()->AsLiteral() != NULL);
ASSERT(prop->key()->AsLiteral()->handle()->IsSmi());
__ Move(rax, prop->key()->AsLiteral()->handle());
// Record source code position for IC call.
SetSourcePosition(prop->position());
Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize();
__ call(ic, RelocInfo::CODE_TARGET, GetPropertyId(prop));
// Push result (function).
__ push(rax);
// Push Global receiver.
__ movq(rcx, GlobalObjectOperand());
__ push(FieldOperand(rcx, GlobalObject::kGlobalReceiverOffset));
EmitCallWithStub(expr, NO_CALL_FUNCTION_FLAGS);
} else {
{ PreservePositionScope scope(masm()->positions_recorder());
VisitForStackValue(prop->obj());
}
EmitKeyedCallWithIC(expr, prop->key());
} }
EmitKeyedCallWithIC(expr, prop->key());
} }
} else { } else {
{ PreservePositionScope scope(masm()->positions_recorder()); { PreservePositionScope scope(masm()->positions_recorder());
@ -3566,17 +3509,11 @@ void FullCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) {
Variable* var = expr->expression()->AsVariableProxy()->AsVariable(); Variable* var = expr->expression()->AsVariableProxy()->AsVariable();
if (prop != NULL) { if (prop != NULL) {
if (prop->is_synthetic()) { VisitForStackValue(prop->obj());
// Result of deleting parameters is false, even when they rewrite VisitForStackValue(prop->key());
// to accesses on the arguments object. __ Push(Smi::FromInt(strict_mode_flag()));
context()->Plug(false); __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION);
} else { context()->Plug(rax);
VisitForStackValue(prop->obj());
VisitForStackValue(prop->key());
__ Push(Smi::FromInt(strict_mode_flag()));
__ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION);
context()->Plug(rax);
}
} else if (var != NULL) { } else if (var != NULL) {
// Delete of an unqualified identifier is disallowed in strict mode // Delete of an unqualified identifier is disallowed in strict mode
// but "delete this" is. // but "delete this" is.