Commit 942fe191 authored by rossberg@chromium.org's avatar rossberg@chromium.org

Reland "Include symbol properties in Object.{create,defineProperties}"

Second try; implementation that doesn't rely on external arrays.

R=mstarzinger@chromium.org
BUG=v8:3440

Review URL: https://codereview.chromium.org/391713002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22378 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent cb3e2beb
......@@ -1171,13 +1171,25 @@ 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 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;
}
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment