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