Commit 139a2f51 authored by Clemens Backes's avatar Clemens Backes Committed by V8 LUCI CQ

[wasm] Do not count jump table size twice

The jump table sizes were added to the estimated code size, and then
again added for computing the reservation size for the code. This CL
moves the jump table size from {EstimateNativeModuleCodeSize} to
{EstimateNativeModuleMetaDataSize} so it is still considered for the
total memory associated with the {NativeModule}, but only added once for
the code space reservation.

R=ahaas@chromium.org

Bug: v8:12520
Change-Id: I871e54833659a0d466f3e8359bb3b515c85dd3cb
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3367622Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78491}
parent dc3eb449
......@@ -2070,15 +2070,9 @@ size_t WasmCodeManager::EstimateNativeModuleCodeSize(int num_functions,
const size_t overhead_per_code_byte =
kTurbofanCodeSizeMultiplier +
(include_liftoff ? kLiftoffCodeSizeMultiplier : 0);
const size_t jump_table_size = RoundUp<kCodeAlignment>(
JumpTableAssembler::SizeForNumberOfSlots(num_functions));
const size_t far_jump_table_size =
RoundUp<kCodeAlignment>(JumpTableAssembler::SizeForNumberOfFarJumpSlots(
WasmCode::kRuntimeStubCount,
NumWasmFunctionsInFarJumpTable(num_functions)));
return jump_table_size // jump table
+ far_jump_table_size // far jump table
+ overhead_per_function * num_functions // per function
// Note that the size for jump tables is added later, in {ReservationSize} /
// {OverheadPerCodeSpace}.
return overhead_per_function * num_functions // per function
+ overhead_per_code_byte * code_section_length // per code byte
+ kImportSize * num_imported_functions; // per import
}
......@@ -2092,11 +2086,19 @@ size_t WasmCodeManager::EstimateNativeModuleMetaDataSize(
// TODO(wasm): Include wire bytes size.
size_t native_module_estimate =
sizeof(NativeModule) + /* NativeModule struct */
(sizeof(WasmCode*) * num_wasm_functions) + /* code table size */
(sizeof(WasmCode) * num_wasm_functions); /* code object size */
sizeof(NativeModule) + // NativeModule struct
(sizeof(WasmCode*) * num_wasm_functions) + // code table size
(sizeof(WasmCode) * num_wasm_functions); // code object size
size_t jump_table_size = RoundUp<kCodeAlignment>(
JumpTableAssembler::SizeForNumberOfSlots(num_wasm_functions));
size_t far_jump_table_size =
RoundUp<kCodeAlignment>(JumpTableAssembler::SizeForNumberOfFarJumpSlots(
WasmCode::kRuntimeStubCount,
NumWasmFunctionsInFarJumpTable(num_wasm_functions)));
return wasm_module_estimate + native_module_estimate;
return wasm_module_estimate + native_module_estimate + jump_table_size +
far_jump_table_size;
}
void WasmCodeManager::SetThreadWritable(bool writable) {
......
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