oat.h revision 88474b416eb257078e590bf9bc7957cee604a186
12faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes/* 22faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * Copyright (C) 2011 The Android Open Source Project 32faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * 42faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * Licensed under the Apache License, Version 2.0 (the "License"); 52faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * you may not use this file except in compliance with the License. 62faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * You may obtain a copy of the License at 72faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * 82faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * http://www.apache.org/licenses/LICENSE-2.0 92faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * 102faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * Unless required by applicable law or agreed to in writing, software 112faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * distributed under the License is distributed on an "AS IS" BASIS, 122faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 132faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * See the License for the specific language governing permissions and 142faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * limitations under the License. 152faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes */ 16e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom 17fc0e3219edc9a5bf81b166e82fd5db2796eb6a0dBrian Carlstrom#ifndef ART_RUNTIME_OAT_H_ 18fc0e3219edc9a5bf81b166e82fd5db2796eb6a0dBrian Carlstrom#define ART_RUNTIME_OAT_H_ 19e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom 20e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom#include <vector> 21e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom 22761600567d73b23324ae0251e871c15d6849ffd8Elliott Hughes#include "base/macros.h" 23e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom#include "dex_file.h" 240f3c55331439970e01af67f80ac117c473bc04cfElliott Hughes#include "instruction_set.h" 25e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom 26e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstromnamespace art { 27e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom 28df1ce91ba97bc79a0637e5504b39318fb1c9f577Ian Rogersclass PACKED(4) OatHeader { 29e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom public: 307c3d13aebdd8611cae58a1048bffb13cbdc465cbBrian Carlstrom static const uint8_t kOatMagic[4]; 317c3d13aebdd8611cae58a1048bffb13cbdc465cbBrian Carlstrom static const uint8_t kOatVersion[4]; 327c3d13aebdd8611cae58a1048bffb13cbdc465cbBrian Carlstrom 33a72ec820f8cb8e04b0ba87a62e36b05a2c92ef36Elliott Hughes OatHeader(); 3481f3ca17e9e8d360cc4a1b6c3155cf01ba3be3bcBrian Carlstrom OatHeader(InstructionSet instruction_set, 3581f3ca17e9e8d360cc4a1b6c3155cf01ba3be3bcBrian Carlstrom const std::vector<const DexFile*>* dex_files, 3628db0129e5d7ef642cf8845c86c0e11832817085Brian Carlstrom uint32_t image_file_location_oat_checksum, 37700c8d31733534a3d978b75a03f6f7e177dc7e81Brian Carlstrom uint32_t image_file_location_oat_data_begin, 3881f3ca17e9e8d360cc4a1b6c3155cf01ba3be3bcBrian Carlstrom const std::string& image_file_location); 39e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom 40e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom bool IsValid() const; 41e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom const char* GetMagic() const; 42e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom uint32_t GetChecksum() const; 43e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom void UpdateChecksum(const void* data, size_t length); 444f6ad8ab428038129b2d0d6c40b7fd625cca15e1Ian Rogers uint32_t GetDexFileCount() const { 454f6ad8ab428038129b2d0d6c40b7fd625cca15e1Ian Rogers DCHECK(IsValid()); 464f6ad8ab428038129b2d0d6c40b7fd625cca15e1Ian Rogers return dex_file_count_; 474f6ad8ab428038129b2d0d6c40b7fd625cca15e1Ian Rogers } 48e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom uint32_t GetExecutableOffset() const; 49e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom void SetExecutableOffset(uint32_t executable_offset); 50468532ea115657709bc32ee498e701a4c71762d4Ian Rogers 51468532ea115657709bc32ee498e701a4c71762d4Ian Rogers const void* GetInterpreterToInterpreterBridge() const; 52468532ea115657709bc32ee498e701a4c71762d4Ian Rogers uint32_t GetInterpreterToInterpreterBridgeOffset() const; 53468532ea115657709bc32ee498e701a4c71762d4Ian Rogers void SetInterpreterToInterpreterBridgeOffset(uint32_t offset); 54468532ea115657709bc32ee498e701a4c71762d4Ian Rogers const void* GetInterpreterToCompiledCodeBridge() const; 55468532ea115657709bc32ee498e701a4c71762d4Ian Rogers uint32_t GetInterpreterToCompiledCodeBridgeOffset() const; 56468532ea115657709bc32ee498e701a4c71762d4Ian Rogers void SetInterpreterToCompiledCodeBridgeOffset(uint32_t offset); 57468532ea115657709bc32ee498e701a4c71762d4Ian Rogers 58468532ea115657709bc32ee498e701a4c71762d4Ian Rogers const void* GetJniDlsymLookup() const; 59468532ea115657709bc32ee498e701a4c71762d4Ian Rogers uint32_t GetJniDlsymLookupOffset() const; 60468532ea115657709bc32ee498e701a4c71762d4Ian Rogers void SetJniDlsymLookupOffset(uint32_t offset); 61468532ea115657709bc32ee498e701a4c71762d4Ian Rogers 620aba0ba155bef7346bde19e53581200b89ae8a7aJeff Hao const void* GetPortableResolutionTrampoline() const; 630aba0ba155bef7346bde19e53581200b89ae8a7aJeff Hao uint32_t GetPortableResolutionTrampolineOffset() const; 640aba0ba155bef7346bde19e53581200b89ae8a7aJeff Hao void SetPortableResolutionTrampolineOffset(uint32_t offset); 6588474b416eb257078e590bf9bc7957cee604a186Jeff Hao const void* GetPortableImtConflictTrampoline() const; 6688474b416eb257078e590bf9bc7957cee604a186Jeff Hao uint32_t GetPortableImtConflictTrampolineOffset() const; 6788474b416eb257078e590bf9bc7957cee604a186Jeff Hao void SetPortableImtConflictTrampolineOffset(uint32_t offset); 68468532ea115657709bc32ee498e701a4c71762d4Ian Rogers const void* GetPortableToInterpreterBridge() const; 69468532ea115657709bc32ee498e701a4c71762d4Ian Rogers uint32_t GetPortableToInterpreterBridgeOffset() const; 70468532ea115657709bc32ee498e701a4c71762d4Ian Rogers void SetPortableToInterpreterBridgeOffset(uint32_t offset); 71468532ea115657709bc32ee498e701a4c71762d4Ian Rogers 720aba0ba155bef7346bde19e53581200b89ae8a7aJeff Hao const void* GetQuickResolutionTrampoline() const; 730aba0ba155bef7346bde19e53581200b89ae8a7aJeff Hao uint32_t GetQuickResolutionTrampolineOffset() const; 740aba0ba155bef7346bde19e53581200b89ae8a7aJeff Hao void SetQuickResolutionTrampolineOffset(uint32_t offset); 7588474b416eb257078e590bf9bc7957cee604a186Jeff Hao const void* GetQuickImtConflictTrampoline() const; 7688474b416eb257078e590bf9bc7957cee604a186Jeff Hao uint32_t GetQuickImtConflictTrampolineOffset() const; 7788474b416eb257078e590bf9bc7957cee604a186Jeff Hao void SetQuickImtConflictTrampolineOffset(uint32_t offset); 78468532ea115657709bc32ee498e701a4c71762d4Ian Rogers const void* GetQuickToInterpreterBridge() const; 79468532ea115657709bc32ee498e701a4c71762d4Ian Rogers uint32_t GetQuickToInterpreterBridgeOffset() const; 80468532ea115657709bc32ee498e701a4c71762d4Ian Rogers void SetQuickToInterpreterBridgeOffset(uint32_t offset); 81468532ea115657709bc32ee498e701a4c71762d4Ian Rogers 820aba0ba155bef7346bde19e53581200b89ae8a7aJeff Hao InstructionSet GetInstructionSet() const; 8328db0129e5d7ef642cf8845c86c0e11832817085Brian Carlstrom uint32_t GetImageFileLocationOatChecksum() const; 84700c8d31733534a3d978b75a03f6f7e177dc7e81Brian Carlstrom uint32_t GetImageFileLocationOatDataBegin() const; 8581f3ca17e9e8d360cc4a1b6c3155cf01ba3be3bcBrian Carlstrom uint32_t GetImageFileLocationSize() const; 8681f3ca17e9e8d360cc4a1b6c3155cf01ba3be3bcBrian Carlstrom const uint8_t* GetImageFileLocationData() const; 8781f3ca17e9e8d360cc4a1b6c3155cf01ba3be3bcBrian Carlstrom std::string GetImageFileLocation() const; 88e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom 89e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom private: 90e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom uint8_t magic_[4]; 91e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom uint8_t version_[4]; 92e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom uint32_t adler32_checksum_; 93a72ec820f8cb8e04b0ba87a62e36b05a2c92ef36Elliott Hughes 94a72ec820f8cb8e04b0ba87a62e36b05a2c92ef36Elliott Hughes InstructionSet instruction_set_; 95e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom uint32_t dex_file_count_; 96e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom uint32_t executable_offset_; 97468532ea115657709bc32ee498e701a4c71762d4Ian Rogers uint32_t interpreter_to_interpreter_bridge_offset_; 98468532ea115657709bc32ee498e701a4c71762d4Ian Rogers uint32_t interpreter_to_compiled_code_bridge_offset_; 99468532ea115657709bc32ee498e701a4c71762d4Ian Rogers uint32_t jni_dlsym_lookup_offset_; 10088474b416eb257078e590bf9bc7957cee604a186Jeff Hao uint32_t portable_imt_conflict_trampoline_offset_; 1010aba0ba155bef7346bde19e53581200b89ae8a7aJeff Hao uint32_t portable_resolution_trampoline_offset_; 102468532ea115657709bc32ee498e701a4c71762d4Ian Rogers uint32_t portable_to_interpreter_bridge_offset_; 10388474b416eb257078e590bf9bc7957cee604a186Jeff Hao uint32_t quick_imt_conflict_trampoline_offset_; 1040aba0ba155bef7346bde19e53581200b89ae8a7aJeff Hao uint32_t quick_resolution_trampoline_offset_; 105468532ea115657709bc32ee498e701a4c71762d4Ian Rogers uint32_t quick_to_interpreter_bridge_offset_; 106e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom 10728db0129e5d7ef642cf8845c86c0e11832817085Brian Carlstrom uint32_t image_file_location_oat_checksum_; 108700c8d31733534a3d978b75a03f6f7e177dc7e81Brian Carlstrom uint32_t image_file_location_oat_data_begin_; 10981f3ca17e9e8d360cc4a1b6c3155cf01ba3be3bcBrian Carlstrom uint32_t image_file_location_size_; 11081f3ca17e9e8d360cc4a1b6c3155cf01ba3be3bcBrian Carlstrom uint8_t image_file_location_data_[0]; // note variable width data at end 11181f3ca17e9e8d360cc4a1b6c3155cf01ba3be3bcBrian Carlstrom 112e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom DISALLOW_COPY_AND_ASSIGN(OatHeader); 113e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom}; 114e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom 115ba150c37d582eeeb8c11ba5245edc281cf31793cBrian Carlstrom// OatMethodOffsets are currently 7x32-bits=224-bits long, so if we can 116ba150c37d582eeeb8c11ba5245edc281cf31793cBrian Carlstrom// save even one OatMethodOffsets struct, the more complicated encoding 117ba150c37d582eeeb8c11ba5245edc281cf31793cBrian Carlstrom// using a bitmap pays for itself since few classes will have 224 118ba150c37d582eeeb8c11ba5245edc281cf31793cBrian Carlstrom// methods. 119ba150c37d582eeeb8c11ba5245edc281cf31793cBrian Carlstromenum OatClassType { 120ba150c37d582eeeb8c11ba5245edc281cf31793cBrian Carlstrom kOatClassAllCompiled = 0, // OatClass is followed by an OatMethodOffsets for each method. 121ba150c37d582eeeb8c11ba5245edc281cf31793cBrian Carlstrom kOatClassSomeCompiled = 1, // A bitmap of which OatMethodOffsets are present follows the OatClass. 122ba150c37d582eeeb8c11ba5245edc281cf31793cBrian Carlstrom kOatClassNoneCompiled = 2, // All methods are interpretted so no OatMethodOffsets are necessary. 123ba150c37d582eeeb8c11ba5245edc281cf31793cBrian Carlstrom kOatClassMax = 3, 124ba150c37d582eeeb8c11ba5245edc281cf31793cBrian Carlstrom}; 125ba150c37d582eeeb8c11ba5245edc281cf31793cBrian Carlstrom 126ba150c37d582eeeb8c11ba5245edc281cf31793cBrian Carlstromstd::ostream& operator<<(std::ostream& os, const OatClassType& rhs); 127ba150c37d582eeeb8c11ba5245edc281cf31793cBrian Carlstrom 128df1ce91ba97bc79a0637e5504b39318fb1c9f577Ian Rogersclass PACKED(4) OatMethodOffsets { 1293320cf46afd082398aa401b246e6f301cebdf64dBrian Carlstrom public: 1303320cf46afd082398aa401b246e6f301cebdf64dBrian Carlstrom OatMethodOffsets(); 131971bf3f9184010d68b9a3ad30b396fa401af91a3Logan Chien 1323320cf46afd082398aa401b246e6f301cebdf64dBrian Carlstrom OatMethodOffsets(uint32_t code_offset, 1333320cf46afd082398aa401b246e6f301cebdf64dBrian Carlstrom uint32_t frame_size_in_bytes, 1343320cf46afd082398aa401b246e6f301cebdf64dBrian Carlstrom uint32_t core_spill_mask, 1353320cf46afd082398aa401b246e6f301cebdf64dBrian Carlstrom uint32_t fp_spill_mask, 1363320cf46afd082398aa401b246e6f301cebdf64dBrian Carlstrom uint32_t mapping_table_offset, 1373320cf46afd082398aa401b246e6f301cebdf64dBrian Carlstrom uint32_t vmap_table_offset, 138df62950e7a32031b82360c407d46a37b94188fbbBrian Carlstrom uint32_t gc_map_offset); 139971bf3f9184010d68b9a3ad30b396fa401af91a3Logan Chien 1403320cf46afd082398aa401b246e6f301cebdf64dBrian Carlstrom ~OatMethodOffsets(); 1413320cf46afd082398aa401b246e6f301cebdf64dBrian Carlstrom 1423320cf46afd082398aa401b246e6f301cebdf64dBrian Carlstrom uint32_t code_offset_; 1433320cf46afd082398aa401b246e6f301cebdf64dBrian Carlstrom uint32_t frame_size_in_bytes_; 1443320cf46afd082398aa401b246e6f301cebdf64dBrian Carlstrom uint32_t core_spill_mask_; 1453320cf46afd082398aa401b246e6f301cebdf64dBrian Carlstrom uint32_t fp_spill_mask_; 1463320cf46afd082398aa401b246e6f301cebdf64dBrian Carlstrom uint32_t mapping_table_offset_; 1473320cf46afd082398aa401b246e6f301cebdf64dBrian Carlstrom uint32_t vmap_table_offset_; 148e7d856b911222aa000ca2be0f8f63f5b292141c3Brian Carlstrom uint32_t gc_map_offset_; 1493320cf46afd082398aa401b246e6f301cebdf64dBrian Carlstrom}; 1503320cf46afd082398aa401b246e6f301cebdf64dBrian Carlstrom 151e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom} // namespace art 152e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom 153fc0e3219edc9a5bf81b166e82fd5db2796eb6a0dBrian Carlstrom#endif // ART_RUNTIME_OAT_H_ 154