Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(513)

Unified Diff: src/objects.cc

Issue 1707743002: [key-accumulator] Starting to reimplement the key-accumulator (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: WIP fast path for collecting receiver-only elements Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 94c077422d87c4aa80152160ea772363a28556b7..cdf9bea4c8aa1c1cf2644fbed197c315265b9480 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -8336,7 +8336,9 @@ MaybeHandle<Object> JSReceiver::OrdinaryToPrimitive(
// TODO(cbruni/jkummerow): Consider moving this into elements.cc.
-bool HasEnumerableElements(JSObject* object) {
+bool JSObject::HasEnumerableElements() {
+ // TODO(cbruni): cleanup
+ JSObject* object = this;
switch (object->GetElementsKind()) {
case FAST_SMI_ELEMENTS:
case FAST_ELEMENTS:
@@ -8401,7 +8403,6 @@ bool HasEnumerableElements(JSObject* object) {
return true;
}
-
// Tests for the fast common case for property enumeration:
// - This object and all prototypes has an enum cache (which means that
// it is no proxy, has no interceptors and needs no access checks).
@@ -8418,7 +8419,7 @@ bool JSReceiver::IsSimpleEnum() {
if (current->IsAccessCheckNeeded()) return false;
DCHECK(!current->HasNamedInterceptor());
DCHECK(!current->HasIndexedInterceptor());
- if (HasEnumerableElements(current)) return false;
+ if (current->HasEnumerableElements()) return false;
if (current != this && enum_length != 0) return false;
}
return true;
@@ -8483,10 +8484,9 @@ bool Map::OnlyHasSimpleProperties() {
!is_dictionary_map();
}
-namespace {
-
-Handle<FixedArray> GetFastEnumPropertyKeys(Isolate* isolate,
- Handle<JSObject> object) {
+// stati
Toon Verwaest 2016/02/24 15:07:06 static
+Handle<FixedArray> JSObject::GetFastEnumPropertyKeys(Isolate* isolate,
+ Handle<JSObject> object) {
Handle<Map> map(object->map());
bool cache_enum_length = map->OnlyHasSimpleProperties();
@@ -8537,8 +8537,9 @@ Handle<FixedArray> GetFastEnumPropertyKeys(Isolate* isolate,
for (int i = 0; i < size; i++) {
PropertyDetails details = descs->GetDetails(i);
+ if (details.IsDontEnum()) continue;
Object* key = descs->GetKey(i);
- if (details.IsDontEnum() || key->IsSymbol()) continue;
+ if (key->IsSymbol()) continue;
storage->set(index, key);
if (!indices.is_null()) {
if (details.type() != DATA) {
@@ -8560,7 +8561,6 @@ Handle<FixedArray> GetFastEnumPropertyKeys(Isolate* isolate,
return storage;
}
-} // namespace
Handle<FixedArray> JSObject::GetEnumPropertyKeys(Handle<JSObject> object) {
Isolate* isolate = object->GetIsolate();
@@ -10840,6 +10840,18 @@ Handle<ArrayList> ArrayList::Add(Handle<ArrayList> array, Handle<Object> obj,
return array;
}
+Handle<ArrayList> ArrayList::Add(Handle<ArrayList> array, Smi* smi,
+ AddMode mode) {
+ int length = array->Length();
+ array = EnsureSpace(array, length + 1);
+ if (mode == kReloadLengthAfterAllocation) {
+ DCHECK(array->Length() <= length);
+ length = array->Length();
+ }
+ array->Set(length, smi);
+ array->SetLength(length + 1);
+ return array;
+}
Handle<ArrayList> ArrayList::Add(Handle<ArrayList> array, Handle<Object> obj1,
Handle<Object> obj2, AddMode mode) {
@@ -16599,7 +16611,6 @@ void FixedArray::SortPairs(FixedArray* numbers, uint32_t len) {
}
}
-
void JSObject::CollectOwnPropertyNames(KeyAccumulator* keys,
PropertyFilter filter) {
if (HasFastProperties()) {
@@ -16640,7 +16651,6 @@ int JSObject::NumberOfOwnElements(PropertyFilter filter) {
return GetOwnElementKeys(NULL, filter);
}
-
void JSObject::CollectOwnElementKeys(Handle<JSObject> object,
KeyAccumulator* keys,
PropertyFilter filter) {
@@ -18640,7 +18650,6 @@ int Dictionary<Derived, Shape, Key>::CopyKeysTo(
return index - start_index;
}
-
template <typename Derived, typename Shape, typename Key>
void Dictionary<Derived, Shape, Key>::CollectKeysTo(
Handle<Dictionary<Derived, Shape, Key> > dictionary, KeyAccumulator* keys,
« src/key-accumulator.cc ('K') | « src/objects.h ('k') | src/objects-printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698