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

Unified Diff: runtime/vm/object_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: address-code-review-comments 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/object_service.cc
diff --git a/runtime/vm/object_service.cc b/runtime/vm/object_service.cc
index 41290fb7e8bde3432be7f9b30fa0c735583c4b19..434099531beea2d92c782a46819d9112a671e5fe 100644
--- a/runtime/vm/object_service.cc
+++ b/runtime/vm/object_service.cc
@@ -8,6 +8,7 @@
#include "vm/object_store.h"
#include "vm/stub_code.h"
#include "vm/symbols.h"
+#include "vm/type_table.h"
namespace dart {
@@ -187,9 +188,15 @@ void TypeArguments::PrintJSONImpl(JSONStream* stream, bool ref) const {
// The index in the canonical_type_arguments table cannot be used as part of
// the object id (as in typearguments/id), because the indices are not
// preserved when the table grows and the entries get rehashed. Use the ring.
- Isolate* isolate = Isolate::Current();
+ Thread* thread = Thread::Current();
+ Zone* zone = thread->zone();
+ Isolate* isolate = thread->isolate();
ObjectStore* object_store = isolate->object_store();
- const Array& table = Array::Handle(object_store->canonical_type_arguments());
+ CanonicalTypeArgumentsSet typeargs_table(
+ zone, object_store->canonical_type_arguments());
+ const Array& table =
+ Array::Handle(HashTables::ToArray(typeargs_table, false));
+ typeargs_table.Release();
ASSERT(table.Length() > 0);
AddCommonObjectProperties(&jsobj, "TypeArguments", ref);
jsobj.AddServiceId(*this);
@@ -1129,11 +1136,13 @@ void Type::PrintJSONImpl(JSONStream* stream, bool ref) const {
jsobj.AddProperty("kind", "Type");
if (IsCanonical()) {
const Class& type_cls = Class::Handle(type_class());
- intptr_t id = type_cls.FindCanonicalTypeIndex(*this);
- ASSERT(id >= 0);
- intptr_t cid = type_cls.id();
- jsobj.AddFixedServiceId("classes/%" Pd "/types/%" Pd "", cid, id);
- jsobj.AddProperty("typeClass", type_cls);
+ if (type_cls.CanonicalType() == raw()) {
+ intptr_t cid = type_cls.id();
+ jsobj.AddFixedServiceId("classes/%" Pd "/types/%" Pd "", cid, 0L);
+ jsobj.AddProperty("typeClass", type_cls);
+ } else {
+ jsobj.AddServiceId(*this);
+ }
} else {
jsobj.AddServiceId(*this);
}
« runtime/vm/object.cc ('K') | « runtime/vm/object.cc ('k') | runtime/vm/object_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698