Index: src/objects.cc |
diff --git a/src/objects.cc b/src/objects.cc |
index 3b41cd22ecb669ccb3eb5d65a12a2ac41025e58b..17a8b668a1d6bcbd660ebca086271a8ca8d961fb 100644 |
--- a/src/objects.cc |
+++ b/src/objects.cc |
@@ -6416,7 +6416,8 @@ MaybeHandle<Object> JSReceiver::DefineProperties(Isolate* isolate, |
Handle<FixedArray> keys; |
ASSIGN_RETURN_ON_EXCEPTION( |
isolate, keys, |
- JSReceiver::GetKeys(props, JSReceiver::OWN_ONLY, ALL_PROPERTIES), Object); |
+ JSReceiver::GetKeys(props, KeyCollectionType::OWN_ONLY, ALL_PROPERTIES), |
+ Object); |
// 6. Let descriptors be an empty List. |
int capacity = keys->length(); |
std::vector<PropertyDescriptor> descriptors(capacity); |
@@ -8127,7 +8128,7 @@ MaybeHandle<JSObject> JSObjectWalkVisitor<ContextObject>::StructureWalk( |
// an array. |
PropertyFilter filter = static_cast<PropertyFilter>( |
ONLY_WRITABLE | ONLY_ENUMERABLE | ONLY_CONFIGURABLE); |
- KeyAccumulator accumulator(isolate, filter); |
+ KeyAccumulator accumulator(isolate, KeyCollectionType::OWN_ONLY, filter); |
accumulator.NextPrototype(); |
copy->CollectOwnPropertyNames(&accumulator, filter); |
Handle<FixedArray> names = accumulator.GetKeys(); |
@@ -8632,7 +8633,7 @@ static Maybe<bool> GetKeysFromJSObject(Isolate* isolate, |
Handle<JSReceiver> receiver, |
Handle<JSObject> object, |
PropertyFilter* filter, |
- JSReceiver::KeyCollectionType type, |
+ KeyCollectionType type, |
KeyAccumulator* accumulator) { |
accumulator->NextPrototype(); |
// Check access rights if required. |
@@ -8640,11 +8641,11 @@ static Maybe<bool> GetKeysFromJSObject(Isolate* isolate, |
!isolate->MayAccess(handle(isolate->context()), object)) { |
// The cross-origin spec says that [[Enumerate]] shall return an empty |
// iterator when it doesn't have access... |
- if (type == JSReceiver::INCLUDE_PROTOS) { |
+ if (type == KeyCollectionType::INCLUDE_PROTOS) { |
return Just(false); |
} |
// ...whereas [[OwnPropertyKeys]] shall return whitelisted properties. |
- DCHECK(type == JSReceiver::OWN_ONLY); |
+ DCHECK_EQ(KeyCollectionType::OWN_ONLY, type); |
*filter = static_cast<PropertyFilter>(*filter | ONLY_ALL_CAN_READ); |
} |
@@ -8695,10 +8696,10 @@ static Maybe<bool> GetKeysFromJSObject(Isolate* isolate, |
static Maybe<bool> GetKeys_Internal(Isolate* isolate, |
Handle<JSReceiver> receiver, |
Handle<JSReceiver> object, |
- JSReceiver::KeyCollectionType type, |
+ KeyCollectionType type, |
PropertyFilter filter, |
KeyAccumulator* accumulator) { |
- PrototypeIterator::WhereToEnd end = type == JSReceiver::OWN_ONLY |
+ PrototypeIterator::WhereToEnd end = type == KeyCollectionType::OWN_ONLY |
? PrototypeIterator::END_AT_NON_HIDDEN |
: PrototypeIterator::END_AT_NULL; |
for (PrototypeIterator iter(isolate, object, |
@@ -8708,12 +8709,12 @@ static Maybe<bool> GetKeys_Internal(Isolate* isolate, |
PrototypeIterator::GetCurrent<JSReceiver>(iter); |
Maybe<bool> result = Just(false); // Dummy initialization. |
if (current->IsJSProxy()) { |
- if (type == JSReceiver::OWN_ONLY) { |
+ if (type == KeyCollectionType::OWN_ONLY) { |
result = JSProxy::OwnPropertyKeys(isolate, receiver, |
Handle<JSProxy>::cast(current), |
filter, accumulator); |
} else { |
- DCHECK(type == JSReceiver::INCLUDE_PROTOS); |
+ DCHECK(type == KeyCollectionType::INCLUDE_PROTOS); |
result = JSProxy::Enumerate( |
isolate, receiver, Handle<JSProxy>::cast(current), accumulator); |
} |
@@ -8875,10 +8876,15 @@ Maybe<bool> JSProxy::OwnPropertyKeys(Isolate* isolate, |
const int kPresent = 1; |
const int kGone = 0; |
IdentityMap<int> unchecked_result_keys(isolate->heap(), &set_zone); |
- int unchecked_result_keys_size = trap_result->length(); |
+ int unchecked_result_keys_size = 0; |
for (int i = 0; i < trap_result->length(); ++i) { |
DCHECK(trap_result->get(i)->IsUniqueName()); |
- unchecked_result_keys.Set(trap_result->get(i), kPresent); |
+ Object* key = trap_result->get(i); |
+ int* found = unchecked_result_keys.Find(key); |
Jakob Kummerow
2016/02/04 15:37:27
nit: (premature?) performance optimization: Get ca
|
+ if (found == nullptr || *found == kGone) { |
+ unchecked_result_keys.Set(key, kPresent); |
+ unchecked_result_keys_size++; |
+ } |
} |
// 17. Repeat, for each key that is an element of targetNonconfigurableKeys: |
for (int i = 0; i < nonconfigurable_keys_length; ++i) { |
@@ -8933,7 +8939,7 @@ MaybeHandle<FixedArray> JSReceiver::GetKeys(Handle<JSReceiver> object, |
GetKeysConversion keys_conversion) { |
USE(ContainsOnlyValidKeys); |
Isolate* isolate = object->GetIsolate(); |
- KeyAccumulator accumulator(isolate, filter); |
+ KeyAccumulator accumulator(isolate, type, filter); |
MAYBE_RETURN( |
GetKeys_Internal(isolate, object, object, type, filter, &accumulator), |
Jakob Kummerow
2016/02/04 15:37:27
We could consider adding public type() and filter(
Camillo Bruni
2016/02/04 17:14:32
right, I think that would be a nice little cleanup
|
MaybeHandle<FixedArray>()); |