| 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 4108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4119 const String& vm_name = String::Handle(Name()); | 4119 const String& vm_name = String::Handle(Name()); |
| 4120 AddNameProperties(&jsobj, user_name, vm_name); | 4120 AddNameProperties(&jsobj, user_name, vm_name); |
| 4121 if (ref) { | 4121 if (ref) { |
| 4122 return; | 4122 return; |
| 4123 } | 4123 } |
| 4124 | 4124 |
| 4125 const Error& err = Error::Handle(EnsureIsFinalized(Isolate::Current())); | 4125 const Error& err = Error::Handle(EnsureIsFinalized(Isolate::Current())); |
| 4126 if (!err.IsNull()) { | 4126 if (!err.IsNull()) { |
| 4127 jsobj.AddProperty("error", err); | 4127 jsobj.AddProperty("error", err); |
| 4128 } | 4128 } |
| 4129 jsobj.AddProperty("implemented", is_implemented()); | |
| 4130 jsobj.AddProperty("abstract", is_abstract()); | 4129 jsobj.AddProperty("abstract", is_abstract()); |
| 4131 jsobj.AddProperty("patch", is_patch()); | |
| 4132 jsobj.AddProperty("finalized", is_finalized()); | |
| 4133 jsobj.AddProperty("const", is_const()); | 4130 jsobj.AddProperty("const", is_const()); |
| 4131 jsobj.AddProperty("_finalized", is_finalized()); |
| 4132 jsobj.AddProperty("_implemented", is_implemented()); |
| 4133 jsobj.AddProperty("_patch", is_patch()); |
| 4134 const Class& superClass = Class::Handle(SuperClass()); | 4134 const Class& superClass = Class::Handle(SuperClass()); |
| 4135 if (!superClass.IsNull()) { | 4135 if (!superClass.IsNull()) { |
| 4136 jsobj.AddProperty("super", superClass); | 4136 jsobj.AddProperty("super", superClass); |
| 4137 } | 4137 } |
| 4138 jsobj.AddProperty("library", Object::Handle(library())); | 4138 jsobj.AddProperty("library", Object::Handle(library())); |
| 4139 const Script& script = Script::Handle(this->script()); | 4139 const Script& script = Script::Handle(this->script()); |
| 4140 if (!script.IsNull()) { | 4140 if (!script.IsNull()) { |
| 4141 jsobj.AddProperty("script", script); | 4141 jsobj.AddProperty("script", script); |
| 4142 jsobj.AddProperty("tokenPos", token_pos()); | 4142 jsobj.AddProperty("tokenPos", token_pos()); |
| 4143 jsobj.AddProperty("endTokenPos", ComputeEndTokenPos()); | 4143 jsobj.AddProperty("endTokenPos", ComputeEndTokenPos()); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4186 // types to the vmservice. | 4186 // types to the vmservice. |
| 4187 subclass ^= subclasses.At(i); | 4187 subclass ^= subclasses.At(i); |
| 4188 subclasses_array.AddValue(subclass); | 4188 subclasses_array.AddValue(subclass); |
| 4189 } | 4189 } |
| 4190 } | 4190 } |
| 4191 } | 4191 } |
| 4192 { | 4192 { |
| 4193 ClassTable* class_table = Isolate::Current()->class_table(); | 4193 ClassTable* class_table = Isolate::Current()->class_table(); |
| 4194 const ClassHeapStats* stats = class_table->StatsWithUpdatedSize(id()); | 4194 const ClassHeapStats* stats = class_table->StatsWithUpdatedSize(id()); |
| 4195 if (stats != NULL) { | 4195 if (stats != NULL) { |
| 4196 JSONObject allocation_stats(&jsobj, "allocationStats"); | 4196 JSONObject allocation_stats(&jsobj, "_allocationStats"); |
| 4197 stats->PrintToJSONObject(*this, &allocation_stats); | 4197 stats->PrintToJSONObject(*this, &allocation_stats); |
| 4198 } | 4198 } |
| 4199 } | 4199 } |
| 4200 } | 4200 } |
| 4201 | 4201 |
| 4202 | 4202 |
| 4203 void Class::InsertCanonicalConstant(intptr_t index, | 4203 void Class::InsertCanonicalConstant(intptr_t index, |
| 4204 const Instance& constant) const { | 4204 const Instance& constant) const { |
| 4205 // The constant needs to be added to the list. Grow the list if it is full. | 4205 // The constant needs to be added to the list. Grow the list if it is full. |
| 4206 Array& canonical_list = Array::Handle(constants()); | 4206 Array& canonical_list = Array::Handle(constants()); |
| (...skipping 2677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6884 if (!parent.IsNull()) { | 6884 if (!parent.IsNull()) { |
| 6885 jsobj.AddProperty("owner", parent); | 6885 jsobj.AddProperty("owner", parent); |
| 6886 } else if (cls.IsTopLevel()) { | 6886 } else if (cls.IsTopLevel()) { |
| 6887 const Library& library = Library::Handle(cls.library()); | 6887 const Library& library = Library::Handle(cls.library()); |
| 6888 jsobj.AddProperty("owner", library); | 6888 jsobj.AddProperty("owner", library); |
| 6889 } else { | 6889 } else { |
| 6890 jsobj.AddProperty("owner", cls); | 6890 jsobj.AddProperty("owner", cls); |
| 6891 } | 6891 } |
| 6892 | 6892 |
| 6893 const char* kind_string = Function::KindToCString(kind()); | 6893 const char* kind_string = Function::KindToCString(kind()); |
| 6894 jsobj.AddProperty("kind", kind_string); | 6894 jsobj.AddProperty("_kind", kind_string); |
| 6895 jsobj.AddProperty("static", is_static()); |
| 6896 jsobj.AddProperty("const", is_const()); |
| 6895 if (ref) { | 6897 if (ref) { |
| 6896 return; | 6898 return; |
| 6897 } | 6899 } |
| 6898 jsobj.AddProperty("static", is_static()); | |
| 6899 jsobj.AddProperty("const", is_const()); | |
| 6900 Code& code = Code::Handle(CurrentCode()); | 6900 Code& code = Code::Handle(CurrentCode()); |
| 6901 if (!code.IsNull()) { | 6901 if (!code.IsNull()) { |
| 6902 jsobj.AddProperty("code", code); | 6902 jsobj.AddProperty("code", code); |
| 6903 } | 6903 } |
| 6904 jsobj.AddProperty("_optimizable", is_optimizable()); | 6904 jsobj.AddProperty("_optimizable", is_optimizable()); |
| 6905 jsobj.AddProperty("_inlinable", is_inlinable()); | 6905 jsobj.AddProperty("_inlinable", is_inlinable()); |
| 6906 code = unoptimized_code(); | 6906 code = unoptimized_code(); |
| 6907 if (!code.IsNull()) { | 6907 if (!code.IsNull()) { |
| 6908 jsobj.AddProperty("_unoptimizedCode", code); | 6908 jsobj.AddProperty("_unoptimizedCode", code); |
| 6909 } | 6909 } |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7223 JSONObject jsobj(stream); | 7223 JSONObject jsobj(stream); |
| 7224 Class& cls = Class::Handle(owner()); | 7224 Class& cls = Class::Handle(owner()); |
| 7225 intptr_t id = cls.FindFieldIndex(*this); | 7225 intptr_t id = cls.FindFieldIndex(*this); |
| 7226 ASSERT(id >= 0); | 7226 ASSERT(id >= 0); |
| 7227 intptr_t cid = cls.id(); | 7227 intptr_t cid = cls.id(); |
| 7228 AddTypeProperties(&jsobj, "Field", JSONType(), ref); | 7228 AddTypeProperties(&jsobj, "Field", JSONType(), ref); |
| 7229 jsobj.AddFixedServiceId("classes/%" Pd "/fields/%" Pd "", cid, id); | 7229 jsobj.AddFixedServiceId("classes/%" Pd "/fields/%" Pd "", cid, id); |
| 7230 const String& user_name = String::Handle(PrettyName()); | 7230 const String& user_name = String::Handle(PrettyName()); |
| 7231 const String& vm_name = String::Handle(name()); | 7231 const String& vm_name = String::Handle(name()); |
| 7232 AddNameProperties(&jsobj, user_name, vm_name); | 7232 AddNameProperties(&jsobj, user_name, vm_name); |
| 7233 if (is_static()) { | |
| 7234 const Instance& valueObj = Instance::Handle(value()); | |
| 7235 jsobj.AddProperty("value", valueObj); | |
| 7236 } | |
| 7237 | |
| 7238 if (cls.IsTopLevel()) { | 7233 if (cls.IsTopLevel()) { |
| 7239 const Library& library = Library::Handle(cls.library()); | 7234 const Library& library = Library::Handle(cls.library()); |
| 7240 jsobj.AddProperty("owner", library); | 7235 jsobj.AddProperty("owner", library); |
| 7241 } else { | 7236 } else { |
| 7242 jsobj.AddProperty("owner", cls); | 7237 jsobj.AddProperty("owner", cls); |
| 7243 } | 7238 } |
| 7244 | 7239 |
| 7245 AbstractType& declared_type = AbstractType::Handle(type()); | 7240 AbstractType& declared_type = AbstractType::Handle(type()); |
| 7246 jsobj.AddProperty("declaredType", declared_type); | 7241 jsobj.AddProperty("declaredType", declared_type); |
| 7247 jsobj.AddProperty("static", is_static()); | 7242 jsobj.AddProperty("static", is_static()); |
| 7248 jsobj.AddProperty("final", is_final()); | 7243 jsobj.AddProperty("final", is_final()); |
| 7249 jsobj.AddProperty("const", is_const()); | 7244 jsobj.AddProperty("const", is_const()); |
| 7250 if (ref) { | 7245 if (ref) { |
| 7251 return; | 7246 return; |
| 7252 } | 7247 } |
| 7248 if (is_static()) { |
| 7249 const Instance& valueObj = Instance::Handle(value()); |
| 7250 jsobj.AddProperty("staticValue", valueObj); |
| 7251 } |
| 7252 |
| 7253 jsobj.AddProperty("_guardNullable", is_nullable()); | 7253 jsobj.AddProperty("_guardNullable", is_nullable()); |
| 7254 if (guarded_cid() == kIllegalCid) { | 7254 if (guarded_cid() == kIllegalCid) { |
| 7255 jsobj.AddProperty("_guardClass", "unknown"); | 7255 jsobj.AddProperty("_guardClass", "unknown"); |
| 7256 } else if (guarded_cid() == kDynamicCid) { | 7256 } else if (guarded_cid() == kDynamicCid) { |
| 7257 jsobj.AddProperty("_guardClass", "dynamic"); | 7257 jsobj.AddProperty("_guardClass", "dynamic"); |
| 7258 } else { | 7258 } else { |
| 7259 ClassTable* table = Isolate::Current()->class_table(); | 7259 ClassTable* table = Isolate::Current()->class_table(); |
| 7260 ASSERT(table->IsValidIndex(guarded_cid())); | 7260 ASSERT(table->IsValidIndex(guarded_cid())); |
| 7261 cls ^= table->At(guarded_cid()); | 7261 cls ^= table->At(guarded_cid()); |
| 7262 jsobj.AddProperty("_guardClass", cls); | 7262 jsobj.AddProperty("_guardClass", cls); |
| (...skipping 6858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14121 jsfield.AddProperty("decl", field); | 14121 jsfield.AddProperty("decl", field); |
| 14122 jsfield.AddProperty("value", fieldValue); | 14122 jsfield.AddProperty("value", fieldValue); |
| 14123 } | 14123 } |
| 14124 } | 14124 } |
| 14125 } | 14125 } |
| 14126 cls = cls.SuperClass(); | 14126 cls = cls.SuperClass(); |
| 14127 } | 14127 } |
| 14128 } | 14128 } |
| 14129 | 14129 |
| 14130 if (NumNativeFields() > 0) { | 14130 if (NumNativeFields() > 0) { |
| 14131 JSONArray jsarr(jsobj, "nativeFields"); | 14131 JSONArray jsarr(jsobj, "_nativeFields"); |
| 14132 for (intptr_t i = 0; i < NumNativeFields(); i++) { | 14132 for (intptr_t i = 0; i < NumNativeFields(); i++) { |
| 14133 intptr_t value = GetNativeField(i); | 14133 intptr_t value = GetNativeField(i); |
| 14134 JSONObject jsfield(&jsarr); | 14134 JSONObject jsfield(&jsarr); |
| 14135 jsfield.AddProperty("index", i); | 14135 jsfield.AddProperty("index", i); |
| 14136 jsfield.AddProperty("value", value); | 14136 jsfield.AddProperty("value", value); |
| 14137 } | 14137 } |
| 14138 } | 14138 } |
| 14139 } | 14139 } |
| 14140 | 14140 |
| 14141 | 14141 |
| (...skipping 6656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20798 return tag_label.ToCString(); | 20798 return tag_label.ToCString(); |
| 20799 } | 20799 } |
| 20800 | 20800 |
| 20801 | 20801 |
| 20802 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20802 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 20803 Instance::PrintJSONImpl(stream, ref); | 20803 Instance::PrintJSONImpl(stream, ref); |
| 20804 } | 20804 } |
| 20805 | 20805 |
| 20806 | 20806 |
| 20807 } // namespace dart | 20807 } // namespace dart |
| OLD | NEW |