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

Side by Side 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: 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/service.h" 5 #include "vm/service.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "include/dart_native_api.h" 8 #include "include/dart_native_api.h"
9 #include "platform/globals.h" 9 #include "platform/globals.h"
10 10
(...skipping 17 matching lines...) Expand all
28 #include "vm/parser.h" 28 #include "vm/parser.h"
29 #include "vm/port.h" 29 #include "vm/port.h"
30 #include "vm/profiler_service.h" 30 #include "vm/profiler_service.h"
31 #include "vm/reusable_handles.h" 31 #include "vm/reusable_handles.h"
32 #include "vm/service_event.h" 32 #include "vm/service_event.h"
33 #include "vm/service_isolate.h" 33 #include "vm/service_isolate.h"
34 #include "vm/source_report.h" 34 #include "vm/source_report.h"
35 #include "vm/stack_frame.h" 35 #include "vm/stack_frame.h"
36 #include "vm/symbols.h" 36 #include "vm/symbols.h"
37 #include "vm/timeline.h" 37 #include "vm/timeline.h"
38 #include "vm/type_table.h"
38 #include "vm/unicode.h" 39 #include "vm/unicode.h"
39 #include "vm/version.h" 40 #include "vm/version.h"
40 41
41 namespace dart { 42 namespace dart {
42 43
43 #define Z (T->zone()) 44 #define Z (T->zone())
44 45
45 46
46 DECLARE_FLAG(bool, trace_service); 47 DECLARE_FLAG(bool, trace_service);
47 DECLARE_FLAG(bool, trace_service_pause_events); 48 DECLARE_FLAG(bool, trace_service_pause_events);
(...skipping 1534 matching lines...) Expand 10 before | Expand all | Expand 10 after
1582 1583
1583 } else if (strcmp(parts[2], "types") == 0) { 1584 } else if (strcmp(parts[2], "types") == 0) {
1584 // Type ids look like: "classes/17/types/11" 1585 // Type ids look like: "classes/17/types/11"
1585 if (num_parts != 4) { 1586 if (num_parts != 4) {
1586 return Object::sentinel().raw(); 1587 return Object::sentinel().raw();
1587 } 1588 }
1588 intptr_t id; 1589 intptr_t id;
1589 if (!GetIntegerId(parts[3], &id)) { 1590 if (!GetIntegerId(parts[3], &id)) {
1590 return Object::sentinel().raw(); 1591 return Object::sentinel().raw();
1591 } 1592 }
1592 Type& type = Type::Handle(zone); 1593 if (id != 0) {
1593 type ^= cls.CanonicalTypeFromIndex(id);
1594 if (type.IsNull()) {
1595 return Object::sentinel().raw(); 1594 return Object::sentinel().raw();
1596 } 1595 }
1597 return type.raw(); 1596 const Type& type = Type::Handle(zone, cls.CanonicalType());
1597 if (!type.IsNull()) {
1598 return type.raw();
1599 }
1598 } 1600 }
1599 1601
1600 // Not found. 1602 // Not found.
1601 return Object::sentinel().raw(); 1603 return Object::sentinel().raw();
1602 } 1604 }
1603 1605
1604 1606
1605 static RawObject* LookupHeapObjectTypeArguments(Thread* thread, 1607 static RawObject* LookupHeapObjectTypeArguments(Thread* thread,
1606 char** parts, int num_parts) { 1608 char** parts, int num_parts) {
1607 Isolate* isolate = thread->isolate(); 1609 Isolate* isolate = thread->isolate();
(...skipping 1951 matching lines...) Expand 10 before | Expand all | Expand 10 after
3559 RUNNABLE_ISOLATE_PARAMETER, 3561 RUNNABLE_ISOLATE_PARAMETER,
3560 NULL, 3562 NULL,
3561 }; 3563 };
3562 3564
3563 3565
3564 static bool GetTypeArgumentsList(Thread* thread, JSONStream* js) { 3566 static bool GetTypeArgumentsList(Thread* thread, JSONStream* js) {
3565 bool only_with_instantiations = false; 3567 bool only_with_instantiations = false;
3566 if (js->ParamIs("onlyWithInstantiations", "true")) { 3568 if (js->ParamIs("onlyWithInstantiations", "true")) {
3567 only_with_instantiations = true; 3569 only_with_instantiations = true;
3568 } 3570 }
3571 Zone* zone = thread->zone();
3569 ObjectStore* object_store = thread->isolate()->object_store(); 3572 ObjectStore* object_store = thread->isolate()->object_store();
3570 const Array& table = Array::Handle(object_store->canonical_type_arguments()); 3573 CanonicalTypeArgumentsSet typeargs_table(
3571 ASSERT(table.Length() > 0); 3574 zone, object_store->canonical_type_arguments());
3572 TypeArguments& type_args = TypeArguments::Handle(); 3575 const intptr_t table_size = typeargs_table.NumEntries();
3573 const intptr_t table_size = table.Length() - 1; 3576 const intptr_t table_used = typeargs_table.NumOccupied();
3574 const intptr_t table_used = Smi::Value(Smi::RawCast(table.At(table_size))); 3577 const Array& typeargs_array = Array::Handle(
3578 zone, HashTables::ToArray(typeargs_table, false));
3579 ASSERT(typeargs_array.Length() == table_used);
3580 TypeArguments& typeargs = TypeArguments::Handle(zone);
3575 JSONObject jsobj(js); 3581 JSONObject jsobj(js);
3576 jsobj.AddProperty("type", "TypeArgumentsList"); 3582 jsobj.AddProperty("type", "TypeArgumentsList");
3577 jsobj.AddProperty("canonicalTypeArgumentsTableSize", table_size); 3583 jsobj.AddProperty("canonicalTypeArgumentsTableSize", table_size);
3578 jsobj.AddProperty("canonicalTypeArgumentsTableUsed", table_used); 3584 jsobj.AddProperty("canonicalTypeArgumentsTableUsed", table_used);
3579 JSONArray members(&jsobj, "typeArguments"); 3585 JSONArray members(&jsobj, "typeArguments");
3580 for (intptr_t i = 0; i < table_size; i++) { 3586 for (intptr_t i = 0; i < table_used; i++) {
3581 type_args ^= table.At(i); 3587 typeargs ^= typeargs_array.At(i);
3582 if (!type_args.IsNull()) { 3588 if (!typeargs.IsNull()) {
3583 if (!only_with_instantiations || type_args.HasInstantiations()) { 3589 if (!only_with_instantiations || typeargs.HasInstantiations()) {
3584 members.AddValue(type_args); 3590 members.AddValue(typeargs);
3585 } 3591 }
3586 } 3592 }
3587 } 3593 }
3594 typeargs_table.Release();
3588 return true; 3595 return true;
3589 } 3596 }
3590 3597
3591 3598
3592 static const MethodParameter* get_version_params[] = { 3599 static const MethodParameter* get_version_params[] = {
3593 NO_ISOLATE_PARAMETER, 3600 NO_ISOLATE_PARAMETER,
3594 NULL, 3601 NULL,
3595 }; 3602 };
3596 3603
3597 3604
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
3979 if (strcmp(method_name, method.name) == 0) { 3986 if (strcmp(method_name, method.name) == 0) {
3980 return &method; 3987 return &method;
3981 } 3988 }
3982 } 3989 }
3983 return NULL; 3990 return NULL;
3984 } 3991 }
3985 3992
3986 #endif // !PRODUCT 3993 #endif // !PRODUCT
3987 3994
3988 } // namespace dart 3995 } // namespace dart
OLDNEW
« runtime/vm/object.cc ('K') | « runtime/vm/raw_object.h ('k') | runtime/vm/type_table.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698