Commit b5e23566 authored by arv's avatar arv Committed by Commit bot

Fix issue with super and computed property names

We did not set up the [[HomeObject]] for properties created for
computed property names.

BUG=v8:3879
LOG=N
R=dslomov@chromium.org

Review URL: https://codereview.chromium.org/914773002

Cr-Commit-Position: refs/heads/master@{#26586}
parent a6f0a373
......@@ -1825,6 +1825,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
} else {
EmitPropertyKey(property, expr->GetIdForProperty(property_index));
VisitForStackValue(value);
EmitSetHomeObjectIfNeeded(value, 2);
switch (property->kind()) {
case ObjectLiteral::Property::CONSTANT:
......
......@@ -1806,6 +1806,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
} else {
EmitPropertyKey(property, expr->GetIdForProperty(property_index));
VisitForStackValue(value);
EmitSetHomeObjectIfNeeded(value, 2);
switch (property->kind()) {
case ObjectLiteral::Property::CONSTANT:
......
......@@ -1747,6 +1747,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
} else {
EmitPropertyKey(property, expr->GetIdForProperty(property_index));
VisitForStackValue(value);
EmitSetHomeObjectIfNeeded(value, 2);
switch (property->kind()) {
case ObjectLiteral::Property::CONSTANT:
......
......@@ -1801,6 +1801,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
} else {
EmitPropertyKey(property, expr->GetIdForProperty(property_index));
VisitForStackValue(value);
EmitSetHomeObjectIfNeeded(value, 2);
switch (property->kind()) {
case ObjectLiteral::Property::CONSTANT:
......
......@@ -1798,6 +1798,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
} else {
EmitPropertyKey(property, expr->GetIdForProperty(property_index));
VisitForStackValue(value);
EmitSetHomeObjectIfNeeded(value, 2);
switch (property->kind()) {
case ObjectLiteral::Property::CONSTANT:
......
......@@ -1767,6 +1767,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
} else {
EmitPropertyKey(property, expr->GetIdForProperty(property_index));
VisitForStackValue(value);
EmitSetHomeObjectIfNeeded(value, 2);
switch (property->kind()) {
case ObjectLiteral::Property::CONSTANT:
......
......@@ -1782,6 +1782,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
} else {
EmitPropertyKey(property, expr->GetIdForProperty(property_index));
VisitForStackValue(value);
EmitSetHomeObjectIfNeeded(value, 2);
switch (property->kind()) {
case ObjectLiteral::Property::CONSTANT:
......
......@@ -1727,6 +1727,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
} else {
EmitPropertyKey(property, expr->GetIdForProperty(property_index));
VisitForStackValue(value);
EmitSetHomeObjectIfNeeded(value, 2);
switch (property->kind()) {
case ObjectLiteral::Property::CONSTANT:
......
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-computed-property-names --harmony-sloppy
// Flags: --harmony-classes --allow-natives-syntax
function ID(x) {
return x;
}
(function TestComputedMethodSuper() {
class Base {
m() {
return ' base m';
}
}
class Derived extends Base {
['a']() { return 'a' + super.m(); }
[ID('b')]() { return 'b' + super.m(); }
[0]() { return '0' + super.m(); }
[ID(1)]() { return '1' + super.m(); }
}
assertSame(Derived.prototype, Derived.prototype.a[%HomeObjectSymbol()]);
assertEquals('a base m', new Derived().a());
assertEquals('b base m', new Derived().b());
assertEquals('0 base m', new Derived()[0]());
assertEquals('1 base m', new Derived()[1]());
})();
(function TestComputedGetterSuper() {
class Base {
m() {
return ' base m';
}
}
class Derived extends Base {
get ['a']() { return 'a' + super.m(); }
get [ID('b')]() { return 'b' + super.m(); }
get [0]() { return '0' + super.m(); }
get [ID(1)]() { return '1' + super.m(); }
}
assertEquals('a base m', new Derived().a);
assertEquals('b base m', new Derived().b);
assertEquals('0 base m', new Derived()[0]);
assertEquals('1 base m', new Derived()[1]);
})();
(function TestComputedSetterSuper() {
var value;
class Base {
m(name, v) {
value = name + ' ' + v;
}
}
class Derived extends Base {
set ['a'](v) { super.m('a', v); }
set [ID('b')](v) { super.m('b', v); }
set [0](v) { super.m('0', v); }
set [ID(1)](v) { super.m('1', v); }
}
new Derived().a = 2;
assertEquals('a 2', value);
new Derived().b = 3;
assertEquals('b 3', value);
new Derived()[0] = 4;
assertEquals('0 4', value);
new Derived()[1] = 5;
assertEquals('1 5', value);
})();
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-computed-property-names --harmony-object-literals
// Flags: --harmony-classes --allow-natives-syntax
function ID(x) {
return x;
}
(function TestComputedMethodSuper() {
var proto = {
m() {
return ' proto m';
}
};
var object = {
__proto__: proto,
['a']() { return 'a' + super.m(); },
[ID('b')]() { return 'b' + super.m(); },
[0]() { return '0' + super.m(); },
[ID(1)]() { return '1' + super.m(); },
};
assertSame(object, object.a[%HomeObjectSymbol()]);
assertEquals('a proto m', object.a());
assertEquals('b proto m', object.b());
assertEquals('0 proto m', object[0]());
assertEquals('1 proto m', object[1]());
})();
(function TestComputedGetterSuper() {
var proto = {
m() {
return ' proto m';
}
};
var object = {
__proto__: proto,
get ['a']() { return 'a' + super.m(); },
get [ID('b')]() { return 'b' + super.m(); },
get [0]() { return '0' + super.m(); },
get [ID(1)]() { return '1' + super.m(); },
};
assertEquals('a proto m', object.a);
assertEquals('b proto m', object.b);
assertEquals('0 proto m', object[0]);
assertEquals('1 proto m', object[1]);
})();
(function TestComputedSetterSuper() {
var value;
var proto = {
m(name, v) {
value = name + ' ' + v;
}
};
var object = {
__proto__: proto,
set ['a'](v) { super.m('a', v); },
set [ID('b')](v) { super.m('b', v); },
set [0](v) { super.m('0', v); },
set [ID(1)](v) { super.m('1', v); },
};
object.a = 2;
assertEquals('a 2', value);
object.b = 3;
assertEquals('b 3', value);
object[0] = 4;
assertEquals('0 4', value);
object[1] = 5;
assertEquals('1 5', value);
})();
......@@ -118,6 +118,7 @@
# TODO(arv): TurboFan does not yet add [[HomeObject]] as needed.
'harmony/object-literals-super': [PASS, NO_VARIANTS],
'harmony/super': [PASS, NO_VARIANTS],
'harmony/computed-property-names-super': [PASS, NO_VARIANTS],
##############################################################################
# Too slow in debug mode with --stress-opt mode.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment