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 13342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13353 bool Code::FindRawCodeVisitor::FindObject(RawObject* raw_obj) const { | 13353 bool Code::FindRawCodeVisitor::FindObject(RawObject* raw_obj) const { |
13354 uword tags = raw_obj->ptr()->tags_; | 13354 uword tags = raw_obj->ptr()->tags_; |
13355 if (RawObject::ClassIdTag::decode(tags) == kInstructionsCid) { | 13355 if (RawObject::ClassIdTag::decode(tags) == kInstructionsCid) { |
13356 RawInstructions* raw_insts = reinterpret_cast<RawInstructions*>(raw_obj); | 13356 RawInstructions* raw_insts = reinterpret_cast<RawInstructions*>(raw_obj); |
13357 return RawInstructions::ContainsPC(raw_insts, pc_); | 13357 return RawInstructions::ContainsPC(raw_insts, pc_); |
13358 } | 13358 } |
13359 return false; | 13359 return false; |
13360 } | 13360 } |
13361 | 13361 |
13362 | 13362 |
| 13363 bool Code::SlowFindRawCodeVisitor::FindObject(RawObject* raw_obj) const { |
| 13364 return RawCode::ContainsPC(raw_obj, pc_); |
| 13365 } |
| 13366 |
| 13367 |
13363 RawCode* Code::LookupCodeInIsolate(Isolate* isolate, uword pc) { | 13368 RawCode* Code::LookupCodeInIsolate(Isolate* isolate, uword pc) { |
13364 ASSERT((isolate == Isolate::Current()) || (isolate == Dart::vm_isolate())); | 13369 ASSERT((isolate == Isolate::Current()) || (isolate == Dart::vm_isolate())); |
13365 NoSafepointScope no_safepoint; | |
13366 FindRawCodeVisitor visitor(pc); | |
13367 RawInstructions* instr; | |
13368 if (Dart::IsRunningPrecompiledCode()) { | |
13369 // TODO(johnmccutchan): Make code lookup work when running precompiled. | |
13370 UNIMPLEMENTED(); | |
13371 return Code::null(); | |
13372 } | |
13373 if (isolate->heap() == NULL) { | 13370 if (isolate->heap() == NULL) { |
13374 return Code::null(); | 13371 return Code::null(); |
13375 } | 13372 } |
13376 instr = isolate->heap()->FindObjectInCodeSpace(&visitor); | 13373 NoSafepointScope no_safepoint; |
13377 if (instr != Instructions::null()) { | 13374 // TODO(johnmccutchan): Make lookup without a back pointer faster and use for |
13378 return Instructions::Handle(instr).code(); | 13375 // both cases. |
| 13376 if (Dart::IsRunningPrecompiledCode()) { |
| 13377 SlowFindRawCodeVisitor visitor(pc); |
| 13378 RawObject* needle = isolate->heap()->FindOldObject(&visitor); |
| 13379 if (needle != Code::null()) { |
| 13380 return static_cast<RawCode*>(needle); |
| 13381 } |
| 13382 return Code::null(); |
| 13383 } else { |
| 13384 FindRawCodeVisitor visitor(pc); |
| 13385 RawInstructions* instr; |
| 13386 instr = isolate->heap()->FindObjectInCodeSpace(&visitor); |
| 13387 if (instr != Instructions::null()) { |
| 13388 return Instructions::Handle(instr).code(); |
| 13389 } |
| 13390 return Code::null(); |
13379 } | 13391 } |
13380 return Code::null(); | |
13381 } | 13392 } |
13382 | 13393 |
13383 | 13394 |
13384 RawCode* Code::LookupCode(uword pc) { | 13395 RawCode* Code::LookupCode(uword pc) { |
13385 return LookupCodeInIsolate(Isolate::Current(), pc); | 13396 return LookupCodeInIsolate(Isolate::Current(), pc); |
13386 } | 13397 } |
13387 | 13398 |
13388 | 13399 |
13389 RawCode* Code::LookupCodeInVmIsolate(uword pc) { | 13400 RawCode* Code::LookupCodeInVmIsolate(uword pc) { |
13390 return LookupCodeInIsolate(Dart::vm_isolate(), pc); | 13401 return LookupCodeInIsolate(Dart::vm_isolate(), pc); |
(...skipping 8457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21848 return tag_label.ToCString(); | 21859 return tag_label.ToCString(); |
21849 } | 21860 } |
21850 | 21861 |
21851 | 21862 |
21852 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 21863 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
21853 Instance::PrintJSONImpl(stream, ref); | 21864 Instance::PrintJSONImpl(stream, ref); |
21854 } | 21865 } |
21855 | 21866 |
21856 | 21867 |
21857 } // namespace dart | 21868 } // namespace dart |
OLD | NEW |