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 1706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1717 | 1717 |
1718 return Error::null(); | 1718 return Error::null(); |
1719 } | 1719 } |
1720 | 1720 |
1721 | 1721 |
1722 void Object::Print() const { | 1722 void Object::Print() const { |
1723 THR_Print("%s\n", ToCString()); | 1723 THR_Print("%s\n", ToCString()); |
1724 } | 1724 } |
1725 | 1725 |
1726 | 1726 |
1727 static void AddNameProperties(JSONObject* jsobj, | |
1728 const String& name, | |
1729 const String& vm_name) { | |
1730 jsobj->AddProperty("name", name.ToCString()); | |
1731 if (!name.Equals(vm_name)) { | |
1732 jsobj->AddProperty("_vmName", vm_name.ToCString()); | |
1733 } | |
1734 } | |
1735 | |
1736 | |
1737 void Object::AddCommonObjectProperties(JSONObject* jsobj, | |
1738 const char* protocol_type, | |
1739 bool ref) const { | |
1740 const char* vm_type = JSONType(); | |
1741 bool same_type = (strcmp(protocol_type, vm_type) == 0); | |
1742 if (ref) { | |
1743 jsobj->AddPropertyF("type", "@%s", protocol_type); | |
1744 } else { | |
1745 jsobj->AddProperty("type", protocol_type); | |
1746 } | |
1747 if (!same_type) { | |
1748 jsobj->AddProperty("_vmType", vm_type); | |
1749 } | |
1750 if (!ref || IsInstance() || IsNull()) { | |
1751 // TODO(turnidge): Provide the type arguments here too? | |
1752 const Class& cls = Class::Handle(this->clazz()); | |
1753 jsobj->AddProperty("class", cls); | |
1754 } | |
1755 if (!ref) { | |
1756 if (raw()->IsHeapObject()) { | |
1757 jsobj->AddProperty("size", raw()->Size()); | |
1758 } else { | |
1759 jsobj->AddProperty("size", (intptr_t)0); | |
1760 } | |
1761 } | |
1762 } | |
1763 | |
1764 | |
1765 void Object::PrintJSON(JSONStream* stream, bool ref) const { | |
1766 if (IsNull()) { | |
1767 JSONObject jsobj(stream); | |
1768 AddCommonObjectProperties(&jsobj, "Instance", ref); | |
1769 jsobj.AddProperty("kind", "Null"); | |
1770 jsobj.AddFixedServiceId("objects/null"); | |
1771 jsobj.AddProperty("valueAsString", "null"); | |
1772 } else { | |
1773 PrintJSONImpl(stream, ref); | |
1774 } | |
1775 } | |
1776 | |
1777 | |
1778 void Object::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
1779 JSONObject jsobj(stream); | |
1780 AddCommonObjectProperties(&jsobj, "Object", ref); | |
1781 jsobj.AddServiceId(*this); | |
1782 if (ref) { | |
1783 return; | |
1784 } | |
1785 } | |
1786 | |
1787 | |
1788 RawString* Object::DictionaryName() const { | 1727 RawString* Object::DictionaryName() const { |
1789 return String::null(); | 1728 return String::null(); |
1790 } | 1729 } |
1791 | 1730 |
1792 | 1731 |
1793 void Object::InitializeObject(uword address, | 1732 void Object::InitializeObject(uword address, |
1794 intptr_t class_id, | 1733 intptr_t class_id, |
1795 intptr_t size, | 1734 intptr_t size, |
1796 bool is_vm_object) { | 1735 bool is_vm_object) { |
1797 uword initial_value = (class_id == kInstructionsCid) | 1736 uword initial_value = (class_id == kInstructionsCid) |
(...skipping 2329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4127 const char* Class::ToCString() const { | 4066 const char* Class::ToCString() const { |
4128 const Library& lib = Library::Handle(library()); | 4067 const Library& lib = Library::Handle(library()); |
4129 const char* library_name = lib.IsNull() ? "" : lib.ToCString(); | 4068 const char* library_name = lib.IsNull() ? "" : lib.ToCString(); |
4130 const char* patch_prefix = is_patch() ? "Patch " : ""; | 4069 const char* patch_prefix = is_patch() ? "Patch " : ""; |
4131 const char* class_name = String::Handle(Name()).ToCString(); | 4070 const char* class_name = String::Handle(Name()).ToCString(); |
4132 return OS::SCreate(Thread::Current()->zone(), | 4071 return OS::SCreate(Thread::Current()->zone(), |
4133 "%s %sClass: %s", library_name, patch_prefix, class_name); | 4072 "%s %sClass: %s", library_name, patch_prefix, class_name); |
4134 } | 4073 } |
4135 | 4074 |
4136 | 4075 |
4137 void Class::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
4138 Isolate* isolate = Isolate::Current(); | |
4139 JSONObject jsobj(stream); | |
4140 if ((raw() == Class::null()) || (id() == kFreeListElement)) { | |
4141 // TODO(turnidge): This is weird and needs to be changed. | |
4142 jsobj.AddProperty("type", "null"); | |
4143 return; | |
4144 } | |
4145 AddCommonObjectProperties(&jsobj, "Class", ref); | |
4146 jsobj.AddFixedServiceId("classes/%" Pd "", id()); | |
4147 const String& user_name = String::Handle(PrettyName()); | |
4148 const String& vm_name = String::Handle(Name()); | |
4149 AddNameProperties(&jsobj, user_name, vm_name); | |
4150 if (ref) { | |
4151 return; | |
4152 } | |
4153 | |
4154 const Error& err = Error::Handle(EnsureIsFinalized(Thread::Current())); | |
4155 if (!err.IsNull()) { | |
4156 jsobj.AddProperty("error", err); | |
4157 } | |
4158 jsobj.AddProperty("abstract", is_abstract()); | |
4159 jsobj.AddProperty("const", is_const()); | |
4160 jsobj.AddProperty("_finalized", is_finalized()); | |
4161 jsobj.AddProperty("_implemented", is_implemented()); | |
4162 jsobj.AddProperty("_patch", is_patch()); | |
4163 jsobj.AddProperty("_traceAllocations", TraceAllocation(isolate)); | |
4164 const Class& superClass = Class::Handle(SuperClass()); | |
4165 if (!superClass.IsNull()) { | |
4166 jsobj.AddProperty("super", superClass); | |
4167 } | |
4168 jsobj.AddProperty("library", Object::Handle(library())); | |
4169 const Script& script = Script::Handle(this->script()); | |
4170 if (!script.IsNull()) { | |
4171 jsobj.AddLocation(script, token_pos(), ComputeEndTokenPos()); | |
4172 } | |
4173 { | |
4174 JSONArray interfaces_array(&jsobj, "interfaces"); | |
4175 const Array& interface_array = Array::Handle(interfaces()); | |
4176 Type& interface_type = Type::Handle(); | |
4177 if (!interface_array.IsNull()) { | |
4178 for (intptr_t i = 0; i < interface_array.Length(); ++i) { | |
4179 interface_type ^= interface_array.At(i); | |
4180 interfaces_array.AddValue(interface_type); | |
4181 } | |
4182 } | |
4183 } | |
4184 { | |
4185 JSONArray fields_array(&jsobj, "fields"); | |
4186 const Array& field_array = Array::Handle(fields()); | |
4187 Field& field = Field::Handle(); | |
4188 if (!field_array.IsNull()) { | |
4189 for (intptr_t i = 0; i < field_array.Length(); ++i) { | |
4190 field ^= field_array.At(i); | |
4191 fields_array.AddValue(field); | |
4192 } | |
4193 } | |
4194 } | |
4195 { | |
4196 JSONArray functions_array(&jsobj, "functions"); | |
4197 const Array& function_array = Array::Handle(functions()); | |
4198 Function& function = Function::Handle(); | |
4199 if (!function_array.IsNull()) { | |
4200 for (intptr_t i = 0; i < function_array.Length(); i++) { | |
4201 function ^= function_array.At(i); | |
4202 functions_array.AddValue(function); | |
4203 } | |
4204 } | |
4205 } | |
4206 { | |
4207 JSONArray subclasses_array(&jsobj, "subclasses"); | |
4208 const GrowableObjectArray& subclasses = | |
4209 GrowableObjectArray::Handle(direct_subclasses()); | |
4210 if (!subclasses.IsNull()) { | |
4211 Class& subclass = Class::Handle(); | |
4212 for (intptr_t i = 0; i < subclasses.Length(); ++i) { | |
4213 // TODO(turnidge): Use the Type directly once regis has added | |
4214 // types to the vmservice. | |
4215 subclass ^= subclasses.At(i); | |
4216 subclasses_array.AddValue(subclass); | |
4217 } | |
4218 } | |
4219 } | |
4220 { | |
4221 ClassTable* class_table = Isolate::Current()->class_table(); | |
4222 const ClassHeapStats* stats = class_table->StatsWithUpdatedSize(id()); | |
4223 if (stats != NULL) { | |
4224 JSONObject allocation_stats(&jsobj, "_allocationStats"); | |
4225 stats->PrintToJSONObject(*this, &allocation_stats); | |
4226 } | |
4227 } | |
4228 } | |
4229 | |
4230 | |
4231 void Class::InsertCanonicalConstant(intptr_t index, | 4076 void Class::InsertCanonicalConstant(intptr_t index, |
4232 const Instance& constant) const { | 4077 const Instance& constant) const { |
4233 // The constant needs to be added to the list. Grow the list if it is full. | 4078 // The constant needs to be added to the list. Grow the list if it is full. |
4234 Array& canonical_list = Array::Handle(constants()); | 4079 Array& canonical_list = Array::Handle(constants()); |
4235 const intptr_t list_len = canonical_list.Length(); | 4080 const intptr_t list_len = canonical_list.Length(); |
4236 if (index >= list_len) { | 4081 if (index >= list_len) { |
4237 const intptr_t new_length = (list_len == 0) ? 4 : list_len + 4; | 4082 const intptr_t new_length = (list_len == 0) ? 4 : list_len + 4; |
4238 const Array& new_canonical_list = | 4083 const Array& new_canonical_list = |
4239 Array::Handle(Array::Grow(canonical_list, new_length, Heap::kOld)); | 4084 Array::Handle(Array::Grow(canonical_list, new_length, Heap::kOld)); |
4240 set_constants(new_canonical_list); | 4085 set_constants(new_canonical_list); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4299 } | 4144 } |
4300 | 4145 |
4301 | 4146 |
4302 const char* UnresolvedClass::ToCString() const { | 4147 const char* UnresolvedClass::ToCString() const { |
4303 const char* cname = String::Handle(Name()).ToCString(); | 4148 const char* cname = String::Handle(Name()).ToCString(); |
4304 return OS::SCreate(Thread::Current()->zone(), | 4149 return OS::SCreate(Thread::Current()->zone(), |
4305 "unresolved class '%s'", cname); | 4150 "unresolved class '%s'", cname); |
4306 } | 4151 } |
4307 | 4152 |
4308 | 4153 |
4309 void UnresolvedClass::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
4310 Object::PrintJSONImpl(stream, ref); | |
4311 } | |
4312 | |
4313 | |
4314 static uint32_t CombineHashes(uint32_t hash, uint32_t other_hash) { | 4154 static uint32_t CombineHashes(uint32_t hash, uint32_t other_hash) { |
4315 hash += other_hash; | 4155 hash += other_hash; |
4316 hash += hash << 10; | 4156 hash += hash << 10; |
4317 hash ^= hash >> 6; // Logical shift, unsigned hash. | 4157 hash ^= hash >> 6; // Logical shift, unsigned hash. |
4318 return hash; | 4158 return hash; |
4319 } | 4159 } |
4320 | 4160 |
4321 | 4161 |
4322 static uint32_t FinalizeHash(uint32_t hash) { | 4162 static uint32_t FinalizeHash(uint32_t hash) { |
4323 hash += hash << 3; | 4163 hash += hash << 3; |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4454 other_type = other.TypeAt(from_index + i); | 4294 other_type = other.TypeAt(from_index + i); |
4455 ASSERT(!other_type.IsNull()); | 4295 ASSERT(!other_type.IsNull()); |
4456 if (!type.TypeTest(test_kind, other_type, bound_error, space)) { | 4296 if (!type.TypeTest(test_kind, other_type, bound_error, space)) { |
4457 return false; | 4297 return false; |
4458 } | 4298 } |
4459 } | 4299 } |
4460 return true; | 4300 return true; |
4461 } | 4301 } |
4462 | 4302 |
4463 | 4303 |
4464 void TypeArguments::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
4465 JSONObject jsobj(stream); | |
4466 // The index in the canonical_type_arguments table cannot be used as part of | |
4467 // the object id (as in typearguments/id), because the indices are not | |
4468 // preserved when the table grows and the entries get rehashed. Use the ring. | |
4469 Isolate* isolate = Isolate::Current(); | |
4470 ObjectStore* object_store = isolate->object_store(); | |
4471 const Array& table = Array::Handle(object_store->canonical_type_arguments()); | |
4472 ASSERT(table.Length() > 0); | |
4473 AddCommonObjectProperties(&jsobj, "TypeArguments", ref); | |
4474 jsobj.AddServiceId(*this); | |
4475 const String& user_name = String::Handle(PrettyName()); | |
4476 const String& vm_name = String::Handle(Name()); | |
4477 AddNameProperties(&jsobj, user_name, vm_name); | |
4478 if (ref) { | |
4479 return; | |
4480 } | |
4481 { | |
4482 JSONArray jsarr(&jsobj, "types"); | |
4483 AbstractType& type_arg = AbstractType::Handle(); | |
4484 for (intptr_t i = 0; i < Length(); i++) { | |
4485 type_arg = TypeAt(i); | |
4486 jsarr.AddValue(type_arg); | |
4487 } | |
4488 } | |
4489 if (!IsInstantiated()) { | |
4490 JSONArray jsarr(&jsobj, "_instantiations"); | |
4491 Array& prior_instantiations = Array::Handle(instantiations()); | |
4492 ASSERT(prior_instantiations.Length() > 0); // Always at least a sentinel. | |
4493 TypeArguments& type_args = TypeArguments::Handle(); | |
4494 intptr_t i = 0; | |
4495 while (true) { | |
4496 if (prior_instantiations.At(i) == Smi::New(StubCode::kNoInstantiator)) { | |
4497 break; | |
4498 } | |
4499 JSONObject instantiation(&jsarr); | |
4500 type_args ^= prior_instantiations.At(i); | |
4501 instantiation.AddProperty("instantiator", type_args, true); | |
4502 type_args ^= prior_instantiations.At(i + 1); | |
4503 instantiation.AddProperty("instantiated", type_args, true); | |
4504 i += 2; | |
4505 } | |
4506 } | |
4507 } | |
4508 | |
4509 | |
4510 bool TypeArguments::HasInstantiations() const { | 4304 bool TypeArguments::HasInstantiations() const { |
4511 const Array& prior_instantiations = Array::Handle(instantiations()); | 4305 const Array& prior_instantiations = Array::Handle(instantiations()); |
4512 ASSERT(prior_instantiations.Length() > 0); // Always at least a sentinel. | 4306 ASSERT(prior_instantiations.Length() > 0); // Always at least a sentinel. |
4513 return prior_instantiations.Length() > 1; | 4307 return prior_instantiations.Length() > 1; |
4514 } | 4308 } |
4515 | 4309 |
4516 | 4310 |
4517 intptr_t TypeArguments::NumInstantiations() const { | 4311 intptr_t TypeArguments::NumInstantiations() const { |
4518 const Array& prior_instantiations = Array::Handle(instantiations()); | 4312 const Array& prior_instantiations = Array::Handle(instantiations()); |
4519 ASSERT(prior_instantiations.Length() > 0); // Always at least a sentinel. | 4313 ASSERT(prior_instantiations.Length() > 0); // Always at least a sentinel. |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5067 | 4861 |
5068 | 4862 |
5069 const char* PatchClass::ToCString() const { | 4863 const char* PatchClass::ToCString() const { |
5070 const Class& cls = Class::Handle(patched_class()); | 4864 const Class& cls = Class::Handle(patched_class()); |
5071 const char* cls_name = cls.ToCString(); | 4865 const char* cls_name = cls.ToCString(); |
5072 return OS::SCreate(Thread::Current()->zone(), | 4866 return OS::SCreate(Thread::Current()->zone(), |
5073 "PatchClass for %s", cls_name); | 4867 "PatchClass for %s", cls_name); |
5074 } | 4868 } |
5075 | 4869 |
5076 | 4870 |
5077 void PatchClass::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
5078 Object::PrintJSONImpl(stream, ref); | |
5079 } | |
5080 | |
5081 | |
5082 RawPatchClass* PatchClass::New(const Class& patched_class, | 4871 RawPatchClass* PatchClass::New(const Class& patched_class, |
5083 const Class& origin_class) { | 4872 const Class& origin_class) { |
5084 const PatchClass& result = PatchClass::Handle(PatchClass::New()); | 4873 const PatchClass& result = PatchClass::Handle(PatchClass::New()); |
5085 result.set_patched_class(patched_class); | 4874 result.set_patched_class(patched_class); |
5086 result.set_origin_class(origin_class); | 4875 result.set_origin_class(origin_class); |
5087 result.set_script(Script::Handle(origin_class.script())); | 4876 result.set_script(Script::Handle(origin_class.script())); |
5088 return result.raw(); | 4877 return result.raw(); |
5089 } | 4878 } |
5090 | 4879 |
5091 | 4880 |
(...skipping 25 matching lines...) Expand all Loading... |
5117 StorePointer(&raw_ptr()->origin_class_, value.raw()); | 4906 StorePointer(&raw_ptr()->origin_class_, value.raw()); |
5118 } | 4907 } |
5119 | 4908 |
5120 | 4909 |
5121 void PatchClass::set_script(const Script& value) const { | 4910 void PatchClass::set_script(const Script& value) const { |
5122 StorePointer(&raw_ptr()->script_, value.raw()); | 4911 StorePointer(&raw_ptr()->script_, value.raw()); |
5123 } | 4912 } |
5124 | 4913 |
5125 | 4914 |
5126 bool Function::HasBreakpoint() const { | 4915 bool Function::HasBreakpoint() const { |
| 4916 if (!FLAG_support_debugger) { |
| 4917 return false; |
| 4918 } |
5127 Thread* thread = Thread::Current(); | 4919 Thread* thread = Thread::Current(); |
5128 return thread->isolate()->debugger()->HasBreakpoint(*this, thread->zone()); | 4920 return thread->isolate()->debugger()->HasBreakpoint(*this, thread->zone()); |
5129 } | 4921 } |
5130 | 4922 |
5131 | 4923 |
5132 void Function::InstallOptimizedCode(const Code& code, bool is_osr) const { | 4924 void Function::InstallOptimizedCode(const Code& code, bool is_osr) const { |
5133 DEBUG_ASSERT(IsMutatorOrAtSafepoint()); | 4925 DEBUG_ASSERT(IsMutatorOrAtSafepoint()); |
5134 // We may not have previous code if 'always_optimize' is set. | 4926 // We may not have previous code if 'always_optimize' is set. |
5135 if (!is_osr && HasCode()) { | 4927 if (!is_osr && HasCode()) { |
5136 Code::Handle(CurrentCode()).DisableDartCode(); | 4928 Code::Handle(CurrentCode()).DisableDartCode(); |
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5777 void Function::SetIsNativeAutoSetupScope(bool value) const { | 5569 void Function::SetIsNativeAutoSetupScope(bool value) const { |
5778 ASSERT(is_native()); | 5570 ASSERT(is_native()); |
5779 set_is_optimizable(value); | 5571 set_is_optimizable(value); |
5780 } | 5572 } |
5781 | 5573 |
5782 | 5574 |
5783 bool Function::CanBeInlined() const { | 5575 bool Function::CanBeInlined() const { |
5784 Thread* thread = Thread::Current(); | 5576 Thread* thread = Thread::Current(); |
5785 return is_inlinable() && | 5577 return is_inlinable() && |
5786 !is_generated_body() && | 5578 !is_generated_body() && |
5787 !thread->isolate()->debugger()->HasBreakpoint(*this, thread->zone()); | 5579 (!FLAG_support_debugger || |
| 5580 !thread->isolate()->debugger()->HasBreakpoint(*this, thread->zone())); |
5788 } | 5581 } |
5789 | 5582 |
5790 | 5583 |
5791 intptr_t Function::NumParameters() const { | 5584 intptr_t Function::NumParameters() const { |
5792 return num_fixed_parameters() + NumOptionalParameters(); | 5585 return num_fixed_parameters() + NumOptionalParameters(); |
5793 } | 5586 } |
5794 | 5587 |
5795 | 5588 |
5796 intptr_t Function::NumImplicitParameters() const { | 5589 intptr_t Function::NumImplicitParameters() const { |
5797 if (kind() == RawFunction::kConstructor) { | 5590 if (kind() == RawFunction::kConstructor) { |
(...skipping 1257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7055 default: | 6848 default: |
7056 UNREACHABLE(); | 6849 UNREACHABLE(); |
7057 } | 6850 } |
7058 const char* function_name = String::Handle(name()).ToCString(); | 6851 const char* function_name = String::Handle(name()).ToCString(); |
7059 return OS::SCreate(Thread::Current()->zone(), | 6852 return OS::SCreate(Thread::Current()->zone(), |
7060 "Function '%s':%s%s%s%s.", | 6853 "Function '%s':%s%s%s%s.", |
7061 function_name, static_str, abstract_str, kind_str, const_str); | 6854 function_name, static_str, abstract_str, kind_str, const_str); |
7062 } | 6855 } |
7063 | 6856 |
7064 | 6857 |
7065 static void AddFunctionServiceId(const JSONObject& jsobj, | |
7066 const Function& f, | |
7067 const Class& cls) { | |
7068 // Special kinds of functions use indices in their respective lists. | |
7069 intptr_t id = -1; | |
7070 const char* selector = NULL; | |
7071 if (f.IsNonImplicitClosureFunction()) { | |
7072 id = Isolate::Current()->FindClosureIndex(f); | |
7073 selector = "closures"; | |
7074 } else if (f.IsImplicitClosureFunction()) { | |
7075 id = cls.FindImplicitClosureFunctionIndex(f); | |
7076 selector = "implicit_closures"; | |
7077 } else if (f.IsNoSuchMethodDispatcher() || f.IsInvokeFieldDispatcher()) { | |
7078 id = cls.FindInvocationDispatcherFunctionIndex(f); | |
7079 selector = "dispatchers"; | |
7080 } | |
7081 if (id != -1) { | |
7082 ASSERT(selector != NULL); | |
7083 jsobj.AddFixedServiceId("classes/%" Pd "/%s/%" Pd "", | |
7084 cls.id(), selector, id); | |
7085 return; | |
7086 } | |
7087 // Regular functions known to their owner use their name (percent-encoded). | |
7088 String& name = String::Handle(f.name()); | |
7089 if (cls.LookupFunction(name) == f.raw()) { | |
7090 name = String::EncodeIRI(name); | |
7091 jsobj.AddFixedServiceId("classes/%" Pd "/functions/%s", | |
7092 cls.id(), name.ToCString()); | |
7093 return; | |
7094 } | |
7095 // Oddball functions (not known to their owner) fall back to use the object | |
7096 // id ring. Current known examples are signature functions of closures | |
7097 // and stubs like 'megamorphic_miss'. | |
7098 jsobj.AddServiceId(f); | |
7099 } | |
7100 | |
7101 | |
7102 void Function::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
7103 Class& cls = Class::Handle(Owner()); | |
7104 ASSERT(!cls.IsNull()); | |
7105 Error& err = Error::Handle(); | |
7106 err ^= cls.EnsureIsFinalized(Thread::Current()); | |
7107 ASSERT(err.IsNull()); | |
7108 JSONObject jsobj(stream); | |
7109 AddCommonObjectProperties(&jsobj, "Function", ref); | |
7110 AddFunctionServiceId(jsobj, *this, cls); | |
7111 const String& user_name = String::Handle(PrettyName()); | |
7112 const String& vm_name = String::Handle(name()); | |
7113 AddNameProperties(&jsobj, user_name, vm_name); | |
7114 const Function& parent = Function::Handle(parent_function()); | |
7115 if (!parent.IsNull()) { | |
7116 jsobj.AddProperty("owner", parent); | |
7117 } else if (cls.IsTopLevel()) { | |
7118 const Library& library = Library::Handle(cls.library()); | |
7119 jsobj.AddProperty("owner", library); | |
7120 } else { | |
7121 jsobj.AddProperty("owner", cls); | |
7122 } | |
7123 | |
7124 const char* kind_string = Function::KindToCString(kind()); | |
7125 jsobj.AddProperty("_kind", kind_string); | |
7126 jsobj.AddProperty("static", is_static()); | |
7127 jsobj.AddProperty("const", is_const()); | |
7128 jsobj.AddProperty("_intrinsic", is_intrinsic()); | |
7129 jsobj.AddProperty("_native", is_native()); | |
7130 if (ref) { | |
7131 return; | |
7132 } | |
7133 Code& code = Code::Handle(CurrentCode()); | |
7134 if (!code.IsNull()) { | |
7135 jsobj.AddProperty("code", code); | |
7136 } | |
7137 Array& ics = Array::Handle(ic_data_array()); | |
7138 if (!ics.IsNull()) { | |
7139 jsobj.AddProperty("_icDataArray", ics); | |
7140 } | |
7141 jsobj.AddProperty("_optimizable", is_optimizable()); | |
7142 jsobj.AddProperty("_inlinable", is_inlinable()); | |
7143 jsobj.AddProperty("_recognized", IsRecognized()); | |
7144 code = unoptimized_code(); | |
7145 if (!code.IsNull()) { | |
7146 jsobj.AddProperty("_unoptimizedCode", code); | |
7147 } | |
7148 jsobj.AddProperty("_usageCounter", usage_counter()); | |
7149 jsobj.AddProperty("_optimizedCallSiteCount", optimized_call_site_count()); | |
7150 jsobj.AddProperty("_deoptimizations", | |
7151 static_cast<intptr_t>(deoptimization_counter())); | |
7152 if ((kind() == RawFunction::kImplicitGetter) || | |
7153 (kind() == RawFunction::kImplicitSetter) || | |
7154 (kind() == RawFunction::kImplicitStaticFinalGetter)) { | |
7155 const Field& field = Field::Handle(LookupImplicitGetterSetterField()); | |
7156 if (!field.IsNull()) { | |
7157 jsobj.AddProperty("_field", field); | |
7158 } | |
7159 } | |
7160 | |
7161 const Script& script = Script::Handle(this->script()); | |
7162 if (!script.IsNull()) { | |
7163 jsobj.AddLocation(script, token_pos(), end_token_pos()); | |
7164 } | |
7165 } | |
7166 | |
7167 | |
7168 void ClosureData::set_context_scope(const ContextScope& value) const { | 6858 void ClosureData::set_context_scope(const ContextScope& value) const { |
7169 StorePointer(&raw_ptr()->context_scope_, value.raw()); | 6859 StorePointer(&raw_ptr()->context_scope_, value.raw()); |
7170 } | 6860 } |
7171 | 6861 |
7172 | 6862 |
7173 void ClosureData::set_implicit_static_closure(const Instance& closure) const { | 6863 void ClosureData::set_implicit_static_closure(const Instance& closure) const { |
7174 ASSERT(!closure.IsNull()); | 6864 ASSERT(!closure.IsNull()); |
7175 ASSERT(raw_ptr()->closure_ == Instance::null()); | 6865 ASSERT(raw_ptr()->closure_ == Instance::null()); |
7176 StorePointer(&raw_ptr()->closure_, closure.raw()); | 6866 StorePointer(&raw_ptr()->closure_, closure.raw()); |
7177 } | 6867 } |
(...skipping 16 matching lines...) Expand all Loading... |
7194 Heap::kOld); | 6884 Heap::kOld); |
7195 return reinterpret_cast<RawClosureData*>(raw); | 6885 return reinterpret_cast<RawClosureData*>(raw); |
7196 } | 6886 } |
7197 | 6887 |
7198 | 6888 |
7199 const char* ClosureData::ToCString() const { | 6889 const char* ClosureData::ToCString() const { |
7200 return "ClosureData class"; | 6890 return "ClosureData class"; |
7201 } | 6891 } |
7202 | 6892 |
7203 | 6893 |
7204 void ClosureData::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
7205 Object::PrintJSONImpl(stream, ref); | |
7206 } | |
7207 | |
7208 | |
7209 void RedirectionData::set_type(const Type& value) const { | 6894 void RedirectionData::set_type(const Type& value) const { |
7210 ASSERT(!value.IsNull()); | 6895 ASSERT(!value.IsNull()); |
7211 StorePointer(&raw_ptr()->type_, value.raw()); | 6896 StorePointer(&raw_ptr()->type_, value.raw()); |
7212 } | 6897 } |
7213 | 6898 |
7214 | 6899 |
7215 void RedirectionData::set_identifier(const String& value) const { | 6900 void RedirectionData::set_identifier(const String& value) const { |
7216 StorePointer(&raw_ptr()->identifier_, value.raw()); | 6901 StorePointer(&raw_ptr()->identifier_, value.raw()); |
7217 } | 6902 } |
7218 | 6903 |
(...skipping 10 matching lines...) Expand all Loading... |
7229 Heap::kOld); | 6914 Heap::kOld); |
7230 return reinterpret_cast<RawRedirectionData*>(raw); | 6915 return reinterpret_cast<RawRedirectionData*>(raw); |
7231 } | 6916 } |
7232 | 6917 |
7233 | 6918 |
7234 const char* RedirectionData::ToCString() const { | 6919 const char* RedirectionData::ToCString() const { |
7235 return "RedirectionData class"; | 6920 return "RedirectionData class"; |
7236 } | 6921 } |
7237 | 6922 |
7238 | 6923 |
7239 void RedirectionData::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
7240 Object::PrintJSONImpl(stream, ref); | |
7241 } | |
7242 | |
7243 | |
7244 RawString* Field::GetterName(const String& field_name) { | 6924 RawString* Field::GetterName(const String& field_name) { |
7245 return String::Concat(Symbols::GetterPrefix(), field_name); | 6925 return String::Concat(Symbols::GetterPrefix(), field_name); |
7246 } | 6926 } |
7247 | 6927 |
7248 | 6928 |
7249 RawString* Field::GetterSymbol(const String& field_name) { | 6929 RawString* Field::GetterSymbol(const String& field_name) { |
7250 return Symbols::FromConcat(Symbols::GetterPrefix(), field_name); | 6930 return Symbols::FromConcat(Symbols::GetterPrefix(), field_name); |
7251 } | 6931 } |
7252 | 6932 |
7253 | 6933 |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7479 const char* kF1 = is_final() ? " final" : ""; | 7159 const char* kF1 = is_final() ? " final" : ""; |
7480 const char* kF2 = is_const() ? " const" : ""; | 7160 const char* kF2 = is_const() ? " const" : ""; |
7481 const char* field_name = String::Handle(name()).ToCString(); | 7161 const char* field_name = String::Handle(name()).ToCString(); |
7482 const Class& cls = Class::Handle(owner()); | 7162 const Class& cls = Class::Handle(owner()); |
7483 const char* cls_name = String::Handle(cls.Name()).ToCString(); | 7163 const char* cls_name = String::Handle(cls.Name()).ToCString(); |
7484 return OS::SCreate(Thread::Current()->zone(), | 7164 return OS::SCreate(Thread::Current()->zone(), |
7485 "Field <%s.%s>:%s%s%s", cls_name, field_name, kF0, kF1, kF2); | 7165 "Field <%s.%s>:%s%s%s", cls_name, field_name, kF0, kF1, kF2); |
7486 } | 7166 } |
7487 | 7167 |
7488 | 7168 |
7489 void Field::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
7490 JSONObject jsobj(stream); | |
7491 Class& cls = Class::Handle(owner()); | |
7492 String& field_name = String::Handle(name()); | |
7493 field_name = String::EncodeIRI(field_name); | |
7494 AddCommonObjectProperties(&jsobj, "Field", ref); | |
7495 jsobj.AddFixedServiceId("classes/%" Pd "/fields/%s", | |
7496 cls.id(), field_name.ToCString()); | |
7497 | |
7498 const String& user_name = String::Handle(PrettyName()); | |
7499 const String& vm_name = String::Handle(name()); | |
7500 AddNameProperties(&jsobj, user_name, vm_name); | |
7501 if (cls.IsTopLevel()) { | |
7502 const Library& library = Library::Handle(cls.library()); | |
7503 jsobj.AddProperty("owner", library); | |
7504 } else { | |
7505 jsobj.AddProperty("owner", cls); | |
7506 } | |
7507 | |
7508 AbstractType& declared_type = AbstractType::Handle(type()); | |
7509 jsobj.AddProperty("declaredType", declared_type); | |
7510 jsobj.AddProperty("static", is_static()); | |
7511 jsobj.AddProperty("final", is_final()); | |
7512 jsobj.AddProperty("const", is_const()); | |
7513 if (ref) { | |
7514 return; | |
7515 } | |
7516 if (is_static()) { | |
7517 const Instance& valueObj = Instance::Handle(StaticValue()); | |
7518 jsobj.AddProperty("staticValue", valueObj); | |
7519 } | |
7520 | |
7521 jsobj.AddProperty("_guardNullable", is_nullable()); | |
7522 if (guarded_cid() == kIllegalCid) { | |
7523 jsobj.AddProperty("_guardClass", "unknown"); | |
7524 } else if (guarded_cid() == kDynamicCid) { | |
7525 jsobj.AddProperty("_guardClass", "dynamic"); | |
7526 } else { | |
7527 ClassTable* table = Isolate::Current()->class_table(); | |
7528 ASSERT(table->IsValidIndex(guarded_cid())); | |
7529 cls ^= table->At(guarded_cid()); | |
7530 jsobj.AddProperty("_guardClass", cls); | |
7531 } | |
7532 if (guarded_list_length() == kUnknownFixedLength) { | |
7533 jsobj.AddProperty("_guardLength", "unknown"); | |
7534 } else if (guarded_list_length() == kNoFixedLength) { | |
7535 jsobj.AddProperty("_guardLength", "variable"); | |
7536 } else { | |
7537 jsobj.AddProperty("_guardLength", guarded_list_length()); | |
7538 } | |
7539 const Class& origin_cls = Class::Handle(origin()); | |
7540 const Script& script = Script::Handle(origin_cls.script()); | |
7541 if (!script.IsNull()) { | |
7542 jsobj.AddLocation(script, token_pos()); | |
7543 } | |
7544 } | |
7545 | |
7546 | |
7547 // Build a closure object that gets (or sets) the contents of a static | 7169 // Build a closure object that gets (or sets) the contents of a static |
7548 // field f and cache the closure in a newly created static field | 7170 // field f and cache the closure in a newly created static field |
7549 // named #f (or #f= in case of a setter). | 7171 // named #f (or #f= in case of a setter). |
7550 RawInstance* Field::AccessorClosure(bool make_setter) const { | 7172 RawInstance* Field::AccessorClosure(bool make_setter) const { |
7551 ASSERT(is_static()); | 7173 ASSERT(is_static()); |
7552 const Class& field_owner = Class::Handle(owner()); | 7174 const Class& field_owner = Class::Handle(owner()); |
7553 | 7175 |
7554 String& closure_name = String::Handle(this->name()); | 7176 String& closure_name = String::Handle(this->name()); |
7555 closure_name = Symbols::FromConcat(Symbols::HashMark(), closure_name); | 7177 closure_name = Symbols::FromConcat(Symbols::HashMark(), closure_name); |
7556 if (make_setter) { | 7178 if (make_setter) { |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7938 return result.raw(); | 7560 return result.raw(); |
7939 } | 7561 } |
7940 | 7562 |
7941 | 7563 |
7942 const char* LiteralToken::ToCString() const { | 7564 const char* LiteralToken::ToCString() const { |
7943 const String& token = String::Handle(literal()); | 7565 const String& token = String::Handle(literal()); |
7944 return token.ToCString(); | 7566 return token.ToCString(); |
7945 } | 7567 } |
7946 | 7568 |
7947 | 7569 |
7948 void LiteralToken::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
7949 Object::PrintJSONImpl(stream, ref); | |
7950 } | |
7951 | |
7952 | |
7953 RawGrowableObjectArray* TokenStream::TokenObjects() const { | 7570 RawGrowableObjectArray* TokenStream::TokenObjects() const { |
7954 return raw_ptr()->token_objects_; | 7571 return raw_ptr()->token_objects_; |
7955 } | 7572 } |
7956 | 7573 |
7957 | 7574 |
7958 void TokenStream::SetTokenObjects(const GrowableObjectArray& value) const { | 7575 void TokenStream::SetTokenObjects(const GrowableObjectArray& value) const { |
7959 StorePointer(&raw_ptr()->token_objects_, value.raw()); | 7576 StorePointer(&raw_ptr()->token_objects_, value.raw()); |
7960 } | 7577 } |
7961 | 7578 |
7962 | 7579 |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8433 isolate->object_store()->set_token_objects(GrowableObjectArray::Handle()); | 8050 isolate->object_store()->set_token_objects(GrowableObjectArray::Handle()); |
8434 isolate->object_store()->set_token_objects_map(Array::null_array()); | 8051 isolate->object_store()->set_token_objects_map(Array::null_array()); |
8435 } | 8052 } |
8436 | 8053 |
8437 | 8054 |
8438 const char* TokenStream::ToCString() const { | 8055 const char* TokenStream::ToCString() const { |
8439 return "TokenStream"; | 8056 return "TokenStream"; |
8440 } | 8057 } |
8441 | 8058 |
8442 | 8059 |
8443 void TokenStream::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
8444 JSONObject jsobj(stream); | |
8445 AddCommonObjectProperties(&jsobj, "Object", ref); | |
8446 // TODO(johnmccutchan): Generate a stable id. TokenStreams hang off | |
8447 // a Script object but do not have a back reference to generate a stable id. | |
8448 jsobj.AddServiceId(*this); | |
8449 if (ref) { | |
8450 return; | |
8451 } | |
8452 const String& private_key = String::Handle(PrivateKey()); | |
8453 jsobj.AddProperty("privateKey", private_key); | |
8454 // TODO(johnmccutchan): Add support for printing LiteralTokens and add | |
8455 // them to members array. | |
8456 JSONArray members(&jsobj, "members"); | |
8457 } | |
8458 | |
8459 | |
8460 TokenStream::Iterator::Iterator(const TokenStream& tokens, | 8060 TokenStream::Iterator::Iterator(const TokenStream& tokens, |
8461 TokenPosition token_pos, | 8061 TokenPosition token_pos, |
8462 Iterator::StreamType stream_type) | 8062 Iterator::StreamType stream_type) |
8463 : tokens_(TokenStream::Handle(tokens.raw())), | 8063 : tokens_(TokenStream::Handle(tokens.raw())), |
8464 data_(ExternalTypedData::Handle(tokens.GetStream())), | 8064 data_(ExternalTypedData::Handle(tokens.GetStream())), |
8465 stream_(reinterpret_cast<uint8_t*>(data_.DataAddr(0)), data_.Length()), | 8065 stream_(reinterpret_cast<uint8_t*>(data_.DataAddr(0)), data_.Length()), |
8466 token_objects_(Array::Handle( | 8066 token_objects_(Array::Handle( |
8467 GrowableObjectArray::Handle(tokens.TokenObjects()).data())), | 8067 GrowableObjectArray::Handle(tokens.TokenObjects()).data())), |
8468 obj_(Object::Handle()), | 8068 obj_(Object::Handle()), |
8469 cur_token_pos_(token_pos.Pos()), | 8069 cur_token_pos_(token_pos.Pos()), |
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9008 for (intptr_t j = 0; j < scripts.Length(); j++) { | 8608 for (intptr_t j = 0; j < scripts.Length(); j++) { |
9009 if (scripts.At(j) == raw()) { | 8609 if (scripts.At(j) == raw()) { |
9010 return lib.raw(); | 8610 return lib.raw(); |
9011 } | 8611 } |
9012 } | 8612 } |
9013 } | 8613 } |
9014 return Library::null(); | 8614 return Library::null(); |
9015 } | 8615 } |
9016 | 8616 |
9017 | 8617 |
9018 // See also Dart_ScriptGetTokenInfo. | |
9019 void Script::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
9020 JSONObject jsobj(stream); | |
9021 AddCommonObjectProperties(&jsobj, "Script", ref); | |
9022 const String& uri = String::Handle(url()); | |
9023 ASSERT(!uri.IsNull()); | |
9024 const String& encoded_uri = String::Handle(String::EncodeIRI(uri)); | |
9025 ASSERT(!encoded_uri.IsNull()); | |
9026 const Library& lib = Library::Handle(FindLibrary()); | |
9027 if (kind() == RawScript::kEvaluateTag) { | |
9028 jsobj.AddServiceId(*this); | |
9029 } else { | |
9030 ASSERT(!lib.IsNull()); | |
9031 jsobj.AddFixedServiceId("libraries/%" Pd "/scripts/%s", | |
9032 lib.index(), encoded_uri.ToCString()); | |
9033 } | |
9034 jsobj.AddPropertyStr("uri", uri); | |
9035 jsobj.AddProperty("_kind", GetKindAsCString()); | |
9036 if (ref) { | |
9037 return; | |
9038 } | |
9039 if (!lib.IsNull()) { | |
9040 jsobj.AddProperty("library", lib); | |
9041 } | |
9042 const String& source = String::Handle(Source()); | |
9043 jsobj.AddProperty("lineOffset", line_offset()); | |
9044 jsobj.AddProperty("columnOffset", col_offset()); | |
9045 if (!source.IsNull()) { | |
9046 jsobj.AddPropertyStr("source", source); | |
9047 } | |
9048 | |
9049 // Print the line number table | |
9050 if (!source.IsNull()) { | |
9051 JSONArray tokenPosTable(&jsobj, "tokenPosTable"); | |
9052 | |
9053 const GrowableObjectArray& lineNumberArray = | |
9054 GrowableObjectArray::Handle(GenerateLineNumberArray()); | |
9055 Object& value = Object::Handle(); | |
9056 intptr_t pos = 0; | |
9057 | |
9058 // Skip leading null. | |
9059 ASSERT(lineNumberArray.Length() > 0); | |
9060 value = lineNumberArray.At(pos); | |
9061 ASSERT(value.IsNull()); | |
9062 pos++; | |
9063 | |
9064 while (pos < lineNumberArray.Length()) { | |
9065 JSONArray lineInfo(&tokenPosTable); | |
9066 while (pos < lineNumberArray.Length()) { | |
9067 value = lineNumberArray.At(pos); | |
9068 pos++; | |
9069 if (value.IsNull()) { | |
9070 break; | |
9071 } | |
9072 const Smi& smi = Smi::Cast(value); | |
9073 lineInfo.AddValue(smi.Value()); | |
9074 } | |
9075 } | |
9076 } | |
9077 } | |
9078 | |
9079 | |
9080 DictionaryIterator::DictionaryIterator(const Library& library) | 8618 DictionaryIterator::DictionaryIterator(const Library& library) |
9081 : array_(Array::Handle(library.dictionary())), | 8619 : array_(Array::Handle(library.dictionary())), |
9082 // Last element in array is a Smi indicating the number of entries used. | 8620 // Last element in array is a Smi indicating the number of entries used. |
9083 size_(Array::Handle(library.dictionary()).Length() - 1), | 8621 size_(Array::Handle(library.dictionary()).Length() - 1), |
9084 next_ix_(0) { | 8622 next_ix_(0) { |
9085 MoveToNextObject(); | 8623 MoveToNextObject(); |
9086 } | 8624 } |
9087 | 8625 |
9088 | 8626 |
9089 RawObject* DictionaryIterator::GetNext() { | 8627 RawObject* DictionaryIterator::GetNext() { |
(...skipping 1379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10469 } | 10007 } |
10470 | 10008 |
10471 | 10009 |
10472 const char* Library::ToCString() const { | 10010 const char* Library::ToCString() const { |
10473 const String& name = String::Handle(url()); | 10011 const String& name = String::Handle(url()); |
10474 return OS::SCreate(Thread::Current()->zone(), | 10012 return OS::SCreate(Thread::Current()->zone(), |
10475 "Library:'%s'", name.ToCString()); | 10013 "Library:'%s'", name.ToCString()); |
10476 } | 10014 } |
10477 | 10015 |
10478 | 10016 |
10479 void Library::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
10480 intptr_t id = index(); | |
10481 ASSERT(id >= 0); | |
10482 JSONObject jsobj(stream); | |
10483 AddCommonObjectProperties(&jsobj, "Library", ref); | |
10484 jsobj.AddFixedServiceId("libraries/%" Pd "", id); | |
10485 const String& vm_name = String::Handle(name()); | |
10486 const String& user_name = | |
10487 String::Handle(String::IdentifierPrettyName(vm_name)); | |
10488 AddNameProperties(&jsobj, user_name, vm_name); | |
10489 const String& library_url = String::Handle(url()); | |
10490 jsobj.AddPropertyStr("uri", library_url); | |
10491 if (ref) { | |
10492 return; | |
10493 } | |
10494 jsobj.AddProperty("debuggable", IsDebuggable()); | |
10495 { | |
10496 JSONArray jsarr(&jsobj, "classes"); | |
10497 ClassDictionaryIterator class_iter(*this); | |
10498 Class& klass = Class::Handle(); | |
10499 while (class_iter.HasNext()) { | |
10500 klass = class_iter.GetNextClass(); | |
10501 if (!klass.IsMixinApplication()) { | |
10502 jsarr.AddValue(klass); | |
10503 } | |
10504 } | |
10505 } | |
10506 { | |
10507 JSONArray jsarr(&jsobj, "dependencies"); | |
10508 | |
10509 Array& ports = Array::Handle(); | |
10510 Namespace& ns = Namespace::Handle(); | |
10511 Library& target = Library::Handle(); | |
10512 | |
10513 // Unprefixed imports. | |
10514 ports = imports(); | |
10515 for (intptr_t i = 0; i < ports.Length(); i++) { | |
10516 ns ^= ports.At(i); | |
10517 if (ns.IsNull()) continue; | |
10518 | |
10519 JSONObject jsdep(&jsarr); | |
10520 jsdep.AddProperty("isDeferred", false); | |
10521 jsdep.AddProperty("isExport", false); | |
10522 jsdep.AddProperty("isImport", true); | |
10523 target = ns.library(); | |
10524 jsdep.AddProperty("target", target); | |
10525 } | |
10526 | |
10527 // Exports. | |
10528 ports = exports(); | |
10529 for (intptr_t i = 0; i < ports.Length(); i++) { | |
10530 ns ^= ports.At(i); | |
10531 if (ns.IsNull()) continue; | |
10532 | |
10533 JSONObject jsdep(&jsarr); | |
10534 jsdep.AddProperty("isDeferred", false); | |
10535 jsdep.AddProperty("isExport", true); | |
10536 jsdep.AddProperty("isImport", false); | |
10537 target = ns.library(); | |
10538 jsdep.AddProperty("target", target); | |
10539 } | |
10540 | |
10541 // Prefixed imports. | |
10542 DictionaryIterator entries(*this); | |
10543 Object& entry = Object::Handle(); | |
10544 LibraryPrefix& prefix = LibraryPrefix::Handle(); | |
10545 String& prefixName = String::Handle(); | |
10546 while (entries.HasNext()) { | |
10547 entry = entries.GetNext(); | |
10548 if (entry.IsLibraryPrefix()) { | |
10549 prefix ^= entry.raw(); | |
10550 ports = prefix.imports(); | |
10551 for (intptr_t i = 0; i < ports.Length(); i++) { | |
10552 ns ^= ports.At(i); | |
10553 if (ns.IsNull()) continue; | |
10554 | |
10555 JSONObject jsdep(&jsarr); | |
10556 jsdep.AddProperty("isDeferred", prefix.is_deferred_load()); | |
10557 jsdep.AddProperty("isExport", false); | |
10558 jsdep.AddProperty("isImport", true); | |
10559 prefixName = prefix.name(); | |
10560 ASSERT(!prefixName.IsNull()); | |
10561 jsdep.AddProperty("prefix", prefixName.ToCString()); | |
10562 target = ns.library(); | |
10563 jsdep.AddProperty("target", target); | |
10564 } | |
10565 } | |
10566 } | |
10567 } | |
10568 { | |
10569 JSONArray jsarr(&jsobj, "variables"); | |
10570 DictionaryIterator entries(*this); | |
10571 Object& entry = Object::Handle(); | |
10572 while (entries.HasNext()) { | |
10573 entry = entries.GetNext(); | |
10574 if (entry.IsField()) { | |
10575 jsarr.AddValue(entry); | |
10576 } | |
10577 } | |
10578 } | |
10579 { | |
10580 JSONArray jsarr(&jsobj, "functions"); | |
10581 DictionaryIterator entries(*this); | |
10582 Object& entry = Object::Handle(); | |
10583 while (entries.HasNext()) { | |
10584 entry = entries.GetNext(); | |
10585 if (entry.IsFunction()) { | |
10586 const Function& func = Function::Cast(entry); | |
10587 if (func.kind() == RawFunction::kRegularFunction || | |
10588 func.kind() == RawFunction::kGetterFunction || | |
10589 func.kind() == RawFunction::kSetterFunction) { | |
10590 jsarr.AddValue(func); | |
10591 } | |
10592 } | |
10593 } | |
10594 } | |
10595 { | |
10596 JSONArray jsarr(&jsobj, "scripts"); | |
10597 Array& scripts = Array::Handle(LoadedScripts()); | |
10598 Script& script = Script::Handle(); | |
10599 for (intptr_t i = 0; i < scripts.Length(); i++) { | |
10600 script ^= scripts.At(i); | |
10601 jsarr.AddValue(script); | |
10602 } | |
10603 } | |
10604 } | |
10605 | |
10606 | |
10607 RawLibrary* LibraryPrefix::GetLibrary(int index) const { | 10017 RawLibrary* LibraryPrefix::GetLibrary(int index) const { |
10608 if ((index >= 0) || (index < num_imports())) { | 10018 if ((index >= 0) || (index < num_imports())) { |
10609 const Array& imports = Array::Handle(this->imports()); | 10019 const Array& imports = Array::Handle(this->imports()); |
10610 Namespace& import = Namespace::Handle(); | 10020 Namespace& import = Namespace::Handle(); |
10611 import ^= imports.At(index); | 10021 import ^= imports.At(index); |
10612 return import.library(); | 10022 return import.library(); |
10613 } | 10023 } |
10614 return Library::null(); | 10024 return Library::null(); |
10615 } | 10025 } |
10616 | 10026 |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10891 } | 10301 } |
10892 | 10302 |
10893 | 10303 |
10894 const char* LibraryPrefix::ToCString() const { | 10304 const char* LibraryPrefix::ToCString() const { |
10895 const String& prefix = String::Handle(name()); | 10305 const String& prefix = String::Handle(name()); |
10896 return OS::SCreate(Thread::Current()->zone(), | 10306 return OS::SCreate(Thread::Current()->zone(), |
10897 "LibraryPrefix:'%s'", prefix.ToCString()); | 10307 "LibraryPrefix:'%s'", prefix.ToCString()); |
10898 } | 10308 } |
10899 | 10309 |
10900 | 10310 |
10901 void LibraryPrefix::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
10902 Object::PrintJSONImpl(stream, ref); | |
10903 } | |
10904 | |
10905 | |
10906 void Namespace::set_metadata_field(const Field& value) const { | 10311 void Namespace::set_metadata_field(const Field& value) const { |
10907 StorePointer(&raw_ptr()->metadata_field_, value.raw()); | 10312 StorePointer(&raw_ptr()->metadata_field_, value.raw()); |
10908 } | 10313 } |
10909 | 10314 |
10910 | 10315 |
10911 void Namespace::AddMetadata(const Object& owner, TokenPosition token_pos) { | 10316 void Namespace::AddMetadata(const Object& owner, TokenPosition token_pos) { |
10912 ASSERT(Field::Handle(metadata_field()).IsNull()); | 10317 ASSERT(Field::Handle(metadata_field()).IsNull()); |
10913 Field& field = Field::Handle(Field::NewTopLevel(Symbols::TopLevel(), | 10318 Field& field = Field::Handle(Field::NewTopLevel(Symbols::TopLevel(), |
10914 false, // is_final | 10319 false, // is_final |
10915 false, // is_const | 10320 false, // is_const |
(...skipping 25 matching lines...) Expand all Loading... |
10941 } | 10346 } |
10942 | 10347 |
10943 | 10348 |
10944 const char* Namespace::ToCString() const { | 10349 const char* Namespace::ToCString() const { |
10945 const Library& lib = Library::Handle(library()); | 10350 const Library& lib = Library::Handle(library()); |
10946 return OS::SCreate(Thread::Current()->zone(), | 10351 return OS::SCreate(Thread::Current()->zone(), |
10947 "Namespace for library '%s'", lib.ToCString()); | 10352 "Namespace for library '%s'", lib.ToCString()); |
10948 } | 10353 } |
10949 | 10354 |
10950 | 10355 |
10951 void Namespace::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
10952 Object::PrintJSONImpl(stream, ref); | |
10953 } | |
10954 | |
10955 | |
10956 bool Namespace::HidesName(const String& name) const { | 10356 bool Namespace::HidesName(const String& name) const { |
10957 // Quick check for common case with no combinators. | 10357 // Quick check for common case with no combinators. |
10958 if (hide_names() == show_names()) { | 10358 if (hide_names() == show_names()) { |
10959 ASSERT(hide_names() == Array::null()); | 10359 ASSERT(hide_names() == Array::null()); |
10960 return false; | 10360 return false; |
10961 } | 10361 } |
10962 const String* plain_name = &name; | 10362 const String* plain_name = &name; |
10963 if (Field::IsGetterName(name)) { | 10363 if (Field::IsGetterName(name)) { |
10964 plain_name = &String::Handle(Field::NameFromGetter(name)); | 10364 plain_name = &String::Handle(Field::NameFromGetter(name)); |
10965 } else if (Field::IsSetterName(name)) { | 10365 } else if (Field::IsSetterName(name)) { |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11217 } | 10617 } |
11218 return result.raw(); | 10618 return result.raw(); |
11219 } | 10619 } |
11220 | 10620 |
11221 | 10621 |
11222 const char* Instructions::ToCString() const { | 10622 const char* Instructions::ToCString() const { |
11223 return "Instructions"; | 10623 return "Instructions"; |
11224 } | 10624 } |
11225 | 10625 |
11226 | 10626 |
11227 void Instructions::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
11228 JSONObject jsobj(stream); | |
11229 AddCommonObjectProperties(&jsobj, "Object", ref); | |
11230 jsobj.AddServiceId(*this); | |
11231 if (ref) { | |
11232 return; | |
11233 } | |
11234 } | |
11235 | |
11236 | |
11237 // Encode integer |value| in SLEB128 format and store into |data|. | 10627 // Encode integer |value| in SLEB128 format and store into |data|. |
11238 static void EncodeSLEB128(GrowableArray<uint8_t>* data, | 10628 static void EncodeSLEB128(GrowableArray<uint8_t>* data, |
11239 intptr_t value) { | 10629 intptr_t value) { |
11240 bool is_last_part = false; | 10630 bool is_last_part = false; |
11241 while (!is_last_part) { | 10631 while (!is_last_part) { |
11242 uint8_t part = value & 0x7f; | 10632 uint8_t part = value & 0x7f; |
11243 value >>= 7; | 10633 value >>= 7; |
11244 if ((value == 0 && (part & 0x40) == 0) || | 10634 if ((value == 0 && (part & 0x40) == 0) || |
11245 (value == static_cast<intptr_t>(-1) && (part & 0x40) != 0)) { | 10635 (value == static_cast<intptr_t>(-1) && (part & 0x40) != 0)) { |
11246 is_last_part = true; | 10636 is_last_part = true; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11324 return static_cast<EntryType>(array.GetInt8(index)); | 10714 return static_cast<EntryType>(array.GetInt8(index)); |
11325 } | 10715 } |
11326 | 10716 |
11327 | 10717 |
11328 const char* ObjectPool::ToCString() const { | 10718 const char* ObjectPool::ToCString() const { |
11329 Zone* zone = Thread::Current()->zone(); | 10719 Zone* zone = Thread::Current()->zone(); |
11330 return zone->PrintToString("ObjectPool len:%" Pd, Length()); | 10720 return zone->PrintToString("ObjectPool len:%" Pd, Length()); |
11331 } | 10721 } |
11332 | 10722 |
11333 | 10723 |
11334 void ObjectPool::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
11335 JSONObject jsobj(stream); | |
11336 AddCommonObjectProperties(&jsobj, "Object", ref); | |
11337 jsobj.AddServiceId(*this); | |
11338 jsobj.AddProperty("length", Length()); | |
11339 if (ref) { | |
11340 return; | |
11341 } | |
11342 | |
11343 { | |
11344 JSONArray jsarr(&jsobj, "_entries"); | |
11345 uword imm; | |
11346 Object& obj = Object::Handle(); | |
11347 for (intptr_t i = 0; i < Length(); i++) { | |
11348 JSONObject jsentry(stream); | |
11349 jsentry.AddProperty("offset", OffsetFromIndex(i)); | |
11350 switch (InfoAt(i)) { | |
11351 case ObjectPool::kTaggedObject: | |
11352 obj = ObjectAt(i); | |
11353 jsentry.AddProperty("kind", "Object"); | |
11354 jsentry.AddProperty("value", obj); | |
11355 break; | |
11356 case ObjectPool::kImmediate: | |
11357 imm = RawValueAt(i); | |
11358 jsentry.AddProperty("kind", "Immediate"); | |
11359 jsentry.AddProperty64("value", imm); | |
11360 break; | |
11361 case ObjectPool::kNativeEntry: | |
11362 imm = RawValueAt(i); | |
11363 jsentry.AddProperty("kind", "NativeEntry"); | |
11364 jsentry.AddProperty64("value", imm); | |
11365 break; | |
11366 default: | |
11367 UNREACHABLE(); | |
11368 } | |
11369 } | |
11370 } | |
11371 } | |
11372 | |
11373 | |
11374 void ObjectPool::DebugPrint() const { | 10724 void ObjectPool::DebugPrint() const { |
11375 THR_Print("Object Pool: {\n"); | 10725 THR_Print("Object Pool: {\n"); |
11376 for (intptr_t i = 0; i < Length(); i++) { | 10726 for (intptr_t i = 0; i < Length(); i++) { |
11377 intptr_t offset = OffsetFromIndex(i); | 10727 intptr_t offset = OffsetFromIndex(i); |
11378 THR_Print(" %" Pd " PP+0x%" Px ": ", i, offset); | 10728 THR_Print(" %" Pd " PP+0x%" Px ": ", i, offset); |
11379 if (InfoAt(i) == kTaggedObject) { | 10729 if (InfoAt(i) == kTaggedObject) { |
11380 RawObject* obj = ObjectAt(i); | 10730 RawObject* obj = ObjectAt(i); |
11381 THR_Print("0x%" Px " %s (obj)\n", | 10731 THR_Print("0x%" Px " %s (obj)\n", |
11382 reinterpret_cast<uword>(obj), | 10732 reinterpret_cast<uword>(obj), |
11383 Object::Handle(obj).ToCString()); | 10733 Object::Handle(obj).ToCString()); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11507 KindAsStr(iter.Kind()), | 10857 KindAsStr(iter.Kind()), |
11508 iter.DeoptId(), | 10858 iter.DeoptId(), |
11509 iter.TokenPos().ToCString(), | 10859 iter.TokenPos().ToCString(), |
11510 iter.TryIndex()); | 10860 iter.TryIndex()); |
11511 } | 10861 } |
11512 return buffer; | 10862 return buffer; |
11513 #undef FORMAT | 10863 #undef FORMAT |
11514 } | 10864 } |
11515 | 10865 |
11516 | 10866 |
11517 void PcDescriptors::PrintToJSONObject(JSONObject* jsobj, bool ref) const { | |
11518 AddCommonObjectProperties(jsobj, "Object", ref); | |
11519 // TODO(johnmccutchan): Generate a stable id. PcDescriptors hang off a Code | |
11520 // object but do not have a back reference to generate an ID. | |
11521 jsobj->AddServiceId(*this); | |
11522 if (ref) { | |
11523 return; | |
11524 } | |
11525 JSONArray members(jsobj, "members"); | |
11526 Iterator iter(*this, RawPcDescriptors::kAnyKind); | |
11527 while (iter.MoveNext()) { | |
11528 JSONObject descriptor(&members); | |
11529 descriptor.AddPropertyF("pcOffset", "%" Px "", iter.PcOffset()); | |
11530 descriptor.AddProperty("kind", KindAsStr(iter.Kind())); | |
11531 descriptor.AddProperty("deoptId", iter.DeoptId()); | |
11532 // TODO(turnidge): Use AddLocation instead. | |
11533 descriptor.AddProperty("tokenPos", iter.TokenPos()); | |
11534 descriptor.AddProperty("tryIndex", iter.TryIndex()); | |
11535 } | |
11536 } | |
11537 | |
11538 | |
11539 void PcDescriptors::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
11540 JSONObject jsobj(stream); | |
11541 PrintToJSONObject(&jsobj, ref); | |
11542 } | |
11543 | |
11544 | |
11545 // Verify assumptions (in debug mode only). | 10867 // Verify assumptions (in debug mode only). |
11546 // - No two deopt descriptors have the same deoptimization id. | 10868 // - No two deopt descriptors have the same deoptimization id. |
11547 // - No two ic-call descriptors have the same deoptimization id (type feedback). | 10869 // - No two ic-call descriptors have the same deoptimization id (type feedback). |
11548 // A function without unique ids is marked as non-optimizable (e.g., because of | 10870 // A function without unique ids is marked as non-optimizable (e.g., because of |
11549 // finally blocks). | 10871 // finally blocks). |
11550 void PcDescriptors::Verify(const Function& function) const { | 10872 void PcDescriptors::Verify(const Function& function) const { |
11551 #if defined(DEBUG) | 10873 #if defined(DEBUG) |
11552 // Only check ids for unoptimized code that is optimizable. | 10874 // Only check ids for unoptimized code that is optimizable. |
11553 if (!function.IsOptimizable()) { | 10875 if (!function.IsOptimizable()) { |
11554 return; | 10876 return; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11633 size, | 10955 size, |
11634 Heap::kOld); | 10956 Heap::kOld); |
11635 NoSafepointScope no_safepoint; | 10957 NoSafepointScope no_safepoint; |
11636 result ^= raw; | 10958 result ^= raw; |
11637 result.SetLength(length); | 10959 result.SetLength(length); |
11638 } | 10960 } |
11639 return result.raw(); | 10961 return result.raw(); |
11640 } | 10962 } |
11641 | 10963 |
11642 | 10964 |
11643 void CodeSourceMap::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
11644 Object::PrintJSONImpl(stream, ref); | |
11645 } | |
11646 | |
11647 | |
11648 const char* CodeSourceMap::ToCString() const { | 10965 const char* CodeSourceMap::ToCString() const { |
11649 // "*" in a printf format specifier tells it to read the field width from | 10966 // "*" in a printf format specifier tells it to read the field width from |
11650 // the printf argument list. | 10967 // the printf argument list. |
11651 #define FORMAT "%#-*" Px "\t%s\n" | 10968 #define FORMAT "%#-*" Px "\t%s\n" |
11652 if (Length() == 0) { | 10969 if (Length() == 0) { |
11653 return "empty CodeSourceMap\n"; | 10970 return "empty CodeSourceMap\n"; |
11654 } | 10971 } |
11655 // 4 bits per hex digit. | 10972 // 4 bits per hex digit. |
11656 const int addr_width = kBitsPerWord / 4; | 10973 const int addr_width = kBitsPerWord / 4; |
11657 // First compute the buffer size required. | 10974 // First compute the buffer size required. |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11812 for (intptr_t i = 0; i < Length(); i++) { | 11129 for (intptr_t i = 0; i < Length(); i++) { |
11813 chars[index++] = IsObject(i) ? '1' : '0'; | 11130 chars[index++] = IsObject(i) ? '1' : '0'; |
11814 } | 11131 } |
11815 chars[index] = '\0'; | 11132 chars[index] = '\0'; |
11816 return chars; | 11133 return chars; |
11817 } | 11134 } |
11818 #undef FORMAT | 11135 #undef FORMAT |
11819 } | 11136 } |
11820 | 11137 |
11821 | 11138 |
11822 void Stackmap::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
11823 Object::PrintJSONImpl(stream, ref); | |
11824 } | |
11825 | |
11826 | |
11827 RawString* LocalVarDescriptors::GetName(intptr_t var_index) const { | 11139 RawString* LocalVarDescriptors::GetName(intptr_t var_index) const { |
11828 ASSERT(var_index < Length()); | 11140 ASSERT(var_index < Length()); |
11829 ASSERT(Object::Handle(*raw()->nameAddrAt(var_index)).IsString()); | 11141 ASSERT(Object::Handle(*raw()->nameAddrAt(var_index)).IsString()); |
11830 return *raw()->nameAddrAt(var_index); | 11142 return *raw()->nameAddrAt(var_index); |
11831 } | 11143 } |
11832 | 11144 |
11833 | 11145 |
11834 void LocalVarDescriptors::SetVar(intptr_t var_index, | 11146 void LocalVarDescriptors::SetVar(intptr_t var_index, |
11835 const String& name, | 11147 const String& name, |
11836 RawLocalVarDescriptors::VarInfo* info) const { | 11148 RawLocalVarDescriptors::VarInfo* info) const { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11913 var_name = GetName(i); | 11225 var_name = GetName(i); |
11914 GetInfo(i, &info); | 11226 GetInfo(i, &info); |
11915 num_chars += PrintVarInfo((buffer + num_chars), | 11227 num_chars += PrintVarInfo((buffer + num_chars), |
11916 (len - num_chars), | 11228 (len - num_chars), |
11917 i, var_name, info); | 11229 i, var_name, info); |
11918 } | 11230 } |
11919 return buffer; | 11231 return buffer; |
11920 } | 11232 } |
11921 | 11233 |
11922 | 11234 |
11923 void LocalVarDescriptors::PrintJSONImpl(JSONStream* stream, | |
11924 bool ref) const { | |
11925 JSONObject jsobj(stream); | |
11926 AddCommonObjectProperties(&jsobj, "Object", ref); | |
11927 // TODO(johnmccutchan): Generate a stable id. LocalVarDescriptors hang off | |
11928 // a Code object but do not have a back reference to generate an ID. | |
11929 jsobj.AddServiceId(*this); | |
11930 if (ref) { | |
11931 return; | |
11932 } | |
11933 JSONArray members(&jsobj, "members"); | |
11934 String& var_name = String::Handle(); | |
11935 for (intptr_t i = 0; i < Length(); i++) { | |
11936 RawLocalVarDescriptors::VarInfo info; | |
11937 var_name = GetName(i); | |
11938 GetInfo(i, &info); | |
11939 JSONObject var(&members); | |
11940 var.AddProperty("name", var_name.ToCString()); | |
11941 var.AddProperty("index", static_cast<intptr_t>(info.index())); | |
11942 var.AddProperty("beginPos", info.begin_pos); | |
11943 var.AddProperty("endPos", info.end_pos); | |
11944 var.AddProperty("scopeId", static_cast<intptr_t>(info.scope_id)); | |
11945 var.AddProperty("kind", KindToCString(info.kind())); | |
11946 } | |
11947 } | |
11948 | |
11949 | |
11950 const char* LocalVarDescriptors::KindToCString( | 11235 const char* LocalVarDescriptors::KindToCString( |
11951 RawLocalVarDescriptors::VarInfoKind kind) { | 11236 RawLocalVarDescriptors::VarInfoKind kind) { |
11952 switch (kind) { | 11237 switch (kind) { |
11953 case RawLocalVarDescriptors::kStackVar: | 11238 case RawLocalVarDescriptors::kStackVar: |
11954 return "StackVar"; | 11239 return "StackVar"; |
11955 case RawLocalVarDescriptors::kContextVar: | 11240 case RawLocalVarDescriptors::kContextVar: |
11956 return "ContextVar"; | 11241 return "ContextVar"; |
11957 case RawLocalVarDescriptors::kContextLevel: | 11242 case RawLocalVarDescriptors::kContextLevel: |
11958 return "ContextLevel"; | 11243 return "ContextLevel"; |
11959 case RawLocalVarDescriptors::kSavedCurrentContext: | 11244 case RawLocalVarDescriptors::kSavedCurrentContext: |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12169 (len - num_chars), | 11454 (len - num_chars), |
12170 FORMAT2, k, type.ToCString()); | 11455 FORMAT2, k, type.ToCString()); |
12171 } | 11456 } |
12172 } | 11457 } |
12173 return buffer; | 11458 return buffer; |
12174 #undef FORMAT1 | 11459 #undef FORMAT1 |
12175 #undef FORMAT2 | 11460 #undef FORMAT2 |
12176 } | 11461 } |
12177 | 11462 |
12178 | 11463 |
12179 void ExceptionHandlers::PrintJSONImpl(JSONStream* stream, | |
12180 bool ref) const { | |
12181 Object::PrintJSONImpl(stream, ref); | |
12182 } | |
12183 | |
12184 | |
12185 intptr_t DeoptInfo::FrameSize(const TypedData& packed) { | 11464 intptr_t DeoptInfo::FrameSize(const TypedData& packed) { |
12186 NoSafepointScope no_safepoint; | 11465 NoSafepointScope no_safepoint; |
12187 typedef ReadStream::Raw<sizeof(intptr_t), intptr_t> Reader; | 11466 typedef ReadStream::Raw<sizeof(intptr_t), intptr_t> Reader; |
12188 ReadStream read_stream(reinterpret_cast<uint8_t*>(packed.DataAddr(0)), | 11467 ReadStream read_stream(reinterpret_cast<uint8_t*>(packed.DataAddr(0)), |
12189 packed.LengthInBytes()); | 11468 packed.LengthInBytes()); |
12190 return Reader::Read(&read_stream); | 11469 return Reader::Read(&read_stream); |
12191 } | 11470 } |
12192 | 11471 |
12193 | 11472 |
12194 intptr_t DeoptInfo::NumMaterializations( | 11473 intptr_t DeoptInfo::NumMaterializations( |
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12994 from.deopt_id(), | 12273 from.deopt_id(), |
12995 from.NumArgsTested())); | 12274 from.NumArgsTested())); |
12996 // Preserve entry array. | 12275 // Preserve entry array. |
12997 result.set_ic_data_array(Array::Handle(zone, from.ic_data())); | 12276 result.set_ic_data_array(Array::Handle(zone, from.ic_data())); |
12998 // Copy deoptimization reasons. | 12277 // Copy deoptimization reasons. |
12999 result.SetDeoptReasons(from.DeoptReasons()); | 12278 result.SetDeoptReasons(from.DeoptReasons()); |
13000 return result.raw(); | 12279 return result.raw(); |
13001 } | 12280 } |
13002 | 12281 |
13003 | 12282 |
13004 void ICData::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
13005 JSONObject jsobj(stream); | |
13006 AddCommonObjectProperties(&jsobj, "Object", ref); | |
13007 jsobj.AddServiceId(*this); | |
13008 jsobj.AddProperty("_owner", Object::Handle(Owner())); | |
13009 jsobj.AddProperty("_selector", String::Handle(target_name()).ToCString()); | |
13010 if (ref) { | |
13011 return; | |
13012 } | |
13013 jsobj.AddProperty("_argumentsDescriptor", | |
13014 Object::Handle(arguments_descriptor())); | |
13015 jsobj.AddProperty("_entries", Object::Handle(ic_data())); | |
13016 } | |
13017 | |
13018 | |
13019 void ICData::PrintToJSONArray(const JSONArray& jsarray, | |
13020 TokenPosition token_pos, | |
13021 bool is_static_call) const { | |
13022 Isolate* isolate = Isolate::Current(); | |
13023 Class& cls = Class::Handle(); | |
13024 Function& func = Function::Handle(); | |
13025 | |
13026 JSONObject jsobj(&jsarray); | |
13027 jsobj.AddProperty("name", String::Handle(target_name()).ToCString()); | |
13028 jsobj.AddProperty("tokenPos", token_pos); | |
13029 // TODO(rmacnak): Figure out how to stringify DeoptReasons(). | |
13030 // jsobj.AddProperty("deoptReasons", ...); | |
13031 | |
13032 JSONArray cache_entries(&jsobj, "cacheEntries"); | |
13033 for (intptr_t i = 0; i < NumberOfChecks(); i++) { | |
13034 func = GetTargetAt(i); | |
13035 if (is_static_call) { | |
13036 cls ^= func.Owner(); | |
13037 } else { | |
13038 intptr_t cid = GetReceiverClassIdAt(i); | |
13039 cls ^= isolate->class_table()->At(cid); | |
13040 } | |
13041 intptr_t count = GetCountAt(i); | |
13042 JSONObject cache_entry(&cache_entries); | |
13043 if (cls.IsTopLevel()) { | |
13044 cache_entry.AddProperty("receiverContainer", | |
13045 Library::Handle(cls.library())); | |
13046 } else { | |
13047 cache_entry.AddProperty("receiverContainer", cls); | |
13048 } | |
13049 cache_entry.AddProperty("count", count); | |
13050 cache_entry.AddProperty("target", func); | |
13051 } | |
13052 } | |
13053 | |
13054 | |
13055 void ICData::PrintToJSONArrayNew(const JSONArray& jsarray, | |
13056 TokenPosition token_pos, | |
13057 bool is_static_call) const { | |
13058 Isolate* isolate = Isolate::Current(); | |
13059 Class& cls = Class::Handle(); | |
13060 Function& func = Function::Handle(); | |
13061 | |
13062 JSONObject jsobj(&jsarray); | |
13063 jsobj.AddProperty("name", String::Handle(target_name()).ToCString()); | |
13064 jsobj.AddProperty("tokenPos", token_pos.value()); | |
13065 // TODO(rmacnak): Figure out how to stringify DeoptReasons(). | |
13066 // jsobj.AddProperty("deoptReasons", ...); | |
13067 | |
13068 JSONArray cache_entries(&jsobj, "cacheEntries"); | |
13069 for (intptr_t i = 0; i < NumberOfChecks(); i++) { | |
13070 JSONObject cache_entry(&cache_entries); | |
13071 func = GetTargetAt(i); | |
13072 intptr_t count = GetCountAt(i); | |
13073 if (!is_static_call) { | |
13074 intptr_t cid = GetReceiverClassIdAt(i); | |
13075 cls ^= isolate->class_table()->At(cid); | |
13076 cache_entry.AddProperty("receiver", cls); | |
13077 } | |
13078 cache_entry.AddProperty("target", func); | |
13079 cache_entry.AddProperty("count", count); | |
13080 } | |
13081 } | |
13082 | |
13083 | |
13084 static Token::Kind RecognizeArithmeticOp(const String& name) { | 12283 static Token::Kind RecognizeArithmeticOp(const String& name) { |
13085 ASSERT(name.IsSymbol()); | 12284 ASSERT(name.IsSymbol()); |
13086 if (name.raw() == Symbols::Plus().raw()) { | 12285 if (name.raw() == Symbols::Plus().raw()) { |
13087 return Token::kADD; | 12286 return Token::kADD; |
13088 } else if (name.raw() == Symbols::Minus().raw()) { | 12287 } else if (name.raw() == Symbols::Minus().raw()) { |
13089 return Token::kSUB; | 12288 return Token::kSUB; |
13090 } else if (name.raw() == Symbols::Star().raw()) { | 12289 } else if (name.raw() == Symbols::Star().raw()) { |
13091 return Token::kMUL; | 12290 return Token::kMUL; |
13092 } else if (name.raw() == Symbols::Slash().raw()) { | 12291 } else if (name.raw() == Symbols::Slash().raw()) { |
13093 return Token::kDIV; | 12292 return Token::kDIV; |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13275 for (intptr_t i = kSCallTableEntryLength; | 12474 for (intptr_t i = kSCallTableEntryLength; |
13276 i < value.Length(); | 12475 i < value.Length(); |
13277 i += kSCallTableEntryLength) { | 12476 i += kSCallTableEntryLength) { |
13278 ASSERT(value.At(i - kSCallTableEntryLength) < value.At(i)); | 12477 ASSERT(value.At(i - kSCallTableEntryLength) < value.At(i)); |
13279 } | 12478 } |
13280 #endif // DEBUG | 12479 #endif // DEBUG |
13281 } | 12480 } |
13282 | 12481 |
13283 | 12482 |
13284 bool Code::HasBreakpoint() const { | 12483 bool Code::HasBreakpoint() const { |
| 12484 if (!FLAG_support_debugger) { |
| 12485 return false; |
| 12486 } |
13285 return Isolate::Current()->debugger()->HasBreakpoint(*this); | 12487 return Isolate::Current()->debugger()->HasBreakpoint(*this); |
13286 } | 12488 } |
13287 | 12489 |
13288 | 12490 |
13289 RawTypedData* Code::GetDeoptInfoAtPc(uword pc, | 12491 RawTypedData* Code::GetDeoptInfoAtPc(uword pc, |
13290 ICData::DeoptReasonId* deopt_reason, | 12492 ICData::DeoptReasonId* deopt_reason, |
13291 uint32_t* deopt_flags) const { | 12493 uint32_t* deopt_flags) const { |
13292 ASSERT(is_optimized()); | 12494 ASSERT(is_optimized()); |
13293 const Instructions& instrs = Instructions::Handle(instructions()); | 12495 const Instructions& instrs = Instructions::Handle(instructions()); |
13294 uword code_entry = instrs.EntryPoint(); | 12496 uword code_entry = instrs.EntryPoint(); |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13821 DEBUG_ASSERT(IsMutatorOrAtSafepoint() || !is_alive()); | 13023 DEBUG_ASSERT(IsMutatorOrAtSafepoint() || !is_alive()); |
13822 // RawInstructions are never allocated in New space and hence a | 13024 // RawInstructions are never allocated in New space and hence a |
13823 // store buffer update is not needed here. | 13025 // store buffer update is not needed here. |
13824 StorePointer(&raw_ptr()->active_instructions_, instructions); | 13026 StorePointer(&raw_ptr()->active_instructions_, instructions); |
13825 StoreNonPointer(&raw_ptr()->entry_point_, | 13027 StoreNonPointer(&raw_ptr()->entry_point_, |
13826 reinterpret_cast<uword>(instructions->ptr()) + | 13028 reinterpret_cast<uword>(instructions->ptr()) + |
13827 Instructions::HeaderSize()); | 13029 Instructions::HeaderSize()); |
13828 } | 13030 } |
13829 | 13031 |
13830 | 13032 |
13831 void Code::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
13832 JSONObject jsobj(stream); | |
13833 AddCommonObjectProperties(&jsobj, "Code", ref); | |
13834 jsobj.AddFixedServiceId("code/%" Px64"-%" Px "", | |
13835 compile_timestamp(), | |
13836 EntryPoint()); | |
13837 const String& user_name = String::Handle(PrettyName()); | |
13838 const String& vm_name = String::Handle(Name()); | |
13839 AddNameProperties(&jsobj, user_name, vm_name); | |
13840 const bool is_stub = IsStubCode() || IsAllocationStubCode(); | |
13841 if (is_stub) { | |
13842 jsobj.AddProperty("kind", "Stub"); | |
13843 } else { | |
13844 jsobj.AddProperty("kind", "Dart"); | |
13845 } | |
13846 jsobj.AddProperty("_optimized", is_optimized()); | |
13847 const Object& obj = Object::Handle(owner()); | |
13848 if (obj.IsFunction()) { | |
13849 const Function& func = Function::Cast(obj); | |
13850 jsobj.AddProperty("_intrinsic", func.is_intrinsic()); | |
13851 jsobj.AddProperty("_native", func.is_native()); | |
13852 } else { | |
13853 jsobj.AddProperty("_intrinsic", false); | |
13854 jsobj.AddProperty("_native", false); | |
13855 } | |
13856 if (ref) { | |
13857 return; | |
13858 } | |
13859 if (obj.IsFunction()) { | |
13860 jsobj.AddProperty("function", obj); | |
13861 } else { | |
13862 // Generate a fake function reference. | |
13863 JSONObject func(&jsobj, "function"); | |
13864 func.AddProperty("type", "@Function"); | |
13865 func.AddProperty("_kind", "Stub"); | |
13866 func.AddProperty("name", user_name.ToCString()); | |
13867 AddNameProperties(&func, user_name, vm_name); | |
13868 } | |
13869 jsobj.AddPropertyF("_startAddress", "%" Px "", EntryPoint()); | |
13870 jsobj.AddPropertyF("_endAddress", "%" Px "", EntryPoint() + Size()); | |
13871 jsobj.AddProperty("_alive", is_alive()); | |
13872 const ObjectPool& object_pool = ObjectPool::Handle(GetObjectPool()); | |
13873 jsobj.AddProperty("_objectPool", object_pool); | |
13874 { | |
13875 JSONArray jsarr(&jsobj, "_disassembly"); | |
13876 if (is_alive()) { | |
13877 // Only disassemble alive code objects. | |
13878 DisassembleToJSONStream formatter(jsarr); | |
13879 Disassemble(&formatter); | |
13880 } | |
13881 } | |
13882 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); | |
13883 if (!descriptors.IsNull()) { | |
13884 JSONObject desc(&jsobj, "_descriptors"); | |
13885 descriptors.PrintToJSONObject(&desc, false); | |
13886 } | |
13887 const Array& inlined_function_table = Array::Handle(GetInlinedIdToFunction()); | |
13888 if (!inlined_function_table.IsNull() && | |
13889 (inlined_function_table.Length() > 0)) { | |
13890 JSONArray inlined_functions(&jsobj, "_inlinedFunctions"); | |
13891 Function& function = Function::Handle(); | |
13892 for (intptr_t i = 0; i < inlined_function_table.Length(); i++) { | |
13893 function ^= inlined_function_table.At(i); | |
13894 ASSERT(!function.IsNull()); | |
13895 inlined_functions.AddValue(function); | |
13896 } | |
13897 } | |
13898 const Array& intervals = Array::Handle(GetInlinedIntervals()); | |
13899 if (!intervals.IsNull() && (intervals.Length() > 0)) { | |
13900 Smi& start = Smi::Handle(); | |
13901 Smi& end = Smi::Handle(); | |
13902 Smi& temp_smi = Smi::Handle(); | |
13903 JSONArray inline_intervals(&jsobj, "_inlinedIntervals"); | |
13904 for (intptr_t i = 0; i < intervals.Length() - Code::kInlIntNumEntries; | |
13905 i += Code::kInlIntNumEntries) { | |
13906 start ^= intervals.At(i + Code::kInlIntStart); | |
13907 if (start.IsNull()) { | |
13908 continue; | |
13909 } | |
13910 end ^= intervals.At(i + Code::kInlIntNumEntries + Code::kInlIntStart); | |
13911 | |
13912 // Format: [start, end, inline functions...] | |
13913 JSONArray inline_interval(&inline_intervals); | |
13914 inline_interval.AddValue(start.Value()); | |
13915 inline_interval.AddValue(end.Value()); | |
13916 | |
13917 temp_smi ^= intervals.At(i + Code::kInlIntInliningId); | |
13918 intptr_t inlining_id = temp_smi.Value(); | |
13919 ASSERT(inlining_id >= 0); | |
13920 intptr_t caller_id = GetCallerId(inlining_id); | |
13921 while (inlining_id >= 0) { | |
13922 inline_interval.AddValue(inlining_id); | |
13923 inlining_id = caller_id; | |
13924 caller_id = GetCallerId(inlining_id); | |
13925 } | |
13926 } | |
13927 } | |
13928 } | |
13929 | |
13930 | |
13931 uword Code::GetLazyDeoptPc() const { | 13033 uword Code::GetLazyDeoptPc() const { |
13932 return (lazy_deopt_pc_offset() != kInvalidPc) | 13034 return (lazy_deopt_pc_offset() != kInvalidPc) |
13933 ? EntryPoint() + lazy_deopt_pc_offset() : 0; | 13035 ? EntryPoint() + lazy_deopt_pc_offset() : 0; |
13934 } | 13036 } |
13935 | 13037 |
13936 | 13038 |
13937 RawStackmap* Code::GetStackmap( | 13039 RawStackmap* Code::GetStackmap( |
13938 uint32_t pc_offset, Array* maps, Stackmap* map) const { | 13040 uint32_t pc_offset, Array* maps, Stackmap* map) const { |
13939 // This code is used during iterating frames during a GC and hence it | 13041 // This code is used during iterating frames during a GC and hence it |
13940 // should not in turn start a GC. | 13042 // should not in turn start a GC. |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14131 | 13233 |
14132 const Context& parent_ctx = Context::Handle(parent()); | 13234 const Context& parent_ctx = Context::Handle(parent()); |
14133 if (!parent_ctx.IsNull()) { | 13235 if (!parent_ctx.IsNull()) { |
14134 parent_ctx.Dump(indent + 2); | 13236 parent_ctx.Dump(indent + 2); |
14135 } | 13237 } |
14136 IndentN(indent); | 13238 IndentN(indent); |
14137 THR_Print("}\n"); | 13239 THR_Print("}\n"); |
14138 } | 13240 } |
14139 | 13241 |
14140 | 13242 |
14141 void Context::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
14142 JSONObject jsobj(stream); | |
14143 // TODO(turnidge): Should the user level type for Context be Context | |
14144 // or Object? | |
14145 AddCommonObjectProperties(&jsobj, "Context", ref); | |
14146 jsobj.AddServiceId(*this); | |
14147 | |
14148 jsobj.AddProperty("length", num_variables()); | |
14149 | |
14150 if (ref) { | |
14151 return; | |
14152 } | |
14153 | |
14154 const Context& parent_context = Context::Handle(parent()); | |
14155 if (!parent_context.IsNull()) { | |
14156 jsobj.AddProperty("parent", parent_context); | |
14157 } | |
14158 | |
14159 JSONArray jsarr(&jsobj, "variables"); | |
14160 Object& var = Object::Handle(); | |
14161 for (intptr_t index = 0; index < num_variables(); index++) { | |
14162 var = At(index); | |
14163 JSONObject jselement(&jsarr); | |
14164 jselement.AddProperty("value", var); | |
14165 } | |
14166 } | |
14167 | |
14168 | |
14169 RawContextScope* ContextScope::New(intptr_t num_variables, bool is_implicit) { | 13243 RawContextScope* ContextScope::New(intptr_t num_variables, bool is_implicit) { |
14170 ASSERT(Object::context_scope_class() != Class::null()); | 13244 ASSERT(Object::context_scope_class() != Class::null()); |
14171 if (num_variables < 0 || num_variables > kMaxElements) { | 13245 if (num_variables < 0 || num_variables > kMaxElements) { |
14172 // This should be caught before we reach here. | 13246 // This should be caught before we reach here. |
14173 FATAL1("Fatal error in ContextScope::New: invalid num_variables %" Pd "\n", | 13247 FATAL1("Fatal error in ContextScope::New: invalid num_variables %" Pd "\n", |
14174 num_variables); | 13248 num_variables); |
14175 } | 13249 } |
14176 intptr_t size = ContextScope::InstanceSize(num_variables); | 13250 intptr_t size = ContextScope::InstanceSize(num_variables); |
14177 ContextScope& result = ContextScope::Handle(); | 13251 ContextScope& result = ContextScope::Handle(); |
14178 { | 13252 { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14292 intptr_t lvl = ContextLevelAt(i); | 13366 intptr_t lvl = ContextLevelAt(i); |
14293 char* chars = OS::SCreate(Thread::Current()->zone(), | 13367 char* chars = OS::SCreate(Thread::Current()->zone(), |
14294 "%s\nvar %s token-pos %s ctx lvl %" Pd " index %" Pd "", | 13368 "%s\nvar %s token-pos %s ctx lvl %" Pd " index %" Pd "", |
14295 prev_cstr, cname, pos.ToCString(), lvl, idx); | 13369 prev_cstr, cname, pos.ToCString(), lvl, idx); |
14296 prev_cstr = chars; | 13370 prev_cstr = chars; |
14297 } | 13371 } |
14298 return prev_cstr; | 13372 return prev_cstr; |
14299 } | 13373 } |
14300 | 13374 |
14301 | 13375 |
14302 void ContextScope::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
14303 Object::PrintJSONImpl(stream, ref); | |
14304 } | |
14305 | |
14306 | |
14307 RawArray* MegamorphicCache::buckets() const { | 13376 RawArray* MegamorphicCache::buckets() const { |
14308 return raw_ptr()->buckets_; | 13377 return raw_ptr()->buckets_; |
14309 } | 13378 } |
14310 | 13379 |
14311 | 13380 |
14312 void MegamorphicCache::set_buckets(const Array& buckets) const { | 13381 void MegamorphicCache::set_buckets(const Array& buckets) const { |
14313 StorePointer(&raw_ptr()->buckets_, buckets.raw()); | 13382 StorePointer(&raw_ptr()->buckets_, buckets.raw()); |
14314 } | 13383 } |
14315 | 13384 |
14316 | 13385 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14437 } | 13506 } |
14438 | 13507 |
14439 | 13508 |
14440 const char* MegamorphicCache::ToCString() const { | 13509 const char* MegamorphicCache::ToCString() const { |
14441 const String& name = String::Handle(target_name()); | 13510 const String& name = String::Handle(target_name()); |
14442 return OS::SCreate(Thread::Current()->zone(), | 13511 return OS::SCreate(Thread::Current()->zone(), |
14443 "MegamorphicCache(%s)", name.ToCString()); | 13512 "MegamorphicCache(%s)", name.ToCString()); |
14444 } | 13513 } |
14445 | 13514 |
14446 | 13515 |
14447 void MegamorphicCache::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
14448 JSONObject jsobj(stream); | |
14449 AddCommonObjectProperties(&jsobj, "Object", ref); | |
14450 jsobj.AddServiceId(*this); | |
14451 jsobj.AddProperty("_selector", String::Handle(target_name()).ToCString()); | |
14452 if (ref) { | |
14453 return; | |
14454 } | |
14455 jsobj.AddProperty("_buckets", Object::Handle(buckets())); | |
14456 jsobj.AddProperty("_mask", mask()); | |
14457 jsobj.AddProperty("_argumentsDescriptor", | |
14458 Object::Handle(arguments_descriptor())); | |
14459 } | |
14460 | |
14461 | |
14462 RawSubtypeTestCache* SubtypeTestCache::New() { | 13516 RawSubtypeTestCache* SubtypeTestCache::New() { |
14463 ASSERT(Object::subtypetestcache_class() != Class::null()); | 13517 ASSERT(Object::subtypetestcache_class() != Class::null()); |
14464 SubtypeTestCache& result = SubtypeTestCache::Handle(); | 13518 SubtypeTestCache& result = SubtypeTestCache::Handle(); |
14465 { | 13519 { |
14466 // SubtypeTestCache objects are long living objects, allocate them in the | 13520 // SubtypeTestCache objects are long living objects, allocate them in the |
14467 // old generation. | 13521 // old generation. |
14468 RawObject* raw = Object::Allocate(SubtypeTestCache::kClassId, | 13522 RawObject* raw = Object::Allocate(SubtypeTestCache::kClassId, |
14469 SubtypeTestCache::InstanceSize(), | 13523 SubtypeTestCache::InstanceSize(), |
14470 Heap::kOld); | 13524 Heap::kOld); |
14471 NoSafepointScope no_safepoint; | 13525 NoSafepointScope no_safepoint; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14523 data.At(data_pos + kInstantiatorTypeArguments); | 13577 data.At(data_pos + kInstantiatorTypeArguments); |
14524 *test_result ^= data.At(data_pos + kTestResult); | 13578 *test_result ^= data.At(data_pos + kTestResult); |
14525 } | 13579 } |
14526 | 13580 |
14527 | 13581 |
14528 const char* SubtypeTestCache::ToCString() const { | 13582 const char* SubtypeTestCache::ToCString() const { |
14529 return "SubtypeTestCache"; | 13583 return "SubtypeTestCache"; |
14530 } | 13584 } |
14531 | 13585 |
14532 | 13586 |
14533 void SubtypeTestCache::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
14534 Object::PrintJSONImpl(stream, ref); | |
14535 } | |
14536 | |
14537 | |
14538 const char* Error::ToErrorCString() const { | 13587 const char* Error::ToErrorCString() const { |
14539 UNREACHABLE(); | 13588 UNREACHABLE(); |
14540 return "Internal Error"; | 13589 return "Internal Error"; |
14541 } | 13590 } |
14542 | 13591 |
14543 | 13592 |
14544 const char* Error::ToCString() const { | 13593 const char* Error::ToCString() const { |
14545 // Error is an abstract class. We should never reach here. | 13594 // Error is an abstract class. We should never reach here. |
14546 UNREACHABLE(); | 13595 UNREACHABLE(); |
14547 return "Error"; | 13596 return "Error"; |
14548 } | 13597 } |
14549 | 13598 |
14550 | 13599 |
14551 void Error::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
14552 UNREACHABLE(); | |
14553 } | |
14554 | |
14555 | |
14556 RawApiError* ApiError::New() { | 13600 RawApiError* ApiError::New() { |
14557 ASSERT(Object::api_error_class() != Class::null()); | 13601 ASSERT(Object::api_error_class() != Class::null()); |
14558 RawObject* raw = Object::Allocate(ApiError::kClassId, | 13602 RawObject* raw = Object::Allocate(ApiError::kClassId, |
14559 ApiError::InstanceSize(), | 13603 ApiError::InstanceSize(), |
14560 Heap::kOld); | 13604 Heap::kOld); |
14561 return reinterpret_cast<RawApiError*>(raw); | 13605 return reinterpret_cast<RawApiError*>(raw); |
14562 } | 13606 } |
14563 | 13607 |
14564 | 13608 |
14565 RawApiError* ApiError::New(const String& message, Heap::Space space) { | 13609 RawApiError* ApiError::New(const String& message, Heap::Space space) { |
(...skipping 20 matching lines...) Expand all Loading... |
14586 const String& msg_str = String::Handle(message()); | 13630 const String& msg_str = String::Handle(message()); |
14587 return msg_str.ToCString(); | 13631 return msg_str.ToCString(); |
14588 } | 13632 } |
14589 | 13633 |
14590 | 13634 |
14591 const char* ApiError::ToCString() const { | 13635 const char* ApiError::ToCString() const { |
14592 return "ApiError"; | 13636 return "ApiError"; |
14593 } | 13637 } |
14594 | 13638 |
14595 | 13639 |
14596 void ApiError::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
14597 JSONObject jsobj(stream); | |
14598 AddCommonObjectProperties(&jsobj, "Error", ref); | |
14599 jsobj.AddProperty("kind", "InternalError"); | |
14600 jsobj.AddServiceId(*this); | |
14601 jsobj.AddProperty("message", ToErrorCString()); | |
14602 } | |
14603 | |
14604 | |
14605 RawLanguageError* LanguageError::New() { | 13640 RawLanguageError* LanguageError::New() { |
14606 ASSERT(Object::language_error_class() != Class::null()); | 13641 ASSERT(Object::language_error_class() != Class::null()); |
14607 RawObject* raw = Object::Allocate(LanguageError::kClassId, | 13642 RawObject* raw = Object::Allocate(LanguageError::kClassId, |
14608 LanguageError::InstanceSize(), | 13643 LanguageError::InstanceSize(), |
14609 Heap::kOld); | 13644 Heap::kOld); |
14610 return reinterpret_cast<RawLanguageError*>(raw); | 13645 return reinterpret_cast<RawLanguageError*>(raw); |
14611 } | 13646 } |
14612 | 13647 |
14613 | 13648 |
14614 RawLanguageError* LanguageError::NewFormattedV(const Error& prev_error, | 13649 RawLanguageError* LanguageError::NewFormattedV(const Error& prev_error, |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14736 const String& msg_str = String::Handle(FormatMessage()); | 13771 const String& msg_str = String::Handle(FormatMessage()); |
14737 return msg_str.ToCString(); | 13772 return msg_str.ToCString(); |
14738 } | 13773 } |
14739 | 13774 |
14740 | 13775 |
14741 const char* LanguageError::ToCString() const { | 13776 const char* LanguageError::ToCString() const { |
14742 return "LanguageError"; | 13777 return "LanguageError"; |
14743 } | 13778 } |
14744 | 13779 |
14745 | 13780 |
14746 void LanguageError::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
14747 JSONObject jsobj(stream); | |
14748 AddCommonObjectProperties(&jsobj, "Error", ref); | |
14749 jsobj.AddProperty("kind", "LanguageError"); | |
14750 jsobj.AddServiceId(*this); | |
14751 jsobj.AddProperty("message", ToErrorCString()); | |
14752 } | |
14753 | |
14754 | |
14755 RawUnhandledException* UnhandledException::New(const Instance& exception, | 13781 RawUnhandledException* UnhandledException::New(const Instance& exception, |
14756 const Instance& stacktrace, | 13782 const Instance& stacktrace, |
14757 Heap::Space space) { | 13783 Heap::Space space) { |
14758 ASSERT(Object::unhandled_exception_class() != Class::null()); | 13784 ASSERT(Object::unhandled_exception_class() != Class::null()); |
14759 UnhandledException& result = UnhandledException::Handle(); | 13785 UnhandledException& result = UnhandledException::Handle(); |
14760 { | 13786 { |
14761 RawObject* raw = Object::Allocate(UnhandledException::kClassId, | 13787 RawObject* raw = Object::Allocate(UnhandledException::kClassId, |
14762 UnhandledException::InstanceSize(), | 13788 UnhandledException::InstanceSize(), |
14763 space); | 13789 space); |
14764 NoSafepointScope no_safepoint; | 13790 NoSafepointScope no_safepoint; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14825 return OS::SCreate(thread->zone(), | 13851 return OS::SCreate(thread->zone(), |
14826 "Unhandled exception:\n%s\n%s", exc_str, stack_str); | 13852 "Unhandled exception:\n%s\n%s", exc_str, stack_str); |
14827 } | 13853 } |
14828 | 13854 |
14829 | 13855 |
14830 const char* UnhandledException::ToCString() const { | 13856 const char* UnhandledException::ToCString() const { |
14831 return "UnhandledException"; | 13857 return "UnhandledException"; |
14832 } | 13858 } |
14833 | 13859 |
14834 | 13860 |
14835 | |
14836 void UnhandledException::PrintJSONImpl(JSONStream* stream, | |
14837 bool ref) const { | |
14838 JSONObject jsobj(stream); | |
14839 AddCommonObjectProperties(&jsobj, "Error", ref); | |
14840 jsobj.AddProperty("kind", "UnhandledException"); | |
14841 jsobj.AddServiceId(*this); | |
14842 jsobj.AddProperty("message", ToErrorCString()); | |
14843 if (ref) { | |
14844 return; | |
14845 } | |
14846 Instance& instance = Instance::Handle(); | |
14847 instance = exception(); | |
14848 jsobj.AddProperty("exception", instance); | |
14849 instance = stacktrace(); | |
14850 jsobj.AddProperty("stacktrace", instance); | |
14851 } | |
14852 | |
14853 | |
14854 RawUnwindError* UnwindError::New(const String& message, Heap::Space space) { | 13861 RawUnwindError* UnwindError::New(const String& message, Heap::Space space) { |
14855 ASSERT(Object::unwind_error_class() != Class::null()); | 13862 ASSERT(Object::unwind_error_class() != Class::null()); |
14856 UnwindError& result = UnwindError::Handle(); | 13863 UnwindError& result = UnwindError::Handle(); |
14857 { | 13864 { |
14858 RawObject* raw = Object::Allocate(UnwindError::kClassId, | 13865 RawObject* raw = Object::Allocate(UnwindError::kClassId, |
14859 UnwindError::InstanceSize(), | 13866 UnwindError::InstanceSize(), |
14860 space); | 13867 space); |
14861 NoSafepointScope no_safepoint; | 13868 NoSafepointScope no_safepoint; |
14862 result ^= raw; | 13869 result ^= raw; |
14863 } | 13870 } |
(...skipping 23 matching lines...) Expand all Loading... |
14887 const String& msg_str = String::Handle(message()); | 13894 const String& msg_str = String::Handle(message()); |
14888 return msg_str.ToCString(); | 13895 return msg_str.ToCString(); |
14889 } | 13896 } |
14890 | 13897 |
14891 | 13898 |
14892 const char* UnwindError::ToCString() const { | 13899 const char* UnwindError::ToCString() const { |
14893 return "UnwindError"; | 13900 return "UnwindError"; |
14894 } | 13901 } |
14895 | 13902 |
14896 | 13903 |
14897 void UnwindError::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
14898 JSONObject jsobj(stream); | |
14899 AddCommonObjectProperties(&jsobj, "Error", ref); | |
14900 jsobj.AddProperty("kind", "TerminationError"); | |
14901 jsobj.AddServiceId(*this); | |
14902 jsobj.AddProperty("message", ToErrorCString()); | |
14903 jsobj.AddProperty("_is_user_initiated", is_user_initiated()); | |
14904 jsobj.AddProperty("_is_vm_restart", is_vm_restart()); | |
14905 } | |
14906 | |
14907 | |
14908 RawObject* Instance::Evaluate(const String& expr, | 13904 RawObject* Instance::Evaluate(const String& expr, |
14909 const Array& param_names, | 13905 const Array& param_names, |
14910 const Array& param_values) const { | 13906 const Array& param_values) const { |
14911 const Class& cls = Class::Handle(clazz()); | 13907 const Class& cls = Class::Handle(clazz()); |
14912 const Function& eval_func = | 13908 const Function& eval_func = |
14913 Function::Handle(EvaluateHelper(cls, expr, param_names, false)); | 13909 Function::Handle(EvaluateHelper(cls, expr, param_names, false)); |
14914 const Array& args = Array::Handle(Array::New(1 + param_values.Length())); | 13910 const Array& args = Array::Handle(Array::New(1 + param_values.Length())); |
14915 PassiveObject& param = PassiveObject::Handle(); | 13911 PassiveObject& param = PassiveObject::Handle(); |
14916 args.SetAt(0, *this); | 13912 args.SetAt(0, *this); |
14917 for (intptr_t i = 0; i < param_values.Length(); i++) { | 13913 for (intptr_t i = 0; i < param_values.Length(); i++) { |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15440 } | 14436 } |
15441 const Type& type = Type::Handle( | 14437 const Type& type = Type::Handle( |
15442 Type::New(cls, type_arguments, TokenPosition::kNoSource)); | 14438 Type::New(cls, type_arguments, TokenPosition::kNoSource)); |
15443 const String& type_name = String::Handle(type.UserVisibleName()); | 14439 const String& type_name = String::Handle(type.UserVisibleName()); |
15444 return OS::SCreate(Thread::Current()->zone(), | 14440 return OS::SCreate(Thread::Current()->zone(), |
15445 "Instance of '%s'", type_name.ToCString()); | 14441 "Instance of '%s'", type_name.ToCString()); |
15446 } | 14442 } |
15447 } | 14443 } |
15448 | 14444 |
15449 | 14445 |
15450 void Instance::PrintSharedInstanceJSON(JSONObject* jsobj, | |
15451 bool ref) const { | |
15452 AddCommonObjectProperties(jsobj, "Instance", ref); | |
15453 if (ref) { | |
15454 return; | |
15455 } | |
15456 | |
15457 // Walk the superclass chain, adding all instance fields. | |
15458 Class& cls = Class::Handle(this->clazz()); | |
15459 { | |
15460 Instance& fieldValue = Instance::Handle(); | |
15461 JSONArray jsarr(jsobj, "fields"); | |
15462 while (!cls.IsNull()) { | |
15463 const Array& field_array = Array::Handle(cls.fields()); | |
15464 Field& field = Field::Handle(); | |
15465 if (!field_array.IsNull()) { | |
15466 for (intptr_t i = 0; i < field_array.Length(); i++) { | |
15467 field ^= field_array.At(i); | |
15468 if (!field.is_static()) { | |
15469 fieldValue ^= GetField(field); | |
15470 JSONObject jsfield(&jsarr); | |
15471 jsfield.AddProperty("type", "BoundField"); | |
15472 jsfield.AddProperty("decl", field); | |
15473 jsfield.AddProperty("value", fieldValue); | |
15474 } | |
15475 } | |
15476 } | |
15477 cls = cls.SuperClass(); | |
15478 } | |
15479 } | |
15480 | |
15481 if (NumNativeFields() > 0) { | |
15482 JSONArray jsarr(jsobj, "_nativeFields"); | |
15483 for (intptr_t i = 0; i < NumNativeFields(); i++) { | |
15484 intptr_t value = GetNativeField(i); | |
15485 JSONObject jsfield(&jsarr); | |
15486 jsfield.AddProperty("index", i); | |
15487 jsfield.AddProperty("value", value); | |
15488 } | |
15489 } | |
15490 } | |
15491 | |
15492 | |
15493 void Instance::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
15494 JSONObject jsobj(stream); | |
15495 | |
15496 // Handle certain special instance values. | |
15497 if (raw() == Object::sentinel().raw()) { | |
15498 jsobj.AddProperty("type", "Sentinel"); | |
15499 jsobj.AddProperty("kind", "NotInitialized"); | |
15500 jsobj.AddProperty("valueAsString", "<not initialized>"); | |
15501 return; | |
15502 } else if (raw() == Object::transition_sentinel().raw()) { | |
15503 jsobj.AddProperty("type", "Sentinel"); | |
15504 jsobj.AddProperty("kind", "BeingInitialized"); | |
15505 jsobj.AddProperty("valueAsString", "<being initialized>"); | |
15506 return; | |
15507 } | |
15508 | |
15509 PrintSharedInstanceJSON(&jsobj, ref); | |
15510 if (IsClosure()) { | |
15511 jsobj.AddProperty("kind", "Closure"); | |
15512 } else { | |
15513 jsobj.AddProperty("kind", "PlainInstance"); | |
15514 } | |
15515 jsobj.AddServiceId(*this); | |
15516 if (IsClosure()) { | |
15517 jsobj.AddProperty("closureFunction", | |
15518 Function::Handle(Closure::Cast(*this).function())); | |
15519 jsobj.AddProperty("closureContext", | |
15520 Context::Handle(Closure::Cast(*this).context())); | |
15521 } | |
15522 if (ref) { | |
15523 return; | |
15524 } | |
15525 if (IsClosure()) { | |
15526 Debugger* debugger = Isolate::Current()->debugger(); | |
15527 Breakpoint* bpt = debugger->BreakpointAtActivation(*this); | |
15528 if (bpt != NULL) { | |
15529 jsobj.AddProperty("_activationBreakpoint", bpt); | |
15530 } | |
15531 } | |
15532 } | |
15533 | |
15534 | |
15535 bool AbstractType::IsResolved() const { | 14446 bool AbstractType::IsResolved() const { |
15536 // AbstractType is an abstract class. | 14447 // AbstractType is an abstract class. |
15537 UNREACHABLE(); | 14448 UNREACHABLE(); |
15538 return false; | 14449 return false; |
15539 } | 14450 } |
15540 | 14451 |
15541 | 14452 |
15542 void AbstractType::SetIsResolved() const { | 14453 void AbstractType::SetIsResolved() const { |
15543 // AbstractType is an abstract class. | 14454 // AbstractType is an abstract class. |
15544 UNREACHABLE(); | 14455 UNREACHABLE(); |
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16076 } | 14987 } |
16077 | 14988 |
16078 | 14989 |
16079 const char* AbstractType::ToCString() const { | 14990 const char* AbstractType::ToCString() const { |
16080 // AbstractType is an abstract class. | 14991 // AbstractType is an abstract class. |
16081 UNREACHABLE(); | 14992 UNREACHABLE(); |
16082 return "AbstractType"; | 14993 return "AbstractType"; |
16083 } | 14994 } |
16084 | 14995 |
16085 | 14996 |
16086 void AbstractType::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
16087 UNREACHABLE(); | |
16088 } | |
16089 | |
16090 | |
16091 RawType* Type::NullType() { | 14997 RawType* Type::NullType() { |
16092 return Isolate::Current()->object_store()->null_type(); | 14998 return Isolate::Current()->object_store()->null_type(); |
16093 } | 14999 } |
16094 | 15000 |
16095 | 15001 |
16096 RawType* Type::DynamicType() { | 15002 RawType* Type::DynamicType() { |
16097 return Object::dynamic_type().raw(); | 15003 return Object::dynamic_type().raw(); |
16098 } | 15004 } |
16099 | 15005 |
16100 | 15006 |
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16677 "Type: (@%p H%" Px ") class '%s', args:[%s]", | 15583 "Type: (@%p H%" Px ") class '%s', args:[%s]", |
16678 raw(), hash, class_name, args_cstr); | 15584 raw(), hash, class_name, args_cstr); |
16679 } else { | 15585 } else { |
16680 const char* args_cstr = TypeArguments::Handle(arguments()).ToCString(); | 15586 const char* args_cstr = TypeArguments::Handle(arguments()).ToCString(); |
16681 return OS::SCreate(Thread::Current()->zone(), | 15587 return OS::SCreate(Thread::Current()->zone(), |
16682 "%sType: class '%s', args:[%s]", unresolved, class_name, args_cstr); | 15588 "%sType: class '%s', args:[%s]", unresolved, class_name, args_cstr); |
16683 } | 15589 } |
16684 } | 15590 } |
16685 | 15591 |
16686 | 15592 |
16687 void Type::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
16688 JSONObject jsobj(stream); | |
16689 PrintSharedInstanceJSON(&jsobj, ref); | |
16690 jsobj.AddProperty("kind", "Type"); | |
16691 if (IsCanonical()) { | |
16692 const Class& type_cls = Class::Handle(type_class()); | |
16693 intptr_t id = type_cls.FindCanonicalTypeIndex(*this); | |
16694 ASSERT(id >= 0); | |
16695 intptr_t cid = type_cls.id(); | |
16696 jsobj.AddFixedServiceId("classes/%" Pd "/types/%" Pd "", cid, id); | |
16697 jsobj.AddProperty("typeClass", type_cls); | |
16698 } else { | |
16699 jsobj.AddServiceId(*this); | |
16700 } | |
16701 const String& user_name = String::Handle(PrettyName()); | |
16702 const String& vm_name = String::Handle(Name()); | |
16703 AddNameProperties(&jsobj, user_name, vm_name); | |
16704 if (ref) { | |
16705 return; | |
16706 } | |
16707 const TypeArguments& typeArgs = TypeArguments::Handle(arguments()); | |
16708 if (!typeArgs.IsNull()) { | |
16709 jsobj.AddProperty("typeArguments", typeArgs); | |
16710 } | |
16711 } | |
16712 | |
16713 | |
16714 void FunctionType::SetIsFinalized() const { | 15593 void FunctionType::SetIsFinalized() const { |
16715 ASSERT(!IsFinalized()); | 15594 ASSERT(!IsFinalized()); |
16716 if (IsInstantiated()) { | 15595 if (IsInstantiated()) { |
16717 set_type_state(RawFunctionType::kFinalizedInstantiated); | 15596 set_type_state(RawFunctionType::kFinalizedInstantiated); |
16718 } else { | 15597 } else { |
16719 set_type_state(RawFunctionType::kFinalizedUninstantiated); | 15598 set_type_state(RawFunctionType::kFinalizedUninstantiated); |
16720 } | 15599 } |
16721 } | 15600 } |
16722 | 15601 |
16723 | 15602 |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17223 return OS::SCreate( | 16102 return OS::SCreate( |
17224 Thread::Current()->zone(), | 16103 Thread::Current()->zone(), |
17225 "%s FunctionType: %s (scope_cls: %s, args: %s)", | 16104 "%s FunctionType: %s (scope_cls: %s, args: %s)", |
17226 unresolved, | 16105 unresolved, |
17227 signature_string.ToCString(), | 16106 signature_string.ToCString(), |
17228 class_name, | 16107 class_name, |
17229 args_cstr); | 16108 args_cstr); |
17230 } | 16109 } |
17231 | 16110 |
17232 | 16111 |
17233 void FunctionType::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
17234 JSONObject jsobj(stream); | |
17235 PrintSharedInstanceJSON(&jsobj, ref); | |
17236 jsobj.AddProperty("kind", "FunctionType"); | |
17237 if (IsCanonical()) { | |
17238 const Class& scope_cls = Class::Handle(scope_class()); | |
17239 intptr_t id = scope_cls.FindCanonicalTypeIndex(*this); | |
17240 ASSERT(id >= 0); | |
17241 intptr_t cid = scope_cls.id(); | |
17242 jsobj.AddFixedServiceId("classes/%" Pd "/types/%" Pd "", cid, id); | |
17243 jsobj.AddProperty("scopeClass", scope_cls); | |
17244 } else { | |
17245 jsobj.AddServiceId(*this); | |
17246 } | |
17247 const String& user_name = String::Handle(PrettyName()); | |
17248 const String& vm_name = String::Handle(Name()); | |
17249 AddNameProperties(&jsobj, user_name, vm_name); | |
17250 if (ref) { | |
17251 return; | |
17252 } | |
17253 const TypeArguments& typeArgs = TypeArguments::Handle(arguments()); | |
17254 if (!typeArgs.IsNull()) { | |
17255 jsobj.AddProperty("typeArguments", typeArgs); | |
17256 } | |
17257 } | |
17258 | |
17259 | |
17260 bool TypeRef::IsInstantiated(TrailPtr trail) const { | 16112 bool TypeRef::IsInstantiated(TrailPtr trail) const { |
17261 if (TestAndAddToTrail(&trail)) { | 16113 if (TestAndAddToTrail(&trail)) { |
17262 return true; | 16114 return true; |
17263 } | 16115 } |
17264 return AbstractType::Handle(type()).IsInstantiated(trail); | 16116 return AbstractType::Handle(type()).IsInstantiated(trail); |
17265 } | 16117 } |
17266 | 16118 |
17267 | 16119 |
17268 bool TypeRef::IsEquivalent(const Instance& other, TrailPtr trail) const { | 16120 bool TypeRef::IsEquivalent(const Instance& other, TrailPtr trail) const { |
17269 if (raw() == other.raw()) { | 16121 if (raw() == other.raw()) { |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17410 const intptr_t hash = ref_type.Hash(); | 16262 const intptr_t hash = ref_type.Hash(); |
17411 return OS::SCreate(Thread::Current()->zone(), | 16263 return OS::SCreate(Thread::Current()->zone(), |
17412 "TypeRef: %s<...> (@%p H%" Px ")", type_cstr, ref_type.raw(), hash); | 16264 "TypeRef: %s<...> (@%p H%" Px ")", type_cstr, ref_type.raw(), hash); |
17413 } else { | 16265 } else { |
17414 return OS::SCreate(Thread::Current()->zone(), | 16266 return OS::SCreate(Thread::Current()->zone(), |
17415 "TypeRef: %s<...>", type_cstr); | 16267 "TypeRef: %s<...>", type_cstr); |
17416 } | 16268 } |
17417 } | 16269 } |
17418 | 16270 |
17419 | 16271 |
17420 void TypeRef::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
17421 JSONObject jsobj(stream); | |
17422 PrintSharedInstanceJSON(&jsobj, ref); | |
17423 jsobj.AddProperty("kind", "TypeRef"); | |
17424 jsobj.AddServiceId(*this); | |
17425 const String& user_name = String::Handle(PrettyName()); | |
17426 const String& vm_name = String::Handle(Name()); | |
17427 AddNameProperties(&jsobj, user_name, vm_name); | |
17428 if (ref) { | |
17429 return; | |
17430 } | |
17431 jsobj.AddProperty("targetType", AbstractType::Handle(type())); | |
17432 } | |
17433 | |
17434 | |
17435 void TypeParameter::SetIsFinalized() const { | 16272 void TypeParameter::SetIsFinalized() const { |
17436 ASSERT(!IsFinalized()); | 16273 ASSERT(!IsFinalized()); |
17437 set_type_state(RawTypeParameter::kFinalizedUninstantiated); | 16274 set_type_state(RawTypeParameter::kFinalizedUninstantiated); |
17438 } | 16275 } |
17439 | 16276 |
17440 | 16277 |
17441 bool TypeParameter::IsEquivalent(const Instance& other, TrailPtr trail) const { | 16278 bool TypeParameter::IsEquivalent(const Instance& other, TrailPtr trail) const { |
17442 if (raw() == other.raw()) { | 16279 if (raw() == other.raw()) { |
17443 return true; | 16280 return true; |
17444 } | 16281 } |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17646 const AbstractType& upper_bound = AbstractType::Handle(bound()); | 16483 const AbstractType& upper_bound = AbstractType::Handle(bound()); |
17647 const char* bound_cstr = String::Handle(upper_bound.Name()).ToCString(); | 16484 const char* bound_cstr = String::Handle(upper_bound.Name()).ToCString(); |
17648 intptr_t len = OS::SNPrint( | 16485 intptr_t len = OS::SNPrint( |
17649 NULL, 0, format, name_cstr, index(), cls_cstr, bound_cstr) + 1; | 16486 NULL, 0, format, name_cstr, index(), cls_cstr, bound_cstr) + 1; |
17650 char* chars = Thread::Current()->zone()->Alloc<char>(len); | 16487 char* chars = Thread::Current()->zone()->Alloc<char>(len); |
17651 OS::SNPrint(chars, len, format, name_cstr, index(), cls_cstr, bound_cstr); | 16488 OS::SNPrint(chars, len, format, name_cstr, index(), cls_cstr, bound_cstr); |
17652 return chars; | 16489 return chars; |
17653 } | 16490 } |
17654 | 16491 |
17655 | 16492 |
17656 void TypeParameter::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
17657 JSONObject jsobj(stream); | |
17658 PrintSharedInstanceJSON(&jsobj, ref); | |
17659 jsobj.AddProperty("kind", "TypeParameter"); | |
17660 jsobj.AddServiceId(*this); | |
17661 const String& user_name = String::Handle(PrettyName()); | |
17662 const String& vm_name = String::Handle(Name()); | |
17663 AddNameProperties(&jsobj, user_name, vm_name); | |
17664 const Class& param_cls = Class::Handle(parameterized_class()); | |
17665 jsobj.AddProperty("parameterizedClass", param_cls); | |
17666 if (ref) { | |
17667 return; | |
17668 } | |
17669 jsobj.AddProperty("parameterIndex", index()); | |
17670 const AbstractType& upper_bound = AbstractType::Handle(bound()); | |
17671 jsobj.AddProperty("bound", upper_bound); | |
17672 } | |
17673 | |
17674 | |
17675 bool BoundedType::IsMalformed() const { | 16493 bool BoundedType::IsMalformed() const { |
17676 return AbstractType::Handle(type()).IsMalformed(); | 16494 return AbstractType::Handle(type()).IsMalformed(); |
17677 } | 16495 } |
17678 | 16496 |
17679 | 16497 |
17680 bool BoundedType::IsMalbounded() const { | 16498 bool BoundedType::IsMalbounded() const { |
17681 return AbstractType::Handle(type()).IsMalbounded(); | 16499 return AbstractType::Handle(type()).IsMalbounded(); |
17682 } | 16500 } |
17683 | 16501 |
17684 | 16502 |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17877 const char* cls_cstr = String::Handle(cls.Name()).ToCString(); | 16695 const char* cls_cstr = String::Handle(cls.Name()).ToCString(); |
17878 intptr_t len = OS::SNPrint( | 16696 intptr_t len = OS::SNPrint( |
17879 NULL, 0, format, type_cstr, bound_cstr, type_param_cstr, cls_cstr) + 1; | 16697 NULL, 0, format, type_cstr, bound_cstr, type_param_cstr, cls_cstr) + 1; |
17880 char* chars = Thread::Current()->zone()->Alloc<char>(len); | 16698 char* chars = Thread::Current()->zone()->Alloc<char>(len); |
17881 OS::SNPrint( | 16699 OS::SNPrint( |
17882 chars, len, format, type_cstr, bound_cstr, type_param_cstr, cls_cstr); | 16700 chars, len, format, type_cstr, bound_cstr, type_param_cstr, cls_cstr); |
17883 return chars; | 16701 return chars; |
17884 } | 16702 } |
17885 | 16703 |
17886 | 16704 |
17887 void BoundedType::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
17888 JSONObject jsobj(stream); | |
17889 PrintSharedInstanceJSON(&jsobj, ref); | |
17890 jsobj.AddProperty("kind", "BoundedType"); | |
17891 jsobj.AddServiceId(*this); | |
17892 const String& user_name = String::Handle(PrettyName()); | |
17893 const String& vm_name = String::Handle(Name()); | |
17894 AddNameProperties(&jsobj, user_name, vm_name); | |
17895 if (ref) { | |
17896 return; | |
17897 } | |
17898 jsobj.AddProperty("targetType", AbstractType::Handle(type())); | |
17899 jsobj.AddProperty("bound", AbstractType::Handle(bound())); | |
17900 } | |
17901 | |
17902 | |
17903 TokenPosition MixinAppType::token_pos() const { | 16705 TokenPosition MixinAppType::token_pos() const { |
17904 return AbstractType::Handle(MixinTypeAt(0)).token_pos(); | 16706 return AbstractType::Handle(MixinTypeAt(0)).token_pos(); |
17905 } | 16707 } |
17906 | 16708 |
17907 | 16709 |
17908 intptr_t MixinAppType::Depth() const { | 16710 intptr_t MixinAppType::Depth() const { |
17909 return Array::Handle(mixin_types()).Length(); | 16711 return Array::Handle(mixin_types()).Length(); |
17910 } | 16712 } |
17911 | 16713 |
17912 | 16714 |
17913 RawString* MixinAppType::Name() const { | 16715 RawString* MixinAppType::Name() const { |
17914 return String::New("MixinAppType"); | 16716 return String::New("MixinAppType"); |
17915 } | 16717 } |
17916 | 16718 |
17917 | 16719 |
17918 const char* MixinAppType::ToCString() const { | 16720 const char* MixinAppType::ToCString() const { |
17919 const char* format = "MixinAppType: super type: %s; first mixin type: %s"; | 16721 const char* format = "MixinAppType: super type: %s; first mixin type: %s"; |
17920 const char* super_type_cstr = String::Handle(AbstractType::Handle( | 16722 const char* super_type_cstr = String::Handle(AbstractType::Handle( |
17921 super_type()).Name()).ToCString(); | 16723 super_type()).Name()).ToCString(); |
17922 const char* first_mixin_type_cstr = String::Handle(AbstractType::Handle( | 16724 const char* first_mixin_type_cstr = String::Handle(AbstractType::Handle( |
17923 MixinTypeAt(0)).Name()).ToCString(); | 16725 MixinTypeAt(0)).Name()).ToCString(); |
17924 intptr_t len = OS::SNPrint( | 16726 intptr_t len = OS::SNPrint( |
17925 NULL, 0, format, super_type_cstr, first_mixin_type_cstr) + 1; | 16727 NULL, 0, format, super_type_cstr, first_mixin_type_cstr) + 1; |
17926 char* chars = Thread::Current()->zone()->Alloc<char>(len); | 16728 char* chars = Thread::Current()->zone()->Alloc<char>(len); |
17927 OS::SNPrint(chars, len, format, super_type_cstr, first_mixin_type_cstr); | 16729 OS::SNPrint(chars, len, format, super_type_cstr, first_mixin_type_cstr); |
17928 return chars; | 16730 return chars; |
17929 } | 16731 } |
17930 | 16732 |
17931 | 16733 |
17932 void MixinAppType::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
17933 UNREACHABLE(); | |
17934 } | |
17935 | |
17936 | |
17937 RawAbstractType* MixinAppType::MixinTypeAt(intptr_t depth) const { | 16734 RawAbstractType* MixinAppType::MixinTypeAt(intptr_t depth) const { |
17938 return AbstractType::RawCast(Array::Handle(mixin_types()).At(depth)); | 16735 return AbstractType::RawCast(Array::Handle(mixin_types()).At(depth)); |
17939 } | 16736 } |
17940 | 16737 |
17941 | 16738 |
17942 void MixinAppType::set_super_type(const AbstractType& value) const { | 16739 void MixinAppType::set_super_type(const AbstractType& value) const { |
17943 StorePointer(&raw_ptr()->super_type_, value.raw()); | 16740 StorePointer(&raw_ptr()->super_type_, value.raw()); |
17944 } | 16741 } |
17945 | 16742 |
17946 | 16743 |
(...skipping 21 matching lines...) Expand all Loading... |
17968 } | 16765 } |
17969 | 16766 |
17970 | 16767 |
17971 const char* Number::ToCString() const { | 16768 const char* Number::ToCString() const { |
17972 // Number is an interface. No instances of Number should exist. | 16769 // Number is an interface. No instances of Number should exist. |
17973 UNREACHABLE(); | 16770 UNREACHABLE(); |
17974 return "Number"; | 16771 return "Number"; |
17975 } | 16772 } |
17976 | 16773 |
17977 | 16774 |
17978 void Number::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
17979 UNREACHABLE(); | |
17980 } | |
17981 | |
17982 | |
17983 const char* Integer::ToCString() const { | 16775 const char* Integer::ToCString() const { |
17984 // Integer is an interface. No instances of Integer should exist except null. | 16776 // Integer is an interface. No instances of Integer should exist except null. |
17985 ASSERT(IsNull()); | 16777 ASSERT(IsNull()); |
17986 return "NULL Integer"; | 16778 return "NULL Integer"; |
17987 } | 16779 } |
17988 | 16780 |
17989 | 16781 |
17990 void Integer::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
17991 JSONObject jsobj(stream); | |
17992 PrintSharedInstanceJSON(&jsobj, ref); | |
17993 jsobj.AddProperty("kind", "Int"); | |
17994 jsobj.AddServiceId(*this); | |
17995 jsobj.AddProperty("valueAsString", ToCString()); | |
17996 } | |
17997 | |
17998 | |
17999 // Throw JavascriptIntegerOverflow exception. | 16782 // Throw JavascriptIntegerOverflow exception. |
18000 static void ThrowJavascriptIntegerOverflow(const Integer& i) { | 16783 static void ThrowJavascriptIntegerOverflow(const Integer& i) { |
18001 const Array& exc_args = Array::Handle(Array::New(1)); | 16784 const Array& exc_args = Array::Handle(Array::New(1)); |
18002 const String& i_str = String::Handle(String::New(i.ToCString())); | 16785 const String& i_str = String::Handle(String::New(i.ToCString())); |
18003 exc_args.SetAt(0, i_str); | 16786 exc_args.SetAt(0, i_str); |
18004 Exceptions::ThrowByType(Exceptions::kJavascriptIntegerOverflowError, | 16787 Exceptions::ThrowByType(Exceptions::kJavascriptIntegerOverflowError, |
18005 exc_args); | 16788 exc_args); |
18006 } | 16789 } |
18007 | 16790 |
18008 | 16791 |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18408 UNREACHABLE(); | 17191 UNREACHABLE(); |
18409 return 0; | 17192 return 0; |
18410 } | 17193 } |
18411 | 17194 |
18412 | 17195 |
18413 const char* Smi::ToCString() const { | 17196 const char* Smi::ToCString() const { |
18414 return OS::SCreate(Thread::Current()->zone(), "%" Pd "", Value()); | 17197 return OS::SCreate(Thread::Current()->zone(), "%" Pd "", Value()); |
18415 } | 17198 } |
18416 | 17199 |
18417 | 17200 |
18418 void Smi::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
18419 JSONObject jsobj(stream); | |
18420 PrintSharedInstanceJSON(&jsobj, ref); | |
18421 jsobj.AddProperty("kind", "Int"); | |
18422 jsobj.AddFixedServiceId("objects/int-%" Pd "", Value()); | |
18423 jsobj.AddPropertyF("valueAsString", "%" Pd "", Value()); | |
18424 } | |
18425 | |
18426 | |
18427 RawClass* Smi::Class() { | 17201 RawClass* Smi::Class() { |
18428 return Isolate::Current()->object_store()->smi_class(); | 17202 return Isolate::Current()->object_store()->smi_class(); |
18429 } | 17203 } |
18430 | 17204 |
18431 | 17205 |
18432 void Mint::set_value(int64_t value) const { | 17206 void Mint::set_value(int64_t value) const { |
18433 StoreNonPointer(&raw_ptr()->value_, value); | 17207 StoreNonPointer(&raw_ptr()->value_, value); |
18434 } | 17208 } |
18435 | 17209 |
18436 | 17210 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18534 } | 17308 } |
18535 return this->IsNegative() ? -1 : 1; | 17309 return this->IsNegative() ? -1 : 1; |
18536 } | 17310 } |
18537 | 17311 |
18538 | 17312 |
18539 const char* Mint::ToCString() const { | 17313 const char* Mint::ToCString() const { |
18540 return OS::SCreate(Thread::Current()->zone(), "%" Pd64 "", value()); | 17314 return OS::SCreate(Thread::Current()->zone(), "%" Pd64 "", value()); |
18541 } | 17315 } |
18542 | 17316 |
18543 | 17317 |
18544 void Mint::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
18545 Integer::PrintJSONImpl(stream, ref); | |
18546 } | |
18547 | |
18548 | |
18549 void Double::set_value(double value) const { | 17318 void Double::set_value(double value) const { |
18550 StoreNonPointer(&raw_ptr()->value_, value); | 17319 StoreNonPointer(&raw_ptr()->value_, value); |
18551 } | 17320 } |
18552 | 17321 |
18553 | 17322 |
18554 bool Double::BitwiseEqualsToDouble(double value) const { | 17323 bool Double::BitwiseEqualsToDouble(double value) const { |
18555 intptr_t value_offset = Double::value_offset(); | 17324 intptr_t value_offset = Double::value_offset(); |
18556 void* this_addr = reinterpret_cast<void*>( | 17325 void* this_addr = reinterpret_cast<void*>( |
18557 reinterpret_cast<uword>(this->raw_ptr()) + value_offset); | 17326 reinterpret_cast<uword>(this->raw_ptr()) + value_offset); |
18558 void* other_addr = reinterpret_cast<void*>(&value); | 17327 void* other_addr = reinterpret_cast<void*>(&value); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18666 return value() < 0 ? "-Infinity" : "Infinity"; | 17435 return value() < 0 ? "-Infinity" : "Infinity"; |
18667 } | 17436 } |
18668 const int kBufferSize = 128; | 17437 const int kBufferSize = 128; |
18669 char* buffer = Thread::Current()->zone()->Alloc<char>(kBufferSize); | 17438 char* buffer = Thread::Current()->zone()->Alloc<char>(kBufferSize); |
18670 buffer[kBufferSize - 1] = '\0'; | 17439 buffer[kBufferSize - 1] = '\0'; |
18671 DoubleToCString(value(), buffer, kBufferSize); | 17440 DoubleToCString(value(), buffer, kBufferSize); |
18672 return buffer; | 17441 return buffer; |
18673 } | 17442 } |
18674 | 17443 |
18675 | 17444 |
18676 void Double::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
18677 JSONObject jsobj(stream); | |
18678 PrintSharedInstanceJSON(&jsobj, ref); | |
18679 jsobj.AddProperty("kind", "Double"); | |
18680 jsobj.AddServiceId(*this); | |
18681 jsobj.AddProperty("valueAsString", ToCString()); | |
18682 } | |
18683 | |
18684 | |
18685 bool Bigint::Neg() const { | 17445 bool Bigint::Neg() const { |
18686 return Bool::Handle(neg()).value(); | 17446 return Bool::Handle(neg()).value(); |
18687 } | 17447 } |
18688 | 17448 |
18689 | 17449 |
18690 void Bigint::SetNeg(bool value) const { | 17450 void Bigint::SetNeg(bool value) const { |
18691 StorePointer(&raw_ptr()->neg_, Bool::Get(value).raw()); | 17451 StorePointer(&raw_ptr()->neg_, Bool::Get(value).raw()); |
18692 } | 17452 } |
18693 | 17453 |
18694 | 17454 |
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19422 Zone* zone = Thread::Current()->zone(); | 18182 Zone* zone = Thread::Current()->zone(); |
19423 return zone->AllocUnsafe(size); | 18183 return zone->AllocUnsafe(size); |
19424 } | 18184 } |
19425 | 18185 |
19426 | 18186 |
19427 const char* Bigint::ToCString() const { | 18187 const char* Bigint::ToCString() const { |
19428 return ToDecCString(&BigintAllocator); | 18188 return ToDecCString(&BigintAllocator); |
19429 } | 18189 } |
19430 | 18190 |
19431 | 18191 |
19432 void Bigint::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
19433 Integer::PrintJSONImpl(stream, ref); | |
19434 } | |
19435 | |
19436 | |
19437 // Synchronize with implementation in compiler (intrinsifier). | 18192 // Synchronize with implementation in compiler (intrinsifier). |
19438 class StringHasher : ValueObject { | 18193 class StringHasher : ValueObject { |
19439 public: | 18194 public: |
19440 StringHasher() : hash_(0) {} | 18195 StringHasher() : hash_(0) {} |
19441 void Add(int32_t ch) { | 18196 void Add(int32_t ch) { |
19442 hash_ = CombineHashes(hash_, ch); | 18197 hash_ = CombineHashes(hash_, ch); |
19443 } | 18198 } |
19444 void Add(const String& str, intptr_t begin_index, intptr_t len); | 18199 void Add(const String& str, intptr_t begin_index, intptr_t len); |
19445 | 18200 |
19446 // Return a non-zero hash of at most 'bits' bits. | 18201 // Return a non-zero hash of at most 'bits' bits. |
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20257 } | 19012 } |
20258 const intptr_t len = Utf8::Length(*this); | 19013 const intptr_t len = Utf8::Length(*this); |
20259 Zone* zone = Thread::Current()->zone(); | 19014 Zone* zone = Thread::Current()->zone(); |
20260 uint8_t* result = zone->Alloc<uint8_t>(len + 1); | 19015 uint8_t* result = zone->Alloc<uint8_t>(len + 1); |
20261 ToUTF8(result, len); | 19016 ToUTF8(result, len); |
20262 result[len] = 0; | 19017 result[len] = 0; |
20263 return reinterpret_cast<const char*>(result); | 19018 return reinterpret_cast<const char*>(result); |
20264 } | 19019 } |
20265 | 19020 |
20266 | 19021 |
20267 void String::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
20268 JSONObject jsobj(stream); | |
20269 if (raw() == Symbols::OptimizedOut().raw()) { | |
20270 // TODO(turnidge): This is a hack. The user could have this | |
20271 // special string in their program. Fixing this involves updating | |
20272 // the debugging api a bit. | |
20273 jsobj.AddProperty("type", "Sentinel"); | |
20274 jsobj.AddProperty("kind", "OptimizedOut"); | |
20275 jsobj.AddProperty("valueAsString", "<optimized out>"); | |
20276 return; | |
20277 } | |
20278 PrintSharedInstanceJSON(&jsobj, ref); | |
20279 jsobj.AddProperty("kind", "String"); | |
20280 jsobj.AddServiceId(*this); | |
20281 jsobj.AddProperty("length", Length()); | |
20282 if (ref) { | |
20283 // String refs always truncate to a fixed count; | |
20284 const intptr_t kFixedCount = 128; | |
20285 if (jsobj.AddPropertyStr("valueAsString", *this, 0, kFixedCount)) { | |
20286 jsobj.AddProperty("count", kFixedCount); | |
20287 jsobj.AddProperty("valueAsStringIsTruncated", true); | |
20288 } | |
20289 return; | |
20290 } | |
20291 | |
20292 intptr_t offset; | |
20293 intptr_t count; | |
20294 stream->ComputeOffsetAndCount(Length(), &offset, &count); | |
20295 if (offset > 0) { | |
20296 jsobj.AddProperty("offset", offset); | |
20297 } | |
20298 if (count < Length()) { | |
20299 jsobj.AddProperty("count", count); | |
20300 } | |
20301 jsobj.AddPropertyStr("valueAsString", *this, offset, count); | |
20302 } | |
20303 | |
20304 | |
20305 void String::ToUTF8(uint8_t* utf8_array, intptr_t array_len) const { | 19022 void String::ToUTF8(uint8_t* utf8_array, intptr_t array_len) const { |
20306 ASSERT(array_len >= Utf8::Length(*this)); | 19023 ASSERT(array_len >= Utf8::Length(*this)); |
20307 Utf8::Encode(*this, reinterpret_cast<char*>(utf8_array), array_len); | 19024 Utf8::Encode(*this, reinterpret_cast<char*>(utf8_array), array_len); |
20308 } | 19025 } |
20309 | 19026 |
20310 | 19027 |
20311 static FinalizablePersistentHandle* AddFinalizer( | 19028 static FinalizablePersistentHandle* AddFinalizer( |
20312 const Object& referent, | 19029 const Object& referent, |
20313 void* peer, | 19030 void* peer, |
20314 Dart_WeakPersistentHandleFinalizer callback) { | 19031 Dart_WeakPersistentHandleFinalizer callback) { |
(...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21184 result.SetCanonical(); | 19901 result.SetCanonical(); |
21185 return result.raw(); | 19902 return result.raw(); |
21186 } | 19903 } |
21187 | 19904 |
21188 | 19905 |
21189 const char* Bool::ToCString() const { | 19906 const char* Bool::ToCString() const { |
21190 return value() ? "true" : "false"; | 19907 return value() ? "true" : "false"; |
21191 } | 19908 } |
21192 | 19909 |
21193 | 19910 |
21194 void Bool::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
21195 const char* str = ToCString(); | |
21196 JSONObject jsobj(stream); | |
21197 PrintSharedInstanceJSON(&jsobj, ref); | |
21198 jsobj.AddProperty("kind", "Bool"); | |
21199 jsobj.AddFixedServiceId("objects/bool-%s", str); | |
21200 jsobj.AddPropertyF("valueAsString", "%s", str); | |
21201 } | |
21202 | |
21203 | |
21204 bool Array::CanonicalizeEquals(const Instance& other) const { | 19911 bool Array::CanonicalizeEquals(const Instance& other) const { |
21205 if (this->raw() == other.raw()) { | 19912 if (this->raw() == other.raw()) { |
21206 // Both handles point to the same raw instance. | 19913 // Both handles point to the same raw instance. |
21207 return true; | 19914 return true; |
21208 } | 19915 } |
21209 | 19916 |
21210 // An Array may be compared to an ImmutableArray. | 19917 // An Array may be compared to an ImmutableArray. |
21211 if (!other.IsArray() || other.IsNull()) { | 19918 if (!other.IsArray() || other.IsNull()) { |
21212 return false; | 19919 return false; |
21213 } | 19920 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21296 if (IsNull()) { | 20003 if (IsNull()) { |
21297 return IsImmutable() ? "_ImmutableList NULL" : "_List NULL"; | 20004 return IsImmutable() ? "_ImmutableList NULL" : "_List NULL"; |
21298 } | 20005 } |
21299 Zone* zone = Thread::Current()->zone(); | 20006 Zone* zone = Thread::Current()->zone(); |
21300 const char* format = IsImmutable() ? "_ImmutableList len:%" Pd | 20007 const char* format = IsImmutable() ? "_ImmutableList len:%" Pd |
21301 : "_List len:%" Pd; | 20008 : "_List len:%" Pd; |
21302 return zone->PrintToString(format, Length()); | 20009 return zone->PrintToString(format, Length()); |
21303 } | 20010 } |
21304 | 20011 |
21305 | 20012 |
21306 void Array::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
21307 JSONObject jsobj(stream); | |
21308 PrintSharedInstanceJSON(&jsobj, ref); | |
21309 jsobj.AddProperty("kind", "List"); | |
21310 jsobj.AddServiceId(*this); | |
21311 jsobj.AddProperty("length", Length()); | |
21312 if (ref) { | |
21313 return; | |
21314 } | |
21315 intptr_t offset; | |
21316 intptr_t count; | |
21317 stream->ComputeOffsetAndCount(Length(), &offset, &count); | |
21318 if (offset > 0) { | |
21319 jsobj.AddProperty("offset", offset); | |
21320 } | |
21321 if (count < Length()) { | |
21322 jsobj.AddProperty("count", count); | |
21323 } | |
21324 intptr_t limit = offset + count; | |
21325 ASSERT(limit <= Length()); | |
21326 { | |
21327 JSONArray jsarr(&jsobj, "elements"); | |
21328 Object& element = Object::Handle(); | |
21329 for (intptr_t index = offset; index < limit; index++) { | |
21330 element = At(index); | |
21331 jsarr.AddValue(element); | |
21332 } | |
21333 } | |
21334 } | |
21335 | |
21336 | |
21337 RawArray* Array::Grow(const Array& source, | 20013 RawArray* Array::Grow(const Array& source, |
21338 intptr_t new_length, | 20014 intptr_t new_length, |
21339 Heap::Space space) { | 20015 Heap::Space space) { |
21340 Zone* zone = Thread::Current()->zone(); | 20016 Zone* zone = Thread::Current()->zone(); |
21341 const Array& result = Array::Handle(zone, Array::New(new_length, space)); | 20017 const Array& result = Array::Handle(zone, Array::New(new_length, space)); |
21342 intptr_t len = 0; | 20018 intptr_t len = 0; |
21343 if (!source.IsNull()) { | 20019 if (!source.IsNull()) { |
21344 len = source.Length(); | 20020 len = source.Length(); |
21345 result.SetTypeArguments( | 20021 result.SetTypeArguments( |
21346 TypeArguments::Handle(zone, source.GetTypeArguments())); | 20022 TypeArguments::Handle(zone, source.GetTypeArguments())); |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21544 | 20220 |
21545 const char* GrowableObjectArray::ToCString() const { | 20221 const char* GrowableObjectArray::ToCString() const { |
21546 if (IsNull()) { | 20222 if (IsNull()) { |
21547 return "_GrowableList NULL"; | 20223 return "_GrowableList NULL"; |
21548 } | 20224 } |
21549 return OS::SCreate(Thread::Current()->zone(), | 20225 return OS::SCreate(Thread::Current()->zone(), |
21550 "Instance(length:%" Pd ") of '_GrowableList'", Length()); | 20226 "Instance(length:%" Pd ") of '_GrowableList'", Length()); |
21551 } | 20227 } |
21552 | 20228 |
21553 | 20229 |
21554 void GrowableObjectArray::PrintJSONImpl(JSONStream* stream, | |
21555 bool ref) const { | |
21556 JSONObject jsobj(stream); | |
21557 PrintSharedInstanceJSON(&jsobj, ref); | |
21558 jsobj.AddProperty("kind", "List"); | |
21559 jsobj.AddServiceId(*this); | |
21560 jsobj.AddProperty("length", Length()); | |
21561 if (ref) { | |
21562 return; | |
21563 } | |
21564 intptr_t offset; | |
21565 intptr_t count; | |
21566 stream->ComputeOffsetAndCount(Length(), &offset, &count); | |
21567 if (offset > 0) { | |
21568 jsobj.AddProperty("offset", offset); | |
21569 } | |
21570 if (count < Length()) { | |
21571 jsobj.AddProperty("count", count); | |
21572 } | |
21573 intptr_t limit = offset + count; | |
21574 ASSERT(limit <= Length()); | |
21575 { | |
21576 JSONArray jsarr(&jsobj, "elements"); | |
21577 Object& element = Object::Handle(); | |
21578 for (intptr_t index = offset; index < limit; index++) { | |
21579 element = At(index); | |
21580 jsarr.AddValue(element); | |
21581 } | |
21582 } | |
21583 } | |
21584 | |
21585 | |
21586 // Equivalent to Dart's operator "==" and hashCode. | 20230 // Equivalent to Dart's operator "==" and hashCode. |
21587 class DefaultHashTraits { | 20231 class DefaultHashTraits { |
21588 public: | 20232 public: |
21589 static bool IsMatch(const Object& a, const Object& b) { | 20233 static bool IsMatch(const Object& a, const Object& b) { |
21590 if (a.IsNull() || b.IsNull()) { | 20234 if (a.IsNull() || b.IsNull()) { |
21591 return (a.IsNull() && b.IsNull()); | 20235 return (a.IsNull() && b.IsNull()); |
21592 } else { | 20236 } else { |
21593 return Instance::Cast(a).OperatorEquals(Instance::Cast(b)); | 20237 return Instance::Cast(a).OperatorEquals(Instance::Cast(b)); |
21594 } | 20238 } |
21595 } | 20239 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21662 return result.raw(); | 20306 return result.raw(); |
21663 } | 20307 } |
21664 | 20308 |
21665 | 20309 |
21666 const char* LinkedHashMap::ToCString() const { | 20310 const char* LinkedHashMap::ToCString() const { |
21667 Zone* zone = Thread::Current()->zone(); | 20311 Zone* zone = Thread::Current()->zone(); |
21668 return zone->PrintToString("_LinkedHashMap len:%" Pd, Length()); | 20312 return zone->PrintToString("_LinkedHashMap len:%" Pd, Length()); |
21669 } | 20313 } |
21670 | 20314 |
21671 | 20315 |
21672 void LinkedHashMap::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
21673 JSONObject jsobj(stream); | |
21674 PrintSharedInstanceJSON(&jsobj, ref); | |
21675 jsobj.AddProperty("kind", "Map"); | |
21676 jsobj.AddServiceId(*this); | |
21677 jsobj.AddProperty("length", Length()); | |
21678 if (ref) { | |
21679 return; | |
21680 } | |
21681 intptr_t offset; | |
21682 intptr_t count; | |
21683 stream->ComputeOffsetAndCount(Length(), &offset, &count); | |
21684 if (offset > 0) { | |
21685 jsobj.AddProperty("offset", offset); | |
21686 } | |
21687 if (count < Length()) { | |
21688 jsobj.AddProperty("count", count); | |
21689 } | |
21690 intptr_t limit = offset + count; | |
21691 ASSERT(limit <= Length()); | |
21692 { | |
21693 JSONArray jsarr(&jsobj, "associations"); | |
21694 Object& object = Object::Handle(); | |
21695 LinkedHashMap::Iterator iterator(*this); | |
21696 int i = 0; | |
21697 while (iterator.MoveNext() && i < limit) { | |
21698 if (i >= offset) { | |
21699 JSONObject jsassoc(&jsarr); | |
21700 object = iterator.CurrentKey(); | |
21701 jsassoc.AddProperty("key", object); | |
21702 object = iterator.CurrentValue(); | |
21703 jsassoc.AddProperty("value", object); | |
21704 } | |
21705 i++; | |
21706 } | |
21707 } | |
21708 } | |
21709 | |
21710 | |
21711 RawFloat32x4* Float32x4::New(float v0, float v1, float v2, float v3, | 20316 RawFloat32x4* Float32x4::New(float v0, float v1, float v2, float v3, |
21712 Heap::Space space) { | 20317 Heap::Space space) { |
21713 ASSERT(Isolate::Current()->object_store()->float32x4_class() != | 20318 ASSERT(Isolate::Current()->object_store()->float32x4_class() != |
21714 Class::null()); | 20319 Class::null()); |
21715 Float32x4& result = Float32x4::Handle(); | 20320 Float32x4& result = Float32x4::Handle(); |
21716 { | 20321 { |
21717 RawObject* raw = Object::Allocate(Float32x4::kClassId, | 20322 RawObject* raw = Object::Allocate(Float32x4::kClassId, |
21718 Float32x4::InstanceSize(), | 20323 Float32x4::InstanceSize(), |
21719 space); | 20324 space); |
21720 NoSafepointScope no_safepoint; | 20325 NoSafepointScope no_safepoint; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21797 const char* Float32x4::ToCString() const { | 20402 const char* Float32x4::ToCString() const { |
21798 float _x = x(); | 20403 float _x = x(); |
21799 float _y = y(); | 20404 float _y = y(); |
21800 float _z = z(); | 20405 float _z = z(); |
21801 float _w = w(); | 20406 float _w = w(); |
21802 return OS::SCreate(Thread::Current()->zone(), | 20407 return OS::SCreate(Thread::Current()->zone(), |
21803 "[%f, %f, %f, %f]", _x, _y, _z, _w); | 20408 "[%f, %f, %f, %f]", _x, _y, _z, _w); |
21804 } | 20409 } |
21805 | 20410 |
21806 | 20411 |
21807 void Float32x4::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
21808 JSONObject jsobj(stream); | |
21809 PrintSharedInstanceJSON(&jsobj, ref); | |
21810 jsobj.AddProperty("kind", "Float32x4"); | |
21811 jsobj.AddServiceId(*this); | |
21812 jsobj.AddProperty("valueAsString", ToCString()); | |
21813 } | |
21814 | |
21815 | |
21816 RawInt32x4* Int32x4::New(int32_t v0, int32_t v1, int32_t v2, int32_t v3, | 20412 RawInt32x4* Int32x4::New(int32_t v0, int32_t v1, int32_t v2, int32_t v3, |
21817 Heap::Space space) { | 20413 Heap::Space space) { |
21818 ASSERT(Isolate::Current()->object_store()->int32x4_class() != | 20414 ASSERT(Isolate::Current()->object_store()->int32x4_class() != |
21819 Class::null()); | 20415 Class::null()); |
21820 Int32x4& result = Int32x4::Handle(); | 20416 Int32x4& result = Int32x4::Handle(); |
21821 { | 20417 { |
21822 RawObject* raw = Object::Allocate(Int32x4::kClassId, | 20418 RawObject* raw = Object::Allocate(Int32x4::kClassId, |
21823 Int32x4::InstanceSize(), | 20419 Int32x4::InstanceSize(), |
21824 space); | 20420 space); |
21825 NoSafepointScope no_safepoint; | 20421 NoSafepointScope no_safepoint; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21902 const char* Int32x4::ToCString() const { | 20498 const char* Int32x4::ToCString() const { |
21903 int32_t _x = x(); | 20499 int32_t _x = x(); |
21904 int32_t _y = y(); | 20500 int32_t _y = y(); |
21905 int32_t _z = z(); | 20501 int32_t _z = z(); |
21906 int32_t _w = w(); | 20502 int32_t _w = w(); |
21907 return OS::SCreate(Thread::Current()->zone(), | 20503 return OS::SCreate(Thread::Current()->zone(), |
21908 "[%08x, %08x, %08x, %08x]", _x, _y, _z, _w); | 20504 "[%08x, %08x, %08x, %08x]", _x, _y, _z, _w); |
21909 } | 20505 } |
21910 | 20506 |
21911 | 20507 |
21912 void Int32x4::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
21913 JSONObject jsobj(stream); | |
21914 PrintSharedInstanceJSON(&jsobj, ref); | |
21915 jsobj.AddProperty("kind", "Int32x4"); | |
21916 jsobj.AddServiceId(*this); | |
21917 jsobj.AddProperty("valueAsString", ToCString()); | |
21918 } | |
21919 | |
21920 | |
21921 RawFloat64x2* Float64x2::New(double value0, double value1, Heap::Space space) { | 20508 RawFloat64x2* Float64x2::New(double value0, double value1, Heap::Space space) { |
21922 ASSERT(Isolate::Current()->object_store()->float64x2_class() != | 20509 ASSERT(Isolate::Current()->object_store()->float64x2_class() != |
21923 Class::null()); | 20510 Class::null()); |
21924 Float64x2& result = Float64x2::Handle(); | 20511 Float64x2& result = Float64x2::Handle(); |
21925 { | 20512 { |
21926 RawObject* raw = Object::Allocate(Float64x2::kClassId, | 20513 RawObject* raw = Object::Allocate(Float64x2::kClassId, |
21927 Float64x2::InstanceSize(), | 20514 Float64x2::InstanceSize(), |
21928 space); | 20515 space); |
21929 NoSafepointScope no_safepoint; | 20516 NoSafepointScope no_safepoint; |
21930 result ^= raw; | 20517 result ^= raw; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21981 } | 20568 } |
21982 | 20569 |
21983 | 20570 |
21984 const char* Float64x2::ToCString() const { | 20571 const char* Float64x2::ToCString() const { |
21985 double _x = x(); | 20572 double _x = x(); |
21986 double _y = y(); | 20573 double _y = y(); |
21987 return OS::SCreate(Thread::Current()->zone(), "[%f, %f]", _x, _y); | 20574 return OS::SCreate(Thread::Current()->zone(), "[%f, %f]", _x, _y); |
21988 } | 20575 } |
21989 | 20576 |
21990 | 20577 |
21991 void Float64x2::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
21992 JSONObject jsobj(stream); | |
21993 PrintSharedInstanceJSON(&jsobj, ref); | |
21994 jsobj.AddProperty("kind", "Float64x2"); | |
21995 jsobj.AddServiceId(*this); | |
21996 jsobj.AddProperty("valueAsString", ToCString()); | |
21997 } | |
21998 | |
21999 | |
22000 const intptr_t TypedData::element_size_table[TypedData::kNumElementSizes] = { | 20578 const intptr_t TypedData::element_size_table[TypedData::kNumElementSizes] = { |
22001 1, // kTypedDataInt8ArrayCid. | 20579 1, // kTypedDataInt8ArrayCid. |
22002 1, // kTypedDataUint8ArrayCid. | 20580 1, // kTypedDataUint8ArrayCid. |
22003 1, // kTypedDataUint8ClampedArrayCid. | 20581 1, // kTypedDataUint8ClampedArrayCid. |
22004 2, // kTypedDataInt16ArrayCid. | 20582 2, // kTypedDataInt16ArrayCid. |
22005 2, // kTypedDataUint16ArrayCid. | 20583 2, // kTypedDataUint16ArrayCid. |
22006 4, // kTypedDataInt32ArrayCid. | 20584 4, // kTypedDataInt32ArrayCid. |
22007 4, // kTypedDataUint32ArrayCid. | 20585 4, // kTypedDataUint32ArrayCid. |
22008 8, // kTypedDataInt64ArrayCid. | 20586 8, // kTypedDataInt64ArrayCid. |
22009 8, // kTypedDataUint64ArrayCid. | 20587 8, // kTypedDataUint64ArrayCid. |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
22078 isolate->object_store()->set_empty_uint32_array(array); | 20656 isolate->object_store()->set_empty_uint32_array(array); |
22079 return array.raw(); | 20657 return array.raw(); |
22080 } | 20658 } |
22081 | 20659 |
22082 | 20660 |
22083 const char* TypedData::ToCString() const { | 20661 const char* TypedData::ToCString() const { |
22084 return "TypedData"; | 20662 return "TypedData"; |
22085 } | 20663 } |
22086 | 20664 |
22087 | 20665 |
22088 void TypedData::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
22089 JSONObject jsobj(stream); | |
22090 PrintSharedInstanceJSON(&jsobj, ref); | |
22091 const Class& cls = Class::Handle(clazz()); | |
22092 const String& kind = String::Handle(cls.UserVisibleName()); | |
22093 jsobj.AddProperty("kind", kind.ToCString()); | |
22094 jsobj.AddServiceId(*this); | |
22095 jsobj.AddProperty("length", Length()); | |
22096 if (ref) { | |
22097 return; | |
22098 } | |
22099 intptr_t offset; | |
22100 intptr_t count; | |
22101 stream->ComputeOffsetAndCount(Length(), &offset, &count); | |
22102 if (offset > 0) { | |
22103 jsobj.AddProperty("offset", offset); | |
22104 } | |
22105 if (count < Length()) { | |
22106 jsobj.AddProperty("count", count); | |
22107 } | |
22108 if (count == 0) { | |
22109 jsobj.AddProperty("bytes", ""); | |
22110 } else { | |
22111 NoSafepointScope no_safepoint; | |
22112 jsobj.AddPropertyBase64("bytes", | |
22113 reinterpret_cast<const uint8_t*>( | |
22114 DataAddr(offset * ElementSizeInBytes())), | |
22115 count * ElementSizeInBytes()); | |
22116 } | |
22117 } | |
22118 | |
22119 | |
22120 FinalizablePersistentHandle* ExternalTypedData::AddFinalizer( | 20666 FinalizablePersistentHandle* ExternalTypedData::AddFinalizer( |
22121 void* peer, Dart_WeakPersistentHandleFinalizer callback) const { | 20667 void* peer, Dart_WeakPersistentHandleFinalizer callback) const { |
22122 return dart::AddFinalizer(*this, peer, callback); | 20668 return dart::AddFinalizer(*this, peer, callback); |
22123 } | 20669 } |
22124 | 20670 |
22125 | 20671 |
22126 RawExternalTypedData* ExternalTypedData::New(intptr_t class_id, | 20672 RawExternalTypedData* ExternalTypedData::New(intptr_t class_id, |
22127 uint8_t* data, | 20673 uint8_t* data, |
22128 intptr_t len, | 20674 intptr_t len, |
22129 Heap::Space space) { | 20675 Heap::Space space) { |
22130 ExternalTypedData& result = ExternalTypedData::Handle(); | 20676 ExternalTypedData& result = ExternalTypedData::Handle(); |
22131 { | 20677 { |
22132 RawObject* raw = Object::Allocate(class_id, | 20678 RawObject* raw = Object::Allocate(class_id, |
22133 ExternalTypedData::InstanceSize(), | 20679 ExternalTypedData::InstanceSize(), |
22134 space); | 20680 space); |
22135 NoSafepointScope no_safepoint; | 20681 NoSafepointScope no_safepoint; |
22136 result ^= raw; | 20682 result ^= raw; |
22137 result.SetLength(len); | 20683 result.SetLength(len); |
22138 result.SetData(data); | 20684 result.SetData(data); |
22139 } | 20685 } |
22140 return result.raw(); | 20686 return result.raw(); |
22141 } | 20687 } |
22142 | 20688 |
22143 | 20689 |
22144 const char* ExternalTypedData::ToCString() const { | 20690 const char* ExternalTypedData::ToCString() const { |
22145 return "ExternalTypedData"; | 20691 return "ExternalTypedData"; |
22146 } | 20692 } |
22147 | 20693 |
22148 | 20694 |
22149 void ExternalTypedData::PrintJSONImpl(JSONStream* stream, | |
22150 bool ref) const { | |
22151 JSONObject jsobj(stream); | |
22152 PrintSharedInstanceJSON(&jsobj, ref); | |
22153 const Class& cls = Class::Handle(clazz()); | |
22154 const String& kind = String::Handle(cls.UserVisibleName()); | |
22155 jsobj.AddProperty("kind", kind.ToCString()); | |
22156 jsobj.AddServiceId(*this); | |
22157 jsobj.AddProperty("length", Length()); | |
22158 if (ref) { | |
22159 return; | |
22160 } | |
22161 intptr_t offset; | |
22162 intptr_t count; | |
22163 stream->ComputeOffsetAndCount(Length(), &offset, &count); | |
22164 if (offset > 0) { | |
22165 jsobj.AddProperty("offset", offset); | |
22166 } | |
22167 if (count < Length()) { | |
22168 jsobj.AddProperty("count", count); | |
22169 } | |
22170 if (count == 0) { | |
22171 jsobj.AddProperty("bytes", ""); | |
22172 } else { | |
22173 NoSafepointScope no_safepoint; | |
22174 jsobj.AddPropertyBase64("bytes", | |
22175 reinterpret_cast<const uint8_t*>( | |
22176 DataAddr(offset * ElementSizeInBytes())), | |
22177 count * ElementSizeInBytes()); | |
22178 } | |
22179 } | |
22180 | |
22181 | |
22182 RawCapability* Capability::New(uint64_t id, Heap::Space space) { | 20695 RawCapability* Capability::New(uint64_t id, Heap::Space space) { |
22183 Capability& result = Capability::Handle(); | 20696 Capability& result = Capability::Handle(); |
22184 { | 20697 { |
22185 RawObject* raw = Object::Allocate(Capability::kClassId, | 20698 RawObject* raw = Object::Allocate(Capability::kClassId, |
22186 Capability::InstanceSize(), | 20699 Capability::InstanceSize(), |
22187 space); | 20700 space); |
22188 NoSafepointScope no_safepoint; | 20701 NoSafepointScope no_safepoint; |
22189 result ^= raw; | 20702 result ^= raw; |
22190 result.StoreNonPointer(&result.raw_ptr()->id_, id); | 20703 result.StoreNonPointer(&result.raw_ptr()->id_, id); |
22191 } | 20704 } |
22192 return result.raw(); | 20705 return result.raw(); |
22193 } | 20706 } |
22194 | 20707 |
22195 | 20708 |
22196 const char* Capability::ToCString() const { | 20709 const char* Capability::ToCString() const { |
22197 return "Capability"; | 20710 return "Capability"; |
22198 } | 20711 } |
22199 | 20712 |
22200 | 20713 |
22201 void Capability::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
22202 Instance::PrintJSONImpl(stream, ref); | |
22203 } | |
22204 | |
22205 | |
22206 RawReceivePort* ReceivePort::New(Dart_Port id, | 20714 RawReceivePort* ReceivePort::New(Dart_Port id, |
22207 bool is_control_port, | 20715 bool is_control_port, |
22208 Heap::Space space) { | 20716 Heap::Space space) { |
22209 ASSERT(id != ILLEGAL_PORT); | 20717 ASSERT(id != ILLEGAL_PORT); |
22210 Thread* thread = Thread::Current(); | 20718 Thread* thread = Thread::Current(); |
22211 Zone* zone = thread->zone(); | 20719 Zone* zone = thread->zone(); |
22212 const SendPort& send_port = | 20720 const SendPort& send_port = |
22213 SendPort::Handle(zone, SendPort::New(id, thread->isolate()->origin_id())); | 20721 SendPort::Handle(zone, SendPort::New(id, thread->isolate()->origin_id())); |
22214 | 20722 |
22215 ReceivePort& result = ReceivePort::Handle(zone); | 20723 ReceivePort& result = ReceivePort::Handle(zone); |
(...skipping 12 matching lines...) Expand all Loading... |
22228 } | 20736 } |
22229 return result.raw(); | 20737 return result.raw(); |
22230 } | 20738 } |
22231 | 20739 |
22232 | 20740 |
22233 const char* ReceivePort::ToCString() const { | 20741 const char* ReceivePort::ToCString() const { |
22234 return "ReceivePort"; | 20742 return "ReceivePort"; |
22235 } | 20743 } |
22236 | 20744 |
22237 | 20745 |
22238 void ReceivePort::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
22239 Instance::PrintJSONImpl(stream, ref); | |
22240 } | |
22241 | |
22242 | |
22243 RawSendPort* SendPort::New(Dart_Port id, Heap::Space space) { | 20746 RawSendPort* SendPort::New(Dart_Port id, Heap::Space space) { |
22244 return New(id, Isolate::Current()->origin_id(), space); | 20747 return New(id, Isolate::Current()->origin_id(), space); |
22245 } | 20748 } |
22246 | 20749 |
22247 | 20750 |
22248 RawSendPort* SendPort::New(Dart_Port id, | 20751 RawSendPort* SendPort::New(Dart_Port id, |
22249 Dart_Port origin_id, | 20752 Dart_Port origin_id, |
22250 Heap::Space space) { | 20753 Heap::Space space) { |
22251 ASSERT(id != ILLEGAL_PORT); | 20754 ASSERT(id != ILLEGAL_PORT); |
22252 SendPort& result = SendPort::Handle(); | 20755 SendPort& result = SendPort::Handle(); |
22253 { | 20756 { |
22254 RawObject* raw = Object::Allocate(SendPort::kClassId, | 20757 RawObject* raw = Object::Allocate(SendPort::kClassId, |
22255 SendPort::InstanceSize(), | 20758 SendPort::InstanceSize(), |
22256 space); | 20759 space); |
22257 NoSafepointScope no_safepoint; | 20760 NoSafepointScope no_safepoint; |
22258 result ^= raw; | 20761 result ^= raw; |
22259 result.StoreNonPointer(&result.raw_ptr()->id_, id); | 20762 result.StoreNonPointer(&result.raw_ptr()->id_, id); |
22260 result.StoreNonPointer(&result.raw_ptr()->origin_id_, origin_id); | 20763 result.StoreNonPointer(&result.raw_ptr()->origin_id_, origin_id); |
22261 } | 20764 } |
22262 return result.raw(); | 20765 return result.raw(); |
22263 } | 20766 } |
22264 | 20767 |
22265 | 20768 |
22266 const char* SendPort::ToCString() const { | 20769 const char* SendPort::ToCString() const { |
22267 return "SendPort"; | 20770 return "SendPort"; |
22268 } | 20771 } |
22269 | 20772 |
22270 | 20773 |
22271 void SendPort::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
22272 Instance::PrintJSONImpl(stream, ref); | |
22273 } | |
22274 | |
22275 | |
22276 const char* Closure::ToCString() const { | 20774 const char* Closure::ToCString() const { |
22277 const Function& fun = Function::Handle(function()); | 20775 const Function& fun = Function::Handle(function()); |
22278 const bool is_implicit_closure = fun.IsImplicitClosureFunction(); | 20776 const bool is_implicit_closure = fun.IsImplicitClosureFunction(); |
22279 const char* fun_sig = String::Handle(fun.UserVisibleSignature()).ToCString(); | 20777 const char* fun_sig = String::Handle(fun.UserVisibleSignature()).ToCString(); |
22280 const char* from = is_implicit_closure ? " from " : ""; | 20778 const char* from = is_implicit_closure ? " from " : ""; |
22281 const char* fun_desc = is_implicit_closure ? fun.ToCString() : ""; | 20779 const char* fun_desc = is_implicit_closure ? fun.ToCString() : ""; |
22282 return OS::SCreate(Thread::Current()->zone(), | 20780 return OS::SCreate(Thread::Current()->zone(), |
22283 "Closure: %s%s%s", fun_sig, from, fun_desc); | 20781 "Closure: %s%s%s", fun_sig, from, fun_desc); |
22284 } | 20782 } |
22285 | 20783 |
22286 | 20784 |
22287 void Closure::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
22288 Instance::PrintJSONImpl(stream, ref); | |
22289 } | |
22290 | |
22291 | |
22292 RawClosure* Closure::New(const Function& function, | 20785 RawClosure* Closure::New(const Function& function, |
22293 const Context& context, | 20786 const Context& context, |
22294 Heap::Space space) { | 20787 Heap::Space space) { |
22295 Closure& result = Closure::Handle(); | 20788 Closure& result = Closure::Handle(); |
22296 { | 20789 { |
22297 RawObject* raw = Object::Allocate(Closure::kClassId, | 20790 RawObject* raw = Object::Allocate(Closure::kClassId, |
22298 Closure::InstanceSize(), | 20791 Closure::InstanceSize(), |
22299 space); | 20792 space); |
22300 NoSafepointScope no_safepoint; | 20793 NoSafepointScope no_safepoint; |
22301 result ^= raw; | 20794 result ^= raw; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
22389 return result.raw(); | 20882 return result.raw(); |
22390 } | 20883 } |
22391 | 20884 |
22392 | 20885 |
22393 const char* Stacktrace::ToCString() const { | 20886 const char* Stacktrace::ToCString() const { |
22394 intptr_t idx = 0; | 20887 intptr_t idx = 0; |
22395 return ToCStringInternal(&idx); | 20888 return ToCStringInternal(&idx); |
22396 } | 20889 } |
22397 | 20890 |
22398 | 20891 |
22399 void Stacktrace::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
22400 JSONObject jsobj(stream); | |
22401 PrintSharedInstanceJSON(&jsobj, ref); | |
22402 jsobj.AddProperty("kind", "StackTrace"); | |
22403 jsobj.AddServiceId(*this); | |
22404 intptr_t idx = 0; | |
22405 jsobj.AddProperty("valueAsString", ToCStringInternal(&idx)); | |
22406 } | |
22407 | |
22408 | |
22409 static intptr_t PrintOneStacktrace(Zone* zone, | 20892 static intptr_t PrintOneStacktrace(Zone* zone, |
22410 GrowableArray<char*>* frame_strings, | 20893 GrowableArray<char*>* frame_strings, |
22411 uword pc, | 20894 uword pc, |
22412 const Function& function, | 20895 const Function& function, |
22413 const Code& code, | 20896 const Code& code, |
22414 intptr_t frame_index) { | 20897 intptr_t frame_index) { |
22415 const TokenPosition token_pos = code.GetTokenIndexOfPC(pc); | 20898 const TokenPosition token_pos = code.GetTokenIndexOfPC(pc); |
22416 const Script& script = Script::Handle(zone, function.script()); | 20899 const Script& script = Script::Handle(zone, function.script()); |
22417 const String& function_name = | 20900 const String& function_name = |
22418 String::Handle(zone, function.QualifiedUserVisibleName()); | 20901 String::Handle(zone, function.QualifiedUserVisibleName()); |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
22648 } | 21131 } |
22649 | 21132 |
22650 | 21133 |
22651 const char* JSRegExp::ToCString() const { | 21134 const char* JSRegExp::ToCString() const { |
22652 const String& str = String::Handle(pattern()); | 21135 const String& str = String::Handle(pattern()); |
22653 return OS::SCreate(Thread::Current()->zone(), | 21136 return OS::SCreate(Thread::Current()->zone(), |
22654 "JSRegExp: pattern=%s flags=%s", str.ToCString(), Flags()); | 21137 "JSRegExp: pattern=%s flags=%s", str.ToCString(), Flags()); |
22655 } | 21138 } |
22656 | 21139 |
22657 | 21140 |
22658 void JSRegExp::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
22659 JSONObject jsobj(stream); | |
22660 PrintSharedInstanceJSON(&jsobj, ref); | |
22661 jsobj.AddProperty("kind", "RegExp"); | |
22662 jsobj.AddServiceId(*this); | |
22663 | |
22664 jsobj.AddProperty("pattern", String::Handle(pattern())); | |
22665 | |
22666 if (ref) { | |
22667 return; | |
22668 } | |
22669 | |
22670 jsobj.AddProperty("isCaseSensitive", !is_ignore_case()); | |
22671 jsobj.AddProperty("isMultiLine", is_multi_line()); | |
22672 | |
22673 Function& func = Function::Handle(); | |
22674 func = function(kOneByteStringCid); | |
22675 jsobj.AddProperty("_oneByteFunction", func); | |
22676 func = function(kTwoByteStringCid); | |
22677 jsobj.AddProperty("_twoByteFunction", func); | |
22678 func = function(kExternalOneByteStringCid); | |
22679 jsobj.AddProperty("_externalOneByteFunction", func); | |
22680 func = function(kExternalTwoByteStringCid); | |
22681 jsobj.AddProperty("_externalTwoByteFunction", func); | |
22682 } | |
22683 | |
22684 | |
22685 RawWeakProperty* WeakProperty::New(Heap::Space space) { | 21141 RawWeakProperty* WeakProperty::New(Heap::Space space) { |
22686 ASSERT(Isolate::Current()->object_store()->weak_property_class() | 21142 ASSERT(Isolate::Current()->object_store()->weak_property_class() |
22687 != Class::null()); | 21143 != Class::null()); |
22688 RawObject* raw = Object::Allocate(WeakProperty::kClassId, | 21144 RawObject* raw = Object::Allocate(WeakProperty::kClassId, |
22689 WeakProperty::InstanceSize(), | 21145 WeakProperty::InstanceSize(), |
22690 space); | 21146 space); |
22691 return reinterpret_cast<RawWeakProperty*>(raw); | 21147 return reinterpret_cast<RawWeakProperty*>(raw); |
22692 } | 21148 } |
22693 | 21149 |
22694 | 21150 |
22695 const char* WeakProperty::ToCString() const { | 21151 const char* WeakProperty::ToCString() const { |
22696 return "_WeakProperty"; | 21152 return "_WeakProperty"; |
22697 } | 21153 } |
22698 | 21154 |
22699 | 21155 |
22700 void WeakProperty::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
22701 JSONObject jsobj(stream); | |
22702 PrintSharedInstanceJSON(&jsobj, ref); | |
22703 jsobj.AddProperty("kind", "WeakProperty"); | |
22704 jsobj.AddServiceId(*this); | |
22705 if (ref) { | |
22706 return; | |
22707 } | |
22708 | |
22709 const Object& key_handle = Object::Handle(key()); | |
22710 jsobj.AddProperty("propertyKey", key_handle); | |
22711 const Object& value_handle = Object::Handle(value()); | |
22712 jsobj.AddProperty("propertyValue", value_handle); | |
22713 } | |
22714 | |
22715 RawAbstractType* MirrorReference::GetAbstractTypeReferent() const { | 21156 RawAbstractType* MirrorReference::GetAbstractTypeReferent() const { |
22716 ASSERT(Object::Handle(referent()).IsAbstractType()); | 21157 ASSERT(Object::Handle(referent()).IsAbstractType()); |
22717 return AbstractType::Cast(Object::Handle(referent())).raw(); | 21158 return AbstractType::Cast(Object::Handle(referent())).raw(); |
22718 } | 21159 } |
22719 | 21160 |
22720 | 21161 |
22721 RawClass* MirrorReference::GetClassReferent() const { | 21162 RawClass* MirrorReference::GetClassReferent() const { |
22722 ASSERT(Object::Handle(referent()).IsClass()); | 21163 ASSERT(Object::Handle(referent()).IsClass()); |
22723 return Class::Cast(Object::Handle(referent())).raw(); | 21164 return Class::Cast(Object::Handle(referent())).raw(); |
22724 } | 21165 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
22761 result.set_referent(referent); | 21202 result.set_referent(referent); |
22762 return result.raw(); | 21203 return result.raw(); |
22763 } | 21204 } |
22764 | 21205 |
22765 | 21206 |
22766 const char* MirrorReference::ToCString() const { | 21207 const char* MirrorReference::ToCString() const { |
22767 return "_MirrorReference"; | 21208 return "_MirrorReference"; |
22768 } | 21209 } |
22769 | 21210 |
22770 | 21211 |
22771 void MirrorReference::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
22772 JSONObject jsobj(stream); | |
22773 PrintSharedInstanceJSON(&jsobj, ref); | |
22774 jsobj.AddProperty("kind", "MirrorReference"); | |
22775 jsobj.AddServiceId(*this); | |
22776 | |
22777 if (ref) { | |
22778 return; | |
22779 } | |
22780 | |
22781 const Object& referent_handle = Object::Handle(referent()); | |
22782 jsobj.AddProperty("mirrorReferent", referent_handle); | |
22783 } | |
22784 | |
22785 | |
22786 void UserTag::MakeActive() const { | 21212 void UserTag::MakeActive() const { |
22787 Isolate* isolate = Isolate::Current(); | 21213 Isolate* isolate = Isolate::Current(); |
22788 ASSERT(isolate != NULL); | 21214 ASSERT(isolate != NULL); |
22789 isolate->set_current_tag(*this); | 21215 isolate->set_current_tag(*this); |
22790 } | 21216 } |
22791 | 21217 |
22792 | 21218 |
22793 RawUserTag* UserTag::New(const String& label, Heap::Space space) { | 21219 RawUserTag* UserTag::New(const String& label, Heap::Space space) { |
22794 Thread* thread = Thread::Current(); | 21220 Thread* thread = Thread::Current(); |
22795 Isolate* isolate = thread->isolate(); | 21221 Isolate* isolate = thread->isolate(); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
22913 } | 21339 } |
22914 return UserTag::null(); | 21340 return UserTag::null(); |
22915 } | 21341 } |
22916 | 21342 |
22917 | 21343 |
22918 const char* UserTag::ToCString() const { | 21344 const char* UserTag::ToCString() const { |
22919 const String& tag_label = String::Handle(label()); | 21345 const String& tag_label = String::Handle(label()); |
22920 return tag_label.ToCString(); | 21346 return tag_label.ToCString(); |
22921 } | 21347 } |
22922 | 21348 |
22923 | |
22924 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
22925 Instance::PrintJSONImpl(stream, ref); | |
22926 } | |
22927 | |
22928 | |
22929 } // namespace dart | 21349 } // namespace dart |
OLD | NEW |