5 #ifndef V8_SNAPSHOT_EMBEDDED_DATA_H_ 6 #define V8_SNAPSHOT_EMBEDDED_DATA_H_ 8 #include "src/base/macros.h" 9 #include "src/builtins/builtins.h" 10 #include "src/globals.h" 11 #include "src/isolate.h" 33 static void CreateOffHeapInstructionStream(
Isolate* isolate, uint8_t** data,
35 static void FreeOffHeapInstructionStream(uint8_t* data,
uint32_t size);
44 Isolate::CurrentEmbeddedBlobSize());
49 isolate->embedded_blob_size());
52 const uint8_t* data()
const {
return data_; }
53 uint32_t size()
const {
return size_; }
55 void Dispose() {
delete[] data_; }
57 Address InstructionStartOfBuiltin(
int i)
const;
58 uint32_t InstructionSizeOfBuiltin(
int i)
const;
60 bool ContainsBuiltin(
int i)
const {
return InstructionSizeOfBuiltin(
i) > 0; }
64 DCHECK(IsInRange(addr, start, start + size_));
65 return static_cast<uint32_t>(addr - start);
69 uint32_t PaddedInstructionSizeOfBuiltin(
int i)
const {
70 uint32_t size = InstructionSizeOfBuiltin(
i);
71 return (size == 0) ? 0 : PadAndAlign(size);
74 size_t CreateHash()
const;
76 return *
reinterpret_cast<const size_t*
>(data_ + HashOffset());
84 STATIC_ASSERT(offsetof(
Metadata, instructions_offset) == 0);
85 STATIC_ASSERT(offsetof(
Metadata, instructions_length) == kUInt32Size);
86 STATIC_ASSERT(
sizeof(
Metadata) == kUInt32Size + kUInt32Size);
95 static constexpr
uint32_t kTableSize = Builtins::builtin_count;
96 static constexpr
uint32_t HashOffset() {
return 0; }
97 static constexpr
uint32_t HashSize() {
return kSizetSize; }
98 static constexpr
uint32_t MetadataOffset() {
99 return HashOffset() + HashSize();
101 static constexpr
uint32_t MetadataSize() {
102 return sizeof(
struct Metadata) * kTableSize;
104 static constexpr
uint32_t RawDataOffset() {
105 return PadAndAlign(MetadataOffset() + MetadataSize());
109 EmbeddedData(
const uint8_t* data,
uint32_t size) : data_(data), size_(size) {
110 DCHECK_NOT_NULL(data);
114 const Metadata* Metadata()
const {
115 return reinterpret_cast<const struct Metadata*
>(data_ + MetadataOffset());
117 const uint8_t* RawData()
const {
return data_ + RawDataOffset(); }
119 static constexpr
int PadAndAlign(
int size) {
122 return RoundUp<kCodeAlignment>(size + 1);
125 void PrintStatistics()
const;
127 const uint8_t* data_;
134 #endif // V8_SNAPSHOT_EMBEDDED_DATA_H_