Commit 6d1522d5 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] Test the --liftoff flag

This adds two tests to verify that the --liftoff flag has the indented
effect, and that Liftoff compilation is off by default.

R=titzer@chromium.org

Bug: v8:6600
Change-Id: Ie7e13184b5068f572b78dbdf7abbcded6d859fc5
Reviewed-on: https://chromium-review.googlesource.com/733561
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48995}
parent c78a98bb
......@@ -1072,5 +1072,14 @@ RUNTIME_FUNCTION(Runtime_WasmTraceMemory) {
return isolate->heap()->undefined_value();
}
RUNTIME_FUNCTION(Runtime_IsLiftoffFunction) {
HandleScope shs(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
CHECK(WasmExportedFunction::IsWasmExportedFunction(*function));
Handle<Code> wasm_code = WasmExportedFunction::cast(*function)->GetWasmCode();
return isolate->heap()->ToBoolean(!wasm_code->is_turbofanned());
}
} // namespace internal
} // namespace v8
......@@ -631,7 +631,8 @@ namespace internal {
F(HeapObjectVerify, 1, 1) \
F(WasmNumInterpretedCalls, 1, 1) \
F(RedirectToWasmInterpreter, 2, 1) \
F(WasmTraceMemory, 4, 1)
F(WasmTraceMemory, 4, 1) \
F(IsLiftoffFunction, 1, 1)
#define FOR_EACH_INTRINSIC_TYPEDARRAY(F) \
F(ArrayBufferGetByteLength, 1, 1) \
......
......@@ -688,4 +688,11 @@
'compiler/stress-deopt-count-*': [SKIP],
}], # arch != x64 or deopt_fuzzer
##############################################################################
# Liftoff is currently only sufficiently implemented on x64 and ia32.
# TODO(clemensh): Implement on all other platforms (crbug.com/v8/6600).
['arch != x64 and arch != ia32', {
'wasm/liftoff': [SKIP],
}], # arch != x64 and arch != ia32
]
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax
// This test makes sure that by default, we do not compile with liftoff.
load("test/mjsunit/wasm/wasm-constants.js");
load("test/mjsunit/wasm/wasm-module-builder.js");
const builder = new WasmModuleBuilder();
builder.addFunction("i32_add", kSig_i_ii)
.addBody([kExprGetLocal, 0, kExprGetLocal, 1, kExprI32Add])
.exportFunc();
const instance = builder.instantiate();
assertFalse(%IsLiftoffFunction(instance.exports.i32_add));
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax --liftoff --wasm-async-compilation
load('test/mjsunit/wasm/wasm-constants.js');
load('test/mjsunit/wasm/wasm-module-builder.js');
(function testLiftoffSync() {
print(arguments.callee.name);
const builder = new WasmModuleBuilder();
builder.addFunction('i32_add', kSig_i_ii)
.addBody([kExprGetLocal, 0, kExprGetLocal, 1, kExprI32Add])
.exportFunc();
const instance = builder.instantiate();
assertTrue(%IsLiftoffFunction(instance.exports.i32_add));
})();
async function testLiftoffAsync() {
print(arguments.callee.name);
const builder = new WasmModuleBuilder();
builder.addFunction('i32_add', kSig_i_ii)
.addBody([kExprGetLocal, 0, kExprGetLocal, 1, kExprI32Add])
.exportFunc();
print('Compiling...');
const module = await WebAssembly.compile(builder.toBuffer());
print('Instantiating...');
const instance = new WebAssembly.Instance(module);
assertTrue(%IsLiftoffFunction(instance.exports.i32_add));
}
assertPromiseResult(testLiftoffAsync());
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