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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
342 // possible break locations. kNoPosition is used to indicate an | 342 // possible break locations. kNoPosition is used to indicate an |
343 // invalid/uninitialized position value. | 343 // invalid/uninitialized position value. |
344 static const int kNoPosition = -1; | 344 static const int kNoPosition = -1; |
345 | 345 |
346 // This string is used to add padding comments to the reloc info in cases | 346 // This string is used to add padding comments to the reloc info in cases |
347 // where we are not sure to have enough space for patching in during | 347 // where we are not sure to have enough space for patching in during |
348 // lazy deoptimization. This is the case if we have indirect calls for which | 348 // lazy deoptimization. This is the case if we have indirect calls for which |
349 // we do not normally record relocation info. | 349 // we do not normally record relocation info. |
350 static const char* const kFillerCommentString; | 350 static const char* const kFillerCommentString; |
351 | 351 |
352 // The minimum size of a comment is equal to three bytes for the extra tagged | 352 // The minimum size of a comment is equal to three bytes for the extra tagged |
Michael Starzinger
2015/07/10 11:22:37
nit: s/three/two/
| |
353 // pc + the tag for the data, and kPointerSize for the actual pointer to the | 353 // pc + the tag for the data, and kPointerSize for the actual pointer to the |
354 // comment. | 354 // comment. |
355 static const int kMinRelocCommentSize = 3 + kPointerSize; | 355 static const int kMinRelocCommentSize = 2 + kPointerSize; |
356 | 356 |
357 // The maximum size for a call instruction including pc-jump. | 357 // The maximum size for a call instruction including pc-jump. |
358 static const int kMaxCallSize = 6; | 358 static const int kMaxCallSize = 6; |
359 | 359 |
360 // The maximum pc delta that will use the short encoding. | 360 // The maximum pc delta that will use the short encoding. |
361 static const int kMaxSmallPCDelta; | 361 static const int kMaxSmallPCDelta; |
362 | 362 |
363 enum Mode { | 363 enum Mode { |
364 // Please note the order is important (see IsCodeTarget, IsGCRelocMode). | 364 // Please note the order is important (see IsCodeTarget, IsGCRelocMode). |
365 CODE_TARGET, // Code target which is not any of the above. | 365 CODE_TARGET, // Code target which is not any of the above. |
(...skipping 16 matching lines...) Expand all Loading... | |
382 // Encoded internal reference, used only on MIPS, MIPS64 and PPC. | 382 // Encoded internal reference, used only on MIPS, MIPS64 and PPC. |
383 INTERNAL_REFERENCE_ENCODED, | 383 INTERNAL_REFERENCE_ENCODED, |
384 | 384 |
385 // Marks constant and veneer pools. Only used on ARM and ARM64. | 385 // Marks constant and veneer pools. Only used on ARM and ARM64. |
386 // They use a custom noncompact encoding. | 386 // They use a custom noncompact encoding. |
387 CONST_POOL, | 387 CONST_POOL, |
388 VENEER_POOL, | 388 VENEER_POOL, |
389 | 389 |
390 DEOPT_REASON, // Deoptimization reason index. | 390 DEOPT_REASON, // Deoptimization reason index. |
391 | 391 |
392 // add more as needed | 392 PC_JUMP, // Used to encode long pc jumps. |
393 | |
393 // Pseudo-types | 394 // Pseudo-types |
394 NUMBER_OF_MODES, // There are at most 15 modes with noncompact encoding. | 395 NUMBER_OF_MODES, |
395 NONE32, // never recorded 32-bit value | 396 NONE32, // never recorded 32-bit value |
396 NONE64, // never recorded 64-bit value | 397 NONE64, // never recorded 64-bit value |
397 CODE_AGE_SEQUENCE, // Not stored in RelocInfo array, used explictly by | 398 CODE_AGE_SEQUENCE, // Not stored in RelocInfo array, used explictly by |
398 // code aging. | 399 // code aging. |
399 | 400 |
400 FIRST_REAL_RELOC_MODE = CODE_TARGET, | 401 FIRST_REAL_RELOC_MODE = CODE_TARGET, |
401 LAST_REAL_RELOC_MODE = VENEER_POOL, | 402 LAST_REAL_RELOC_MODE = VENEER_POOL, |
402 FIRST_PSEUDO_RELOC_MODE = CODE_AGE_SEQUENCE, | |
403 LAST_PSEUDO_RELOC_MODE = CODE_AGE_SEQUENCE, | |
404 LAST_CODE_ENUM = DEBUG_BREAK, | 403 LAST_CODE_ENUM = DEBUG_BREAK, |
405 LAST_GCED_ENUM = CELL, | 404 LAST_GCED_ENUM = CELL, |
406 // Modes <= LAST_COMPACT_ENUM are guaranteed to have compact encoding. | |
407 LAST_COMPACT_ENUM = CODE_TARGET_WITH_ID, | |
408 LAST_STANDARD_NONCOMPACT_ENUM = INTERNAL_REFERENCE_ENCODED | |
409 }; | 405 }; |
410 | 406 |
411 RelocInfo() {} | 407 RelocInfo() {} |
412 | 408 |
413 RelocInfo(byte* pc, Mode rmode, intptr_t data, Code* host) | 409 RelocInfo(byte* pc, Mode rmode, intptr_t data, Code* host) |
414 : pc_(pc), rmode_(rmode), data_(data), host_(host) { | 410 : pc_(pc), rmode_(rmode), data_(data), host_(host) { |
415 } | 411 } |
416 | 412 |
417 static inline bool IsRealRelocMode(Mode mode) { | 413 static inline bool IsRealRelocMode(Mode mode) { |
418 return mode >= FIRST_REAL_RELOC_MODE && | 414 return mode >= FIRST_REAL_RELOC_MODE && |
419 mode <= LAST_REAL_RELOC_MODE; | 415 mode <= LAST_REAL_RELOC_MODE; |
420 } | 416 } |
421 static inline bool IsPseudoRelocMode(Mode mode) { | |
422 DCHECK(!IsRealRelocMode(mode)); | |
423 return mode >= FIRST_PSEUDO_RELOC_MODE && | |
424 mode <= LAST_PSEUDO_RELOC_MODE; | |
425 } | |
426 static inline bool IsConstructCall(Mode mode) { | 417 static inline bool IsConstructCall(Mode mode) { |
427 return mode == CONSTRUCT_CALL; | 418 return mode == CONSTRUCT_CALL; |
428 } | 419 } |
429 static inline bool IsCodeTarget(Mode mode) { | 420 static inline bool IsCodeTarget(Mode mode) { |
430 return mode <= LAST_CODE_ENUM; | 421 return mode <= LAST_CODE_ENUM; |
431 } | 422 } |
432 static inline bool IsEmbeddedObject(Mode mode) { | 423 static inline bool IsEmbeddedObject(Mode mode) { |
433 return mode == EMBEDDED_OBJECT; | 424 return mode == EMBEDDED_OBJECT; |
434 } | 425 } |
435 static inline bool IsCell(Mode mode) { return mode == CELL; } | 426 static inline bool IsCell(Mode mode) { return mode == CELL; } |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
679 // Update the state of the stream after reloc info buffer | 670 // Update the state of the stream after reloc info buffer |
680 // and/or code is moved while the stream is active. | 671 // and/or code is moved while the stream is active. |
681 void Reposition(byte* pos, byte* pc) { | 672 void Reposition(byte* pos, byte* pc) { |
682 pos_ = pos; | 673 pos_ = pos; |
683 last_pc_ = pc; | 674 last_pc_ = pc; |
684 } | 675 } |
685 | 676 |
686 void Finish() { FlushPosition(); } | 677 void Finish() { FlushPosition(); } |
687 | 678 |
688 // Max size (bytes) of a written RelocInfo. Longest encoding is | 679 // Max size (bytes) of a written RelocInfo. Longest encoding is |
689 // ExtraTag, VariableLengthPCJump, ExtraTag, pc_delta, ExtraTag, data_delta. | 680 // ExtraTag, VariableLengthPCJump, ExtraTag, pc_delta, data_delta. |
690 // On ia32 and arm this is 1 + 4 + 1 + 1 + 1 + 4 = 12. | 681 // On ia32 and arm this is 1 + 4 + 1 + 1 + 4 = 11. |
691 // On x64 this is 1 + 4 + 1 + 1 + 1 + 8 == 16; | 682 // On x64 this is 1 + 4 + 1 + 1 + 8 == 15; |
692 // Here we use the maximum of the two. | 683 // Here we use the maximum of the two. |
693 static const int kMaxSize = 16; | 684 static const int kMaxSize = 15; |
694 | 685 |
695 private: | 686 private: |
696 inline uint32_t WriteVariableLengthPCJump(uint32_t pc_delta); | 687 inline uint32_t WriteLongPCJump(uint32_t pc_delta); |
697 inline void WriteTaggedPC(uint32_t pc_delta, int tag); | 688 |
698 inline void WriteExtraTaggedPC(uint32_t pc_delta, int extra_tag); | 689 inline void WriteShortTaggedPC(uint32_t pc_delta, int tag); |
699 inline void WriteInt(int number); | 690 inline void WriteShortTaggedData(intptr_t data_delta, int tag); |
700 inline void WriteDebugBreakSlotData(int data); | 691 |
701 inline void WriteExtraTaggedIntData(int data_delta, int top_tag); | 692 inline void WriteMode(RelocInfo::Mode rmode); |
702 inline void WriteExtraTaggedPoolData(int data, int pool_type); | 693 inline void WriteModeAndPC(uint32_t pc_delta, RelocInfo::Mode rmode); |
703 inline void WriteExtraTaggedData(intptr_t data_delta, int top_tag); | 694 inline void WriteIntData(int data_delta); |
704 inline void WriteTaggedData(intptr_t data_delta, int tag); | 695 inline void WriteData(intptr_t data_delta); |
705 inline void WriteExtraTag(int extra_tag, int top_tag); | |
706 inline void WritePosition(int pc_delta, int pos_delta, RelocInfo::Mode rmode); | 696 inline void WritePosition(int pc_delta, int pos_delta, RelocInfo::Mode rmode); |
707 | 697 |
708 void FlushPosition(); | 698 void FlushPosition(); |
709 | 699 |
710 byte* pos_; | 700 byte* pos_; |
711 byte* last_pc_; | 701 byte* last_pc_; |
712 int last_id_; | 702 int last_id_; |
713 int last_position_; | 703 int last_position_; |
714 RelocInfo::Mode last_mode_; | 704 RelocInfo::Mode last_mode_; |
715 int next_position_candidate_pos_delta_; | 705 int next_position_candidate_pos_delta_; |
(...skipping 30 matching lines...) Expand all Loading... | |
746 DCHECK(!done()); | 736 DCHECK(!done()); |
747 return &rinfo_; | 737 return &rinfo_; |
748 } | 738 } |
749 | 739 |
750 private: | 740 private: |
751 // Advance* moves the position before/after reading. | 741 // Advance* moves the position before/after reading. |
752 // *Read* reads from current byte(s) into rinfo_. | 742 // *Read* reads from current byte(s) into rinfo_. |
753 // *Get* just reads and returns info on current byte. | 743 // *Get* just reads and returns info on current byte. |
754 void Advance(int bytes = 1) { pos_ -= bytes; } | 744 void Advance(int bytes = 1) { pos_ -= bytes; } |
755 int AdvanceGetTag(); | 745 int AdvanceGetTag(); |
756 int GetExtraTag(); | 746 RelocInfo::Mode GetMode(); |
757 int GetTopTag(); | 747 |
758 void ReadTaggedPC(); | 748 void AdvanceReadLongPCJump(); |
749 | |
750 int GetShortDataTypeTag(); | |
751 void ReadShortTaggedPC(); | |
752 void ReadShortTaggedId(); | |
753 void ReadShortTaggedPosition(); | |
754 void ReadShortTaggedData(); | |
755 | |
759 void AdvanceReadPC(); | 756 void AdvanceReadPC(); |
760 void AdvanceReadId(); | 757 void AdvanceReadId(); |
761 void AdvanceReadInt(); | 758 void AdvanceReadInt(); |
762 void AdvanceReadPoolData(); | |
763 void AdvanceReadDebugBreakSlotData(); | |
764 void AdvanceReadPosition(); | 759 void AdvanceReadPosition(); |
765 void AdvanceReadData(); | 760 void AdvanceReadData(); |
766 void AdvanceReadVariableLengthPCJump(); | |
767 int GetLocatableTypeTag(); | |
768 void ReadTaggedId(); | |
769 void ReadTaggedPosition(); | |
770 void ReadTaggedData(); | |
771 | 761 |
772 // If the given mode is wanted, set it in rinfo_ and return true. | 762 // If the given mode is wanted, set it in rinfo_ and return true. |
773 // Else return false. Used for efficiently skipping unwanted modes. | 763 // Else return false. Used for efficiently skipping unwanted modes. |
774 bool SetMode(RelocInfo::Mode mode) { | 764 bool SetMode(RelocInfo::Mode mode) { |
775 return (mode_mask_ & (1 << mode)) ? (rinfo_.rmode_ = mode, true) : false; | 765 return (mode_mask_ & (1 << mode)) ? (rinfo_.rmode_ = mode, true) : false; |
776 } | 766 } |
777 | 767 |
778 byte* pos_; | 768 byte* pos_; |
779 byte* end_; | 769 byte* end_; |
780 byte* code_age_sequence_; | 770 byte* code_age_sequence_; |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1257 }; | 1247 }; |
1258 | 1248 |
1259 Label emitted_label_; // Records pc_offset of emitted pool | 1249 Label emitted_label_; // Records pc_offset of emitted pool |
1260 PerTypeEntryInfo info_[ConstantPoolEntry::NUMBER_OF_TYPES]; | 1250 PerTypeEntryInfo info_[ConstantPoolEntry::NUMBER_OF_TYPES]; |
1261 }; | 1251 }; |
1262 | 1252 |
1263 | 1253 |
1264 } } // namespace v8::internal | 1254 } } // namespace v8::internal |
1265 | 1255 |
1266 #endif // V8_ASSEMBLER_H_ | 1256 #endif // V8_ASSEMBLER_H_ |
OLD | NEW |