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