Commit f87539b4 authored by Jakob Kummerow's avatar Jakob Kummerow Committed by Commit Bot

[cleanup] Replace some "default:" with explicit cases

When the intention is to handle every case, *and* when we can be
reasonably sure that no invalid enum values will occur (e.g. from
reading untrusted data), then we shouldn't have a "default:" case
in a switch statement so that the compiler will warn us when a
case is missing.

Bug: v8:10506
Change-Id: Iefdebd54802611e7ec3479afa3c4e6506f97a095
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2204284
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Auto-Submit: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67854}
parent 4f9b30b0
......@@ -348,8 +348,6 @@ void LiftoffAssembler::Load(LiftoffRegister dst, Register src_addr,
case LoadType::kS128Load:
Ldr(dst.fp().Q(), src_op);
break;
default:
UNREACHABLE();
}
}
......@@ -386,8 +384,6 @@ void LiftoffAssembler::Store(Register dst_addr, Register offset_reg,
case StoreType::kS128Store:
Str(src.fp().Q(), dst_op);
break;
default:
UNREACHABLE();
}
}
......
......@@ -336,8 +336,6 @@ void LiftoffAssembler::Load(LiftoffRegister dst, Register src_addr,
case LoadType::kS128Load:
movdqu(dst.fp(), src_op);
break;
default:
UNREACHABLE();
}
}
......@@ -405,8 +403,6 @@ void LiftoffAssembler::Store(Register dst_addr, Register offset_reg,
case StoreType::kS128Store:
Movdqu(dst_op, src.fp());
break;
default:
UNREACHABLE();
}
}
......
......@@ -306,8 +306,6 @@ void LiftoffAssembler::Load(LiftoffRegister dst, Register src_addr,
case LoadType::kS128Load:
Movdqu(dst.fp(), src_op);
break;
default:
UNREACHABLE();
}
}
......@@ -345,8 +343,6 @@ void LiftoffAssembler::Store(Register dst_addr, Register offset_reg,
case StoreType::kS128Store:
Movdqu(dst_op, src.fp());
break;
default:
UNREACHABLE();
}
}
......
......@@ -320,10 +320,10 @@ ValueType read_value_type(Decoder* decoder, const byte* pc,
// Although void is included in ValueType, it is technically not a value
// type and is only used to indicate a void block return type. The caller
// of this function is responsible to check for its presence separately.
return kWasmBottom;
default:
return kWasmBottom;
break;
}
// Malformed modules specifying invalid types can get here.
return kWasmBottom;
}
} // namespace value_type_reader
......@@ -1623,13 +1623,20 @@ class WasmDecoder : public Decoder {
}
case kExprRttGet:
case kExprRttSub: {
// TODO(7748): Impelement.
decoder->error(pc, "rtt opcodes not impelemented yet");
// TODO(7748): Implement.
decoder->error(pc, "rtt opcodes not implemented yet");
return 2;
}
default:
case kExprI31New:
case kExprI31GetS:
case kExprI31GetU:
case kExprRefTest:
case kExprRefCast:
return 2;
default:
UNREACHABLE();
}
}
default:
......@@ -2705,7 +2712,8 @@ class WasmFullDecoder : public WasmDecoder<validate> {
case kControlTry:
TRACE_PART("T");
break;
default:
case kControlIfElse:
case kControlTryCatch:
break;
}
if (c.start_merge.arity) TRACE_PART("%u-", c.start_merge.arity);
......
......@@ -788,7 +788,9 @@ class WasmGraphBuildingInterface {
case ValueType::kOptRef:
case ValueType::kEqRef:
return builder_->RefNull();
default:
case ValueType::kStmt:
case ValueType::kBottom:
case ValueType::kRef:
UNREACHABLE();
}
}
......
......@@ -1782,8 +1782,6 @@ class AsyncCompileJob::CompilationStateCallback {
// {kFinishedTopTierCompilation}, hence don't remember this in
// {last_event_}.
return;
default:
UNREACHABLE();
}
#ifdef DEBUG
last_event_ = event;
......
......@@ -126,9 +126,8 @@ ValueType TypeOf(const WasmModule* module, const WasmInitExpr& expr) {
return kWasmNullRef;
case WasmInitExpr::kRefFuncConst:
return kWasmFuncRef;
default:
UNREACHABLE();
}
UNREACHABLE();
}
// Reads a length-prefixed string, checking that it is within bounds. Returns
......
......@@ -198,7 +198,6 @@ class InterpreterHandle {
return false;
// RUNNING should never occur here.
case WasmInterpreter::State::RUNNING:
default:
UNREACHABLE();
}
}
......
......@@ -595,7 +595,12 @@ void WasmModuleBuilder::WriteTo(ZoneBuffer* buffer) const {
case ValueType::kEqRef:
buffer->write_u8(kExprRefNull);
break;
default:
case ValueType::kStmt:
case ValueType::kS128:
case ValueType::kBottom:
case ValueType::kRef:
case ValueType::kAnyRef:
case ValueType::kNullRef:
UNREACHABLE();
}
}
......
......@@ -458,9 +458,8 @@ Handle<JSArray> GetImports(Isolate* isolate,
case kExternalException:
import_kind = exception_string;
break;
default:
UNREACHABLE();
}
DCHECK(!import_kind->is_null());
Handle<String> import_module =
WasmModuleObject::ExtractUtf8StringFromModuleBytes(
......
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