Commit c736a452 authored by cbruni's avatar cbruni Committed by Commit bot

[keys] Moving property/keys related methods to KeyAccumulator in keys.cc

The Great Keys Migration:
This is part of a bigger effort to centralize optimizations for key collections
in a central place. This necessary to avoid the penalty that would be introduced
by fixing shadowed property iteration.

BUG=v8:4758, v8:705
LOG=N

Review-Url: https://codereview.chromium.org/1938413002
Cr-Commit-Position: refs/heads/master@{#35991}
parent 21ce625b
...@@ -1482,6 +1482,15 @@ class StackLimitCheck BASE_EMBEDDED { ...@@ -1482,6 +1482,15 @@ class StackLimitCheck BASE_EMBEDDED {
Isolate* isolate_; Isolate* isolate_;
}; };
#define STACK_CHECK(isolate, result_value) \
do { \
StackLimitCheck stack_check(isolate); \
if (stack_check.HasOverflowed()) { \
isolate->Throw(*isolate->factory()->NewRangeError( \
MessageTemplate::kStackOverflow)); \
return result_value; \
} \
} while (false)
// Support for temporarily postponing interrupts. When the outermost // Support for temporarily postponing interrupts. When the outermost
// postpone scope is left the interrupts will be re-enabled and any // postpone scope is left the interrupts will be re-enabled and any
......
This diff is collapsed.
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef V8_KEY_ACCUMULATOR_H_ #ifndef V8_KEYS_H_
#define V8_KEY_ACCUMULATOR_H_ #define V8_KEYS_H_
#include "src/isolate.h" #include "src/isolate.h"
#include "src/objects.h" #include "src/objects.h"
...@@ -53,6 +53,16 @@ class KeyAccumulator final BASE_EMBEDDED { ...@@ -53,6 +53,16 @@ class KeyAccumulator final BASE_EMBEDDED {
int length() { return length_; } int length() { return length_; }
Isolate* isolate() { return isolate_; } Isolate* isolate() { return isolate_; }
void set_filter_proxy_keys(bool filter) { filter_proxy_keys_ = filter; } void set_filter_proxy_keys(bool filter) { filter_proxy_keys_ = filter; }
PropertyFilter filter() { return filter_; }
Maybe<bool> GetKeys_Internal(Handle<JSReceiver> receiver,
Handle<JSReceiver> object,
KeyCollectionType type);
static Handle<FixedArray> GetEnumPropertyKeys(Isolate* isolate,
Handle<JSObject> object);
void CollectOwnElementKeys(Handle<JSObject> object);
void CollectOwnPropertyNames(Handle<JSObject> object);
private: private:
bool AddIntegerKey(uint32_t key); bool AddIntegerKey(uint32_t key);
...@@ -60,6 +70,12 @@ class KeyAccumulator final BASE_EMBEDDED { ...@@ -60,6 +70,12 @@ class KeyAccumulator final BASE_EMBEDDED {
bool AddSymbolKey(Handle<Object> array); bool AddSymbolKey(Handle<Object> array);
void SortCurrentElementsListRemoveDuplicates(); void SortCurrentElementsListRemoveDuplicates();
Maybe<bool> JSProxyOwnPropertyKeys(Handle<JSReceiver> receiver,
Handle<JSProxy> proxy);
Maybe<bool> GetKeysFromJSObject(Handle<JSReceiver> receiver,
Handle<JSObject> object,
KeyCollectionType type);
Isolate* isolate_; Isolate* isolate_;
KeyCollectionType type_; KeyCollectionType type_;
PropertyFilter filter_; PropertyFilter filter_;
...@@ -126,4 +142,4 @@ class FastKeyAccumulator { ...@@ -126,4 +142,4 @@ class FastKeyAccumulator {
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
#endif // V8_KEY_ACCUMULATOR_H_ #endif // V8_KEYS_H_
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "src/api.h" #include "src/api.h"
#include "src/execution.h" #include "src/execution.h"
#include "src/isolate-inl.h" #include "src/isolate-inl.h"
#include "src/keys.h"
#include "src/string-builder.h" #include "src/string-builder.h"
namespace v8 { namespace v8 {
...@@ -271,7 +272,8 @@ Handle<Object> CallSite::GetMethodName() { ...@@ -271,7 +272,8 @@ Handle<Object> CallSite::GetMethodName() {
if (!current->IsJSObject()) break; if (!current->IsJSObject()) break;
Handle<JSObject> current_obj = Handle<JSObject>::cast(current); Handle<JSObject> current_obj = Handle<JSObject>::cast(current);
if (current_obj->IsAccessCheckNeeded()) break; if (current_obj->IsAccessCheckNeeded()) break;
Handle<FixedArray> keys = JSObject::GetEnumPropertyKeys(current_obj); Handle<FixedArray> keys =
KeyAccumulator::GetEnumPropertyKeys(isolate_, current_obj);
for (int i = 0; i < keys->length(); i++) { for (int i = 0; i < keys->length(); i++) {
HandleScope inner_scope(isolate_); HandleScope inner_scope(isolate_);
if (!keys->get(i)->IsName()) continue; if (!keys->get(i)->IsName()) continue;
......
This diff is collapsed.
...@@ -2270,18 +2270,6 @@ class JSObject: public JSReceiver { ...@@ -2270,18 +2270,6 @@ class JSObject: public JSReceiver {
inline void SetInternalField(int index, Smi* value); inline void SetInternalField(int index, Smi* value);
bool WasConstructedFromApiFunction(); bool WasConstructedFromApiFunction();
void CollectOwnPropertyNames(KeyAccumulator* keys,
PropertyFilter filter = ALL_PROPERTIES);
static void CollectOwnElementKeys(Handle<JSObject> object,
KeyAccumulator* keys,
PropertyFilter filter);
static Handle<FixedArray> GetEnumPropertyKeys(Handle<JSObject> object);
static Handle<FixedArray> GetFastEnumPropertyKeys(Isolate* isolate,
Handle<JSObject> object);
// Returns a new map with all transitions dropped from the object's current // Returns a new map with all transitions dropped from the object's current
// map and the ElementsKind set. // map and the ElementsKind set.
static Handle<Map> GetElementsTransitionMap(Handle<JSObject> object, static Handle<Map> GetElementsTransitionMap(Handle<JSObject> object,
......
...@@ -213,7 +213,7 @@ RUNTIME_FUNCTION(Runtime_GetArrayKeys) { ...@@ -213,7 +213,7 @@ RUNTIME_FUNCTION(Runtime_GetArrayKeys) {
} }
accumulator.NextPrototype(); accumulator.NextPrototype();
Handle<JSObject> current = PrototypeIterator::GetCurrent<JSObject>(iter); Handle<JSObject> current = PrototypeIterator::GetCurrent<JSObject>(iter);
JSObject::CollectOwnElementKeys(current, &accumulator, ALL_PROPERTIES); accumulator.CollectOwnElementKeys(current);
} }
// Erase any keys >= length. // Erase any keys >= length.
Handle<FixedArray> keys = accumulator.GetKeys(KEEP_NUMBERS); Handle<FixedArray> keys = accumulator.GetKeys(KEEP_NUMBERS);
......
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