Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: src/assembler.h

Issue 1230183002: Change and simplify RelocInfo format. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix typo Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/assembler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 two bytes for the extra tagged
353 // pc + the tag for the data, and kPointerSize for the actual pointer to the 353 // pc and kPointerSize for the actual pointer to the comment.
354 // comment. 354 static const int kMinRelocCommentSize = 2 + kPointerSize;
355 static const int kMinRelocCommentSize = 3 + kPointerSize;
356 355
357 // The maximum size for a call instruction including pc-jump. 356 // The maximum size for a call instruction including pc-jump.
358 static const int kMaxCallSize = 6; 357 static const int kMaxCallSize = 6;
359 358
360 // The maximum pc delta that will use the short encoding. 359 // The maximum pc delta that will use the short encoding.
361 static const int kMaxSmallPCDelta; 360 static const int kMaxSmallPCDelta;
362 361
363 enum Mode { 362 enum Mode {
364 // Please note the order is important (see IsCodeTarget, IsGCRelocMode). 363 // Please note the order is important (see IsCodeTarget, IsGCRelocMode).
365 CODE_TARGET, // Code target which is not any of the above. 364 CODE_TARGET, // Code target which is not any of the above.
(...skipping 14 matching lines...) Expand all
380 INTERNAL_REFERENCE, // An address inside the same function. 379 INTERNAL_REFERENCE, // An address inside the same function.
381 380
382 // Encoded internal reference, used only on MIPS, MIPS64 and PPC. 381 // Encoded internal reference, used only on MIPS, MIPS64 and PPC.
383 INTERNAL_REFERENCE_ENCODED, 382 INTERNAL_REFERENCE_ENCODED,
384 383
385 // Marks constant and veneer pools. Only used on ARM and ARM64. 384 // Marks constant and veneer pools. Only used on ARM and ARM64.
386 // They use a custom noncompact encoding. 385 // They use a custom noncompact encoding.
387 CONST_POOL, 386 CONST_POOL,
388 VENEER_POOL, 387 VENEER_POOL,
389 388
390 DEOPT_REASON, // Deoptimization reason index. 389 DEOPT_REASON, // Deoptimization reason index.
391 390
392 // add more as needed 391 // This is not an actual reloc mode, but used to encode a long pc jump that
392 // cannot be encoded as part of another record.
393 PC_JUMP,
394
393 // Pseudo-types 395 // Pseudo-types
394 NUMBER_OF_MODES, // There are at most 15 modes with noncompact encoding. 396 NUMBER_OF_MODES,
395 NONE32, // never recorded 32-bit value 397 NONE32, // never recorded 32-bit value
396 NONE64, // never recorded 64-bit value 398 NONE64, // never recorded 64-bit value
397 CODE_AGE_SEQUENCE, // Not stored in RelocInfo array, used explictly by 399 CODE_AGE_SEQUENCE, // Not stored in RelocInfo array, used explictly by
398 // code aging. 400 // code aging.
399 401
400 FIRST_REAL_RELOC_MODE = CODE_TARGET, 402 FIRST_REAL_RELOC_MODE = CODE_TARGET,
401 LAST_REAL_RELOC_MODE = VENEER_POOL, 403 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, 404 LAST_CODE_ENUM = DEBUG_BREAK,
405 LAST_GCED_ENUM = CELL, 405 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 }; 406 };
410 407
411 RelocInfo() {} 408 RelocInfo() {}
412 409
413 RelocInfo(byte* pc, Mode rmode, intptr_t data, Code* host) 410 RelocInfo(byte* pc, Mode rmode, intptr_t data, Code* host)
414 : pc_(pc), rmode_(rmode), data_(data), host_(host) { 411 : pc_(pc), rmode_(rmode), data_(data), host_(host) {
415 } 412 }
416 413
417 static inline bool IsRealRelocMode(Mode mode) { 414 static inline bool IsRealRelocMode(Mode mode) {
418 return mode >= FIRST_REAL_RELOC_MODE && 415 return mode >= FIRST_REAL_RELOC_MODE &&
419 mode <= LAST_REAL_RELOC_MODE; 416 mode <= LAST_REAL_RELOC_MODE;
420 } 417 }
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) { 418 static inline bool IsConstructCall(Mode mode) {
427 return mode == CONSTRUCT_CALL; 419 return mode == CONSTRUCT_CALL;
428 } 420 }
429 static inline bool IsCodeTarget(Mode mode) { 421 static inline bool IsCodeTarget(Mode mode) {
430 return mode <= LAST_CODE_ENUM; 422 return mode <= LAST_CODE_ENUM;
431 } 423 }
432 static inline bool IsEmbeddedObject(Mode mode) { 424 static inline bool IsEmbeddedObject(Mode mode) {
433 return mode == EMBEDDED_OBJECT; 425 return mode == EMBEDDED_OBJECT;
434 } 426 }
435 static inline bool IsCell(Mode mode) { return mode == CELL; } 427 static inline bool IsCell(Mode mode) { return mode == CELL; }
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 // Update the state of the stream after reloc info buffer 671 // Update the state of the stream after reloc info buffer
680 // and/or code is moved while the stream is active. 672 // and/or code is moved while the stream is active.
681 void Reposition(byte* pos, byte* pc) { 673 void Reposition(byte* pos, byte* pc) {
682 pos_ = pos; 674 pos_ = pos;
683 last_pc_ = pc; 675 last_pc_ = pc;
684 } 676 }
685 677
686 void Finish() { FlushPosition(); } 678 void Finish() { FlushPosition(); }
687 679
688 // Max size (bytes) of a written RelocInfo. Longest encoding is 680 // Max size (bytes) of a written RelocInfo. Longest encoding is
689 // ExtraTag, VariableLengthPCJump, ExtraTag, pc_delta, ExtraTag, data_delta. 681 // ExtraTag, VariableLengthPCJump, ExtraTag, pc_delta, data_delta.
690 // On ia32 and arm this is 1 + 4 + 1 + 1 + 1 + 4 = 12. 682 // On ia32 and arm this is 1 + 4 + 1 + 1 + 4 = 11.
691 // On x64 this is 1 + 4 + 1 + 1 + 1 + 8 == 16; 683 // On x64 this is 1 + 4 + 1 + 1 + 8 == 15;
692 // Here we use the maximum of the two. 684 // Here we use the maximum of the two.
693 static const int kMaxSize = 16; 685 static const int kMaxSize = 15;
694 686
695 private: 687 private:
696 inline uint32_t WriteVariableLengthPCJump(uint32_t pc_delta); 688 inline uint32_t WriteLongPCJump(uint32_t pc_delta);
697 inline void WriteTaggedPC(uint32_t pc_delta, int tag); 689
698 inline void WriteExtraTaggedPC(uint32_t pc_delta, int extra_tag); 690 inline void WriteShortTaggedPC(uint32_t pc_delta, int tag);
699 inline void WriteInt(int number); 691 inline void WriteShortTaggedData(intptr_t data_delta, int tag);
700 inline void WriteDebugBreakSlotData(int data); 692
701 inline void WriteExtraTaggedIntData(int data_delta, int top_tag); 693 inline void WriteMode(RelocInfo::Mode rmode);
702 inline void WriteExtraTaggedPoolData(int data, int pool_type); 694 inline void WriteModeAndPC(uint32_t pc_delta, RelocInfo::Mode rmode);
703 inline void WriteExtraTaggedData(intptr_t data_delta, int top_tag); 695 inline void WriteIntData(int data_delta);
704 inline void WriteTaggedData(intptr_t data_delta, int tag); 696 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); 697 inline void WritePosition(int pc_delta, int pos_delta, RelocInfo::Mode rmode);
707 698
708 void FlushPosition(); 699 void FlushPosition();
709 700
710 byte* pos_; 701 byte* pos_;
711 byte* last_pc_; 702 byte* last_pc_;
712 int last_id_; 703 int last_id_;
713 int last_position_; 704 int last_position_;
714 RelocInfo::Mode last_mode_; 705 RelocInfo::Mode last_mode_;
715 int next_position_candidate_pos_delta_; 706 int next_position_candidate_pos_delta_;
(...skipping 30 matching lines...) Expand all
746 DCHECK(!done()); 737 DCHECK(!done());
747 return &rinfo_; 738 return &rinfo_;
748 } 739 }
749 740
750 private: 741 private:
751 // Advance* moves the position before/after reading. 742 // Advance* moves the position before/after reading.
752 // *Read* reads from current byte(s) into rinfo_. 743 // *Read* reads from current byte(s) into rinfo_.
753 // *Get* just reads and returns info on current byte. 744 // *Get* just reads and returns info on current byte.
754 void Advance(int bytes = 1) { pos_ -= bytes; } 745 void Advance(int bytes = 1) { pos_ -= bytes; }
755 int AdvanceGetTag(); 746 int AdvanceGetTag();
756 int GetExtraTag(); 747 RelocInfo::Mode GetMode();
757 int GetTopTag(); 748
758 void ReadTaggedPC(); 749 void AdvanceReadLongPCJump();
750
751 int GetShortDataTypeTag();
752 void ReadShortTaggedPC();
753 void ReadShortTaggedId();
754 void ReadShortTaggedPosition();
755 void ReadShortTaggedData();
756
759 void AdvanceReadPC(); 757 void AdvanceReadPC();
760 void AdvanceReadId(); 758 void AdvanceReadId();
761 void AdvanceReadInt(); 759 void AdvanceReadInt();
762 void AdvanceReadPoolData();
763 void AdvanceReadDebugBreakSlotData();
764 void AdvanceReadPosition(); 760 void AdvanceReadPosition();
765 void AdvanceReadData(); 761 void AdvanceReadData();
766 void AdvanceReadVariableLengthPCJump();
767 int GetLocatableTypeTag();
768 void ReadTaggedId();
769 void ReadTaggedPosition();
770 void ReadTaggedData();
771 762
772 // If the given mode is wanted, set it in rinfo_ and return true. 763 // If the given mode is wanted, set it in rinfo_ and return true.
773 // Else return false. Used for efficiently skipping unwanted modes. 764 // Else return false. Used for efficiently skipping unwanted modes.
774 bool SetMode(RelocInfo::Mode mode) { 765 bool SetMode(RelocInfo::Mode mode) {
775 return (mode_mask_ & (1 << mode)) ? (rinfo_.rmode_ = mode, true) : false; 766 return (mode_mask_ & (1 << mode)) ? (rinfo_.rmode_ = mode, true) : false;
776 } 767 }
777 768
778 byte* pos_; 769 byte* pos_;
779 byte* end_; 770 byte* end_;
780 byte* code_age_sequence_; 771 byte* code_age_sequence_;
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
1257 }; 1248 };
1258 1249
1259 Label emitted_label_; // Records pc_offset of emitted pool 1250 Label emitted_label_; // Records pc_offset of emitted pool
1260 PerTypeEntryInfo info_[ConstantPoolEntry::NUMBER_OF_TYPES]; 1251 PerTypeEntryInfo info_[ConstantPoolEntry::NUMBER_OF_TYPES];
1261 }; 1252 };
1262 1253
1263 1254
1264 } } // namespace v8::internal 1255 } } // namespace v8::internal
1265 1256
1266 #endif // V8_ASSEMBLER_H_ 1257 #endif // V8_ASSEMBLER_H_
OLDNEW
« no previous file with comments | « no previous file | src/assembler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698