OLD | NEW |
---|---|
1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
2 // All Rights Reserved. | 2 // All Rights Reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
10 // | 10 // |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
321 const int kLastChunkTag = 1; | 321 const int kLastChunkTag = 1; |
322 | 322 |
323 | 323 |
324 const int kDataJumpExtraTag = kPCJumpExtraTag - 1; | 324 const int kDataJumpExtraTag = kPCJumpExtraTag - 1; |
325 | 325 |
326 const int kCodeWithIdTag = 0; | 326 const int kCodeWithIdTag = 0; |
327 const int kNonstatementPositionTag = 1; | 327 const int kNonstatementPositionTag = 1; |
328 const int kStatementPositionTag = 2; | 328 const int kStatementPositionTag = 2; |
329 const int kCommentTag = 3; | 329 const int kCommentTag = 3; |
330 | 330 |
331 // Reuse the same value for deopt reason tag in short record format. | |
Michael Starzinger
2015/02/04 11:30:51
IIUC, this assumes that comments are always encode
loislo
2015/02/04 14:38:49
done
| |
332 const int kDeoptReasonTag = 3; | |
333 | |
331 const int kPoolExtraTag = kPCJumpExtraTag - 2; | 334 const int kPoolExtraTag = kPCJumpExtraTag - 2; |
332 const int kConstPoolTag = 0; | 335 const int kConstPoolTag = 0; |
333 const int kVeneerPoolTag = 1; | 336 const int kVeneerPoolTag = 1; |
334 | 337 |
335 | 338 |
336 uint32_t RelocInfoWriter::WriteVariableLengthPCJump(uint32_t pc_delta) { | 339 uint32_t RelocInfoWriter::WriteVariableLengthPCJump(uint32_t pc_delta) { |
337 // Return if the pc_delta can fit in kSmallPCDeltaBits bits. | 340 // Return if the pc_delta can fit in kSmallPCDeltaBits bits. |
338 // Otherwise write a variable length PC jump for the bits that do | 341 // Otherwise write a variable length PC jump for the bits that do |
339 // not fit in the kSmallPCDeltaBits bits. | 342 // not fit in the kSmallPCDeltaBits bits. |
340 if (is_uintn(pc_delta, kSmallPCDeltaBits)) return pc_delta; | 343 if (is_uintn(pc_delta, kSmallPCDeltaBits)) return pc_delta; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
416 #endif | 419 #endif |
417 DCHECK(rinfo->rmode() < RelocInfo::NUMBER_OF_MODES); | 420 DCHECK(rinfo->rmode() < RelocInfo::NUMBER_OF_MODES); |
418 DCHECK(rinfo->pc() - last_pc_ >= 0); | 421 DCHECK(rinfo->pc() - last_pc_ >= 0); |
419 DCHECK(RelocInfo::LAST_STANDARD_NONCOMPACT_ENUM - RelocInfo::LAST_COMPACT_ENUM | 422 DCHECK(RelocInfo::LAST_STANDARD_NONCOMPACT_ENUM - RelocInfo::LAST_COMPACT_ENUM |
420 <= kMaxStandardNonCompactModes); | 423 <= kMaxStandardNonCompactModes); |
421 // Use unsigned delta-encoding for pc. | 424 // Use unsigned delta-encoding for pc. |
422 uint32_t pc_delta = static_cast<uint32_t>(rinfo->pc() - last_pc_); | 425 uint32_t pc_delta = static_cast<uint32_t>(rinfo->pc() - last_pc_); |
423 RelocInfo::Mode rmode = rinfo->rmode(); | 426 RelocInfo::Mode rmode = rinfo->rmode(); |
424 | 427 |
425 // The two most common modes are given small tags, and usually fit in a byte. | 428 // The two most common modes are given small tags, and usually fit in a byte. |
426 if (rmode == RelocInfo::EMBEDDED_OBJECT) { | 429 if (rmode == RelocInfo::DEOPT_REASON) { |
Michael Starzinger
2015/02/04 11:30:51
nit: Can we move this to after EMBEDDED_OBJECT, CO
loislo
2015/02/04 14:38:50
done
| |
430 WriteTaggedPC(pc_delta, kLocatableTag); | |
431 WriteTaggedData(rinfo->data(), kDeoptReasonTag); | |
Michael Starzinger
2015/02/04 11:30:51
Can we have a DCHECK here that the deopt reason re
loislo
2015/02/04 14:38:49
done
| |
432 } else if (rmode == RelocInfo::EMBEDDED_OBJECT) { | |
427 WriteTaggedPC(pc_delta, kEmbeddedObjectTag); | 433 WriteTaggedPC(pc_delta, kEmbeddedObjectTag); |
428 } else if (rmode == RelocInfo::CODE_TARGET) { | 434 } else if (rmode == RelocInfo::CODE_TARGET) { |
429 WriteTaggedPC(pc_delta, kCodeTargetTag); | 435 WriteTaggedPC(pc_delta, kCodeTargetTag); |
430 DCHECK(begin_pos - pos_ <= RelocInfo::kMaxCallSize); | 436 DCHECK(begin_pos - pos_ <= RelocInfo::kMaxCallSize); |
431 } else if (rmode == RelocInfo::CODE_TARGET_WITH_ID) { | 437 } else if (rmode == RelocInfo::CODE_TARGET_WITH_ID) { |
432 // Use signed delta-encoding for id. | 438 // Use signed delta-encoding for id. |
433 DCHECK(static_cast<int>(rinfo->data()) == rinfo->data()); | 439 DCHECK(static_cast<int>(rinfo->data()) == rinfo->data()); |
434 int id_delta = static_cast<int>(rinfo->data()) - last_id_; | 440 int id_delta = static_cast<int>(rinfo->data()) - last_id_; |
435 // Check if delta is small enough to fit in a tagged byte. | 441 // Check if delta is small enough to fit in a tagged byte. |
436 if (is_intn(id_delta, kSmallDataBits)) { | 442 if (is_intn(id_delta, kSmallDataBits)) { |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
576 | 582 |
577 | 583 |
578 inline void RelocIterator::ReadTaggedPosition() { | 584 inline void RelocIterator::ReadTaggedPosition() { |
579 int8_t signed_b = *pos_; | 585 int8_t signed_b = *pos_; |
580 // Signed right shift is arithmetic shift. Tested in test-utils.cc. | 586 // Signed right shift is arithmetic shift. Tested in test-utils.cc. |
581 last_position_ += signed_b >> kLocatableTypeTagBits; | 587 last_position_ += signed_b >> kLocatableTypeTagBits; |
582 rinfo_.data_ = last_position_; | 588 rinfo_.data_ = last_position_; |
583 } | 589 } |
584 | 590 |
585 | 591 |
592 inline void RelocIterator::ReadTaggedData() { | |
593 uint8_t unsigned_b = *pos_; | |
594 rinfo_.data_ = unsigned_b >> kTagBits; | |
595 } | |
596 | |
597 | |
586 static inline RelocInfo::Mode GetPositionModeFromTag(int tag) { | 598 static inline RelocInfo::Mode GetPositionModeFromTag(int tag) { |
587 DCHECK(tag == kNonstatementPositionTag || | 599 DCHECK(tag == kNonstatementPositionTag || |
588 tag == kStatementPositionTag); | 600 tag == kStatementPositionTag); |
589 return (tag == kNonstatementPositionTag) ? | 601 return (tag == kNonstatementPositionTag) ? |
590 RelocInfo::POSITION : | 602 RelocInfo::POSITION : |
591 RelocInfo::STATEMENT_POSITION; | 603 RelocInfo::STATEMENT_POSITION; |
592 } | 604 } |
593 | 605 |
594 | 606 |
595 void RelocIterator::next() { | 607 void RelocIterator::next() { |
(...skipping 13 matching lines...) Expand all Loading... | |
609 if (SetMode(RelocInfo::CODE_TARGET)) return; | 621 if (SetMode(RelocInfo::CODE_TARGET)) return; |
610 } else if (tag == kLocatableTag) { | 622 } else if (tag == kLocatableTag) { |
611 ReadTaggedPC(); | 623 ReadTaggedPC(); |
612 Advance(); | 624 Advance(); |
613 int locatable_tag = GetLocatableTypeTag(); | 625 int locatable_tag = GetLocatableTypeTag(); |
614 if (locatable_tag == kCodeWithIdTag) { | 626 if (locatable_tag == kCodeWithIdTag) { |
615 if (SetMode(RelocInfo::CODE_TARGET_WITH_ID)) { | 627 if (SetMode(RelocInfo::CODE_TARGET_WITH_ID)) { |
616 ReadTaggedId(); | 628 ReadTaggedId(); |
617 return; | 629 return; |
618 } | 630 } |
631 } else if (locatable_tag == kDeoptReasonTag) { | |
632 ReadTaggedData(); | |
633 if (SetMode(RelocInfo::DEOPT_REASON)) return; | |
619 } else { | 634 } else { |
620 // Compact encoding is never used for comments, | |
621 // so it must be a position. | |
622 DCHECK(locatable_tag == kNonstatementPositionTag || | 635 DCHECK(locatable_tag == kNonstatementPositionTag || |
623 locatable_tag == kStatementPositionTag); | 636 locatable_tag == kStatementPositionTag); |
624 if (mode_mask_ & RelocInfo::kPositionMask) { | 637 if (mode_mask_ & RelocInfo::kPositionMask) { |
625 ReadTaggedPosition(); | 638 ReadTaggedPosition(); |
626 if (SetMode(GetPositionModeFromTag(locatable_tag))) return; | 639 if (SetMode(GetPositionModeFromTag(locatable_tag))) return; |
627 } | 640 } |
628 } | 641 } |
629 } else { | 642 } else { |
630 DCHECK(tag == kDefaultTag); | 643 DCHECK(tag == kDefaultTag); |
631 int extra_tag = GetExtraTag(); | 644 int extra_tag = GetExtraTag(); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
776 case RelocInfo::COMMENT: | 789 case RelocInfo::COMMENT: |
777 return "comment"; | 790 return "comment"; |
778 case RelocInfo::POSITION: | 791 case RelocInfo::POSITION: |
779 return "position"; | 792 return "position"; |
780 case RelocInfo::STATEMENT_POSITION: | 793 case RelocInfo::STATEMENT_POSITION: |
781 return "statement position"; | 794 return "statement position"; |
782 case RelocInfo::EXTERNAL_REFERENCE: | 795 case RelocInfo::EXTERNAL_REFERENCE: |
783 return "external reference"; | 796 return "external reference"; |
784 case RelocInfo::INTERNAL_REFERENCE: | 797 case RelocInfo::INTERNAL_REFERENCE: |
785 return "internal reference"; | 798 return "internal reference"; |
799 case RelocInfo::DEOPT_REASON: | |
800 return "deopt reason"; | |
786 case RelocInfo::CONST_POOL: | 801 case RelocInfo::CONST_POOL: |
787 return "constant pool"; | 802 return "constant pool"; |
788 case RelocInfo::VENEER_POOL: | 803 case RelocInfo::VENEER_POOL: |
789 return "veneer pool"; | 804 return "veneer pool"; |
790 case RelocInfo::DEBUG_BREAK_SLOT: | 805 case RelocInfo::DEBUG_BREAK_SLOT: |
791 return "debug break slot"; | 806 return "debug break slot"; |
792 case RelocInfo::CODE_AGE_SEQUENCE: | 807 case RelocInfo::CODE_AGE_SEQUENCE: |
793 return "code_age_sequence"; | 808 return "code_age_sequence"; |
794 case RelocInfo::NUMBER_OF_MODES: | 809 case RelocInfo::NUMBER_OF_MODES: |
795 UNREACHABLE(); | 810 UNREACHABLE(); |
796 return "number_of_modes"; | 811 return "number_of_modes"; |
797 } | 812 } |
798 return "unknown relocation type"; | 813 return "unknown relocation type"; |
799 } | 814 } |
800 | 815 |
801 | 816 |
802 void RelocInfo::Print(Isolate* isolate, std::ostream& os) { // NOLINT | 817 void RelocInfo::Print(Isolate* isolate, std::ostream& os) { // NOLINT |
803 os << static_cast<const void*>(pc_) << " " << RelocModeName(rmode_); | 818 os << static_cast<const void*>(pc_) << " " << RelocModeName(rmode_); |
804 if (IsComment(rmode_)) { | 819 if (IsComment(rmode_)) { |
805 os << " (" << reinterpret_cast<char*>(data_) << ")"; | 820 os << " (" << reinterpret_cast<char*>(data_) << ")"; |
821 } else if (rmode_ == DEOPT_REASON) { | |
822 os << " (" << Deoptimizer::GetDeoptReason( | |
823 static_cast<Deoptimizer::DeoptReason>(data_)) << ")"; | |
806 } else if (rmode_ == EMBEDDED_OBJECT) { | 824 } else if (rmode_ == EMBEDDED_OBJECT) { |
807 os << " (" << Brief(target_object()) << ")"; | 825 os << " (" << Brief(target_object()) << ")"; |
808 } else if (rmode_ == EXTERNAL_REFERENCE) { | 826 } else if (rmode_ == EXTERNAL_REFERENCE) { |
809 ExternalReferenceEncoder ref_encoder(isolate); | 827 ExternalReferenceEncoder ref_encoder(isolate); |
810 os << " (" << ref_encoder.NameOfAddress(target_reference()) << ") (" | 828 os << " (" << ref_encoder.NameOfAddress(target_reference()) << ") (" |
811 << static_cast<const void*>(target_reference()) << ")"; | 829 << static_cast<const void*>(target_reference()) << ")"; |
812 } else if (IsCodeTarget(rmode_)) { | 830 } else if (IsCodeTarget(rmode_)) { |
813 Code* code = Code::GetCodeFromTargetAddress(target_address()); | 831 Code* code = Code::GetCodeFromTargetAddress(target_address()); |
814 os << " (" << Code::Kind2String(code->kind()) << ") (" | 832 os << " (" << Code::Kind2String(code->kind()) << ") (" |
815 << static_cast<const void*>(target_address()) << ")"; | 833 << static_cast<const void*>(target_address()) << ")"; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
856 CHECK(code->address() == HeapObject::cast(found)->address()); | 874 CHECK(code->address() == HeapObject::cast(found)->address()); |
857 break; | 875 break; |
858 } | 876 } |
859 case RUNTIME_ENTRY: | 877 case RUNTIME_ENTRY: |
860 case JS_RETURN: | 878 case JS_RETURN: |
861 case COMMENT: | 879 case COMMENT: |
862 case POSITION: | 880 case POSITION: |
863 case STATEMENT_POSITION: | 881 case STATEMENT_POSITION: |
864 case EXTERNAL_REFERENCE: | 882 case EXTERNAL_REFERENCE: |
865 case INTERNAL_REFERENCE: | 883 case INTERNAL_REFERENCE: |
884 case DEOPT_REASON: | |
866 case CONST_POOL: | 885 case CONST_POOL: |
867 case VENEER_POOL: | 886 case VENEER_POOL: |
868 case DEBUG_BREAK_SLOT: | 887 case DEBUG_BREAK_SLOT: |
869 case NONE32: | 888 case NONE32: |
870 case NONE64: | 889 case NONE64: |
871 break; | 890 break; |
872 case NUMBER_OF_MODES: | 891 case NUMBER_OF_MODES: |
873 UNREACHABLE(); | 892 UNREACHABLE(); |
874 break; | 893 break; |
875 case CODE_AGE_SEQUENCE: | 894 case CODE_AGE_SEQUENCE: |
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1591 assembler_->RecordRelocInfo(RelocInfo::POSITION, state_.current_position); | 1610 assembler_->RecordRelocInfo(RelocInfo::POSITION, state_.current_position); |
1592 state_.written_position = state_.current_position; | 1611 state_.written_position = state_.current_position; |
1593 written = true; | 1612 written = true; |
1594 } | 1613 } |
1595 | 1614 |
1596 // Return whether something was written. | 1615 // Return whether something was written. |
1597 return written; | 1616 return written; |
1598 } | 1617 } |
1599 | 1618 |
1600 } } // namespace v8::internal | 1619 } } // namespace v8::internal |
OLD | NEW |