Commit 9d3a38ae authored by Andreas Haas's avatar Andreas Haas Committed by Commit Bot

[wasm] Add testing opcode to test unsupported opcodes in Liftoff

Liftoff is not fully feature complete yet. To test that Liftoff can
bailout to TurboFan also for debugging, this CL adds
* an opcode that is only implemented in TurboFan
* a flag that allows that opcode to be compiled with TurboFan
* a bailout for this opcode to Liftoff.

R=clemensb@chromium.org

Bug: v8:7581
Change-Id: Ie4b4654d0d36ab937a7dfe9b1bb6a187b17615fb
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2629284
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72113}
parent bf9e8d2c
......@@ -824,6 +824,9 @@ DEFINE_NEG_IMPLICATION(liftoff_only, wasm_tier_up)
DEFINE_NEG_IMPLICATION(fuzzing, liftoff_only)
DEFINE_BOOL(experimental_liftoff_extern_ref, false,
"enable support for externref in Liftoff")
DEFINE_DEBUG_BOOL(
enable_testing_opcode_in_wasm, false,
"enables a testing opcode in wasm that is only implemented in TurboFan")
// We can't tier up (from Liftoff to TurboFan) in single-threaded mode, hence
// disable tier up in that configuration for now.
DEFINE_NEG_IMPLICATION(single_threaded, wasm_tier_up)
......
......@@ -1997,6 +1997,10 @@ class LiftoffCompiler {
__ AssertUnreachable(AbortReason::kUnexpectedReturnFromWasmTrap);
}
void NopForTestingUnsupportedInLiftoff(FullDecoder* decoder) {
unsupported(decoder, kOtherReason, "testing opcode");
}
void Select(FullDecoder* decoder, const Value& cond, const Value& fval,
const Value& tval, Value* result) {
LiftoffRegList pinned;
......
......@@ -1008,6 +1008,7 @@ struct ControlBase : public PcForErrors<validate> {
F(TableSet, const Value& index, const Value& value, \
const TableIndexImmediate<validate>& imm) \
F(Unreachable) \
F(NopForTestingUnsupportedInLiftoff) \
F(Select, const Value& cond, const Value& fval, const Value& tval, \
Value* result) \
F(BrOrRet, uint32_t depth) \
......@@ -1620,6 +1621,7 @@ class WasmDecoder : public Decoder {
/********** Control opcodes **********/
case kExprUnreachable:
case kExprNop:
case kExprNopForTestingUnsupportedInLiftoff:
case kExprElse:
case kExprEnd:
case kExprReturn:
......@@ -2016,6 +2018,7 @@ class WasmDecoder : public Decoder {
case kExprTry:
case kExprCatch:
case kExprNop:
case kExprNopForTestingUnsupportedInLiftoff:
case kExprReturn:
case kExprReturnCall:
case kExprReturnCallIndirect:
......@@ -2384,6 +2387,15 @@ class WasmFullDecoder : public WasmDecoder<validate> {
DECODE(Nop) { return 1; }
DECODE(NopForTestingUnsupportedInLiftoff) {
if (!VALIDATE(FLAG_enable_testing_opcode_in_wasm)) {
this->DecodeError("Invalid opcode 0x%x", opcode);
return 0;
}
CALL_INTERFACE_IF_REACHABLE(NopForTestingUnsupportedInLiftoff);
return 1;
}
#define BUILD_SIMPLE_OPCODE(op, _, sig) \
DECODE(op) { return BuildSimpleOperator_##sig(kExpr##op); }
FOREACH_SIMPLE_OPCODE(BUILD_SIMPLE_OPCODE)
......@@ -3237,6 +3249,7 @@ class WasmFullDecoder : public WasmDecoder<validate> {
DECODE_IMPL(BrTable);
DECODE_IMPL(Return);
DECODE_IMPL(Unreachable);
DECODE_IMPL(NopForTestingUnsupportedInLiftoff);
DECODE_IMPL(I32Const);
DECODE_IMPL(I64Const);
DECODE_IMPL(F32Const);
......
......@@ -439,6 +439,8 @@ class WasmGraphBuildingInterface {
BUILD(Trap, wasm::TrapReason::kTrapUnreachable, decoder->position());
}
void NopForTestingUnsupportedInLiftoff(FullDecoder* decoder) {}
void Select(FullDecoder* decoder, const Value& cond, const Value& fval,
const Value& tval, Value* result) {
TFNode* controls[2];
......
......@@ -138,6 +138,7 @@ constexpr const char* WasmOpcodes::OpcodeName(WasmOpcode opcode) {
CASE_I64_OP(SExtendI32, "extend32_s")
CASE_OP(Unreachable, "unreachable")
CASE_OP(Nop, "nop")
CASE_OP(NopForTestingUnsupportedInLiftoff, "nop_for_testing")
CASE_OP(Block, "block")
CASE_OP(Loop, "loop")
CASE_OP(If, "if")
......
......@@ -46,7 +46,8 @@ bool V8_EXPORT_PRIVATE IsJSCompatibleSignature(const FunctionSig* sig,
V(Return, 0x0f, _) \
V(Delegate, 0x16, _ /* eh_prototype */) \
V(Let, 0x17, _ /* typed_funcref prototype */) \
V(BrOnNull, 0xd4, _ /* gc prototype */)
V(BrOnNull, 0xd4, _ /* gc prototype */) \
V(NopForTestingUnsupportedInLiftoff, 0x18, _)
// Constants, locals, globals, and calls.
#define FOREACH_MISC_OPCODE(V) \
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --experimental-wasm-reftypes
// Flags: --enable-testing-opcode-in-wasm
// Test that tiering up and tiering down works even if functions cannot be
// compiled with Liftoff.
......@@ -11,11 +11,12 @@ load('test/mjsunit/wasm/wasm-module-builder.js');
// Create a simple Wasm module.
function create_builder(i) {
const kExprNopForTestingUnsupportedInLiftoff = 0x18;
const builder = new WasmModuleBuilder();
builder.addFunction('main', kSig_i_r)
builder.addFunction('main', kSig_i_i)
.addBody([
kExprLocalGet, 0, kExprRefIsNull, ...wasmI32Const(i),
kExprI32Add
kExprLocalGet, 0, kExprNopForTestingUnsupportedInLiftoff,
...wasmI32Const(i), kExprI32Add
])
.exportFunc();
return builder;
......
......@@ -117,6 +117,10 @@
'debug/debug-stepout-scope-part8': [SKIP],
}], # 'arch == arm and mode == debug'
['mode != debug', {
# Test uses a flag only available in debug mode
'debug/wasm/debug-enabled-tier-down-wasm-unsupported-liftoff': [SKIP],
}],
##############################################################################
['arch == s390 or arch == s390x', {
......
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