Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/object.h" | 5 #include "vm/object.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
| 10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
| (...skipping 4019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4030 } | 4030 } |
| 4031 return FinalizeHash(result); | 4031 return FinalizeHash(result); |
| 4032 } | 4032 } |
| 4033 | 4033 |
| 4034 | 4034 |
| 4035 RawString* TypeArguments::SubvectorName(intptr_t from_index, | 4035 RawString* TypeArguments::SubvectorName(intptr_t from_index, |
| 4036 intptr_t len, | 4036 intptr_t len, |
| 4037 NameVisibility name_visibility) const { | 4037 NameVisibility name_visibility) const { |
| 4038 ASSERT(from_index + len <= Length()); | 4038 ASSERT(from_index + len <= Length()); |
| 4039 String& name = String::Handle(); | 4039 String& name = String::Handle(); |
| 4040 const intptr_t num_strings = 2*len + 1; // "<""T"", ""T"">". | 4040 const intptr_t num_strings = (len == 0) ? 2 : 2*len + 1; // "<""T"", ""T"">". |
| 4041 const Array& strings = Array::Handle(Array::New(num_strings)); | 4041 const Array& strings = Array::Handle(Array::New(num_strings)); |
| 4042 intptr_t s = 0; | 4042 intptr_t s = 0; |
| 4043 strings.SetAt(s++, Symbols::LAngleBracket()); | 4043 strings.SetAt(s++, Symbols::LAngleBracket()); |
| 4044 AbstractType& type = AbstractType::Handle(); | 4044 AbstractType& type = AbstractType::Handle(); |
| 4045 for (intptr_t i = 0; i < len; i++) { | 4045 for (intptr_t i = 0; i < len; i++) { |
| 4046 type = TypeAt(from_index + i); | 4046 type = TypeAt(from_index + i); |
| 4047 name = type.BuildName(name_visibility); | 4047 name = type.BuildName(name_visibility); |
| 4048 strings.SetAt(s++, name); | 4048 strings.SetAt(s++, name); |
| 4049 if (i < len - 1) { | 4049 if (i < len - 1) { |
| 4050 strings.SetAt(s++, Symbols::CommaSpace()); | 4050 strings.SetAt(s++, Symbols::CommaSpace()); |
| (...skipping 2267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6318 selector = "closures"; | 6318 selector = "closures"; |
| 6319 } else if (IsImplicitClosureFunction()) { | 6319 } else if (IsImplicitClosureFunction()) { |
| 6320 id = cls.FindImplicitClosureFunctionIndex(*this); | 6320 id = cls.FindImplicitClosureFunctionIndex(*this); |
| 6321 selector = "implicit_closures"; | 6321 selector = "implicit_closures"; |
| 6322 } else if (IsNoSuchMethodDispatcher() || IsInvokeFieldDispatcher()) { | 6322 } else if (IsNoSuchMethodDispatcher() || IsInvokeFieldDispatcher()) { |
| 6323 id = cls.FindInvocationDispatcherFunctionIndex(*this); | 6323 id = cls.FindInvocationDispatcherFunctionIndex(*this); |
| 6324 selector = "dispatchers"; | 6324 selector = "dispatchers"; |
| 6325 } else { | 6325 } else { |
| 6326 id = cls.FindFunctionIndex(*this); | 6326 id = cls.FindFunctionIndex(*this); |
| 6327 selector = "functions"; | 6327 selector = "functions"; |
| 6328 } | 6328 } |
|
turnidge
2014/03/23 22:24:20
Did you consider grabbing an id from the object id
koda
2014/03/24 17:18:34
I wasn't sure whether all fields still work in all
| |
| 6329 ASSERT(id >= 0); | 6329 // TODO(17697): Oddball functions are treated as plain objects and use the |
| 6330 // object id ring. Current known examples are signature functions of closures | |
| 6331 // and stubs like 'megamorphic_miss'. | |
| 6332 if (id < 0) { | |
| 6333 return Object::PrintToJSONStream(stream, ref); | |
| 6334 } | |
| 6330 intptr_t cid = cls.id(); | 6335 intptr_t cid = cls.id(); |
| 6331 JSONObject jsobj(stream); | 6336 JSONObject jsobj(stream); |
| 6332 jsobj.AddProperty("type", JSONType(ref)); | 6337 jsobj.AddProperty("type", JSONType(ref)); |
| 6333 jsobj.AddPropertyF("id", "classes/%" Pd "/%s/%" Pd "", cid, selector, id); | 6338 jsobj.AddPropertyF("id", "classes/%" Pd "/%s/%" Pd "", cid, selector, id); |
| 6334 jsobj.AddProperty("name", internal_name); | 6339 jsobj.AddProperty("name", internal_name); |
| 6335 jsobj.AddProperty("user_name", user_name); | 6340 jsobj.AddProperty("user_name", user_name); |
| 6336 jsobj.AddProperty("class", cls); | 6341 jsobj.AddProperty("class", cls); |
| 6337 const Function& parent = Function::Handle(parent_function()); | 6342 const Function& parent = Function::Handle(parent_function()); |
| 6338 if (!parent.IsNull()) { | 6343 if (!parent.IsNull()) { |
| 6339 jsobj.AddProperty("parent", parent); | 6344 jsobj.AddProperty("parent", parent); |
| (...skipping 7134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 13474 OS::SNPrint(chars, len, format, class_name, args_cstr); | 13479 OS::SNPrint(chars, len, format, class_name, args_cstr); |
| 13475 return chars; | 13480 return chars; |
| 13476 } | 13481 } |
| 13477 } else { | 13482 } else { |
| 13478 return "Unresolved Type"; | 13483 return "Unresolved Type"; |
| 13479 } | 13484 } |
| 13480 } | 13485 } |
| 13481 | 13486 |
| 13482 | 13487 |
| 13483 void Type::PrintToJSONStream(JSONStream* stream, bool ref) const { | 13488 void Type::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 13489 // TODO(koda): Decide whether to assign stable ids to non-canonical types. | |
| 13490 if (!IsCanonical()) { | |
| 13491 return Object::PrintToJSONStream(stream, ref); | |
| 13492 } | |
|
turnidge
2014/03/23 22:24:20
Ditto previous comment. You could print an id fro
koda
2014/03/24 17:18:34
Also, here: not sure whether all printed propertie
| |
| 13484 ASSERT(IsCanonical()); | 13493 ASSERT(IsCanonical()); |
| 13485 JSONObject jsobj(stream); | 13494 JSONObject jsobj(stream); |
| 13486 jsobj.AddProperty("type", JSONType(ref)); | 13495 jsobj.AddProperty("type", JSONType(ref)); |
| 13487 const Class& type_cls = Class::Handle(type_class()); | 13496 const Class& type_cls = Class::Handle(type_class()); |
| 13488 intptr_t id = type_cls.FindCanonicalTypeIndex(*this); | 13497 intptr_t id = type_cls.FindCanonicalTypeIndex(*this); |
| 13489 ASSERT(id >= 0); | 13498 ASSERT(id >= 0); |
| 13490 intptr_t cid = type_cls.id(); | 13499 intptr_t cid = type_cls.id(); |
| 13491 jsobj.AddPropertyF("id", "classes/%" Pd "/types/%" Pd "", cid, id); | 13500 jsobj.AddPropertyF("id", "classes/%" Pd "/types/%" Pd "", cid, id); |
| 13492 const char* name = String::Handle(Name()).ToCString(); | 13501 const char* name = String::Handle(Name()).ToCString(); |
| 13493 const char* user_name = String::Handle(UserVisibleName()).ToCString(); | 13502 const char* user_name = String::Handle(UserVisibleName()).ToCString(); |
| (...skipping 3255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 16749 jsobj.AddProperty("length", Length()); | 16758 jsobj.AddProperty("length", Length()); |
| 16750 if (ref) { | 16759 if (ref) { |
| 16751 return; | 16760 return; |
| 16752 } | 16761 } |
| 16753 { | 16762 { |
| 16754 JSONArray jsarr(&jsobj, "elements"); | 16763 JSONArray jsarr(&jsobj, "elements"); |
| 16755 for (intptr_t index = 0; index < Length(); index++) { | 16764 for (intptr_t index = 0; index < Length(); index++) { |
| 16756 JSONObject jselement(&jsarr); | 16765 JSONObject jselement(&jsarr); |
| 16757 jselement.AddProperty("index", index); | 16766 jselement.AddProperty("index", index); |
| 16758 | 16767 |
| 16759 Instance& instance = Instance::Handle(); | 16768 Object& element = Object::Handle(At(index)); |
| 16760 instance ^= At(index); | 16769 jselement.AddProperty("value", element); |
| 16761 jselement.AddProperty("value", instance); | |
| 16762 } | 16770 } |
| 16763 } | 16771 } |
| 16764 } | 16772 } |
| 16765 | 16773 |
| 16766 | 16774 |
| 16767 RawArray* Array::Grow(const Array& source, | 16775 RawArray* Array::Grow(const Array& source, |
| 16768 intptr_t new_length, | 16776 intptr_t new_length, |
| 16769 Heap::Space space) { | 16777 Heap::Space space) { |
| 16770 const Array& result = Array::Handle(Array::New(new_length, space)); | 16778 const Array& result = Array::Handle(Array::New(new_length, space)); |
| 16771 intptr_t len = 0; | 16779 intptr_t len = 0; |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 17089 jsobj.AddProperty("length", Length()); | 17097 jsobj.AddProperty("length", Length()); |
| 17090 if (ref) { | 17098 if (ref) { |
| 17091 return; | 17099 return; |
| 17092 } | 17100 } |
| 17093 { | 17101 { |
| 17094 JSONArray jsarr(&jsobj, "elements"); | 17102 JSONArray jsarr(&jsobj, "elements"); |
| 17095 for (intptr_t index = 0; index < Length(); index++) { | 17103 for (intptr_t index = 0; index < Length(); index++) { |
| 17096 JSONObject jselement(&jsarr); | 17104 JSONObject jselement(&jsarr); |
| 17097 jselement.AddProperty("index", index); | 17105 jselement.AddProperty("index", index); |
| 17098 | 17106 |
| 17099 Instance& instance = Instance::Handle(); | 17107 Object& element = Object::Handle(At(index)); |
| 17100 instance ^= At(index); | 17108 jselement.AddProperty("value", element); |
| 17101 jselement.AddProperty("value", instance); | |
| 17102 } | 17109 } |
| 17103 } | 17110 } |
| 17104 } | 17111 } |
| 17105 | 17112 |
| 17106 | 17113 |
| 17107 RawFloat32x4* Float32x4::New(float v0, float v1, float v2, float v3, | 17114 RawFloat32x4* Float32x4::New(float v0, float v1, float v2, float v3, |
| 17108 Heap::Space space) { | 17115 Heap::Space space) { |
| 17109 ASSERT(Isolate::Current()->object_store()->float32x4_class() != | 17116 ASSERT(Isolate::Current()->object_store()->float32x4_class() != |
| 17110 Class::null()); | 17117 Class::null()); |
| 17111 Float32x4& result = Float32x4::Handle(); | 17118 Float32x4& result = Float32x4::Handle(); |
| (...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 17953 return "_MirrorReference"; | 17960 return "_MirrorReference"; |
| 17954 } | 17961 } |
| 17955 | 17962 |
| 17956 | 17963 |
| 17957 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 17964 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 17958 Instance::PrintToJSONStream(stream, ref); | 17965 Instance::PrintToJSONStream(stream, ref); |
| 17959 } | 17966 } |
| 17960 | 17967 |
| 17961 | 17968 |
| 17962 } // namespace dart | 17969 } // namespace dart |
| OLD | NEW |