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

Unified Diff: src/hydrogen.cc

Issue 779173010: Create optimized inline versions of Map and Set initialization (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « src/hydrogen.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 5947643733d67e6835047cc3eb5f6a3d799a980b..9114100d442cdbdf42801a573467b4d6a5acf236 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -12648,6 +12648,61 @@ void HOptimizedGraphBuilder::GenerateMapGetSize(CallRuntime* call) {
}
+template <typename CollectionType>
+HValue* HOptimizedGraphBuilder::BuildAllocateOrderedHashTable() {
+ static const int kInitialCapacity = CollectionType::kMinCapacity;
+ static const int kInitialNumBuckets =
+ kInitialCapacity / CollectionType::kLoadFactor;
+ HValue* size = Add<HConstant>(
+ FixedArray::kHeaderSize + CollectionType::kHashTableStartIndex +
+ kInitialNumBuckets + (kInitialCapacity * CollectionType::kEntrySize));
+ HValue* table =
+ Add<HAllocate>(size, HType::HeapObject(), NOT_TENURED, FIXED_ARRAY_TYPE);
adamk 2014/12/08 21:41:14 One question about HAllocate: do I need to add cod
Dmitry Lomov (no reviews) 2014/12/09 12:05:39 Yes. See HOGB::BuildAllocateFixedTypedArray for in
adamk 2014/12/09 19:24:23 Added a bunch of proper initialization. Now the co
+ Add<HStoreNamedField>(
+ table, HObjectAccess::ForMap(),
+ Add<HConstant>(isolate()->factory()->ordered_hash_table_map()));
+ HValue* not_found = Add<HConstant>(CollectionType::kNotFound);
+ for (int i = 0; i < kInitialNumBuckets; ++i) {
+ Add<HStoreKeyed>(table,
+ Add<HConstant>(CollectionType::kHashTableStartIndex + i),
+ not_found, FAST_ELEMENTS);
+ }
+ Add<HStoreNamedField>(
+ table,
+ HObjectAccess::ForOrderedHashTableNumberOfBuckets<CollectionType>(),
+ Add<HConstant>(kInitialNumBuckets));
+ Add<HStoreNamedField>(
+ table,
+ HObjectAccess::ForOrderedHashTableNumberOfElements<CollectionType>(),
+ graph()->GetConstant0());
+ Add<HStoreNamedField>(
+ table, HObjectAccess::ForOrderedHashTableNumberOfDeletedElements<
+ CollectionType>(),
+ graph()->GetConstant0());
+ return table;
+}
+
+
+void HOptimizedGraphBuilder::GenerateSetInitialize(CallRuntime* call) {
+ DCHECK(call->arguments()->length() == 1);
+ CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
+ HValue* receiver = Pop();
+ HValue* table = BuildAllocateOrderedHashTable<OrderedHashSet>();
+ Add<HStoreNamedField>(receiver, HObjectAccess::ForJSCollectionTable(), table);
+ return ast_context()->ReturnValue(receiver);
+}
+
+
+void HOptimizedGraphBuilder::GenerateMapInitialize(CallRuntime* call) {
+ DCHECK(call->arguments()->length() == 1);
+ CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
+ HValue* receiver = Pop();
+ HValue* table = BuildAllocateOrderedHashTable<OrderedHashMap>();
+ Add<HStoreNamedField>(receiver, HObjectAccess::ForJSCollectionTable(), table);
+ return ast_context()->ReturnValue(receiver);
+}
+
+
void HOptimizedGraphBuilder::GenerateGetCachedArrayIndex(CallRuntime* call) {
DCHECK(call->arguments()->length() == 1);
CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
« no previous file with comments | « src/hydrogen.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698