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

Unified Diff: runtime/vm/service.cc

Issue 1965493004: Canonicalize generic types in an isolate specific hash table (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: sync-tot Created 4 years, 7 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: runtime/vm/service.cc
diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc
index 7e5e58f99202c9c4876194c56cacf1633141349e..315e704d94958994f4603747278b8543d5126695 100644
--- a/runtime/vm/service.cc
+++ b/runtime/vm/service.cc
@@ -35,6 +35,7 @@
#include "vm/stack_frame.h"
#include "vm/symbols.h"
#include "vm/timeline.h"
+#include "vm/type_table.h"
#include "vm/unicode.h"
#include "vm/version.h"
@@ -3566,25 +3567,30 @@ static bool GetTypeArgumentsList(Thread* thread, JSONStream* js) {
if (js->ParamIs("onlyWithInstantiations", "true")) {
only_with_instantiations = true;
}
+ Zone* zone = thread->zone();
ObjectStore* object_store = thread->isolate()->object_store();
- const Array& table = Array::Handle(object_store->canonical_type_arguments());
- ASSERT(table.Length() > 0);
- TypeArguments& type_args = TypeArguments::Handle();
- const intptr_t table_size = table.Length() - 1;
- const intptr_t table_used = Smi::Value(Smi::RawCast(table.At(table_size)));
+ CanonicalTypeArgumentsSet typeargs_table(
+ zone, object_store->canonical_type_arguments());
+ const intptr_t table_size = typeargs_table.NumEntries();
+ const intptr_t table_used = typeargs_table.NumOccupied();
+ const Array& typeargs_array = Array::Handle(
+ zone, HashTables::ToArray(typeargs_table, false));
+ ASSERT(typeargs_array.Length() == table_used);
+ TypeArguments& typeargs = TypeArguments::Handle(zone);
JSONObject jsobj(js);
jsobj.AddProperty("type", "TypeArgumentsList");
jsobj.AddProperty("canonicalTypeArgumentsTableSize", table_size);
jsobj.AddProperty("canonicalTypeArgumentsTableUsed", table_used);
JSONArray members(&jsobj, "typeArguments");
- for (intptr_t i = 0; i < table_size; i++) {
- type_args ^= table.At(i);
- if (!type_args.IsNull()) {
- if (!only_with_instantiations || type_args.HasInstantiations()) {
- members.AddValue(type_args);
+ for (intptr_t i = 0; i < table_used; i++) {
+ typeargs ^= typeargs_array.At(i);
+ if (!typeargs.IsNull()) {
+ if (!only_with_instantiations || typeargs.HasInstantiations()) {
+ members.AddValue(typeargs);
}
}
}
+ typeargs_table.Release();
return true;
}

Powered by Google App Engine
This is Rietveld 408576698