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

Side by Side Diff: src/assembler.h

Issue 2021323003: [wasm] remove faux code objects Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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 | « src/arm64/assembler-arm64-inl.h ('k') | 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 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 // They use a custom noncompact encoding. 414 // They use a custom noncompact encoding.
415 CONST_POOL, 415 CONST_POOL,
416 VENEER_POOL, 416 VENEER_POOL,
417 417
418 DEOPT_REASON, // Deoptimization reason index. 418 DEOPT_REASON, // Deoptimization reason index.
419 DEOPT_ID, // Deoptimization inlining id. 419 DEOPT_ID, // Deoptimization inlining id.
420 420
421 // This is not an actual reloc mode, but used to encode a long pc jump that 421 // This is not an actual reloc mode, but used to encode a long pc jump that
422 // cannot be encoded as part of another record. 422 // cannot be encoded as part of another record.
423 PC_JUMP, 423 PC_JUMP,
424 424 WASM_DIRECT_CALL,
425 WASM_IMPORT_CALL,
425 // Pseudo-types 426 // Pseudo-types
426 NUMBER_OF_MODES, 427 NUMBER_OF_MODES,
427 NONE32, // never recorded 32-bit value 428 NONE32, // never recorded 32-bit value
428 NONE64, // never recorded 64-bit value 429 NONE64, // never recorded 64-bit value
429 CODE_AGE_SEQUENCE, // Not stored in RelocInfo array, used explictly by 430 CODE_AGE_SEQUENCE, // Not stored in RelocInfo array, used explictly by
430 // code aging. 431 // code aging.
431 432
432 FIRST_REAL_RELOC_MODE = CODE_TARGET, 433 FIRST_REAL_RELOC_MODE = CODE_TARGET,
433 LAST_REAL_RELOC_MODE = VENEER_POOL, 434 LAST_REAL_RELOC_MODE = VENEER_POOL,
434 LAST_CODE_ENUM = DEBUGGER_STATEMENT, 435 LAST_CODE_ENUM = DEBUGGER_STATEMENT,
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 } 523 }
523 static inline bool IsGeneratorContinuation(Mode mode) { 524 static inline bool IsGeneratorContinuation(Mode mode) {
524 return mode == GENERATOR_CONTINUATION; 525 return mode == GENERATOR_CONTINUATION;
525 } 526 }
526 static inline bool IsWasmMemoryReference(Mode mode) { 527 static inline bool IsWasmMemoryReference(Mode mode) {
527 return mode == WASM_MEMORY_REFERENCE; 528 return mode == WASM_MEMORY_REFERENCE;
528 } 529 }
529 static inline bool IsWasmMemorySizeReference(Mode mode) { 530 static inline bool IsWasmMemorySizeReference(Mode mode) {
530 return mode == WASM_MEMORY_SIZE_REFERENCE; 531 return mode == WASM_MEMORY_SIZE_REFERENCE;
531 } 532 }
533 static inline bool IsWasmCall(Mode mode) {
534 return mode == WASM_DIRECT_CALL || mode == WASM_IMPORT_CALL;
535 }
532 static inline int ModeMask(Mode mode) { return 1 << mode; } 536 static inline int ModeMask(Mode mode) { return 1 << mode; }
533 537
534 // Accessors 538 // Accessors
535 Isolate* isolate() const { return isolate_; } 539 Isolate* isolate() const { return isolate_; }
536 byte* pc() const { return pc_; } 540 byte* pc() const { return pc_; }
537 void set_pc(byte* pc) { pc_ = pc; } 541 void set_pc(byte* pc) { pc_ = pc; }
538 Mode rmode() const { return rmode_; } 542 Mode rmode() const { return rmode_; }
539 intptr_t data() const { return data_; } 543 intptr_t data() const { return data_; }
540 Code* host() const { return host_; } 544 Code* host() const { return host_; }
541 void set_host(Code* host) { host_ = host; } 545 void set_host(Code* host) { host_ = host; }
542 546
543 // Apply a relocation by delta bytes. When the code object is moved, PC 547 // Apply a relocation by delta bytes. When the code object is moved, PC
544 // relative addresses have to be updated as well as absolute addresses 548 // relative addresses have to be updated as well as absolute addresses
545 // inside the code (internal references). 549 // inside the code (internal references).
546 // Do not forget to flush the icache afterwards! 550 // Do not forget to flush the icache afterwards!
547 INLINE(void apply(intptr_t delta)); 551 INLINE(void apply(intptr_t delta));
548 552
549 // Is the pointer this relocation info refers to coded like a plain pointer 553 // Is the pointer this relocation info refers to coded like a plain pointer
550 // or is it strange in some way (e.g. relative or patched into a series of 554 // or is it strange in some way (e.g. relative or patched into a series of
551 // instructions). 555 // instructions).
552 bool IsCodedSpecially(); 556 bool IsCodedSpecially();
553 557
554 // If true, the pointer this relocation info refers to is an entry in the 558 // If true, the pointer this relocation info refers to is an entry in the
555 // constant pool, otherwise the pointer is embedded in the instruction stream. 559 // constant pool, otherwise the pointer is embedded in the instruction stream.
556 bool IsInConstantPool(); 560 bool IsInConstantPool();
557 561
558 Address wasm_memory_reference(); 562 Address wasm_memory_reference();
559 uint32_t wasm_memory_size_reference(); 563 uint32_t wasm_memory_size_reference();
564 uint32_t wasm_function_index();
565
560 void update_wasm_memory_reference( 566 void update_wasm_memory_reference(
561 Address old_base, Address new_base, uint32_t old_size, uint32_t new_size, 567 Address old_base, Address new_base, uint32_t old_size, uint32_t new_size,
562 ICacheFlushMode icache_flush_mode = SKIP_ICACHE_FLUSH); 568 ICacheFlushMode icache_flush_mode = SKIP_ICACHE_FLUSH);
563 569
564 // this relocation applies to; 570 // this relocation applies to;
565 // can only be called if IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_) 571 // can only be called if IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)
566 INLINE(Address target_address()); 572 INLINE(Address target_address());
567 INLINE(void set_target_address(Address target, 573 INLINE(void set_target_address(Address target,
568 WriteBarrierMode write_barrier_mode = 574 WriteBarrierMode write_barrier_mode =
569 UPDATE_WRITE_BARRIER, 575 UPDATE_WRITE_BARRIER,
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 #ifdef ENABLE_DISASSEMBLER 664 #ifdef ENABLE_DISASSEMBLER
659 // Printing 665 // Printing
660 static const char* RelocModeName(Mode rmode); 666 static const char* RelocModeName(Mode rmode);
661 void Print(Isolate* isolate, std::ostream& os); // NOLINT 667 void Print(Isolate* isolate, std::ostream& os); // NOLINT
662 #endif // ENABLE_DISASSEMBLER 668 #endif // ENABLE_DISASSEMBLER
663 #ifdef VERIFY_HEAP 669 #ifdef VERIFY_HEAP
664 void Verify(Isolate* isolate); 670 void Verify(Isolate* isolate);
665 #endif 671 #endif
666 672
667 static const int kCodeTargetMask = (1 << (LAST_CODE_ENUM + 1)) - 1; 673 static const int kCodeTargetMask = (1 << (LAST_CODE_ENUM + 1)) - 1;
674 static const int kWasmDirectCallMask = 1 << WASM_DIRECT_CALL;
675 static const int kWasmImportCallMask = 1 << WASM_IMPORT_CALL;
668 static const int kPositionMask = 1 << POSITION | 1 << STATEMENT_POSITION; 676 static const int kPositionMask = 1 << POSITION | 1 << STATEMENT_POSITION;
669 static const int kDataMask = 677 static const int kDataMask =
670 (1 << CODE_TARGET_WITH_ID) | kPositionMask | (1 << COMMENT); 678 (1 << CODE_TARGET_WITH_ID) | kPositionMask | (1 << COMMENT);
671 static const int kDebugBreakSlotMask = 1 << DEBUG_BREAK_SLOT_AT_POSITION | 679 static const int kDebugBreakSlotMask = 1 << DEBUG_BREAK_SLOT_AT_POSITION |
672 1 << DEBUG_BREAK_SLOT_AT_RETURN | 680 1 << DEBUG_BREAK_SLOT_AT_RETURN |
673 1 << DEBUG_BREAK_SLOT_AT_CALL; 681 1 << DEBUG_BREAK_SLOT_AT_CALL;
674 static const int kApplyMask; // Modes affected by apply. Depends on arch. 682 static const int kApplyMask; // Modes affected by apply. Depends on arch.
675 683
676 private: 684 private:
677 Isolate* isolate_; 685 Isolate* isolate_;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 732
725 void Finish() { FlushPosition(); } 733 void Finish() { FlushPosition(); }
726 734
727 // Max size (bytes) of a written RelocInfo. Longest encoding is 735 // Max size (bytes) of a written RelocInfo. Longest encoding is
728 // ExtraTag, VariableLengthPCJump, ExtraTag, pc_delta, data_delta. 736 // ExtraTag, VariableLengthPCJump, ExtraTag, pc_delta, data_delta.
729 // On ia32 and arm this is 1 + 4 + 1 + 1 + 4 = 11. 737 // On ia32 and arm this is 1 + 4 + 1 + 1 + 4 = 11.
730 // On x64 this is 1 + 4 + 1 + 1 + 8 == 15; 738 // On x64 this is 1 + 4 + 1 + 1 + 8 == 15;
731 // Here we use the maximum of the two. 739 // Here we use the maximum of the two.
732 static const int kMaxSize = 15; 740 static const int kMaxSize = 15;
733 741
742 // Update the mode. This should be used carefully, the new mode should have
743 // the same schema as the old one.
744 void WriteModeNoAdvance(RelocInfo::Mode rmode);
745
734 private: 746 private:
735 inline uint32_t WriteLongPCJump(uint32_t pc_delta); 747 inline uint32_t WriteLongPCJump(uint32_t pc_delta);
736 748
737 inline void WriteShortTaggedPC(uint32_t pc_delta, int tag); 749 inline void WriteShortTaggedPC(uint32_t pc_delta, int tag);
738 inline void WriteShortTaggedData(intptr_t data_delta, int tag); 750 inline void WriteShortTaggedData(intptr_t data_delta, int tag);
739 751
740 inline void WriteMode(RelocInfo::Mode rmode); 752 inline void WriteMode(RelocInfo::Mode rmode);
741 inline void WriteModeAndPC(uint32_t pc_delta, RelocInfo::Mode rmode); 753 inline void WriteModeAndPC(uint32_t pc_delta, RelocInfo::Mode rmode);
742 inline void WriteIntData(int data_delta); 754 inline void WriteIntData(int data_delta);
743 inline void WriteData(intptr_t data_delta); 755 inline void WriteData(intptr_t data_delta);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 // Iteration 790 // Iteration
779 bool done() const { return done_; } 791 bool done() const { return done_; }
780 void next(); 792 void next();
781 793
782 // Return pointer valid until next next(). 794 // Return pointer valid until next next().
783 RelocInfo* rinfo() { 795 RelocInfo* rinfo() {
784 DCHECK(!done()); 796 DCHECK(!done());
785 return &rinfo_; 797 return &rinfo_;
786 } 798 }
787 799
800 byte* mode_pos() const { return mode_pos_; }
801
788 private: 802 private:
789 // Advance* moves the position before/after reading. 803 // Advance* moves the position before/after reading.
790 // *Read* reads from current byte(s) into rinfo_. 804 // *Read* reads from current byte(s) into rinfo_.
791 // *Get* just reads and returns info on current byte. 805 // *Get* just reads and returns info on current byte.
792 void Advance(int bytes = 1) { pos_ -= bytes; } 806 void Advance(int bytes = 1) { pos_ -= bytes; }
793 int AdvanceGetTag(); 807 int AdvanceGetTag();
794 RelocInfo::Mode GetMode(); 808 RelocInfo::Mode GetMode();
795 809
796 void AdvanceReadLongPCJump(); 810 void AdvanceReadLongPCJump();
797 811
798 int GetShortDataTypeTag(); 812 int GetShortDataTypeTag();
799 void ReadShortTaggedPC(); 813 void ReadShortTaggedPC();
800 void ReadShortTaggedId(); 814 void ReadShortTaggedId();
801 void ReadShortTaggedPosition(); 815 void ReadShortTaggedPosition();
802 void ReadShortTaggedData(); 816 void ReadShortTaggedData();
803 817
804 void AdvanceReadPC(); 818 void AdvanceReadPC();
805 void AdvanceReadId(); 819 void AdvanceReadId();
806 void AdvanceReadInt(); 820 void AdvanceReadInt();
807 void AdvanceReadPosition(); 821 void AdvanceReadPosition();
808 void AdvanceReadData(); 822 void AdvanceReadData();
809 823
810 // If the given mode is wanted, set it in rinfo_ and return true. 824 // If the given mode is wanted, set it in rinfo_ and return true.
811 // Else return false. Used for efficiently skipping unwanted modes. 825 // Else return false. Used for efficiently skipping unwanted modes.
812 bool SetMode(RelocInfo::Mode mode) { 826 bool SetMode(RelocInfo::Mode mode) {
813 return (mode_mask_ & (1 << mode)) ? (rinfo_.rmode_ = mode, true) : false; 827 return (mode_mask_ & (1 << mode)) ? (rinfo_.rmode_ = mode, true) : false;
814 } 828 }
815 829
816 byte* pos_; 830 byte* pos_;
831 byte* mode_pos_;
817 byte* end_; 832 byte* end_;
818 byte* code_age_sequence_; 833 byte* code_age_sequence_;
819 RelocInfo rinfo_; 834 RelocInfo rinfo_;
820 bool done_; 835 bool done_;
821 int mode_mask_; 836 int mode_mask_;
822 int last_id_; 837 int last_id_;
823 int last_position_; 838 int last_position_;
824 DISALLOW_COPY_AND_ASSIGN(RelocIterator); 839 DISALLOW_COPY_AND_ASSIGN(RelocIterator);
825 }; 840 };
826 841
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
1338 std::vector<ConstantPoolEntry> shared_entries; 1353 std::vector<ConstantPoolEntry> shared_entries;
1339 }; 1354 };
1340 1355
1341 Label emitted_label_; // Records pc_offset of emitted pool 1356 Label emitted_label_; // Records pc_offset of emitted pool
1342 PerTypeEntryInfo info_[ConstantPoolEntry::NUMBER_OF_TYPES]; 1357 PerTypeEntryInfo info_[ConstantPoolEntry::NUMBER_OF_TYPES];
1343 }; 1358 };
1344 1359
1345 } // namespace internal 1360 } // namespace internal
1346 } // namespace v8 1361 } // namespace v8
1347 #endif // V8_ASSEMBLER_H_ 1362 #endif // V8_ASSEMBLER_H_
OLDNEW
« no previous file with comments | « src/arm64/assembler-arm64-inl.h ('k') | src/assembler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698