EmitNamedPropertyAssignment(expr);
break;
case NAMED_SUPER_PROPERTY:
- EmitNamedSuperPropertyAssignment(expr);
+ EmitNamedSuperPropertyStore(property);
+ context()->Plug(r0);
break;
case KEYED_PROPERTY:
EmitKeyedPropertyAssignment(expr);
}
-void FullCodeGenerator::EmitNamedSuperPropertyAssignment(Assignment* expr) {
+void FullCodeGenerator::EmitNamedSuperPropertyStore(Property* prop) {
// Assignment to named property of super.
// r0 : value
// stack : receiver ('this'), home_object
- Property* prop = expr->target()->AsProperty();
DCHECK(prop != NULL);
Literal* key = prop->key()->AsLiteral();
DCHECK(key != NULL);
__ CallRuntime((strict_mode() == STRICT ? Runtime::kStoreToSuper_Strict
: Runtime::kStoreToSuper_Sloppy),
4);
- context()->Plug(r0);
}
// Expression can only be a property, a global or a (parameter or local)
// slot.
- enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY };
+ enum LhsKind {
+ VARIABLE,
+ NAMED_PROPERTY,
+ KEYED_PROPERTY,
+ NAMED_SUPER_PROPERTY
+ };
LhsKind assign_type = VARIABLE;
Property* prop = expr->expression()->AsProperty();
// In case of a property we use the uninitialized expression context
// of the key to detect a named property.
if (prop != NULL) {
assign_type =
- (prop->key()->IsPropertyName()) ? NAMED_PROPERTY : KEYED_PROPERTY;
- if (prop->IsSuperAccess()) {
- // throw exception.
- VisitSuperReference(prop->obj()->AsSuperReference());
- return;
- }
+ (prop->key()->IsPropertyName())
+ ? (prop->IsSuperAccess() ? NAMED_SUPER_PROPERTY : NAMED_PROPERTY)
+ : KEYED_PROPERTY;
}
// Evaluate expression and get value.
VisitForStackValue(prop->obj());
__ ldr(LoadDescriptor::ReceiverRegister(), MemOperand(sp, 0));
EmitNamedPropertyLoad(prop);
+ } else if (assign_type == NAMED_SUPER_PROPERTY) {
+ VisitForStackValue(prop->obj()->AsSuperReference()->this_var());
+ EmitLoadHomeObject(prop->obj()->AsSuperReference());
+ __ Push(result_register());
+ const Register scratch = r1;
+ __ ldr(scratch, MemOperand(sp, kPointerSize));
+ __ Push(scratch);
+ __ Push(result_register());
+ EmitNamedSuperPropertyLoad(prop);
} else {
VisitForStackValue(prop->obj());
VisitForStackValue(prop->key());
case NAMED_PROPERTY:
__ str(r0, MemOperand(sp, kPointerSize));
break;
+ case NAMED_SUPER_PROPERTY:
+ __ str(r0, MemOperand(sp, 2 * kPointerSize));
+ break;
case KEYED_PROPERTY:
__ str(r0, MemOperand(sp, 2 * kPointerSize));
break;
case NAMED_PROPERTY:
__ str(r0, MemOperand(sp, kPointerSize));
break;
+ case NAMED_SUPER_PROPERTY:
+ __ str(r0, MemOperand(sp, 2 * kPointerSize));
+ break;
case KEYED_PROPERTY:
__ str(r0, MemOperand(sp, 2 * kPointerSize));
break;
}
break;
}
+ case NAMED_SUPER_PROPERTY: {
+ EmitNamedSuperPropertyStore(prop);
+ if (expr->is_postfix()) {
+ if (!context()->IsEffect()) {
+ context()->PlugTOS();
+ }
+ } else {
+ context()->Plug(r0);
+ }
+ break;
+ }
case KEYED_PROPERTY: {
__ Pop(StoreDescriptor::ReceiverRegister(),
StoreDescriptor::NameRegister());
EmitNamedPropertyAssignment(expr);
break;
case NAMED_SUPER_PROPERTY:
- EmitNamedSuperPropertyAssignment(expr);
+ EmitNamedSuperPropertyStore(property);
+ context()->Plug(x0);
break;
case KEYED_PROPERTY:
EmitKeyedPropertyAssignment(expr);
}
-void FullCodeGenerator::EmitNamedSuperPropertyAssignment(Assignment* expr) {
+void FullCodeGenerator::EmitNamedSuperPropertyStore(Property* prop) {
// Assignment to named property of super.
// x0 : value
// stack : receiver ('this'), home_object
- Property* prop = expr->target()->AsProperty();
DCHECK(prop != NULL);
Literal* key = prop->key()->AsLiteral();
DCHECK(key != NULL);
__ CallRuntime((strict_mode() == STRICT ? Runtime::kStoreToSuper_Strict
: Runtime::kStoreToSuper_Sloppy),
4);
- context()->Plug(x0);
}
// Expression can only be a property, a global or a (parameter or local)
// slot.
- enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY };
+ enum LhsKind {
+ VARIABLE,
+ NAMED_PROPERTY,
+ KEYED_PROPERTY,
+ NAMED_SUPER_PROPERTY
+ };
LhsKind assign_type = VARIABLE;
Property* prop = expr->expression()->AsProperty();
// In case of a property we use the uninitialized expression context
// of the key to detect a named property.
if (prop != NULL) {
assign_type =
- (prop->key()->IsPropertyName()) ? NAMED_PROPERTY : KEYED_PROPERTY;
- if (prop->IsSuperAccess()) {
- // throw exception.
- VisitSuperReference(prop->obj()->AsSuperReference());
- return;
- }
+ (prop->key()->IsPropertyName())
+ ? (prop->IsSuperAccess() ? NAMED_SUPER_PROPERTY : NAMED_PROPERTY)
+ : KEYED_PROPERTY;
}
// Evaluate expression and get value.
VisitForStackValue(prop->obj());
__ Peek(LoadDescriptor::ReceiverRegister(), 0);
EmitNamedPropertyLoad(prop);
+ } else if (assign_type == NAMED_SUPER_PROPERTY) {
+ VisitForStackValue(prop->obj()->AsSuperReference()->this_var());
+ EmitLoadHomeObject(prop->obj()->AsSuperReference());
+ __ Push(result_register());
+ const Register scratch = x10;
+ __ Peek(scratch, kPointerSize);
+ __ Push(scratch, result_register());
+ EmitNamedSuperPropertyLoad(prop);
} else {
// KEYED_PROPERTY
VisitForStackValue(prop->obj());
case NAMED_PROPERTY:
__ Poke(x0, kPointerSize);
break;
+ case NAMED_SUPER_PROPERTY:
+ __ Poke(x0, kPointerSize * 2);
+ break;
case KEYED_PROPERTY:
__ Poke(x0, kPointerSize * 2);
break;
case NAMED_PROPERTY:
__ Poke(x0, kXRegSize);
break;
+ case NAMED_SUPER_PROPERTY:
+ __ Poke(x0, 2 * kXRegSize);
+ break;
case KEYED_PROPERTY:
__ Poke(x0, 2 * kXRegSize);
break;
}
break;
}
+ case NAMED_SUPER_PROPERTY: {
+ EmitNamedSuperPropertyStore(prop);
+ if (expr->is_postfix()) {
+ if (!context()->IsEffect()) {
+ context()->PlugTOS();
+ }
+ } else {
+ context()->Plug(x0);
+ }
+ break;
+ }
case KEYED_PROPERTY: {
__ Pop(StoreDescriptor::NameRegister());
__ Pop(StoreDescriptor::ReceiverRegister());
// Complete a super named property assignment. The right-hand-side value
// is expected in accumulator.
- void EmitNamedSuperPropertyAssignment(Assignment* expr);
+ void EmitNamedSuperPropertyStore(Property* prop);
// Complete a keyed property assignment. The receiver and key are
// expected on top of the stack and the right-hand-side value in the
EmitNamedPropertyAssignment(expr);
break;
case NAMED_SUPER_PROPERTY:
- EmitNamedSuperPropertyAssignment(expr);
+ EmitNamedSuperPropertyStore(property);
+ context()->Plug(eax);
break;
case KEYED_PROPERTY:
EmitKeyedPropertyAssignment(expr);
}
-void FullCodeGenerator::EmitNamedSuperPropertyAssignment(Assignment* expr) {
+void FullCodeGenerator::EmitNamedSuperPropertyStore(Property* prop) {
// Assignment to named property of super.
// eax : value
// stack : receiver ('this'), home_object
- Property* prop = expr->target()->AsProperty();
DCHECK(prop != NULL);
Literal* key = prop->key()->AsLiteral();
DCHECK(key != NULL);
__ CallRuntime((strict_mode() == STRICT ? Runtime::kStoreToSuper_Strict
: Runtime::kStoreToSuper_Sloppy),
4);
- context()->Plug(eax);
}
// Expression can only be a property, a global or a (parameter or local)
// slot.
- enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY };
+ enum LhsKind {
+ VARIABLE,
+ NAMED_PROPERTY,
+ KEYED_PROPERTY,
+ NAMED_SUPER_PROPERTY
+ };
LhsKind assign_type = VARIABLE;
Property* prop = expr->expression()->AsProperty();
// In case of a property we use the uninitialized expression context
// of the key to detect a named property.
if (prop != NULL) {
assign_type =
- (prop->key()->IsPropertyName()) ? NAMED_PROPERTY : KEYED_PROPERTY;
- if (prop->IsSuperAccess()) {
- // throw exception.
- VisitSuperReference(prop->obj()->AsSuperReference());
- return;
- }
+ (prop->key()->IsPropertyName())
+ ? (prop->IsSuperAccess() ? NAMED_SUPER_PROPERTY : NAMED_PROPERTY)
+ : KEYED_PROPERTY;
}
// Evaluate expression and get value.
VisitForStackValue(prop->obj());
__ mov(LoadDescriptor::ReceiverRegister(), Operand(esp, 0));
EmitNamedPropertyLoad(prop);
+ } else if (assign_type == NAMED_SUPER_PROPERTY) {
+ VisitForStackValue(prop->obj()->AsSuperReference()->this_var());
+ EmitLoadHomeObject(prop->obj()->AsSuperReference());
+ __ push(result_register());
+ __ push(MemOperand(esp, kPointerSize));
+ __ push(result_register());
+ EmitNamedSuperPropertyLoad(prop);
} else {
VisitForStackValue(prop->obj());
VisitForStackValue(prop->key());
case NAMED_PROPERTY:
__ mov(Operand(esp, kPointerSize), eax);
break;
+ case NAMED_SUPER_PROPERTY:
+ __ mov(Operand(esp, 2 * kPointerSize), eax);
+ break;
case KEYED_PROPERTY:
__ mov(Operand(esp, 2 * kPointerSize), eax);
break;
case NAMED_PROPERTY:
__ mov(Operand(esp, kPointerSize), eax);
break;
+ case NAMED_SUPER_PROPERTY:
+ __ mov(Operand(esp, 2 * kPointerSize), eax);
+ break;
case KEYED_PROPERTY:
__ mov(Operand(esp, 2 * kPointerSize), eax);
break;
}
break;
}
+ case NAMED_SUPER_PROPERTY: {
+ EmitNamedSuperPropertyStore(prop);
+ if (expr->is_postfix()) {
+ if (!context()->IsEffect()) {
+ context()->PlugTOS();
+ }
+ } else {
+ context()->Plug(eax);
+ }
+ break;
+ }
case KEYED_PROPERTY: {
__ pop(StoreDescriptor::NameRegister());
__ pop(StoreDescriptor::ReceiverRegister());
EmitNamedPropertyAssignment(expr);
break;
case NAMED_SUPER_PROPERTY:
- EmitNamedSuperPropertyAssignment(expr);
+ EmitNamedSuperPropertyStore(property);
+ context()->Plug(rax);
break;
case KEYED_PROPERTY:
EmitKeyedPropertyAssignment(expr);
}
-void FullCodeGenerator::EmitNamedSuperPropertyAssignment(Assignment* expr) {
+void FullCodeGenerator::EmitNamedSuperPropertyStore(Property* prop) {
// Assignment to named property of super.
// rax : value
// stack : receiver ('this'), home_object
- Property* prop = expr->target()->AsProperty();
DCHECK(prop != NULL);
Literal* key = prop->key()->AsLiteral();
DCHECK(key != NULL);
__ CallRuntime((strict_mode() == STRICT ? Runtime::kStoreToSuper_Strict
: Runtime::kStoreToSuper_Sloppy),
4);
- context()->Plug(rax);
}
// Expression can only be a property, a global or a (parameter or local)
// slot.
- enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY };
+ enum LhsKind {
+ VARIABLE,
+ NAMED_PROPERTY,
+ KEYED_PROPERTY,
+ NAMED_SUPER_PROPERTY
+ };
LhsKind assign_type = VARIABLE;
Property* prop = expr->expression()->AsProperty();
// In case of a property we use the uninitialized expression context
// of the key to detect a named property.
if (prop != NULL) {
assign_type =
- (prop->key()->IsPropertyName()) ? NAMED_PROPERTY : KEYED_PROPERTY;
- if (prop->IsSuperAccess()) {
- // throw exception.
- VisitSuperReference(prop->obj()->AsSuperReference());
- return;
- }
+ (prop->key()->IsPropertyName())
+ ? (prop->IsSuperAccess() ? NAMED_SUPER_PROPERTY : NAMED_PROPERTY)
+ : KEYED_PROPERTY;
}
// Evaluate expression and get value.
VisitForStackValue(prop->obj());
__ movp(LoadDescriptor::ReceiverRegister(), Operand(rsp, 0));
EmitNamedPropertyLoad(prop);
+ } else if (assign_type == NAMED_SUPER_PROPERTY) {
+ VisitForStackValue(prop->obj()->AsSuperReference()->this_var());
+ EmitLoadHomeObject(prop->obj()->AsSuperReference());
+ __ Push(result_register());
+ __ Push(MemOperand(rsp, kPointerSize));
+ __ Push(result_register());
+ EmitNamedSuperPropertyLoad(prop);
} else {
VisitForStackValue(prop->obj());
VisitForStackValue(prop->key());
case NAMED_PROPERTY:
__ movp(Operand(rsp, kPointerSize), rax);
break;
+ case NAMED_SUPER_PROPERTY:
+ __ movp(Operand(rsp, 2 * kPointerSize), rax);
+ break;
case KEYED_PROPERTY:
__ movp(Operand(rsp, 2 * kPointerSize), rax);
break;
case NAMED_PROPERTY:
__ movp(Operand(rsp, kPointerSize), rax);
break;
+ case NAMED_SUPER_PROPERTY:
+ __ movp(Operand(rsp, 2 * kPointerSize), rax);
+ break;
case KEYED_PROPERTY:
__ movp(Operand(rsp, 2 * kPointerSize), rax);
break;
}
break;
}
+ case NAMED_SUPER_PROPERTY: {
+ EmitNamedSuperPropertyStore(prop);
+ if (expr->is_postfix()) {
+ if (!context()->IsEffect()) {
+ context()->PlugTOS();
+ }
+ } else {
+ context()->Plug(rax);
+ }
+ break;
+ }
case KEYED_PROPERTY: {
__ Pop(StoreDescriptor::NameRegister());
__ Pop(StoreDescriptor::ReceiverRegister());
}());
+(function TestCountOperations() {
+ function Base() {}
+ Base.prototype = {
+ constructor: Base,
+ get x() {
+ return this._x;
+ },
+ set x(v) {
+ this._x = v;
+ },
+ _x: 1
+ };
+
+ function Derived() {}
+ Derived.__proto__ = Base;
+ Derived.prototype = {
+ __proto__: Base.prototype,
+ constructor: Derived,
+ _x: 2
+ };
+
+ Derived.prototype.testCounts = function() {
+ assertEquals(2, this._x);
+ assertEquals(2, super.x);
+ super.x++;
+ assertEquals(3, super.x);
+ ++super.x;
+ assertEquals(4, super.x);
+ assertEquals(4, super.x++);
+ assertEquals(5, super.x);
+ assertEquals(6, ++super.x);
+ assertEquals(6, super.x);
+ assertEquals(6, this._x);
+
+ super.x--;
+ assertEquals(5, super.x);
+ --super.x;
+ assertEquals(4, super.x);
+ assertEquals(4, super.x--);
+ assertEquals(3, super.x);
+ assertEquals(2, --super.x);
+ assertEquals(2, super.x);
+ assertEquals(2, this._x);
+ }.toMethod(Derived.prototype);
+ new Derived().testCounts();
+}());
+
+
(function TestUnsupportedCases() {
function f1(x) { return super[x]; }
+ function f2(x) { super[x] = 5; }
var o = {}
assertThrows(function(){f1.toMethod(o)(x);}, ReferenceError);
- function f2() { super.x++; }
- assertThrows(function(){f2.toMethod(o)();}, ReferenceError);
+ assertThrows(function(){f2.toMethod(o)(x);}, ReferenceError);
}());