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 1735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1746 Exceptions::Throw(thread, exception); | 1746 Exceptions::Throw(thread, exception); |
1747 UNREACHABLE(); | 1747 UNREACHABLE(); |
1748 } | 1748 } |
1749 ClassTable* class_table = isolate->class_table(); | 1749 ClassTable* class_table = isolate->class_table(); |
1750 if (space == Heap::kNew) { | 1750 if (space == Heap::kNew) { |
1751 class_table->UpdateAllocatedNew(cls_id, size); | 1751 class_table->UpdateAllocatedNew(cls_id, size); |
1752 } else { | 1752 } else { |
1753 class_table->UpdateAllocatedOld(cls_id, size); | 1753 class_table->UpdateAllocatedOld(cls_id, size); |
1754 } | 1754 } |
1755 const Class& cls = Class::Handle(class_table->At(cls_id)); | 1755 const Class& cls = Class::Handle(class_table->At(cls_id)); |
1756 if (cls.trace_allocation()) { | 1756 if (cls.TraceAllocation(isolate)) { |
1757 Profiler::RecordAllocation(isolate, cls_id); | 1757 Profiler::RecordAllocation(isolate, cls_id); |
1758 } | 1758 } |
1759 NoSafepointScope no_safepoint; | 1759 NoSafepointScope no_safepoint; |
1760 InitializeObject(address, cls_id, size, (isolate == Dart::vm_isolate())); | 1760 InitializeObject(address, cls_id, size, (isolate == Dart::vm_isolate())); |
1761 RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag); | 1761 RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag); |
1762 ASSERT(cls_id == RawObject::ClassIdTag::decode(raw_obj->ptr()->tags_)); | 1762 ASSERT(cls_id == RawObject::ClassIdTag::decode(raw_obj->ptr()->tags_)); |
1763 return raw_obj; | 1763 return raw_obj; |
1764 } | 1764 } |
1765 | 1765 |
1766 | 1766 |
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2748 a.Register(code); | 2748 a.Register(code); |
2749 } | 2749 } |
2750 | 2750 |
2751 | 2751 |
2752 void Class::DisableCHAOptimizedCode() { | 2752 void Class::DisableCHAOptimizedCode() { |
2753 CHACodeArray a(*this); | 2753 CHACodeArray a(*this); |
2754 a.DisableCode(); | 2754 a.DisableCode(); |
2755 } | 2755 } |
2756 | 2756 |
2757 | 2757 |
| 2758 bool Class::TraceAllocation(Isolate* isolate) const { |
| 2759 ClassTable* class_table = isolate->class_table(); |
| 2760 return class_table->TraceAllocationFor(id()); |
| 2761 } |
| 2762 |
| 2763 |
2758 void Class::SetTraceAllocation(bool trace_allocation) const { | 2764 void Class::SetTraceAllocation(bool trace_allocation) const { |
2759 const bool changed = trace_allocation != this->trace_allocation(); | 2765 Isolate* isolate = Isolate::Current(); |
| 2766 const bool changed = trace_allocation != this->TraceAllocation(isolate); |
2760 if (changed) { | 2767 if (changed) { |
2761 set_state_bits( | |
2762 TraceAllocationBit::update(trace_allocation, raw_ptr()->state_bits_)); | |
2763 Isolate* isolate = Isolate::Current(); | |
2764 ClassTable* class_table = isolate->class_table(); | 2768 ClassTable* class_table = isolate->class_table(); |
2765 class_table->TraceAllocationsFor(id(), trace_allocation); | 2769 class_table->SetTraceAllocationFor(id(), trace_allocation); |
2766 DisableAllocationStub(); | 2770 DisableAllocationStub(); |
2767 } | 2771 } |
2768 } | 2772 } |
2769 | 2773 |
2770 | 2774 |
2771 void Class::set_cha_codes(const Array& cache) const { | 2775 void Class::set_cha_codes(const Array& cache) const { |
2772 StorePointer(&raw_ptr()->cha_codes_, cache.raw()); | 2776 StorePointer(&raw_ptr()->cha_codes_, cache.raw()); |
2773 } | 2777 } |
2774 | 2778 |
2775 | 2779 |
(...skipping 1424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4200 const char* library_name = lib.IsNull() ? "" : lib.ToCString(); | 4204 const char* library_name = lib.IsNull() ? "" : lib.ToCString(); |
4201 const char* class_name = String::Handle(Name()).ToCString(); | 4205 const char* class_name = String::Handle(Name()).ToCString(); |
4202 intptr_t len = OS::SNPrint(NULL, 0, format, library_name, class_name) + 1; | 4206 intptr_t len = OS::SNPrint(NULL, 0, format, library_name, class_name) + 1; |
4203 char* chars = Thread::Current()->zone()->Alloc<char>(len); | 4207 char* chars = Thread::Current()->zone()->Alloc<char>(len); |
4204 OS::SNPrint(chars, len, format, library_name, class_name); | 4208 OS::SNPrint(chars, len, format, library_name, class_name); |
4205 return chars; | 4209 return chars; |
4206 } | 4210 } |
4207 | 4211 |
4208 | 4212 |
4209 void Class::PrintJSONImpl(JSONStream* stream, bool ref) const { | 4213 void Class::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 4214 Isolate* isolate = Isolate::Current(); |
4210 JSONObject jsobj(stream); | 4215 JSONObject jsobj(stream); |
4211 if ((raw() == Class::null()) || (id() == kFreeListElement)) { | 4216 if ((raw() == Class::null()) || (id() == kFreeListElement)) { |
4212 // TODO(turnidge): This is weird and needs to be changed. | 4217 // TODO(turnidge): This is weird and needs to be changed. |
4213 jsobj.AddProperty("type", "null"); | 4218 jsobj.AddProperty("type", "null"); |
4214 return; | 4219 return; |
4215 } | 4220 } |
4216 AddCommonObjectProperties(&jsobj, "Class", ref); | 4221 AddCommonObjectProperties(&jsobj, "Class", ref); |
4217 jsobj.AddFixedServiceId("classes/%" Pd "", id()); | 4222 jsobj.AddFixedServiceId("classes/%" Pd "", id()); |
4218 const String& user_name = String::Handle(PrettyName()); | 4223 const String& user_name = String::Handle(PrettyName()); |
4219 const String& vm_name = String::Handle(Name()); | 4224 const String& vm_name = String::Handle(Name()); |
4220 AddNameProperties(&jsobj, user_name, vm_name); | 4225 AddNameProperties(&jsobj, user_name, vm_name); |
4221 if (ref) { | 4226 if (ref) { |
4222 return; | 4227 return; |
4223 } | 4228 } |
4224 | 4229 |
4225 const Error& err = Error::Handle(EnsureIsFinalized(Isolate::Current())); | 4230 const Error& err = Error::Handle(EnsureIsFinalized(Isolate::Current())); |
4226 if (!err.IsNull()) { | 4231 if (!err.IsNull()) { |
4227 jsobj.AddProperty("error", err); | 4232 jsobj.AddProperty("error", err); |
4228 } | 4233 } |
4229 jsobj.AddProperty("abstract", is_abstract()); | 4234 jsobj.AddProperty("abstract", is_abstract()); |
4230 jsobj.AddProperty("const", is_const()); | 4235 jsobj.AddProperty("const", is_const()); |
4231 jsobj.AddProperty("_finalized", is_finalized()); | 4236 jsobj.AddProperty("_finalized", is_finalized()); |
4232 jsobj.AddProperty("_implemented", is_implemented()); | 4237 jsobj.AddProperty("_implemented", is_implemented()); |
4233 jsobj.AddProperty("_patch", is_patch()); | 4238 jsobj.AddProperty("_patch", is_patch()); |
4234 jsobj.AddProperty("_traceAllocations", trace_allocation()); | 4239 jsobj.AddProperty("_traceAllocations", TraceAllocation(isolate)); |
4235 const Class& superClass = Class::Handle(SuperClass()); | 4240 const Class& superClass = Class::Handle(SuperClass()); |
4236 if (!superClass.IsNull()) { | 4241 if (!superClass.IsNull()) { |
4237 jsobj.AddProperty("super", superClass); | 4242 jsobj.AddProperty("super", superClass); |
4238 } | 4243 } |
4239 jsobj.AddProperty("library", Object::Handle(library())); | 4244 jsobj.AddProperty("library", Object::Handle(library())); |
4240 const Script& script = Script::Handle(this->script()); | 4245 const Script& script = Script::Handle(this->script()); |
4241 if (!script.IsNull()) { | 4246 if (!script.IsNull()) { |
4242 jsobj.AddLocation(script, token_pos(), ComputeEndTokenPos()); | 4247 jsobj.AddLocation(script, token_pos(), ComputeEndTokenPos()); |
4243 } | 4248 } |
4244 { | 4249 { |
(...skipping 17126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21371 return tag_label.ToCString(); | 21376 return tag_label.ToCString(); |
21372 } | 21377 } |
21373 | 21378 |
21374 | 21379 |
21375 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 21380 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
21376 Instance::PrintJSONImpl(stream, ref); | 21381 Instance::PrintJSONImpl(stream, ref); |
21377 } | 21382 } |
21378 | 21383 |
21379 | 21384 |
21380 } // namespace dart | 21385 } // namespace dart |
OLD | NEW |