31d2bb8670
Fix 1: Track Scope::needs_home_object and Scope::uses_super_property accurately. When "eval" is seen, figure out whether it can access "super" and if yes, set the corresponding home object as needed. Fix 2: The object literal scope shouldn't be entered for things inside spreads. Original: https://chromium-review.googlesource.com/c/v8/v8/+/2563275 Previous reland: https://chromium-review.googlesource.com/c/v8/v8/+/2637220 This saves memory (the home object doesn't need to be stored for each method, but only once per class) and hopefully makes the home object a constant in the optimized code. Detailed documentation of the changes: https://docs.google.com/document/d/1ZVXcoQdf9IdMsnRI9iyUjyq9NDoEyx9nA3XqMgwflMs/edit?usp=sharing Bug: v8:9237 Bug: chromium:1167918 Bug: chromium:1167981 Bug: chromium:1167988 Bug: chromium:1168055 Bug: chromium:1171195 Bug: chromium:1171600 Change-Id: I9686e0d90cd0c1128757eca440a88748897ee91e Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2655509 Commit-Queue: Marja Hölttä <marja@chromium.org> Reviewed-by: Leszek Swirski <leszeks@chromium.org> Cr-Commit-Position: refs/heads/master@{#72422}
77 lines
1.7 KiB
JavaScript
77 lines
1.7 KiB
JavaScript
// 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: --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(); },
|
|
};
|
|
|
|
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);
|
|
})();
|