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/raw_object.h" | 5 #include "vm/raw_object.h" |
6 | 6 |
7 #include "vm/class_table.h" | 7 #include "vm/class_table.h" |
8 #include "vm/dart.h" | 8 #include "vm/dart.h" |
9 #include "vm/freelist.h" | 9 #include "vm/freelist.h" |
10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 | 432 |
433 | 433 |
434 intptr_t RawFunction::VisitFunctionPointers(RawFunction* raw_obj, | 434 intptr_t RawFunction::VisitFunctionPointers(RawFunction* raw_obj, |
435 ObjectPointerVisitor* visitor) { | 435 ObjectPointerVisitor* visitor) { |
436 if (visitor->visit_function_code() || !CheckUsageCounter(raw_obj)) { | 436 if (visitor->visit_function_code() || !CheckUsageCounter(raw_obj)) { |
437 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 437 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
438 return Function::InstanceSize(); | 438 return Function::InstanceSize(); |
439 } | 439 } |
440 visitor->VisitPointers(raw_obj->from(), raw_obj->to_no_code()); | 440 visitor->VisitPointers(raw_obj->from(), raw_obj->to_no_code()); |
441 | 441 |
442 if (ShouldVisitCode(raw_obj->ptr()->instructions_->ptr()->code_)) { | 442 if (ShouldVisitCode(raw_obj->ptr()->code_)) { |
443 visitor->VisitPointer( | 443 visitor->VisitPointer( |
444 reinterpret_cast<RawObject**>(&raw_obj->ptr()->instructions_)); | 444 reinterpret_cast<RawObject**>(&raw_obj->ptr()->code_)); |
445 } else { | 445 } else { |
446 visitor->add_skipped_code_function(raw_obj); | 446 visitor->add_skipped_code_function(raw_obj); |
447 } | 447 } |
448 | 448 |
449 if (ShouldVisitCode(raw_obj->ptr()->unoptimized_code_)) { | 449 if (ShouldVisitCode(raw_obj->ptr()->unoptimized_code_)) { |
450 visitor->VisitPointer( | 450 visitor->VisitPointer( |
451 reinterpret_cast<RawObject**>(&raw_obj->ptr()->unoptimized_code_)); | 451 reinterpret_cast<RawObject**>(&raw_obj->ptr()->unoptimized_code_)); |
452 } else { | 452 } else { |
453 visitor->add_skipped_code_function(raw_obj); | 453 visitor->add_skipped_code_function(raw_obj); |
454 } | 454 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 } | 498 } |
499 | 499 |
500 | 500 |
501 intptr_t RawNamespace::VisitNamespacePointers( | 501 intptr_t RawNamespace::VisitNamespacePointers( |
502 RawNamespace* raw_obj, ObjectPointerVisitor* visitor) { | 502 RawNamespace* raw_obj, ObjectPointerVisitor* visitor) { |
503 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 503 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
504 return Namespace::InstanceSize(); | 504 return Namespace::InstanceSize(); |
505 } | 505 } |
506 | 506 |
507 | 507 |
| 508 bool RawCode::ContainsPC(RawObject* raw_obj, uword pc) { |
| 509 uword tags = raw_obj->ptr()->tags_; |
| 510 if (RawObject::ClassIdTag::decode(tags) == kCodeCid) { |
| 511 RawCode* raw_code = reinterpret_cast<RawCode*>(raw_obj); |
| 512 return RawInstructions::ContainsPC(raw_code->ptr()->instructions_, pc); |
| 513 } |
| 514 return false; |
| 515 } |
| 516 |
| 517 |
508 intptr_t RawCode::VisitCodePointers(RawCode* raw_obj, | 518 intptr_t RawCode::VisitCodePointers(RawCode* raw_obj, |
509 ObjectPointerVisitor* visitor) { | 519 ObjectPointerVisitor* visitor) { |
510 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 520 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
511 | 521 |
512 RawCode* obj = raw_obj->ptr(); | 522 RawCode* obj = raw_obj->ptr(); |
513 intptr_t length = Code::PtrOffBits::decode(obj->state_bits_); | 523 intptr_t length = Code::PtrOffBits::decode(obj->state_bits_); |
514 if (Code::AliveBit::decode(obj->state_bits_)) { | 524 if (Code::AliveBit::decode(obj->state_bits_)) { |
515 // Also visit all the embedded pointers in the corresponding instructions. | 525 // Also visit all the embedded pointers in the corresponding instructions. |
516 uword entry_point = reinterpret_cast<uword>(obj->instructions_->ptr()) + | 526 uword entry_point = reinterpret_cast<uword>(obj->instructions_->ptr()) + |
517 Instructions::HeaderSize(); | 527 Instructions::HeaderSize(); |
(...skipping 21 matching lines...) Expand all Loading... |
539 visitor->VisitPointer(&(first + i)->raw_obj_); | 549 visitor->VisitPointer(&(first + i)->raw_obj_); |
540 } | 550 } |
541 } | 551 } |
542 return ObjectPool::InstanceSize(raw_obj->ptr()->length_); | 552 return ObjectPool::InstanceSize(raw_obj->ptr()->length_); |
543 } | 553 } |
544 | 554 |
545 | 555 |
546 intptr_t RawInstructions::VisitInstructionsPointers( | 556 intptr_t RawInstructions::VisitInstructionsPointers( |
547 RawInstructions* raw_obj, ObjectPointerVisitor* visitor) { | 557 RawInstructions* raw_obj, ObjectPointerVisitor* visitor) { |
548 RawInstructions* obj = raw_obj->ptr(); | 558 RawInstructions* obj = raw_obj->ptr(); |
549 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
550 return Instructions::InstanceSize(obj->size_); | 559 return Instructions::InstanceSize(obj->size_); |
551 } | 560 } |
552 | 561 |
553 | 562 |
554 bool RawInstructions::ContainsPC(RawObject* raw_obj, uword pc) { | 563 bool RawInstructions::ContainsPC(RawInstructions* raw_instr, uword pc) { |
555 uword tags = raw_obj->ptr()->tags_; | 564 uword start_pc = |
556 if (RawObject::ClassIdTag::decode(tags) == kInstructionsCid) { | 565 reinterpret_cast<uword>(raw_instr->ptr()) + Instructions::HeaderSize(); |
557 RawInstructions* raw_instr = reinterpret_cast<RawInstructions*>(raw_obj); | 566 uword end_pc = start_pc + raw_instr->ptr()->size_; |
558 uword start_pc = | 567 ASSERT(end_pc > start_pc); |
559 reinterpret_cast<uword>(raw_instr->ptr()) + Instructions::HeaderSize(); | 568 return (pc >= start_pc) && (pc < end_pc); |
560 uword end_pc = start_pc + raw_instr->ptr()->size_; | |
561 ASSERT(end_pc > start_pc); | |
562 if ((pc >= start_pc) && (pc < end_pc)) { | |
563 return true; | |
564 } | |
565 } | |
566 return false; | |
567 } | 569 } |
568 | 570 |
569 | 571 |
570 intptr_t RawPcDescriptors::VisitPcDescriptorsPointers( | 572 intptr_t RawPcDescriptors::VisitPcDescriptorsPointers( |
571 RawPcDescriptors* raw_obj, ObjectPointerVisitor* visitor) { | 573 RawPcDescriptors* raw_obj, ObjectPointerVisitor* visitor) { |
572 return PcDescriptors::InstanceSize(raw_obj->ptr()->length_); | 574 return PcDescriptors::InstanceSize(raw_obj->ptr()->length_); |
573 } | 575 } |
574 | 576 |
575 | 577 |
576 intptr_t RawStackmap::VisitStackmapPointers(RawStackmap* raw_obj, | 578 intptr_t RawStackmap::VisitStackmapPointers(RawStackmap* raw_obj, |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
932 intptr_t RawUserTag::VisitUserTagPointers( | 934 intptr_t RawUserTag::VisitUserTagPointers( |
933 RawUserTag* raw_obj, ObjectPointerVisitor* visitor) { | 935 RawUserTag* raw_obj, ObjectPointerVisitor* visitor) { |
934 // Make sure that we got here with the tagged pointer as this. | 936 // Make sure that we got here with the tagged pointer as this. |
935 ASSERT(raw_obj->IsHeapObject()); | 937 ASSERT(raw_obj->IsHeapObject()); |
936 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 938 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
937 return UserTag::InstanceSize(); | 939 return UserTag::InstanceSize(); |
938 } | 940 } |
939 | 941 |
940 | 942 |
941 } // namespace dart | 943 } // namespace dart |
OLD | NEW |