Refactor ObjectGetOwnPropertyKeys to accept bitmask rather than boolean

BUG=v8:3549
LOG=Y
R=arv@chromium.org, rossberg@chromium.org

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

Patch from Caitlin Potter <caitpotter88@gmail.com>.

Cr-Commit-Position: refs/heads/master@{#25111}
git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@25111 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
arv@chromium.org 2014-11-04 15:08:24 +00:00
parent faa71f966a
commit d6ca29ce4c
2 changed files with 10 additions and 10 deletions

View File

@ -73,7 +73,7 @@ function ObjectGetOwnPropertySymbols(obj) {
// TODO(arv): Proxies use a shared trap for String and Symbol keys. // TODO(arv): Proxies use a shared trap for String and Symbol keys.
return ObjectGetOwnPropertyKeys(obj, true); return ObjectGetOwnPropertyKeys(obj, PROPERTY_ATTRIBUTES_STRING);
} }

View File

@ -1038,16 +1038,14 @@ function ToNameArray(obj, trap, includeSymbols) {
} }
function ObjectGetOwnPropertyKeys(obj, symbolsOnly) { function ObjectGetOwnPropertyKeys(obj, filter) {
var nameArrays = new InternalArray(); var nameArrays = new InternalArray();
var filter = symbolsOnly ? filter |= PROPERTY_ATTRIBUTES_PRIVATE_SYMBOL;
PROPERTY_ATTRIBUTES_STRING | PROPERTY_ATTRIBUTES_PRIVATE_SYMBOL :
PROPERTY_ATTRIBUTES_SYMBOLIC;
// Find all the indexed properties. // Find all the indexed properties.
// Only get own element names if we want to include string keys. // Only get own element names if we want to include string keys.
if (!symbolsOnly) { if ((filter & PROPERTY_ATTRIBUTES_STRING) === 0) {
var ownElementNames = %GetOwnElementNames(obj); var ownElementNames = %GetOwnElementNames(obj);
for (var i = 0; i < ownElementNames.length; ++i) { for (var i = 0; i < ownElementNames.length; ++i) {
ownElementNames[i] = %_NumberToString(ownElementNames[i]); ownElementNames[i] = %_NumberToString(ownElementNames[i]);
@ -1089,10 +1087,12 @@ function ObjectGetOwnPropertyKeys(obj, symbolsOnly) {
var j = 0; var j = 0;
for (var i = 0; i < propertyNames.length; ++i) { for (var i = 0; i < propertyNames.length; ++i) {
var name = propertyNames[i]; var name = propertyNames[i];
if (symbolsOnly) { if (IS_SYMBOL(name)) {
if (!IS_SYMBOL(name) || IS_PRIVATE(name)) continue; if ((filter & PROPERTY_ATTRIBUTES_SYMBOLIC) || IS_PRIVATE(name)) {
continue;
}
} else { } else {
if (IS_SYMBOL(name)) continue; if (filter & PROPERTY_ATTRIBUTES_STRING) continue;
name = ToString(name); name = ToString(name);
} }
if (seenKeys[name]) continue; if (seenKeys[name]) continue;
@ -1116,7 +1116,7 @@ function ObjectGetOwnPropertyNames(obj) {
return ToNameArray(names, "getOwnPropertyNames", false); return ToNameArray(names, "getOwnPropertyNames", false);
} }
return ObjectGetOwnPropertyKeys(obj, false); return ObjectGetOwnPropertyKeys(obj, PROPERTY_ATTRIBUTES_SYMBOLIC);
} }