Revision: 22378
Author: rossb...@chromium.org
Date: Mon Jul 14 14:00:33 2014 UTC
Log: Reland "Include symbol properties in
Object.{create,defineProperties}"
Second try; implementation that doesn't rely on external arrays.
R=mstarzin...@chromium.org
BUG=v8:3440
Review URL: https://codereview.chromium.org/391713002
http://code.google.com/p/v8/source/detail?r=22378
Modified:
/branches/bleeding_edge/src/v8natives.js
/branches/bleeding_edge/test/mjsunit/es6/symbols.js
=======================================
--- /branches/bleeding_edge/src/v8natives.js Mon Jul 14 12:27:08 2014 UTC
+++ /branches/bleeding_edge/src/v8natives.js Mon Jul 14 14:00:33 2014 UTC
@@ -1171,13 +1171,25 @@
}
-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 filter = PROPERTY_ATTRIBUTES_STRING |
PROPERTY_ATTRIBUTES_PRIVATE_SYMBOL;
+ var symbols = %GetOwnPropertyNames(object, filter);
+ for (var i = 0; i < symbols.length; ++i) {
+ var symbol = symbols[i];
+ if (IS_SYMBOL(symbol)) {
+ var desc = ObjectGetOwnPropertyDescriptor(object, symbol);
+ if (desc.enumerable) names.push(symbol);
+ }
+ }
+
return names;
}
=======================================
--- /branches/bleeding_edge/test/mjsunit/es6/symbols.js Mon Jul 14 12:27:08
2014 UTC
+++ /branches/bleeding_edge/test/mjsunit/es6/symbols.js Mon Jul 14 14:00:33
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.