oat.h revision 7c3d13aebdd8611cae58a1048bffb13cbdc465cb
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); 65468532ea115657709bc32ee498e701a4c71762d4Ian Rogers const void* GetPortableToInterpreterBridge() const; 66468532ea115657709bc32ee498e701a4c71762d4Ian Rogers uint32_t GetPortableToInterpreterBridgeOffset() const; 67468532ea115657709bc32ee498e701a4c71762d4Ian Rogers void SetPortableToInterpreterBridgeOffset(uint32_t offset); 68468532ea115657709bc32ee498e701a4c71762d4Ian Rogers 690aba0ba155bef7346bde19e53581200b89ae8a7aJeff Hao const void* GetQuickResolutionTrampoline() const; 700aba0ba155bef7346bde19e53581200b89ae8a7aJeff Hao uint32_t GetQuickResolutionTrampolineOffset() const; 710aba0ba155bef7346bde19e53581200b89ae8a7aJeff Hao void SetQuickResolutionTrampolineOffset(uint32_t offset); 72468532ea115657709bc32ee498e701a4c71762d4Ian Rogers const void* GetQuickToInterpreterBridge() const; 73468532ea115657709bc32ee498e701a4c71762d4Ian Rogers uint32_t GetQuickToInterpreterBridgeOffset() const; 74468532ea115657709bc32ee498e701a4c71762d4Ian Rogers void SetQuickToInterpreterBridgeOffset(uint32_t offset); 75468532ea115657709bc32ee498e701a4c71762d4Ian Rogers 760aba0ba155bef7346bde19e53581200b89ae8a7aJeff Hao InstructionSet GetInstructionSet() const; 7728db0129e5d7ef642cf8845c86c0e11832817085Brian Carlstrom uint32_t GetImageFileLocationOatChecksum() const; 78700c8d31733534a3d978b75a03f6f7e177dc7e81Brian Carlstrom uint32_t GetImageFileLocationOatDataBegin() const; 7981f3ca17e9e8d360cc4a1b6c3155cf01ba3be3bcBrian Carlstrom uint32_t GetImageFileLocationSize() const; 8081f3ca17e9e8d360cc4a1b6c3155cf01ba3be3bcBrian Carlstrom const uint8_t* GetImageFileLocationData() const; 8181f3ca17e9e8d360cc4a1b6c3155cf01ba3be3bcBrian Carlstrom std::string GetImageFileLocation() const; 82e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom 83e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom private: 84e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom uint8_t magic_[4]; 85e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom uint8_t version_[4]; 86e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom uint32_t adler32_checksum_; 87a72ec820f8cb8e04b0ba87a62e36b05a2c92ef36Elliott Hughes 88a72ec820f8cb8e04b0ba87a62e36b05a2c92ef36Elliott Hughes InstructionSet instruction_set_; 89e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom uint32_t dex_file_count_; 90e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom uint32_t executable_offset_; 91468532ea115657709bc32ee498e701a4c71762d4Ian Rogers uint32_t interpreter_to_interpreter_bridge_offset_; 92468532ea115657709bc32ee498e701a4c71762d4Ian Rogers uint32_t interpreter_to_compiled_code_bridge_offset_; 93468532ea115657709bc32ee498e701a4c71762d4Ian Rogers uint32_t jni_dlsym_lookup_offset_; 940aba0ba155bef7346bde19e53581200b89ae8a7aJeff Hao uint32_t portable_resolution_trampoline_offset_; 95468532ea115657709bc32ee498e701a4c71762d4Ian Rogers uint32_t portable_to_interpreter_bridge_offset_; 960aba0ba155bef7346bde19e53581200b89ae8a7aJeff Hao uint32_t quick_resolution_trampoline_offset_; 97468532ea115657709bc32ee498e701a4c71762d4Ian Rogers uint32_t quick_to_interpreter_bridge_offset_; 98e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom 9928db0129e5d7ef642cf8845c86c0e11832817085Brian Carlstrom uint32_t image_file_location_oat_checksum_; 100700c8d31733534a3d978b75a03f6f7e177dc7e81Brian Carlstrom uint32_t image_file_location_oat_data_begin_; 10181f3ca17e9e8d360cc4a1b6c3155cf01ba3be3bcBrian Carlstrom uint32_t image_file_location_size_; 10281f3ca17e9e8d360cc4a1b6c3155cf01ba3be3bcBrian Carlstrom uint8_t image_file_location_data_[0]; // note variable width data at end 10381f3ca17e9e8d360cc4a1b6c3155cf01ba3be3bcBrian Carlstrom 104e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom DISALLOW_COPY_AND_ASSIGN(OatHeader); 105e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom}; 106e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom 107df1ce91ba97bc79a0637e5504b39318fb1c9f577Ian Rogersclass PACKED(4) OatMethodOffsets { 1083320cf46afd082398aa401b246e6f301cebdf64dBrian Carlstrom public: 1093320cf46afd082398aa401b246e6f301cebdf64dBrian Carlstrom OatMethodOffsets(); 110971bf3f9184010d68b9a3ad30b396fa401af91a3Logan Chien 1113320cf46afd082398aa401b246e6f301cebdf64dBrian Carlstrom OatMethodOffsets(uint32_t code_offset, 1123320cf46afd082398aa401b246e6f301cebdf64dBrian Carlstrom uint32_t frame_size_in_bytes, 1133320cf46afd082398aa401b246e6f301cebdf64dBrian Carlstrom uint32_t core_spill_mask, 1143320cf46afd082398aa401b246e6f301cebdf64dBrian Carlstrom uint32_t fp_spill_mask, 1153320cf46afd082398aa401b246e6f301cebdf64dBrian Carlstrom uint32_t mapping_table_offset, 1163320cf46afd082398aa401b246e6f301cebdf64dBrian Carlstrom uint32_t vmap_table_offset, 117df62950e7a32031b82360c407d46a37b94188fbbBrian Carlstrom uint32_t gc_map_offset); 118971bf3f9184010d68b9a3ad30b396fa401af91a3Logan Chien 1193320cf46afd082398aa401b246e6f301cebdf64dBrian Carlstrom ~OatMethodOffsets(); 1203320cf46afd082398aa401b246e6f301cebdf64dBrian Carlstrom 1213320cf46afd082398aa401b246e6f301cebdf64dBrian Carlstrom uint32_t code_offset_; 1223320cf46afd082398aa401b246e6f301cebdf64dBrian Carlstrom uint32_t frame_size_in_bytes_; 1233320cf46afd082398aa401b246e6f301cebdf64dBrian Carlstrom uint32_t core_spill_mask_; 1243320cf46afd082398aa401b246e6f301cebdf64dBrian Carlstrom uint32_t fp_spill_mask_; 1253320cf46afd082398aa401b246e6f301cebdf64dBrian Carlstrom uint32_t mapping_table_offset_; 1263320cf46afd082398aa401b246e6f301cebdf64dBrian Carlstrom uint32_t vmap_table_offset_; 127e7d856b911222aa000ca2be0f8f63f5b292141c3Brian Carlstrom uint32_t gc_map_offset_; 1283320cf46afd082398aa401b246e6f301cebdf64dBrian Carlstrom}; 1293320cf46afd082398aa401b246e6f301cebdf64dBrian Carlstrom 130e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom} // namespace art 131e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom 132fc0e3219edc9a5bf81b166e82fd5db2796eb6a0dBrian Carlstrom#endif // ART_RUNTIME_OAT_H_ 133