Revision: 22370
Author: rossb...@chromium.org
Date: Mon Jul 14 10:59:29 2014 UTC
Log: Include symbol properties in Object.{create,defineProperties}
R=mstarzin...@chromium.org
BUG=v8:3440
LOG=Y
Review URL: https://codereview.chromium.org/391683002
http://code.google.com/p/v8/source/detail?r=22370
Modified:
/branches/bleeding_edge/src/v8natives.js
/branches/bleeding_edge/test/mjsunit/es6/symbols.js
=======================================
--- /branches/bleeding_edge/src/v8natives.js Tue Jul 1 12:12:34 2014 UTC
+++ /branches/bleeding_edge/src/v8natives.js Mon Jul 14 10:59:29 2014 UTC
@@ -1171,13 +1171,21 @@
}
-function GetOwnEnumerablePropertyNames(properties) {
+function GetOwnEnumerablePropertyNames(object) {
var names = new InternalArray();
- for (var key in properties) {
- if (%HasOwnProperty(properties, key)) {
+ for (var key in object) {
+ if (%HasOwnProperty(object, key)) {
names.push(key);
}
}
+ // FLAG_harmony_symbols may be on, but symbols aren't included by for-in.
+ var symbols = ObjectGetOwnPropertyKeys(object, true);
+ for (var i in symbols) {
+ var symbol = symbols[i];
+ if (ObjectGetOwnPropertyDescriptor(object, symbol).enumerable) {
+ names.push(symbol);
+ }
+ }
return names;
}
=======================================
--- /branches/bleeding_edge/test/mjsunit/es6/symbols.js Fri May 16 14:42:02
2014 UTC
+++ /branches/bleeding_edge/test/mjsunit/es6/symbols.js Mon Jul 14 10:59:29
2014 UTC
@@ -367,6 +367,34 @@
}
+function TestDefineProperties() {
+ var properties = {}
+ for (var i in symbols) {
+ Object.defineProperty(
+ properties, symbols[i], {value: {value: i}, enumerable: i % 2 ===
0})
+ }
+ var o = Object.defineProperties({}, properties)
+ for (var i in symbols) {
+ assertEquals(i % 2 === 0, symbols[i] in o)
+ }
+}
+TestDefineProperties()
+
+
+function TestCreate() {
+ var properties = {}
+ for (var i in symbols) {
+ Object.defineProperty(
+ properties, symbols[i], {value: {value: i}, enumerable: i % 2 === 0})
+ }
+ var o = Object.create(Object.prototype, properties)
+ for (var i in symbols) {
+ assertEquals(i % 2 === 0, symbols[i] in o)
+ }
+}
+TestCreate()
+
+
function TestCachedKeyAfterScavenge() {
gc();
// Keyed property lookup are cached. Hereby we assume that the keys are
--
--
v8-dev mailing list
v8-dev@googlegroups.com
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 v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.