13#if (defined(DART_TARGET_OS_WINDOWS) || defined(DART_HOST_OS_WINDOWS)) && \
14 (defined(TARGET_ARCH_X64) || defined(TARGET_ARCH_ARM64))
16static void InitUnwindingRecord(intptr_t
offset,
17 CodeRangeUnwindingRecord* record,
18 size_t code_size_in_bytes) {
19#if defined(TARGET_ARCH_X64)
21 record->runtime_function[0].BeginAddress = 0;
22 record->runtime_function[0].EndAddress = code_size_in_bytes;
23 record->runtime_function[0].UnwindData =
24 offset + offsetof(CodeRangeUnwindingRecord, unwind_info);
25 record->runtime_function_count = 1;
26#elif defined(TARGET_ARCH_ARM64)
28 const intptr_t kInstrSize = 4;
37 const uint32_t max_runtime_function_count =
39 sizeof(CodeRangeUnwindingRecord)) /
40 sizeof(RUNTIME_FUNCTION) +
41 kDefaultRuntimeFunctionCount);
43 uint32_t runtime_function_index = 0;
44 uint32_t current_unwind_start_address = 0;
45 int64_t remaining_size_in_bytes =
static_cast<int64_t
>(code_size_in_bytes);
52 while (remaining_size_in_bytes >= kMaxFunctionLength &&
53 runtime_function_index < max_runtime_function_count) {
54 record->runtime_function[runtime_function_index].BeginAddress =
55 current_unwind_start_address;
56 record->runtime_function[runtime_function_index].UnwindData =
58 static_cast<DWORD>(offsetof(CodeRangeUnwindingRecord, unwind_info));
60 runtime_function_index++;
61 current_unwind_start_address += kMaxFunctionLength;
62 remaining_size_in_bytes -= kMaxFunctionLength;
66 record->unwind_info.unwind_info.FunctionLength = kMaxFunctionLength >> 2;
68 if (remaining_size_in_bytes > 0 &&
69 runtime_function_index < max_runtime_function_count) {
70 ASSERT((remaining_size_in_bytes % kInstrSize) == 0);
72 record->unwind_info1.unwind_info.FunctionLength =
static_cast<uint32_t
>(
73 remaining_size_in_bytes >> kFunctionLengthShiftSize);
74 record->runtime_function[runtime_function_index].BeginAddress =
75 current_unwind_start_address;
76 record->runtime_function[runtime_function_index].UnwindData =
78 static_cast<DWORD>(offsetof(CodeRangeUnwindingRecord, unwind_info1));
80 remaining_size_in_bytes -= kMaxFunctionLength;
81 record->runtime_function_count = runtime_function_index + 1;
83 record->runtime_function_count = runtime_function_index;
89 ASSERT(remaining_size_in_bytes <= 0);
91#error What architecture?
93 record->magic = kUnwindingRecordMagic;
97 uint8_t* target_buffer) {
98 CodeRangeUnwindingRecord* record =
99 new (target_buffer) CodeRangeUnwindingRecord();
101 return target_buffer;
106#if defined(DART_HOST_OS_WINDOWS) && \
107 (defined(TARGET_ARCH_X64) || defined(TARGET_ARCH_ARM64))
113 ASSERT(
sizeof(CodeRangeUnwindingRecord) <=
116 intptr_t unwinding_record_offset =
118 CodeRangeUnwindingRecord* record =
119 new (
reinterpret_cast<uint8_t*
>(
page->memory_->start()) +
120 unwinding_record_offset) CodeRangeUnwindingRecord();
121 InitUnwindingRecord(unwinding_record_offset, record,
page->memory_->size());
123 DWORD status = RtlAddGrowableFunctionTable(
124 &record->dynamic_table,
125 record->runtime_function,
126 record->runtime_function_count,
127 record->runtime_function_count,
128 page->memory_->start(),
129 page->memory_->end());
131 FATAL(
"Failed to add growable function table: 0x%x\n", status);
137 intptr_t unwinding_record_offset =
139 CodeRangeUnwindingRecord* record =
140 reinterpret_cast<CodeRangeUnwindingRecord*
>(
141 reinterpret_cast<uint8_t*
>(
page->memory_->start()) +
142 unwinding_record_offset);
144 RtlDeleteGrowableFunctionTable(record->dynamic_table);
#define RELEASE_ASSERT(cond)
static void UnregisterExecutablePage(Page *page)
static void RegisterExecutablePage(Page *page)
static const void * GenerateRecordsInto(intptr_t offset, uint8_t *target_buffer)