| 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 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1092 str = lib.PrivateName(public_class_name); | 1092 str = lib.PrivateName(public_class_name); |
| 1093 cls.set_name(str); | 1093 cls.set_name(str); |
| 1094 lib.AddClass(cls); | 1094 lib.AddClass(cls); |
| 1095 } | 1095 } |
| 1096 | 1096 |
| 1097 | 1097 |
| 1098 RawError* Object::Init(Isolate* isolate) { | 1098 RawError* Object::Init(Isolate* isolate) { |
| 1099 Thread* thread = Thread::Current(); | 1099 Thread* thread = Thread::Current(); |
| 1100 Zone* zone = thread->zone(); | 1100 Zone* zone = thread->zone(); |
| 1101 ASSERT(isolate == thread->isolate()); | 1101 ASSERT(isolate == thread->isolate()); |
| 1102 #ifndef PRODUCT |
| 1102 TimelineDurationScope tds(thread, | 1103 TimelineDurationScope tds(thread, |
| 1103 isolate->GetIsolateStream(), | 1104 isolate->GetIsolateStream(), |
| 1104 "Object::Init"); | 1105 "Object::Init"); |
| 1106 #endif |
| 1105 | 1107 |
| 1106 #if defined(DART_NO_SNAPSHOT) | 1108 #if defined(DART_NO_SNAPSHOT) |
| 1107 // Object::Init version when we are running in a version of dart that does | 1109 // Object::Init version when we are running in a version of dart that does |
| 1108 // not have a full snapshot linked in. | 1110 // not have a full snapshot linked in. |
| 1109 ObjectStore* object_store = isolate->object_store(); | 1111 ObjectStore* object_store = isolate->object_store(); |
| 1110 | 1112 |
| 1111 Class& cls = Class::Handle(zone); | 1113 Class& cls = Class::Handle(zone); |
| 1112 Type& type = Type::Handle(zone); | 1114 Type& type = Type::Handle(zone); |
| 1113 Array& array = Array::Handle(zone); | 1115 Array& array = Array::Handle(zone); |
| 1114 Library& lib = Library::Handle(zone); | 1116 Library& lib = Library::Handle(zone); |
| (...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1811 Exceptions::Throw(thread, exception); | 1813 Exceptions::Throw(thread, exception); |
| 1812 UNREACHABLE(); | 1814 UNREACHABLE(); |
| 1813 } | 1815 } |
| 1814 ClassTable* class_table = isolate->class_table(); | 1816 ClassTable* class_table = isolate->class_table(); |
| 1815 if (space == Heap::kNew) { | 1817 if (space == Heap::kNew) { |
| 1816 class_table->UpdateAllocatedNew(cls_id, size); | 1818 class_table->UpdateAllocatedNew(cls_id, size); |
| 1817 } else { | 1819 } else { |
| 1818 class_table->UpdateAllocatedOld(cls_id, size); | 1820 class_table->UpdateAllocatedOld(cls_id, size); |
| 1819 } | 1821 } |
| 1820 const Class& cls = Class::Handle(class_table->At(cls_id)); | 1822 const Class& cls = Class::Handle(class_table->At(cls_id)); |
| 1821 if (cls.TraceAllocation(isolate)) { | 1823 if (FLAG_profiler && cls.TraceAllocation(isolate)) { |
| 1822 Profiler::SampleAllocation(thread, cls_id); | 1824 Profiler::SampleAllocation(thread, cls_id); |
| 1823 } | 1825 } |
| 1824 NoSafepointScope no_safepoint; | 1826 NoSafepointScope no_safepoint; |
| 1825 InitializeObject(address, cls_id, size, (isolate == Dart::vm_isolate())); | 1827 InitializeObject(address, cls_id, size, (isolate == Dart::vm_isolate())); |
| 1826 RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag); | 1828 RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag); |
| 1827 ASSERT(cls_id == RawObject::ClassIdTag::decode(raw_obj->ptr()->tags_)); | 1829 ASSERT(cls_id == RawObject::ClassIdTag::decode(raw_obj->ptr()->tags_)); |
| 1828 return raw_obj; | 1830 return raw_obj; |
| 1829 } | 1831 } |
| 1830 | 1832 |
| 1831 | 1833 |
| (...skipping 8722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10554 } | 10556 } |
| 10555 } | 10557 } |
| 10556 if (!func.IsNull()) { | 10558 if (!func.IsNull()) { |
| 10557 return func.raw(); | 10559 return func.raw(); |
| 10558 } | 10560 } |
| 10559 } | 10561 } |
| 10560 return Function::null(); | 10562 return Function::null(); |
| 10561 } | 10563 } |
| 10562 | 10564 |
| 10563 | 10565 |
| 10564 #if defined(DART_NO_SNAPSHOT) | 10566 #if defined(DART_NO_SNAPSHOT) && !defined(PRODUCT) |
| 10565 void Library::CheckFunctionFingerprints() { | 10567 void Library::CheckFunctionFingerprints() { |
| 10566 GrowableArray<Library*> all_libs; | 10568 GrowableArray<Library*> all_libs; |
| 10567 Function& func = Function::Handle(); | 10569 Function& func = Function::Handle(); |
| 10568 bool has_errors = false; | 10570 bool has_errors = false; |
| 10569 | 10571 |
| 10570 #define CHECK_FINGERPRINTS(class_name, function_name, dest, fp) \ | 10572 #define CHECK_FINGERPRINTS(class_name, function_name, dest, fp) \ |
| 10571 func = GetFunction(all_libs, #class_name, #function_name); \ | 10573 func = GetFunction(all_libs, #class_name, #function_name); \ |
| 10572 if (func.IsNull()) { \ | 10574 if (func.IsNull()) { \ |
| 10573 has_errors = true; \ | 10575 has_errors = true; \ |
| 10574 OS::Print("Function not found %s.%s\n", #class_name, #function_name); \ | 10576 OS::Print("Function not found %s.%s\n", #class_name, #function_name); \ |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10616 } \ | 10618 } \ |
| 10617 | 10619 |
| 10618 RECOGNIZED_LIST_FACTORY_LIST(CHECK_FACTORY_FINGERPRINTS); | 10620 RECOGNIZED_LIST_FACTORY_LIST(CHECK_FACTORY_FINGERPRINTS); |
| 10619 | 10621 |
| 10620 #undef CHECK_FACTORY_FINGERPRINTS | 10622 #undef CHECK_FACTORY_FINGERPRINTS |
| 10621 | 10623 |
| 10622 if (has_errors) { | 10624 if (has_errors) { |
| 10623 FATAL("Fingerprint mismatch."); | 10625 FATAL("Fingerprint mismatch."); |
| 10624 } | 10626 } |
| 10625 } | 10627 } |
| 10626 #endif // defined(DART_NO_SNAPSHOT). | 10628 #endif // defined(DART_NO_SNAPSHOT) && !defined(PRODUCT). |
| 10627 | 10629 |
| 10628 | 10630 |
| 10629 RawInstructions* Instructions::New(intptr_t size) { | 10631 RawInstructions* Instructions::New(intptr_t size) { |
| 10630 ASSERT(Object::instructions_class() != Class::null()); | 10632 ASSERT(Object::instructions_class() != Class::null()); |
| 10631 if (size < 0 || size > kMaxElements) { | 10633 if (size < 0 || size > kMaxElements) { |
| 10632 // This should be caught before we reach here. | 10634 // This should be caught before we reach here. |
| 10633 FATAL1("Fatal error in Instructions::New: invalid size %" Pd "\n", size); | 10635 FATAL1("Fatal error in Instructions::New: invalid size %" Pd "\n", size); |
| 10634 } | 10636 } |
| 10635 Instructions& result = Instructions::Handle(); | 10637 Instructions& result = Instructions::Handle(); |
| 10636 { | 10638 { |
| (...skipping 1978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12615 } else { | 12617 } else { |
| 12616 ASSERT(code.IsNull() || | 12618 ASSERT(code.IsNull() || |
| 12617 (code.function() == array.At(i + kSCallTableFunctionEntry))); | 12619 (code.function() == array.At(i + kSCallTableFunctionEntry))); |
| 12618 } | 12620 } |
| 12619 #endif | 12621 #endif |
| 12620 array.SetAt(i + kSCallTableCodeEntry, code); | 12622 array.SetAt(i + kSCallTableCodeEntry, code); |
| 12621 } | 12623 } |
| 12622 | 12624 |
| 12623 | 12625 |
| 12624 void Code::Disassemble(DisassemblyFormatter* formatter) const { | 12626 void Code::Disassemble(DisassemblyFormatter* formatter) const { |
| 12627 if (!FLAG_support_disassembler) { |
| 12628 return; |
| 12629 } |
| 12625 const Instructions& instr = Instructions::Handle(instructions()); | 12630 const Instructions& instr = Instructions::Handle(instructions()); |
| 12626 uword start = instr.EntryPoint(); | 12631 uword start = instr.EntryPoint(); |
| 12627 if (formatter == NULL) { | 12632 if (formatter == NULL) { |
| 12628 Disassembler::Disassemble(start, start + instr.size(), *this); | 12633 Disassembler::Disassemble(start, start + instr.size(), *this); |
| 12629 } else { | 12634 } else { |
| 12630 Disassembler::Disassemble(start, start + instr.size(), formatter, *this); | 12635 Disassembler::Disassemble(start, start + instr.size(), formatter, *this); |
| 12631 } | 12636 } |
| 12632 } | 12637 } |
| 12633 | 12638 |
| 12634 | 12639 |
| (...skipping 8752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 21387 return UserTag::null(); | 21392 return UserTag::null(); |
| 21388 } | 21393 } |
| 21389 | 21394 |
| 21390 | 21395 |
| 21391 const char* UserTag::ToCString() const { | 21396 const char* UserTag::ToCString() const { |
| 21392 const String& tag_label = String::Handle(label()); | 21397 const String& tag_label = String::Handle(label()); |
| 21393 return tag_label.ToCString(); | 21398 return tag_label.ToCString(); |
| 21394 } | 21399 } |
| 21395 | 21400 |
| 21396 } // namespace dart | 21401 } // namespace dart |
| OLD | NEW |