Reviewers: adamk, rossberg, wingo,
Message:
PTAL --- this is working locally.
I've not tested with computed properties in classes (it could be that there
is
still a bug with nested class expressions in object literals or arrays?).
There may be a performance regression, but it would only because work was
not
being done that needed to be done before.
Description:
[es6] fix object literals with computed property names
Now, if a literal contains computed properties, it is non-simple and
must be build with the runtime. This ensures the correct behaviour.
BUG=v8:4387
LOG=N
R=adamk, rossberg, wingo
Please review this at https://codereview.chromium.org/1307223002/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+13, -1 lines):
M src/ast.cc
M test/mjsunit/es6/computed-property-names.js
Index: src/ast.cc
diff --git a/src/ast.cc b/src/ast.cc
index
624d462323a9574c278af3e01a240976509239ac..eea011034cfcb7761f5a5a3506cf05afcc547315
100644
--- a/src/ast.cc
+++ b/src/ast.cc
@@ -433,7 +433,8 @@ void ObjectLiteral::BuildConstantProperties(Isolate*
isolate) {
int position = 0;
// Accumulate the value in local variables and store it at the end.
- bool is_simple = true;
+ // If computed properties are used, the literal is never simple.
+ bool is_simple = boilerplate_properties_ != 0 || properties()->length()
== 0;
int depth_acc = 1;
uint32_t max_element_index = 0;
uint32_t elements = 0;
Index: test/mjsunit/es6/computed-property-names.js
diff --git a/test/mjsunit/es6/computed-property-names.js
b/test/mjsunit/es6/computed-property-names.js
index
80a047cc9cd3491aca0d9d9bacd390329e08606a..8c1aeb52af756480042ac174055f4f2c4f9a1caa
100644
--- a/test/mjsunit/es6/computed-property-names.js
+++ b/test/mjsunit/es6/computed-property-names.js
@@ -298,3 +298,14 @@ function ID(x) {
};
}, MyError);
})();
+
+
+(function TestNestedLiteral() {
+ var key = "test";
+ for (var i = 0; i < 10; ++i) {
+ assertEquals(i, ({ a: { [key + i]: i } }).a[key + i]);
+ assertEquals(i, ({ a: { b: { [key + i]: i } } }).a.b[key + i]);
+ assertEquals(i, ([ { [key + i]: i } ])[0][key + i]);
+ assertEquals(i, ([ { b: { [key + i]: i } } ])[0].b[key + i]);
+ }
+})();
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.