[wasm][cleanup] Clean up signature of WasmTierUpFunction
The runtime function took two parameters, the instance and the function index. The function index, however, seems to be unnatural information, as the function index is a value that only has meaning with the binary format of a wasm module, and not for the embedder of a wasm module. This CL changes the signature of the runtime function to a single parameter, the wasm function that should be optimized. R=manoskouk@chromium.org Bug: v8:12926 Change-Id: I6802cb6c8ffc586f4997a4a069735785ce59583d Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4171625 Reviewed-by: Manos Koukoutos <manoskouk@chromium.org> Commit-Queue: Andreas Haas <ahaas@chromium.org> Cr-Commit-Position: refs/heads/main@{#85352}
This commit is contained in:
parent
6d40296e5a
commit
589591026a
@ -425,10 +425,14 @@ RUNTIME_FUNCTION(Runtime_WasmTraceMemory) {
|
||||
|
||||
RUNTIME_FUNCTION(Runtime_WasmTierUpFunction) {
|
||||
HandleScope scope(isolate);
|
||||
DCHECK_EQ(2, args.length());
|
||||
Handle<WasmInstanceObject> instance = args.at<WasmInstanceObject>(0);
|
||||
int function_index = args.smi_value_at(1);
|
||||
wasm::TierUpNowForTesting(isolate, *instance, function_index);
|
||||
DCHECK_EQ(1, args.length());
|
||||
Handle<JSFunction> function = args.at<JSFunction>(0);
|
||||
CHECK(WasmExportedFunction::IsWasmExportedFunction(*function));
|
||||
Handle<WasmExportedFunction> exp_fun =
|
||||
Handle<WasmExportedFunction>::cast(function);
|
||||
WasmInstanceObject instance = exp_fun->instance();
|
||||
int func_index = exp_fun->function_index();
|
||||
wasm::TierUpNowForTesting(isolate, instance, func_index);
|
||||
return ReadOnlyRoots(isolate).undefined_value();
|
||||
}
|
||||
|
||||
|
@ -672,7 +672,7 @@ namespace internal {
|
||||
F(WasmGetNumberOfInstances, 1, 1) \
|
||||
F(WasmNumCodeSpaces, 1, 1) \
|
||||
F(WasmEnterDebugging, 0, 1) \
|
||||
F(WasmTierUpFunction, 2, 1) \
|
||||
F(WasmTierUpFunction, 1, 1) \
|
||||
F(WasmTraceEnter, 0, 1) \
|
||||
F(WasmTraceExit, 1, 1) \
|
||||
F(WasmTraceMemory, 1, 1)
|
||||
|
@ -15,7 +15,8 @@ let loadFct = builder.addFunction('load', kSig_i_i).addBody([
|
||||
kExprI32LoadMem, 0, 0, // i32.load_mem
|
||||
]).exportFunc();
|
||||
const instance = builder.instantiate();
|
||||
for (let i = 0; i < 20; i++) instance.exports.load(1);
|
||||
%WasmTierUpFunction(instance, loadFct.index);
|
||||
assertFalse(%IsLiftoffFunction(instance.exports.load));
|
||||
instance.exports.load(1);
|
||||
const load = instance.exports.load;
|
||||
for (let i = 0; i < 20; i++) load(1);
|
||||
%WasmTierUpFunction(load);
|
||||
assertFalse(%IsLiftoffFunction(load));
|
||||
load(1);
|
||||
|
@ -26,5 +26,5 @@ let instance = builder.instantiate();
|
||||
let main = instance.exports.main;
|
||||
|
||||
for (let i = 0; i < 20; i++) main();
|
||||
%WasmTierUpFunction(instance, main_func.index);
|
||||
%WasmTierUpFunction(main);
|
||||
main();
|
||||
|
@ -25,5 +25,5 @@ let instance = builder.instantiate();
|
||||
let main = instance.exports.main;
|
||||
|
||||
for (let i = 0; i < 20; i++) assertEquals(0, main());
|
||||
%WasmTierUpFunction(instance, main_func.index);
|
||||
%WasmTierUpFunction(main);
|
||||
assertEquals(0, main());
|
||||
|
@ -79,10 +79,9 @@ if (simdSupported) {
|
||||
],
|
||||
});
|
||||
}
|
||||
const functionIdx = {};
|
||||
|
||||
for (const [name, code] of Object.entries(testCases)) {
|
||||
functionIdx[name] = builder.addFunction(name, makeSig([], []))
|
||||
builder.addFunction(name, makeSig([], []))
|
||||
.exportFunc()
|
||||
.addBody([
|
||||
// Some call that allocates a feedback vector.
|
||||
@ -96,7 +95,7 @@ for (const [name, code] of Object.entries(testCases)) {
|
||||
// allocation of this slot can be skipped. However, this should be treated
|
||||
// consistently between liftoff and turbofan.
|
||||
kExprCallFunction, callee.index,
|
||||
]).index;
|
||||
]);
|
||||
}
|
||||
|
||||
const instance = builder.instantiate();
|
||||
@ -110,11 +109,11 @@ function run(fct) {
|
||||
}
|
||||
}
|
||||
|
||||
for (const [name, index] of Object.entries(functionIdx)) {
|
||||
for (const [name, code] of Object.entries(testCases)) {
|
||||
print(`Test ${name}`);
|
||||
// Create feedback vectors in liftoff compilation.
|
||||
for (let i = 0; i < 5; ++i) run(instance.exports[name]);
|
||||
// Force turbofan compilation.
|
||||
%WasmTierUpFunction(instance, index);
|
||||
%WasmTierUpFunction(instance.exports[name]);
|
||||
run(instance.exports[name]);
|
||||
}
|
||||
|
@ -121,6 +121,6 @@ let testFct = () => {
|
||||
|
||||
for (let i = 0; i < 20; i++) testFct();
|
||||
for (let fct of fcts) {
|
||||
%WasmTierUpFunction(instance, fct.index);
|
||||
%WasmTierUpFunction(wasm[fct.name]);
|
||||
}
|
||||
testFct();
|
||||
|
@ -14,10 +14,10 @@ builder.addFunction('load', kSig_i_i)
|
||||
kExprI32LoadMem, 0, 100])
|
||||
.exportFunc();
|
||||
|
||||
const module = builder.instantiate();
|
||||
%WasmTierUpFunction(module, 0);
|
||||
const load = builder.instantiate().exports.load;
|
||||
%WasmTierUpFunction(load);
|
||||
// 100 is added as part of the load instruction above
|
||||
// Last valid address (64k - 100 - 4)
|
||||
assertEquals(0, module.exports.load(0x10000 - 100 - 4));
|
||||
assertEquals(0, load(0x10000 - 100 - 4));
|
||||
// First invalid address (64k - 100)
|
||||
assertTraps(kTrapMemOutOfBounds, _ => { module.exports.load(0x10000 - 100);});
|
||||
assertTraps(kTrapMemOutOfBounds, _ => { load(0x10000 - 100);});
|
||||
|
@ -31,7 +31,7 @@ function check(instance) {
|
||||
checkForDebugCode(instance);
|
||||
|
||||
for (let i = 0; i < num_functions; ++i) {
|
||||
%WasmTierUpFunction(instance, i);
|
||||
%WasmTierUpFunction(instance.exports['f' + i]);
|
||||
}
|
||||
checkForDebugCode(instance);
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
|
||||
let instance = builder.instantiate();
|
||||
for (let i = 0; i < 20; i++) assertEquals(14, instance.exports.main(10));
|
||||
%WasmTierUpFunction(instance, main.index);
|
||||
%WasmTierUpFunction(instance.exports.main);
|
||||
// The tiered-up function should have {callee} speculatively inlined.
|
||||
assertEquals(14, instance.exports.main(10));
|
||||
})();
|
||||
@ -75,7 +75,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
let instance = builder.instantiate();
|
||||
|
||||
for (let i = 0; i < 20; i++) assertEquals(14, instance.exports.main(10, 1));
|
||||
%WasmTierUpFunction(instance, main.index);
|
||||
%WasmTierUpFunction(instance.exports.main);
|
||||
// Tier-up is done, and {callee0} should be inlined in the trace.
|
||||
assertEquals(14, instance.exports.main(10, 1));
|
||||
|
||||
@ -105,7 +105,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
let instance = builder.instantiate();
|
||||
|
||||
for (let i = 0; i < 20; i++) assertEquals(14, instance.exports.main(10));
|
||||
%WasmTierUpFunction(instance, main.index);
|
||||
%WasmTierUpFunction(instance.exports.main);
|
||||
// After tier-up, the tail call should be speculatively inlined.
|
||||
assertEquals(14, instance.exports.main(10));
|
||||
})();
|
||||
@ -145,7 +145,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
let instance = builder.instantiate();
|
||||
|
||||
assertEquals(9, instance.exports.main(10, 1));
|
||||
%WasmTierUpFunction(instance, main.index);
|
||||
%WasmTierUpFunction(instance.exports.main);
|
||||
// After tier-up, {callee0} should be inlined in the trace.
|
||||
assertEquals(9, instance.exports.main(10, 1))
|
||||
|
||||
@ -190,7 +190,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
|
||||
// Run 'main' until it is tiered-up.
|
||||
assertEquals(1, instance2.exports.main(0, instance1.exports.f1));
|
||||
%WasmTierUpFunction(instance2, main.index);
|
||||
%WasmTierUpFunction(instance2.exports.main);
|
||||
// The function f1 defined in another module should not be inlined.
|
||||
assertEquals(1, instance2.exports.main(0, instance1.exports.f1));
|
||||
})();
|
||||
@ -232,7 +232,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
assertEquals(16, instance2.exports.main(5, f1, f2));
|
||||
}
|
||||
}
|
||||
%WasmTierUpFunction(instance2, main.index);
|
||||
%WasmTierUpFunction(instance2.exports.main);
|
||||
// WebAssembly.Function objects should not be inlined.
|
||||
assertEquals(16, instance2.exports.main(5, f1, f2));
|
||||
assertEquals(12, instance2.exports.main(5, f1, f1));
|
||||
|
@ -65,7 +65,7 @@ let kSig_v_w = makeSig([kWasmStringRef], []);
|
||||
// Bug 3: Builtin calls that have neither a kNoThrow annotation nor exception-
|
||||
// handling support make the Wasm inliner sad.
|
||||
for (let i = 0; i < 20; i++) f1(10);
|
||||
%WasmTierUpFunction(instance, caller.index);
|
||||
%WasmTierUpFunction(f1);
|
||||
f1(10);
|
||||
})();
|
||||
|
||||
@ -94,5 +94,5 @@ assertThrows(() => f2("1234567890")); // 650M characters is too much.
|
||||
// Bug 5: Operations that can trap must not be marked as kEliminatable,
|
||||
// otherwise the trap may be eliminated.
|
||||
for (let i = 0; i < 3; i++) f2("a"); // 65M characters is okay.
|
||||
%WasmTierUpFunction(instance, concat.index);
|
||||
%WasmTierUpFunction(f2);
|
||||
assertThrows(() => f2("1234567890")); // Optimized code still traps.
|
||||
|
Loading…
Reference in New Issue
Block a user