Reviewers: Michael Starzinger,

Description:
Include symbol properties in Object.{create,defineProperties}

R=mstarzin...@chromium.org
BUG=v8:3440
LOG=Y

Please review this at https://codereview.chromium.org/391683002/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+42, -3 lines):
  M src/v8natives.js
  M test/mjsunit/es6/symbols.js


Index: src/v8natives.js
diff --git a/src/v8natives.js b/src/v8natives.js
index 5ffff2ecacd9f789d475595aa506c3093d20bfe4..14c6c1b4eff2eea2e4e3687fc910716eb9567551 100644
--- a/src/v8natives.js
+++ b/src/v8natives.js
@@ -1171,13 +1171,24 @@ function ObjectDefineProperty(obj, p, attributes) {
 }


-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];
+    %DebugPrint(symbol);
+    if (ObjectGetOwnPropertyDescriptor(object, symbol).enumerable) {
+      %DebugPrint('yes');
+      names.push(symbol);
+    }
+    else %DebugPrint('no');
+  }
   return names;
 }

Index: test/mjsunit/es6/symbols.js
diff --git a/test/mjsunit/es6/symbols.js b/test/mjsunit/es6/symbols.js
index 220439291cb86125aee42f5ef5f76724f6d07766..b465bee14a9b4630af3eb56be4bf18ccf008fc9c 100644
--- a/test/mjsunit/es6/symbols.js
+++ b/test/mjsunit/es6/symbols.js
@@ -367,6 +367,34 @@ for (var i in objs) {
 }


+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.

Reply via email to