summaryrefslogtreecommitdiff
path: root/deps/v8/src/key-accumulator.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/key-accumulator.cc')
-rw-r--r--deps/v8/src/key-accumulator.cc54
1 files changed, 53 insertions, 1 deletions
diff --git a/deps/v8/src/key-accumulator.cc b/deps/v8/src/key-accumulator.cc
index 91b014aacd..e7a9c3cceb 100644
--- a/deps/v8/src/key-accumulator.cc
+++ b/deps/v8/src/key-accumulator.cc
@@ -6,7 +6,9 @@
#include "src/elements.h"
#include "src/factory.h"
+#include "src/isolate-inl.h"
#include "src/objects-inl.h"
+#include "src/property-descriptor.h"
namespace v8 {
@@ -97,9 +99,11 @@ bool KeyAccumulator::AddKey(Object* key, AddKeyConversion convert) {
bool KeyAccumulator::AddKey(Handle<Object> key, AddKeyConversion convert) {
if (key->IsSymbol()) {
- if (filter_ == SKIP_SYMBOLS) return false;
+ if (filter_ & SKIP_SYMBOLS) return false;
+ if (Handle<Symbol>::cast(key)->is_private()) return false;
return AddSymbolKey(key);
}
+ if (filter_ & SKIP_STRINGS) return false;
// Make sure we do not add keys to a proxy-level (see AddKeysFromProxy).
DCHECK_LE(0, level_string_length_);
// In some cases (e.g. proxies) we might get in String-converted ints which
@@ -217,6 +221,54 @@ void KeyAccumulator::AddKeysFromProxy(Handle<JSObject> array_like) {
}
+MaybeHandle<FixedArray> FilterProxyKeys(Isolate* isolate, Handle<JSProxy> owner,
+ Handle<FixedArray> keys,
+ PropertyFilter filter) {
+ if (filter == ALL_PROPERTIES) {
+ // Nothing to do.
+ return keys;
+ }
+ int store_position = 0;
+ for (int i = 0; i < keys->length(); ++i) {
+ Handle<Name> key(Name::cast(keys->get(i)), isolate);
+ if (key->FilterKey(filter)) continue; // Skip this key.
+ if (filter & ONLY_ENUMERABLE) {
+ PropertyDescriptor desc;
+ Maybe<bool> found =
+ JSProxy::GetOwnPropertyDescriptor(isolate, owner, key, &desc);
+ MAYBE_RETURN(found, MaybeHandle<FixedArray>());
+ if (!found.FromJust() || !desc.enumerable()) continue; // Skip this key.
+ }
+ // Keep this key.
+ if (store_position != i) {
+ keys->set(store_position, *key);
+ }
+ store_position++;
+ }
+ if (store_position == 0) return isolate->factory()->empty_fixed_array();
+ keys->Shrink(store_position);
+ return keys;
+}
+
+
+// Returns "nothing" in case of exception, "true" on success.
+Maybe<bool> KeyAccumulator::AddKeysFromProxy(Handle<JSProxy> proxy,
+ Handle<FixedArray> keys) {
+ ASSIGN_RETURN_ON_EXCEPTION_VALUE(
+ isolate_, keys, FilterProxyKeys(isolate_, proxy, keys, filter_),
+ Nothing<bool>());
+ // Proxies define a complete list of keys with no distinction of
+ // elements and properties, which breaks the normal assumption for the
+ // KeyAccumulator.
+ AddKeys(keys, PROXY_MAGIC);
+ // Invert the current length to indicate a present proxy, so we can ignore
+ // element keys for this level. Otherwise we would not fully respect the order
+ // given by the proxy.
+ level_string_length_ = -level_string_length_;
+ return Just(true);
+}
+
+
void KeyAccumulator::AddElementKeysFromInterceptor(
Handle<JSObject> array_like) {
AddKeys(array_like, CONVERT_TO_ARRAY_INDEX);