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,
}
void NativeModule::UnpackAndRegisterProtectedInstructions() {
for (uint32_t i = num_imported_functions_, e = num_functions_; i < e; ++i) {
WasmCode* wasm_code = code(i);
for (WasmCode* wasm_code : code_table()) {
if (wasm_code == nullptr) continue;
wasm_code->RegisterTrapHandlerData();
}
}
void NativeModule::ReleaseProtectedInstructions() {
for (uint32_t i = num_imported_functions_, e = num_functions_; i < e; ++i) {
WasmCode* wasm_code = code(i);
if (wasm_code->HasTrapHandlerIndex()) {
CHECK_LT(wasm_code->trap_handler_index(),
static_cast<size_t>(std::numeric_limits<int>::max()));
trap_handler::ReleaseHandlerData(
static_cast<int>(wasm_code->trap_handler_index()));
wasm_code->ResetTrapHandlerIndex();
}
for (WasmCode* wasm_code : code_table()) {
if (wasm_code == nullptr || !wasm_code->HasTrapHandlerIndex()) continue;
CHECK_LT(wasm_code->trap_handler_index(),
static_cast<size_t>(std::numeric_limits<int>::max()));
trap_handler::ReleaseHandlerData(
static_cast<int>(wasm_code->trap_handler_index()));
wasm_code->ResetTrapHandlerIndex();
}
}
......
......@@ -1596,11 +1596,7 @@ void WasmCompiledModule::LogWasmCodes(Isolate* isolate) {
if (native_module == nullptr) return;
// TODO(titzer): we skip the logging of the import wrappers
// here, but they should be included somehow.
const uint32_t num_imported_functions =
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);
for (wasm::WasmCode* code : native_module->code_table()) {
if (code == nullptr) continue;
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