| 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/become.h" | 10 #include "vm/become.h" |
| (...skipping 1827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1838 | 1838 |
| 1839 uword address = heap->Allocate(size, space); | 1839 uword address = heap->Allocate(size, space); |
| 1840 if (address == 0) { | 1840 if (address == 0) { |
| 1841 // Use the preallocated out of memory exception to avoid calling | 1841 // Use the preallocated out of memory exception to avoid calling |
| 1842 // into dart code or allocating any code. | 1842 // into dart code or allocating any code. |
| 1843 const Instance& exception = | 1843 const Instance& exception = |
| 1844 Instance::Handle(isolate->object_store()->out_of_memory()); | 1844 Instance::Handle(isolate->object_store()->out_of_memory()); |
| 1845 Exceptions::Throw(thread, exception); | 1845 Exceptions::Throw(thread, exception); |
| 1846 UNREACHABLE(); | 1846 UNREACHABLE(); |
| 1847 } | 1847 } |
| 1848 #ifndef PRODUCT |
| 1848 ClassTable* class_table = isolate->class_table(); | 1849 ClassTable* class_table = isolate->class_table(); |
| 1849 if (space == Heap::kNew) { | 1850 if (space == Heap::kNew) { |
| 1850 class_table->UpdateAllocatedNew(cls_id, size); | 1851 class_table->UpdateAllocatedNew(cls_id, size); |
| 1851 } else { | 1852 } else { |
| 1852 class_table->UpdateAllocatedOld(cls_id, size); | 1853 class_table->UpdateAllocatedOld(cls_id, size); |
| 1853 } | 1854 } |
| 1854 const Class& cls = Class::Handle(class_table->At(cls_id)); | 1855 const Class& cls = Class::Handle(class_table->At(cls_id)); |
| 1855 if (FLAG_profiler && cls.TraceAllocation(isolate)) { | 1856 if (FLAG_profiler && cls.TraceAllocation(isolate)) { |
| 1856 Profiler::SampleAllocation(thread, cls_id); | 1857 Profiler::SampleAllocation(thread, cls_id); |
| 1857 } | 1858 } |
| 1859 #endif // !PRODUCT |
| 1858 NoSafepointScope no_safepoint; | 1860 NoSafepointScope no_safepoint; |
| 1859 InitializeObject(address, cls_id, size, (isolate == Dart::vm_isolate())); | 1861 InitializeObject(address, cls_id, size, (isolate == Dart::vm_isolate())); |
| 1860 RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag); | 1862 RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag); |
| 1861 ASSERT(cls_id == RawObject::ClassIdTag::decode(raw_obj->ptr()->tags_)); | 1863 ASSERT(cls_id == RawObject::ClassIdTag::decode(raw_obj->ptr()->tags_)); |
| 1862 return raw_obj; | 1864 return raw_obj; |
| 1863 } | 1865 } |
| 1864 | 1866 |
| 1865 | 1867 |
| 1866 class StoreBufferUpdateVisitor : public ObjectPointerVisitor { | 1868 class StoreBufferUpdateVisitor : public ObjectPointerVisitor { |
| 1867 public: | 1869 public: |
| (...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2801 a.DisableCode(); | 2803 a.DisableCode(); |
| 2802 } | 2804 } |
| 2803 | 2805 |
| 2804 | 2806 |
| 2805 void Class::DisableAllCHAOptimizedCode() { | 2807 void Class::DisableAllCHAOptimizedCode() { |
| 2806 DisableCHAOptimizedCode(Class::Handle()); | 2808 DisableCHAOptimizedCode(Class::Handle()); |
| 2807 } | 2809 } |
| 2808 | 2810 |
| 2809 | 2811 |
| 2810 bool Class::TraceAllocation(Isolate* isolate) const { | 2812 bool Class::TraceAllocation(Isolate* isolate) const { |
| 2813 #ifndef PRODUCT |
| 2811 ClassTable* class_table = isolate->class_table(); | 2814 ClassTable* class_table = isolate->class_table(); |
| 2812 return class_table->TraceAllocationFor(id()); | 2815 return class_table->TraceAllocationFor(id()); |
| 2816 #else |
| 2817 return false; |
| 2818 #endif |
| 2813 } | 2819 } |
| 2814 | 2820 |
| 2815 | 2821 |
| 2816 void Class::SetTraceAllocation(bool trace_allocation) const { | 2822 void Class::SetTraceAllocation(bool trace_allocation) const { |
| 2823 #ifndef PRODUCT |
| 2817 Isolate* isolate = Isolate::Current(); | 2824 Isolate* isolate = Isolate::Current(); |
| 2818 const bool changed = trace_allocation != this->TraceAllocation(isolate); | 2825 const bool changed = trace_allocation != this->TraceAllocation(isolate); |
| 2819 if (changed) { | 2826 if (changed) { |
| 2820 ClassTable* class_table = isolate->class_table(); | 2827 ClassTable* class_table = isolate->class_table(); |
| 2821 class_table->SetTraceAllocationFor(id(), trace_allocation); | 2828 class_table->SetTraceAllocationFor(id(), trace_allocation); |
| 2822 DisableAllocationStub(); | 2829 DisableAllocationStub(); |
| 2823 } | 2830 } |
| 2831 #else |
| 2832 UNREACHABLE(); |
| 2833 #endif |
| 2824 } | 2834 } |
| 2825 | 2835 |
| 2826 | 2836 |
| 2827 bool Class::ValidatePostFinalizePatch(const Class& orig_class, | 2837 bool Class::ValidatePostFinalizePatch(const Class& orig_class, |
| 2828 Error* error) const { | 2838 Error* error) const { |
| 2829 ASSERT(error != NULL); | 2839 ASSERT(error != NULL); |
| 2830 // Not allowed to add new fields in a post finalization patch. | 2840 // Not allowed to add new fields in a post finalization patch. |
| 2831 if (fields() != Object::empty_array().raw()) { | 2841 if (fields() != Object::empty_array().raw()) { |
| 2832 *error = LanguageError::NewFormatted( | 2842 *error = LanguageError::NewFormatted( |
| 2833 *error, // No previous error. | 2843 *error, // No previous error. |
| (...skipping 19751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 22585 return UserTag::null(); | 22595 return UserTag::null(); |
| 22586 } | 22596 } |
| 22587 | 22597 |
| 22588 | 22598 |
| 22589 const char* UserTag::ToCString() const { | 22599 const char* UserTag::ToCString() const { |
| 22590 const String& tag_label = String::Handle(label()); | 22600 const String& tag_label = String::Handle(label()); |
| 22591 return tag_label.ToCString(); | 22601 return tag_label.ToCString(); |
| 22592 } | 22602 } |
| 22593 | 22603 |
| 22594 } // namespace dart | 22604 } // namespace dart |
| OLD | NEW |