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

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-merge-conflicts 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
« no previous file with comments | « runtime/vm/object_reload.cc ('k') | runtime/vm/object_store.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 920 matching lines...) Expand 10 before | Expand all | Expand 10 after
1123 UNREACHABLE(); 1130 UNREACHABLE();
1124 } 1131 }
1125 1132
1126 1133
1127 void Type::PrintJSONImpl(JSONStream* stream, bool ref) const { 1134 void Type::PrintJSONImpl(JSONStream* stream, bool ref) const {
1128 JSONObject jsobj(stream); 1135 JSONObject jsobj(stream);
1129 PrintSharedInstanceJSON(&jsobj, ref); 1136 PrintSharedInstanceJSON(&jsobj, ref);
1130 jsobj.AddProperty("kind", "Type"); 1137 jsobj.AddProperty("kind", "Type");
1131 if (IsCanonical()) { 1138 if (IsCanonical()) {
1132 const Class& type_cls = Class::Handle(type_class()); 1139 const Class& type_cls = Class::Handle(type_class());
1133 intptr_t id = type_cls.FindCanonicalTypeIndex(*this); 1140 if (type_cls.CanonicalType() == raw()) {
1134 ASSERT(id >= 0); 1141 intptr_t cid = type_cls.id();
1135 intptr_t cid = type_cls.id(); 1142 jsobj.AddFixedServiceId("classes/%" Pd "/types/%d", cid, 0);
1136 jsobj.AddFixedServiceId("classes/%" Pd "/types/%" Pd "", cid, id); 1143 jsobj.AddProperty("typeClass", type_cls);
1137 jsobj.AddProperty("typeClass", type_cls); 1144 } else {
1145 jsobj.AddServiceId(*this);
1146 }
1138 } else { 1147 } else {
1139 jsobj.AddServiceId(*this); 1148 jsobj.AddServiceId(*this);
1140 } 1149 }
1141 const String& user_name = String::Handle(UserVisibleName()); 1150 const String& user_name = String::Handle(UserVisibleName());
1142 const String& vm_name = String::Handle(Name()); 1151 const String& vm_name = String::Handle(Name());
1143 AddNameProperties(&jsobj, user_name, vm_name); 1152 AddNameProperties(&jsobj, user_name, vm_name);
1144 if (ref) { 1153 if (ref) {
1145 return; 1154 return;
1146 } 1155 }
1147 const TypeArguments& typeArgs = TypeArguments::Handle(arguments()); 1156 const TypeArguments& typeArgs = TypeArguments::Handle(arguments());
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
1588 jsobj.AddProperty("mirrorReferent", referent_handle); 1597 jsobj.AddProperty("mirrorReferent", referent_handle);
1589 } 1598 }
1590 1599
1591 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 1600 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
1592 Instance::PrintJSONImpl(stream, ref); 1601 Instance::PrintJSONImpl(stream, ref);
1593 } 1602 }
1594 1603
1595 #endif 1604 #endif
1596 1605
1597 } // namespace dart 1606 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object_reload.cc ('k') | runtime/vm/object_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698