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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/debugger.h" 5 #include "vm/debugger.h"
6 #include "vm/disassembler.h" 6 #include "vm/disassembler.h"
7 #include "vm/object.h" 7 #include "vm/object.h"
8 #include "vm/object_store.h" 8 #include "vm/object_store.h"
9 #include "vm/stub_code.h" 9 #include "vm/stub_code.h"
10 #include "vm/symbols.h" 10 #include "vm/symbols.h"
11 #include "vm/type_table.h"
11 12
12 namespace dart { 13 namespace dart {
13 14
14 #ifndef PRODUCT 15 #ifndef PRODUCT
15 16
16 static void AddNameProperties(JSONObject* jsobj, 17 static void AddNameProperties(JSONObject* jsobj,
17 const String& name, 18 const String& name,
18 const String& vm_name) { 19 const String& vm_name) {
19 jsobj->AddProperty("name", name.ToCString()); 20 jsobj->AddProperty("name", name.ToCString());
20 if (!name.Equals(vm_name)) { 21 if (!name.Equals(vm_name)) {
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 void UnresolvedClass::PrintJSONImpl(JSONStream* stream, bool ref) const { 181 void UnresolvedClass::PrintJSONImpl(JSONStream* stream, bool ref) const {
181 Object::PrintJSONImpl(stream, ref); 182 Object::PrintJSONImpl(stream, ref);
182 } 183 }
183 184
184 185
185 void TypeArguments::PrintJSONImpl(JSONStream* stream, bool ref) const { 186 void TypeArguments::PrintJSONImpl(JSONStream* stream, bool ref) const {
186 JSONObject jsobj(stream); 187 JSONObject jsobj(stream);
187 // The index in the canonical_type_arguments table cannot be used as part of 188 // The index in the canonical_type_arguments table cannot be used as part of
188 // the object id (as in typearguments/id), because the indices are not 189 // the object id (as in typearguments/id), because the indices are not
189 // preserved when the table grows and the entries get rehashed. Use the ring. 190 // preserved when the table grows and the entries get rehashed. Use the ring.
190 Isolate* isolate = Isolate::Current(); 191 Thread* thread = Thread::Current();
192 Zone* zone = thread->zone();
193 Isolate* isolate = thread->isolate();
191 ObjectStore* object_store = isolate->object_store(); 194 ObjectStore* object_store = isolate->object_store();
192 const Array& table = Array::Handle(object_store->canonical_type_arguments()); 195 CanonicalTypeArgumentsSet typeargs_table(
196 zone, object_store->canonical_type_arguments());
197 const Array& table =
198 Array::Handle(HashTables::ToArray(typeargs_table, false));
199 typeargs_table.Release();
193 ASSERT(table.Length() > 0); 200 ASSERT(table.Length() > 0);
194 AddCommonObjectProperties(&jsobj, "TypeArguments", ref); 201 AddCommonObjectProperties(&jsobj, "TypeArguments", ref);
195 jsobj.AddServiceId(*this); 202 jsobj.AddServiceId(*this);
196 const String& user_name = String::Handle(UserVisibleName()); 203 const String& user_name = String::Handle(UserVisibleName());
197 const String& vm_name = String::Handle(Name()); 204 const String& vm_name = String::Handle(Name());
198 AddNameProperties(&jsobj, user_name, vm_name); 205 AddNameProperties(&jsobj, user_name, vm_name);
199 if (ref) { 206 if (ref) {
200 return; 207 return;
201 } 208 }
202 { 209 {
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after
1122 UNREACHABLE(); 1129 UNREACHABLE();
1123 } 1130 }
1124 1131
1125 1132
1126 void Type::PrintJSONImpl(JSONStream* stream, bool ref) const { 1133 void Type::PrintJSONImpl(JSONStream* stream, bool ref) const {
1127 JSONObject jsobj(stream); 1134 JSONObject jsobj(stream);
1128 PrintSharedInstanceJSON(&jsobj, ref); 1135 PrintSharedInstanceJSON(&jsobj, ref);
1129 jsobj.AddProperty("kind", "Type"); 1136 jsobj.AddProperty("kind", "Type");
1130 if (IsCanonical()) { 1137 if (IsCanonical()) {
1131 const Class& type_cls = Class::Handle(type_class()); 1138 const Class& type_cls = Class::Handle(type_class());
1132 intptr_t id = type_cls.FindCanonicalTypeIndex(*this); 1139 if (type_cls.CanonicalType() == raw()) {
1133 ASSERT(id >= 0); 1140 intptr_t cid = type_cls.id();
1134 intptr_t cid = type_cls.id(); 1141 jsobj.AddFixedServiceId("classes/%" Pd "/types/%" Pd "", cid, 0L);
1135 jsobj.AddFixedServiceId("classes/%" Pd "/types/%" Pd "", cid, id); 1142 jsobj.AddProperty("typeClass", type_cls);
1136 jsobj.AddProperty("typeClass", type_cls); 1143 } else {
1144 jsobj.AddServiceId(*this);
1145 }
1137 } else { 1146 } else {
1138 jsobj.AddServiceId(*this); 1147 jsobj.AddServiceId(*this);
1139 } 1148 }
1140 const String& user_name = String::Handle(UserVisibleName()); 1149 const String& user_name = String::Handle(UserVisibleName());
1141 const String& vm_name = String::Handle(Name()); 1150 const String& vm_name = String::Handle(Name());
1142 AddNameProperties(&jsobj, user_name, vm_name); 1151 AddNameProperties(&jsobj, user_name, vm_name);
1143 if (ref) { 1152 if (ref) {
1144 return; 1153 return;
1145 } 1154 }
1146 const TypeArguments& typeArgs = TypeArguments::Handle(arguments()); 1155 const TypeArguments& typeArgs = TypeArguments::Handle(arguments());
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
1587 jsobj.AddProperty("mirrorReferent", referent_handle); 1596 jsobj.AddProperty("mirrorReferent", referent_handle);
1588 } 1597 }
1589 1598
1590 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 1599 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
1591 Instance::PrintJSONImpl(stream, ref); 1600 Instance::PrintJSONImpl(stream, ref);
1592 } 1601 }
1593 1602
1594 #endif 1603 #endif
1595 1604
1596 } // namespace dart 1605 } // namespace dart
OLDNEW
« 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