| OLD | NEW |
| 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 1943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1954 parent_field_map = source_class.OffsetToFieldMap(); | 1954 parent_field_map = source_class.OffsetToFieldMap(); |
| 1955 intptr_t offset = slot_offset.Value(); | 1955 intptr_t offset = slot_offset.Value(); |
| 1956 if (offset > 0 && offset < parent_field_map.Length()) { | 1956 if (offset > 0 && offset < parent_field_map.Length()) { |
| 1957 field ^= parent_field_map.At(offset); | 1957 field ^= parent_field_map.At(offset); |
| 1958 jselement.AddProperty("parentField", field); | 1958 jselement.AddProperty("parentField", field); |
| 1959 } | 1959 } |
| 1960 } else { | 1960 } else { |
| 1961 intptr_t element_index = slot_offset.Value(); | 1961 intptr_t element_index = slot_offset.Value(); |
| 1962 jselement.AddProperty("_parentWordOffset", element_index); | 1962 jselement.AddProperty("_parentWordOffset", element_index); |
| 1963 } | 1963 } |
| 1964 | |
| 1965 // We nil out the array after generating the response to prevent | |
| 1966 // reporting suprious references when repeatedly looking for the | |
| 1967 // references to an object. | |
| 1968 path.SetAt(i * 2, Object::null_object()); | |
| 1969 } | 1964 } |
| 1970 } | 1965 } |
| 1966 |
| 1967 // We nil out the array after generating the response to prevent |
| 1968 // reporting suprious references when repeatedly looking for the |
| 1969 // references to an object. |
| 1970 for (intptr_t i = 0; i < path.Length(); i++) { |
| 1971 path.SetAt(i, Object::null_object()); |
| 1972 } |
| 1973 |
| 1971 return true; | 1974 return true; |
| 1972 } | 1975 } |
| 1973 | 1976 |
| 1974 | 1977 |
| 1975 static const MethodParameter* get_inbound_references_params[] = { | 1978 static const MethodParameter* get_inbound_references_params[] = { |
| 1976 RUNNABLE_ISOLATE_PARAMETER, | 1979 RUNNABLE_ISOLATE_PARAMETER, |
| 1977 NULL, | 1980 NULL, |
| 1978 }; | 1981 }; |
| 1979 | 1982 |
| 1980 | 1983 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2072 } else { | 2075 } else { |
| 2073 intptr_t element_index = slot_offset.Value(); | 2076 intptr_t element_index = slot_offset.Value(); |
| 2074 jselement.AddProperty("_parentWordOffset", element_index); | 2077 jselement.AddProperty("_parentWordOffset", element_index); |
| 2075 } | 2078 } |
| 2076 } | 2079 } |
| 2077 } | 2080 } |
| 2078 | 2081 |
| 2079 // We nil out the array after generating the response to prevent | 2082 // We nil out the array after generating the response to prevent |
| 2080 // reporting spurious references when looking for inbound references | 2083 // reporting spurious references when looking for inbound references |
| 2081 // after looking for a retaining path. | 2084 // after looking for a retaining path. |
| 2082 for (intptr_t i = 0; i < limit; ++i) { | 2085 for (intptr_t i = 0; i < path.Length(); i++) { |
| 2083 path.SetAt(i * 2, Object::null_object()); | 2086 path.SetAt(i, Object::null_object()); |
| 2084 } | 2087 } |
| 2085 | 2088 |
| 2086 return true; | 2089 return true; |
| 2087 } | 2090 } |
| 2088 | 2091 |
| 2089 | 2092 |
| 2090 static const MethodParameter* get_retaining_path_params[] = { | 2093 static const MethodParameter* get_retaining_path_params[] = { |
| 2091 RUNNABLE_ISOLATE_PARAMETER, | 2094 RUNNABLE_ISOLATE_PARAMETER, |
| 2092 NULL, | 2095 NULL, |
| 2093 }; | 2096 }; |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2379 !obj.IsClass()) { | 2382 !obj.IsClass()) { |
| 2380 PrintInvalidParamError(js, "classId"); | 2383 PrintInvalidParamError(js, "classId"); |
| 2381 return true; | 2384 return true; |
| 2382 } | 2385 } |
| 2383 const Class& cls = Class::Cast(obj); | 2386 const Class& cls = Class::Cast(obj); |
| 2384 Array& storage = Array::Handle(Array::New(limit)); | 2387 Array& storage = Array::Handle(Array::New(limit)); |
| 2385 GetInstancesVisitor visitor(cls, storage); | 2388 GetInstancesVisitor visitor(cls, storage); |
| 2386 ObjectGraph graph(thread); | 2389 ObjectGraph graph(thread); |
| 2387 graph.IterateObjects(&visitor); | 2390 graph.IterateObjects(&visitor); |
| 2388 intptr_t count = visitor.count(); | 2391 intptr_t count = visitor.count(); |
| 2389 if (count < limit) { | |
| 2390 // Truncate the list using utility method for GrowableObjectArray. | |
| 2391 GrowableObjectArray& wrapper = GrowableObjectArray::Handle( | |
| 2392 GrowableObjectArray::New(storage)); | |
| 2393 wrapper.SetLength(count); | |
| 2394 storage = Array::MakeArray(wrapper); | |
| 2395 } | |
| 2396 JSONObject jsobj(js); | 2392 JSONObject jsobj(js); |
| 2397 jsobj.AddProperty("type", "InstanceSet"); | 2393 jsobj.AddProperty("type", "InstanceSet"); |
| 2398 jsobj.AddProperty("totalCount", count); | 2394 jsobj.AddProperty("totalCount", count); |
| 2399 { | 2395 { |
| 2400 JSONArray samples(&jsobj, "samples"); | 2396 JSONArray samples(&jsobj, "samples"); |
| 2401 for (int i = 0; i < storage.Length(); i++) { | 2397 for (int i = 0; (i < storage.Length()) && (i < count); i++) { |
| 2402 const Object& sample = Object::Handle(storage.At(i)); | 2398 const Object& sample = Object::Handle(storage.At(i)); |
| 2403 samples.AddValue(sample); | 2399 samples.AddValue(sample); |
| 2404 } | 2400 } |
| 2405 } | 2401 } |
| 2402 |
| 2403 // We nil out the array after generating the response to prevent |
| 2404 // reporting spurious references when looking for inbound references |
| 2405 // after looking at allInstances. |
| 2406 for (intptr_t i = 0; i < storage.Length(); i++) { |
| 2407 storage.SetAt(i, Object::null_object()); |
| 2408 } |
| 2409 |
| 2406 return true; | 2410 return true; |
| 2407 } | 2411 } |
| 2408 | 2412 |
| 2409 | 2413 |
| 2410 static const char* const report_enum_names[] = { | 2414 static const char* const report_enum_names[] = { |
| 2411 SourceReport::kCallSitesStr, | 2415 SourceReport::kCallSitesStr, |
| 2412 SourceReport::kCoverageStr, | 2416 SourceReport::kCoverageStr, |
| 2413 SourceReport::kPossibleBreakpointsStr, | 2417 SourceReport::kPossibleBreakpointsStr, |
| 2414 SourceReport::kProfileStr, | 2418 SourceReport::kProfileStr, |
| 2415 NULL, | 2419 NULL, |
| (...skipping 1755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4171 if (strcmp(method_name, method.name) == 0) { | 4175 if (strcmp(method_name, method.name) == 0) { |
| 4172 return &method; | 4176 return &method; |
| 4173 } | 4177 } |
| 4174 } | 4178 } |
| 4175 return NULL; | 4179 return NULL; |
| 4176 } | 4180 } |
| 4177 | 4181 |
| 4178 #endif // !PRODUCT | 4182 #endif // !PRODUCT |
| 4179 | 4183 |
| 4180 } // namespace dart | 4184 } // namespace dart |
| OLD | NEW |