| 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 13311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13322 intptr_t pointer_offset_count = assembler->CountPointerOffsets(); | 13322 intptr_t pointer_offset_count = assembler->CountPointerOffsets(); |
| 13323 Code& code = Code::ZoneHandle(Code::New(pointer_offset_count)); | 13323 Code& code = Code::ZoneHandle(Code::New(pointer_offset_count)); |
| 13324 #ifdef TARGET_ARCH_IA32 | 13324 #ifdef TARGET_ARCH_IA32 |
| 13325 assembler->set_code_object(code); | 13325 assembler->set_code_object(code); |
| 13326 #endif | 13326 #endif |
| 13327 Instructions& instrs = | 13327 Instructions& instrs = |
| 13328 Instructions::ZoneHandle(Instructions::New(assembler->CodeSize())); | 13328 Instructions::ZoneHandle(Instructions::New(assembler->CodeSize())); |
| 13329 INC_STAT(Thread::Current(), total_instr_size, assembler->CodeSize()); | 13329 INC_STAT(Thread::Current(), total_instr_size, assembler->CodeSize()); |
| 13330 INC_STAT(Thread::Current(), total_code_size, assembler->CodeSize()); | 13330 INC_STAT(Thread::Current(), total_code_size, assembler->CodeSize()); |
| 13331 | 13331 |
| 13332 instrs.set_code(code.raw()); | |
| 13333 // Copy the instructions into the instruction area and apply all fixups. | 13332 // Copy the instructions into the instruction area and apply all fixups. |
| 13334 // Embedded pointers are still in handles at this point. | 13333 // Embedded pointers are still in handles at this point. |
| 13335 MemoryRegion region(reinterpret_cast<void*>(instrs.EntryPoint()), | 13334 MemoryRegion region(reinterpret_cast<void*>(instrs.EntryPoint()), |
| 13336 instrs.size()); | 13335 instrs.size()); |
| 13337 assembler->FinalizeInstructions(region); | 13336 assembler->FinalizeInstructions(region); |
| 13338 VerifiedMemory::Accept(region.start(), region.size()); | 13337 VerifiedMemory::Accept(region.start(), region.size()); |
| 13339 CPU::FlushICache(instrs.EntryPoint(), instrs.size()); | 13338 CPU::FlushICache(instrs.EntryPoint(), instrs.size()); |
| 13340 | 13339 |
| 13341 code.set_compile_timestamp(OS::GetCurrentTimeMicros()); | 13340 code.set_compile_timestamp(OS::GetCurrentTimeMicros()); |
| 13342 CodeObservers::NotifyAll(name, | 13341 CodeObservers::NotifyAll(name, |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13403 if (CodeObservers::AreActive()) { | 13402 if (CodeObservers::AreActive()) { |
| 13404 return FinalizeCode(function.ToLibNamePrefixedQualifiedCString(), | 13403 return FinalizeCode(function.ToLibNamePrefixedQualifiedCString(), |
| 13405 assembler, | 13404 assembler, |
| 13406 optimized); | 13405 optimized); |
| 13407 } else { | 13406 } else { |
| 13408 return FinalizeCode("", assembler); | 13407 return FinalizeCode("", assembler); |
| 13409 } | 13408 } |
| 13410 } | 13409 } |
| 13411 | 13410 |
| 13412 | 13411 |
| 13413 // Check if object matches find condition. | |
| 13414 bool Code::FindRawCodeVisitor::FindObject(RawObject* raw_obj) const { | |
| 13415 uword tags = raw_obj->ptr()->tags_; | |
| 13416 if (RawObject::ClassIdTag::decode(tags) == kInstructionsCid) { | |
| 13417 RawInstructions* raw_insts = reinterpret_cast<RawInstructions*>(raw_obj); | |
| 13418 return RawInstructions::ContainsPC(raw_insts, pc_); | |
| 13419 } | |
| 13420 return false; | |
| 13421 } | |
| 13422 | |
| 13423 | |
| 13424 bool Code::SlowFindRawCodeVisitor::FindObject(RawObject* raw_obj) const { | 13412 bool Code::SlowFindRawCodeVisitor::FindObject(RawObject* raw_obj) const { |
| 13425 return RawCode::ContainsPC(raw_obj, pc_); | 13413 return RawCode::ContainsPC(raw_obj, pc_); |
| 13426 } | 13414 } |
| 13427 | 13415 |
| 13428 | 13416 |
| 13429 RawCode* Code::LookupCodeInIsolate(Isolate* isolate, uword pc) { | 13417 RawCode* Code::LookupCodeInIsolate(Isolate* isolate, uword pc) { |
| 13430 ASSERT((isolate == Isolate::Current()) || (isolate == Dart::vm_isolate())); | 13418 ASSERT((isolate == Isolate::Current()) || (isolate == Dart::vm_isolate())); |
| 13431 if (isolate->heap() == NULL) { | 13419 if (isolate->heap() == NULL) { |
| 13432 return Code::null(); | 13420 return Code::null(); |
| 13433 } | 13421 } |
| 13434 NoSafepointScope no_safepoint; | 13422 NoSafepointScope no_safepoint; |
| 13435 // TODO(johnmccutchan): Make lookup without a back pointer faster and use for | 13423 SlowFindRawCodeVisitor visitor(pc); |
| 13436 // both cases. | 13424 RawObject* needle = isolate->heap()->FindOldObject(&visitor); |
| 13437 if (Dart::IsRunningPrecompiledCode()) { | 13425 if (needle != Code::null()) { |
| 13438 SlowFindRawCodeVisitor visitor(pc); | 13426 return static_cast<RawCode*>(needle); |
| 13439 RawObject* needle = isolate->heap()->FindOldObject(&visitor); | |
| 13440 if (needle != Code::null()) { | |
| 13441 return static_cast<RawCode*>(needle); | |
| 13442 } | |
| 13443 return Code::null(); | |
| 13444 } else { | |
| 13445 FindRawCodeVisitor visitor(pc); | |
| 13446 RawInstructions* instr; | |
| 13447 instr = isolate->heap()->FindObjectInCodeSpace(&visitor); | |
| 13448 if (instr != Instructions::null()) { | |
| 13449 return Instructions::Handle(instr).code(); | |
| 13450 } | |
| 13451 return Code::null(); | |
| 13452 } | 13427 } |
| 13428 return Code::null(); |
| 13453 } | 13429 } |
| 13454 | 13430 |
| 13455 | 13431 |
| 13456 RawCode* Code::LookupCode(uword pc) { | 13432 RawCode* Code::LookupCode(uword pc) { |
| 13457 return LookupCodeInIsolate(Isolate::Current(), pc); | 13433 return LookupCodeInIsolate(Isolate::Current(), pc); |
| 13458 } | 13434 } |
| 13459 | 13435 |
| 13460 | 13436 |
| 13461 RawCode* Code::LookupCodeInVmIsolate(uword pc) { | 13437 RawCode* Code::LookupCodeInVmIsolate(uword pc) { |
| 13462 return LookupCodeInIsolate(Dart::vm_isolate(), pc); | 13438 return LookupCodeInIsolate(Dart::vm_isolate(), pc); |
| (...skipping 8462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 21925 return tag_label.ToCString(); | 21901 return tag_label.ToCString(); |
| 21926 } | 21902 } |
| 21927 | 21903 |
| 21928 | 21904 |
| 21929 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 21905 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 21930 Instance::PrintJSONImpl(stream, ref); | 21906 Instance::PrintJSONImpl(stream, ref); |
| 21931 } | 21907 } |
| 21932 | 21908 |
| 21933 | 21909 |
| 21934 } // namespace dart | 21910 } // namespace dart |
| OLD | NEW |