Commit 0a9c3a0a authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] [cleanup] Use {code_table} accessor for iteration

This reads much nicer than the for loop with {num_imported_functions_}
and {num_functions}, and is potentially even faster, because we access
the code table directly and not via function index.

R=mstarzinger@chromium.org

Bug: v8:7754
Change-Id: I83e5c0253d8f78c22982a79d878431ba75cfc027
Reviewed-on: https://chromium-review.googlesource.com/1090271Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53574}
parent b6888b63
...@@ -818,23 +818,20 @@ WasmCode* NativeModule::CloneCode(const WasmCode* original_code, ...@@ -818,23 +818,20 @@ WasmCode* NativeModule::CloneCode(const WasmCode* original_code,
} }
void NativeModule::UnpackAndRegisterProtectedInstructions() { void NativeModule::UnpackAndRegisterProtectedInstructions() {
for (uint32_t i = num_imported_functions_, e = num_functions_; i < e; ++i) { for (WasmCode* wasm_code : code_table()) {
WasmCode* wasm_code = code(i);
if (wasm_code == nullptr) continue; if (wasm_code == nullptr) continue;
wasm_code->RegisterTrapHandlerData(); wasm_code->RegisterTrapHandlerData();
} }
} }
void NativeModule::ReleaseProtectedInstructions() { void NativeModule::ReleaseProtectedInstructions() {
for (uint32_t i = num_imported_functions_, e = num_functions_; i < e; ++i) { for (WasmCode* wasm_code : code_table()) {
WasmCode* wasm_code = code(i); if (wasm_code == nullptr || !wasm_code->HasTrapHandlerIndex()) continue;
if (wasm_code->HasTrapHandlerIndex()) { CHECK_LT(wasm_code->trap_handler_index(),
CHECK_LT(wasm_code->trap_handler_index(), static_cast<size_t>(std::numeric_limits<int>::max()));
static_cast<size_t>(std::numeric_limits<int>::max())); trap_handler::ReleaseHandlerData(
trap_handler::ReleaseHandlerData( static_cast<int>(wasm_code->trap_handler_index()));
static_cast<int>(wasm_code->trap_handler_index())); wasm_code->ResetTrapHandlerIndex();
wasm_code->ResetTrapHandlerIndex();
}
} }
} }
......
...@@ -1596,11 +1596,7 @@ void WasmCompiledModule::LogWasmCodes(Isolate* isolate) { ...@@ -1596,11 +1596,7 @@ void WasmCompiledModule::LogWasmCodes(Isolate* isolate) {
if (native_module == nullptr) return; if (native_module == nullptr) return;
// TODO(titzer): we skip the logging of the import wrappers // TODO(titzer): we skip the logging of the import wrappers
// here, but they should be included somehow. // here, but they should be included somehow.
const uint32_t num_imported_functions = for (wasm::WasmCode* code : native_module->code_table()) {
native_module->shared_module_data()->module()->num_imported_functions;
const uint32_t num_functions = native_module->num_functions();
for (uint32_t i = num_imported_functions; i < num_functions; i++) {
wasm::WasmCode* code = native_module->code(i);
if (code == nullptr) continue; if (code == nullptr) continue;
code->LogCode(isolate); code->LogCode(isolate);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment