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 13011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13022 intptr_t pointer_offset_count = assembler->CountPointerOffsets(); | 13022 intptr_t pointer_offset_count = assembler->CountPointerOffsets(); |
13023 Code& code = Code::ZoneHandle(Code::New(pointer_offset_count)); | 13023 Code& code = Code::ZoneHandle(Code::New(pointer_offset_count)); |
13024 #ifdef TARGET_ARCH_IA32 | 13024 #ifdef TARGET_ARCH_IA32 |
13025 assembler->set_code_object(code); | 13025 assembler->set_code_object(code); |
13026 #endif | 13026 #endif |
13027 Instructions& instrs = | 13027 Instructions& instrs = |
13028 Instructions::ZoneHandle(Instructions::New(assembler->CodeSize())); | 13028 Instructions::ZoneHandle(Instructions::New(assembler->CodeSize())); |
13029 INC_STAT(Thread::Current(), total_instr_size, assembler->CodeSize()); | 13029 INC_STAT(Thread::Current(), total_instr_size, assembler->CodeSize()); |
13030 INC_STAT(Thread::Current(), total_code_size, assembler->CodeSize()); | 13030 INC_STAT(Thread::Current(), total_code_size, assembler->CodeSize()); |
13031 | 13031 |
| 13032 instrs.set_code(code.raw()); |
13032 // Copy the instructions into the instruction area and apply all fixups. | 13033 // Copy the instructions into the instruction area and apply all fixups. |
13033 // Embedded pointers are still in handles at this point. | 13034 // Embedded pointers are still in handles at this point. |
13034 MemoryRegion region(reinterpret_cast<void*>(instrs.EntryPoint()), | 13035 MemoryRegion region(reinterpret_cast<void*>(instrs.EntryPoint()), |
13035 instrs.size()); | 13036 instrs.size()); |
13036 assembler->FinalizeInstructions(region); | 13037 assembler->FinalizeInstructions(region); |
13037 VerifiedMemory::Accept(region.start(), region.size()); | 13038 VerifiedMemory::Accept(region.start(), region.size()); |
13038 CPU::FlushICache(instrs.EntryPoint(), instrs.size()); | 13039 CPU::FlushICache(instrs.EntryPoint(), instrs.size()); |
13039 | 13040 |
13040 code.set_compile_timestamp(OS::GetCurrentTimeMicros()); | 13041 code.set_compile_timestamp(OS::GetCurrentTimeMicros()); |
13041 CodeObservers::NotifyAll(name, | 13042 CodeObservers::NotifyAll(name, |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13103 return FinalizeCode(function.ToLibNamePrefixedQualifiedCString(), | 13104 return FinalizeCode(function.ToLibNamePrefixedQualifiedCString(), |
13104 assembler, | 13105 assembler, |
13105 optimized); | 13106 optimized); |
13106 } else { | 13107 } else { |
13107 return FinalizeCode("", assembler); | 13108 return FinalizeCode("", assembler); |
13108 } | 13109 } |
13109 } | 13110 } |
13110 | 13111 |
13111 | 13112 |
13112 // Check if object matches find condition. | 13113 // Check if object matches find condition. |
13113 bool Code::FindRawCodeVisitor::FindObject(RawObject* obj) const { | 13114 bool Code::FindRawCodeVisitor::FindObject(RawObject* raw_obj) const { |
13114 return RawCode::ContainsPC(obj, pc_); | 13115 uword tags = raw_obj->ptr()->tags_; |
| 13116 if (RawObject::ClassIdTag::decode(tags) == kInstructionsCid) { |
| 13117 RawInstructions* raw_insts = reinterpret_cast<RawInstructions*>(raw_obj); |
| 13118 return RawInstructions::ContainsPC(raw_insts, pc_); |
| 13119 } |
| 13120 return false; |
13115 } | 13121 } |
13116 | 13122 |
13117 | 13123 |
13118 RawCode* Code::LookupCodeInIsolate(Isolate* isolate, uword pc) { | 13124 RawCode* Code::LookupCodeInIsolate(Isolate* isolate, uword pc) { |
13119 ASSERT((isolate == Isolate::Current()) || (isolate == Dart::vm_isolate())); | 13125 ASSERT((isolate == Isolate::Current()) || (isolate == Dart::vm_isolate())); |
13120 NoSafepointScope no_safepoint; | 13126 NoSafepointScope no_safepoint; |
13121 FindRawCodeVisitor visitor(pc); | 13127 FindRawCodeVisitor visitor(pc); |
13122 RawObject* instr; | 13128 RawInstructions* instr; |
| 13129 if (Dart::IsRunningPrecompiledCode()) { |
| 13130 // TODO(johnmccutchan): Make code lookup work when running precompiled. |
| 13131 UNIMPLEMENTED(); |
| 13132 return Code::null(); |
| 13133 } |
13123 if (isolate->heap() == NULL) { | 13134 if (isolate->heap() == NULL) { |
13124 return Code::null(); | 13135 return Code::null(); |
13125 } | 13136 } |
13126 instr = isolate->heap()->FindOldObject(&visitor); | 13137 instr = isolate->heap()->FindObjectInCodeSpace(&visitor); |
13127 if (instr != Code::null()) { | 13138 if (instr != Instructions::null()) { |
13128 return static_cast<RawCode*>(instr); | 13139 return Instructions::Handle(instr).code(); |
13129 } | 13140 } |
13130 return Code::null(); | 13141 return Code::null(); |
13131 } | 13142 } |
13132 | 13143 |
13133 | 13144 |
13134 RawCode* Code::LookupCode(uword pc) { | 13145 RawCode* Code::LookupCode(uword pc) { |
13135 return LookupCodeInIsolate(Isolate::Current(), pc); | 13146 return LookupCodeInIsolate(Isolate::Current(), pc); |
13136 } | 13147 } |
13137 | 13148 |
13138 | 13149 |
(...skipping 8305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21444 return tag_label.ToCString(); | 21455 return tag_label.ToCString(); |
21445 } | 21456 } |
21446 | 21457 |
21447 | 21458 |
21448 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 21459 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
21449 Instance::PrintJSONImpl(stream, ref); | 21460 Instance::PrintJSONImpl(stream, ref); |
21450 } | 21461 } |
21451 | 21462 |
21452 | 21463 |
21453 } // namespace dart | 21464 } // namespace dart |
OLD | NEW |