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()->code_)) { | 442 if (ShouldVisitCode(raw_obj->ptr()->instructions_->ptr()->code_)) { |
443 visitor->VisitPointer( | 443 visitor->VisitPointer( |
444 reinterpret_cast<RawObject**>(&raw_obj->ptr()->code_)); | 444 reinterpret_cast<RawObject**>(&raw_obj->ptr()->instructions_)); |
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 | |
518 intptr_t RawCode::VisitCodePointers(RawCode* raw_obj, | 508 intptr_t RawCode::VisitCodePointers(RawCode* raw_obj, |
519 ObjectPointerVisitor* visitor) { | 509 ObjectPointerVisitor* visitor) { |
520 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 510 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
521 | 511 |
522 RawCode* obj = raw_obj->ptr(); | 512 RawCode* obj = raw_obj->ptr(); |
523 intptr_t length = Code::PtrOffBits::decode(obj->state_bits_); | 513 intptr_t length = Code::PtrOffBits::decode(obj->state_bits_); |
524 if (Code::AliveBit::decode(obj->state_bits_)) { | 514 if (Code::AliveBit::decode(obj->state_bits_)) { |
525 // Also visit all the embedded pointers in the corresponding instructions. | 515 // Also visit all the embedded pointers in the corresponding instructions. |
526 uword entry_point = reinterpret_cast<uword>(obj->instructions_->ptr()) + | 516 uword entry_point = reinterpret_cast<uword>(obj->instructions_->ptr()) + |
527 Instructions::HeaderSize(); | 517 Instructions::HeaderSize(); |
(...skipping 21 matching lines...) Expand all Loading... |
549 visitor->VisitPointer(&(first + i)->raw_obj_); | 539 visitor->VisitPointer(&(first + i)->raw_obj_); |
550 } | 540 } |
551 } | 541 } |
552 return ObjectPool::InstanceSize(raw_obj->ptr()->length_); | 542 return ObjectPool::InstanceSize(raw_obj->ptr()->length_); |
553 } | 543 } |
554 | 544 |
555 | 545 |
556 intptr_t RawInstructions::VisitInstructionsPointers( | 546 intptr_t RawInstructions::VisitInstructionsPointers( |
557 RawInstructions* raw_obj, ObjectPointerVisitor* visitor) { | 547 RawInstructions* raw_obj, ObjectPointerVisitor* visitor) { |
558 RawInstructions* obj = raw_obj->ptr(); | 548 RawInstructions* obj = raw_obj->ptr(); |
| 549 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
559 return Instructions::InstanceSize(obj->size_); | 550 return Instructions::InstanceSize(obj->size_); |
560 } | 551 } |
561 | 552 |
562 | 553 |
563 bool RawInstructions::ContainsPC(RawInstructions* raw_instr, uword pc) { | 554 bool RawInstructions::ContainsPC(RawObject* raw_obj, uword pc) { |
564 uword start_pc = | 555 uword tags = raw_obj->ptr()->tags_; |
565 reinterpret_cast<uword>(raw_instr->ptr()) + Instructions::HeaderSize(); | 556 if (RawObject::ClassIdTag::decode(tags) == kInstructionsCid) { |
566 uword end_pc = start_pc + raw_instr->ptr()->size_; | 557 RawInstructions* raw_instr = reinterpret_cast<RawInstructions*>(raw_obj); |
567 ASSERT(end_pc > start_pc); | 558 uword start_pc = |
568 return (pc >= start_pc) && (pc < end_pc); | 559 reinterpret_cast<uword>(raw_instr->ptr()) + Instructions::HeaderSize(); |
| 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; |
569 } | 567 } |
570 | 568 |
571 | 569 |
572 intptr_t RawPcDescriptors::VisitPcDescriptorsPointers( | 570 intptr_t RawPcDescriptors::VisitPcDescriptorsPointers( |
573 RawPcDescriptors* raw_obj, ObjectPointerVisitor* visitor) { | 571 RawPcDescriptors* raw_obj, ObjectPointerVisitor* visitor) { |
574 return PcDescriptors::InstanceSize(raw_obj->ptr()->length_); | 572 return PcDescriptors::InstanceSize(raw_obj->ptr()->length_); |
575 } | 573 } |
576 | 574 |
577 | 575 |
578 intptr_t RawStackmap::VisitStackmapPointers(RawStackmap* raw_obj, | 576 intptr_t RawStackmap::VisitStackmapPointers(RawStackmap* raw_obj, |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
934 intptr_t RawUserTag::VisitUserTagPointers( | 932 intptr_t RawUserTag::VisitUserTagPointers( |
935 RawUserTag* raw_obj, ObjectPointerVisitor* visitor) { | 933 RawUserTag* raw_obj, ObjectPointerVisitor* visitor) { |
936 // Make sure that we got here with the tagged pointer as this. | 934 // Make sure that we got here with the tagged pointer as this. |
937 ASSERT(raw_obj->IsHeapObject()); | 935 ASSERT(raw_obj->IsHeapObject()); |
938 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 936 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
939 return UserTag::InstanceSize(); | 937 return UserTag::InstanceSize(); |
940 } | 938 } |
941 | 939 |
942 | 940 |
943 } // namespace dart | 941 } // namespace dart |
OLD | NEW |