diff --git a/runtime/bin/elf_loader.cc b/runtime/bin/elf_loader.cc index 99f7185525f..ff44319e339 100644 --- a/runtime/bin/elf_loader.cc +++ b/runtime/bin/elf_loader.cc @@ -270,7 +270,6 @@ class LoadedElf { } bool LoadedElf::Load() { - UnwindingRecordsPlatform::Init(); VirtualMemory::Init(); if (error_ != nullptr) { @@ -300,7 +299,6 @@ LoadedElf::~LoadedElf() { UnwindingRecordsPlatform::UnregisterDynamicTable( dynamic_runtime_function_tables_[i]); } - UnwindingRecordsPlatform::Cleanup(); #endif // Unmap the image. diff --git a/runtime/platform/unwinding_records.cc b/runtime/platform/unwinding_records.cc index 1b9c4f6f540..e6e69d0ed0b 100644 --- a/runtime/platform/unwinding_records.cc +++ b/runtime/platform/unwinding_records.cc @@ -19,8 +19,6 @@ intptr_t UnwindingRecordsPlatform::SizeInBytes() { #if !defined(DART_HOST_OS_WINDOWS) || \ (!defined(TARGET_ARCH_X64) && !defined(TARGET_ARCH_ARM64)) -void UnwindingRecordsPlatform::Init() {} -void UnwindingRecordsPlatform::Cleanup() {} void UnwindingRecordsPlatform::RegisterExecutableMemory( void* start, intptr_t size, diff --git a/runtime/platform/unwinding_records.h b/runtime/platform/unwinding_records.h index 8eab924da31..12333ca025f 100644 --- a/runtime/platform/unwinding_records.h +++ b/runtime/platform/unwinding_records.h @@ -12,18 +12,12 @@ namespace dart { class UnwindingRecordsPlatform : public AllStatic { public: - static void Init(); - static void Cleanup(); - static intptr_t SizeInBytes(); static void RegisterExecutableMemory(void* start, intptr_t size, void** pp_dynamic_table); static void UnregisterDynamicTable(void* p_dynamic_table); - - static void* GetAddGrowableFunctionTableFunc(); - static void* GetDeleteGrowableFunctionTableFunc(); }; #if (defined(DART_TARGET_OS_WINDOWS) || defined(DART_HOST_OS_WINDOWS)) && \ diff --git a/runtime/platform/unwinding_records_win.cc b/runtime/platform/unwinding_records_win.cc index ade1986eb3c..937cd1d833e 100644 --- a/runtime/platform/unwinding_records_win.cc +++ b/runtime/platform/unwinding_records_win.cc @@ -27,48 +27,10 @@ intptr_t UnwindingRecordsPlatform::SizeInBytes() { #if defined(DART_HOST_OS_WINDOWS) && \ (defined(TARGET_ARCH_X64) || defined(TARGET_ARCH_ARM64)) -static HMODULE ntdll_module; -static decltype(&::RtlAddGrowableFunctionTable) - add_growable_function_table_func_ = nullptr; -static decltype(&::RtlDeleteGrowableFunctionTable) - delete_growable_function_table_func_ = nullptr; - -void* UnwindingRecordsPlatform::GetAddGrowableFunctionTableFunc() { - return add_growable_function_table_func_; -} - -void* UnwindingRecordsPlatform::GetDeleteGrowableFunctionTableFunc() { - return delete_growable_function_table_func_; -} - -void UnwindingRecordsPlatform::Init() { - ntdll_module = - LoadLibraryEx(L"ntdll.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32); - ASSERT(ntdll_module != nullptr); - // This pair of functions is not available on Windows 7. - add_growable_function_table_func_ = - reinterpret_cast( - ::GetProcAddress(ntdll_module, "RtlAddGrowableFunctionTable")); - delete_growable_function_table_func_ = - reinterpret_cast( - ::GetProcAddress(ntdll_module, "RtlDeleteGrowableFunctionTable")); - // Either both available, or both not available. - ASSERT((add_growable_function_table_func_ == nullptr) == - (delete_growable_function_table_func_ == nullptr)); -} - -void UnwindingRecordsPlatform::Cleanup() { - FreeLibrary(ntdll_module); -} - void UnwindingRecordsPlatform::RegisterExecutableMemory( void* start, intptr_t size, void** pp_dynamic_table) { - auto func = add_growable_function_table_func_; - if (func == nullptr) { - return; - } intptr_t unwinding_record_offset = size - kReservedUnwindingRecordsSizeBytes; uint8_t* record_ptr = static_cast(start) + unwinding_record_offset; CodeRangeUnwindingRecord* record = @@ -76,21 +38,20 @@ void UnwindingRecordsPlatform::RegisterExecutableMemory( RELEASE_ASSERT(record->magic == kUnwindingRecordMagic); uword start_num = reinterpret_cast(start); uword end_num = start_num + size; - DWORD status = func(pp_dynamic_table, - /*FunctionTable=*/record->runtime_function, - /*EntryCount=*/record->runtime_function_count, - /*MaximumEntryCount=*/record->runtime_function_count, - /*RangeBase=*/start_num, - /*RangeEnd=*/end_num); + DWORD status = RtlAddGrowableFunctionTable( + pp_dynamic_table, + /*FunctionTable=*/record->runtime_function, + /*EntryCount=*/record->runtime_function_count, + /*MaximumEntryCount=*/record->runtime_function_count, + /*RangeBase=*/start_num, + /*RangeEnd=*/end_num); if (status != 0) { FATAL("Failed to add growable function table: 0x%x\n", status); } } void UnwindingRecordsPlatform::UnregisterDynamicTable(void* p_dynamic_table) { - auto func = delete_growable_function_table_func_; - if (func == nullptr) return; - func(p_dynamic_table); + RtlDeleteGrowableFunctionTable(p_dynamic_table); } #endif // defined(DART_HOST_OS_WINDOWS) diff --git a/runtime/vm/dart.cc b/runtime/vm/dart.cc index 2799481d2ca..62044e37f91 100644 --- a/runtime/vm/dart.cc +++ b/runtime/vm/dart.cc @@ -342,7 +342,6 @@ char* Dart::DartInit(const Dart_InitializeParams* params) { ForwardingCorpse::Init(); Api::Init(); NativeSymbolResolver::Init(); - UnwindingRecordsPlatform::Init(); Page::Init(); StoreBuffer::Init(); MarkingStack::Init(); @@ -758,7 +757,6 @@ char* Dart::Cleanup() { StoreBuffer::Cleanup(); Object::Cleanup(); Page::Cleanup(); - UnwindingRecordsPlatform::Cleanup(); StubCode::Cleanup(); #if defined(SUPPORT_TIMELINE) if (FLAG_trace_shutdown) { diff --git a/runtime/vm/unwinding_records_win.cc b/runtime/vm/unwinding_records_win.cc index 84aebe36387..a92c2931df5 100644 --- a/runtime/vm/unwinding_records_win.cc +++ b/runtime/vm/unwinding_records_win.cc @@ -109,11 +109,6 @@ const void* UnwindingRecords::GenerateRecordsInto(intptr_t offset, // Special exception-unwinding records are put at the end of executable // page on Windows for 64-bit applications. void UnwindingRecords::RegisterExecutablePage(Page* page) { - // Won't set up unwinding records on Windows 7, so users won't be able - // to benefit from proper unhandled exceptions filtering. - auto function = static_cast( - UnwindingRecordsPlatform::GetAddGrowableFunctionTableFunc()); - if (function == nullptr) return; ASSERT(page->is_executable()); ASSERT(sizeof(CodeRangeUnwindingRecord) <= UnwindingRecordsPlatform::SizeInBytes()); @@ -125,7 +120,7 @@ void UnwindingRecords::RegisterExecutablePage(Page* page) { unwinding_record_offset) CodeRangeUnwindingRecord(); InitUnwindingRecord(unwinding_record_offset, record, page->memory_->size()); RELEASE_ASSERT(record->magic == kUnwindingRecordMagic); - DWORD status = function( + DWORD status = RtlAddGrowableFunctionTable( /*DynamicTable=*/&record->dynamic_table, /*FunctionTable=*/record->runtime_function, /*EntryCount=*/record->runtime_function_count, @@ -138,9 +133,6 @@ void UnwindingRecords::RegisterExecutablePage(Page* page) { } void UnwindingRecords::UnregisterExecutablePage(Page* page) { - auto function = static_cast( - UnwindingRecordsPlatform::GetDeleteGrowableFunctionTableFunc()); - if (function == nullptr) return; ASSERT(page->is_executable() && !page->is_image()); intptr_t unwinding_record_offset = page->memory_->size() - UnwindingRecordsPlatform::SizeInBytes(); @@ -149,7 +141,7 @@ void UnwindingRecords::UnregisterExecutablePage(Page* page) { reinterpret_cast(page->memory_->start()) + unwinding_record_offset); RELEASE_ASSERT(record->magic == kUnwindingRecordMagic); - function(record->dynamic_table); + RtlDeleteGrowableFunctionTable(record->dynamic_table); } #endif // defined(DART_HOST_OS_WINDOWS)