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

Unified Diff: src/hydrogen.cc

Issue 796503002: Create optimized versions of the Map/Set clear method (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/hydrogen-instructions.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 0c10a4e28e37fec66a019c467d0768aef601f05f..68c4ce3d32db2522d7b92b63e173c27ad19e6b69 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -12727,6 +12727,46 @@ void HOptimizedGraphBuilder::GenerateMapInitialize(CallRuntime* call) {
}
+template <typename CollectionType>
+void HOptimizedGraphBuilder::BuildOrderedHashTableClear(HValue* receiver) {
+ HValue* old_table =
+ Add<HLoadNamedField>(receiver, static_cast<HValue*>(NULL),
+ HObjectAccess::ForJSCollectionTable());
+ HValue* new_table = BuildAllocateOrderedHashTable<CollectionType>();
+ Add<HStoreNamedField>(
+ old_table, HObjectAccess::ForOrderedHashTableNextTable<CollectionType>(),
+ new_table);
+ Add<HStoreNamedField>(
+ old_table, HObjectAccess::ForOrderedHashTableNumberOfDeletedElements<
+ CollectionType>(),
+ Add<HConstant>(CollectionType::kClearedTableSentinel));
+ Add<HStoreNamedField>(receiver, HObjectAccess::ForJSCollectionTable(),
+ new_table);
+}
+
+
+void HOptimizedGraphBuilder::GenerateSetClear(CallRuntime* call) {
+ DCHECK(call->arguments()->length() == 1);
+ CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
+ HValue* receiver = Pop();
+
+ NoObservableSideEffectsScope no_effects(this);
+ BuildOrderedHashTableClear<OrderedHashSet>(receiver);
+ return ast_context()->ReturnValue(graph()->GetConstantUndefined());
+}
+
+
+void HOptimizedGraphBuilder::GenerateMapClear(CallRuntime* call) {
+ DCHECK(call->arguments()->length() == 1);
+ CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
+ HValue* receiver = Pop();
+
+ NoObservableSideEffectsScope no_effects(this);
+ BuildOrderedHashTableClear<OrderedHashMap>(receiver);
+ return ast_context()->ReturnValue(graph()->GetConstantUndefined());
+}
+
+
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/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698