Commit 852f43cd authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[wasm] Make opcode properties constexpr

This allows the compiler to eliminate more unneeded branches. Since all
functions just do a lookup in a static table (either directly, or via
compiling a switch to such a lookup), they are also good candidates for
inlining, which is made possible by this change.

One DCHECK is removed instead of pulling in the inl header, which would
require more refactoring since the check is in a non-inl header.

R=thibaudm@chromium.org
TBR=jkummerow@chromium.org

Bug: v8:10576
Change-Id: If0fd25fd62c5f30b896fc67a5458a5ae475a6351
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2259944
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarThibaud Michaud <thibaudm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68508}
parent 2d984508
......@@ -55,7 +55,7 @@
#include "src/wasm/wasm-linkage.h"
#include "src/wasm/wasm-module.h"
#include "src/wasm/wasm-objects-inl.h"
#include "src/wasm/wasm-opcodes.h"
#include "src/wasm/wasm-opcodes-inl.h"
namespace v8 {
namespace internal {
......
......@@ -314,7 +314,7 @@ class ErrorUtils : public AllStatic {
class MessageFormatter {
public:
static const char* TemplateString(MessageTemplate index);
V8_EXPORT_PRIVATE static const char* TemplateString(MessageTemplate index);
V8_EXPORT_PRIVATE static MaybeHandle<String> Format(Isolate* isolate,
MessageTemplate index,
......
......@@ -27,7 +27,7 @@
#include "src/wasm/wasm-engine.h"
#include "src/wasm/wasm-linkage.h"
#include "src/wasm/wasm-objects.h"
#include "src/wasm/wasm-opcodes.h"
#include "src/wasm/wasm-opcodes-inl.h"
namespace v8 {
namespace internal {
......
......@@ -137,7 +137,6 @@ class Decoder {
if (length == nullptr) {
length = &unused_length;
}
DCHECK(WasmOpcodes::IsPrefixOpcode(static_cast<WasmOpcode>(*pc)));
uint32_t index;
if (*pc == WasmOpcode::kSimdPrefix) {
// SIMD opcodes can be multiple bytes (when LEB128 encoded).
......
......@@ -13,7 +13,7 @@
#include "src/wasm/wasm-limits.h"
#include "src/wasm/wasm-linkage.h"
#include "src/wasm/wasm-module.h"
#include "src/wasm/wasm-opcodes.h"
#include "src/wasm/wasm-opcodes-inl.h"
namespace v8 {
namespace internal {
......
......@@ -16,7 +16,7 @@
#include "src/wasm/wasm-limits.h"
#include "src/wasm/wasm-linkage.h"
#include "src/wasm/wasm-module.h"
#include "src/wasm/wasm-opcodes.h"
#include "src/wasm/wasm-opcodes-inl.h"
namespace v8 {
namespace internal {
......
......@@ -23,6 +23,7 @@
#include "src/wasm/wasm-limits.h"
#include "src/wasm/wasm-module.h"
#include "src/wasm/wasm-objects-inl.h"
#include "src/wasm/wasm-opcodes-inl.h"
#include "src/wasm/wasm-value.h"
#include "src/zone/accounting-allocator.h"
......
This diff is collapsed.
This diff is collapsed.
......@@ -728,21 +728,21 @@ enum TrapReason {
// A collection of opcode-related static methods.
class V8_EXPORT_PRIVATE WasmOpcodes {
public:
static const char* OpcodeName(WasmOpcode);
static const FunctionSig* Signature(WasmOpcode);
static const FunctionSig* AsmjsSignature(WasmOpcode);
static bool IsPrefixOpcode(WasmOpcode);
static bool IsControlOpcode(WasmOpcode);
static bool IsExternRefOpcode(WasmOpcode);
static bool IsThrowingOpcode(WasmOpcode);
static bool IsSimdPostMvpOpcode(WasmOpcode);
static constexpr const char* OpcodeName(WasmOpcode);
static constexpr const FunctionSig* Signature(WasmOpcode);
static constexpr const FunctionSig* AsmjsSignature(WasmOpcode);
static constexpr bool IsPrefixOpcode(WasmOpcode);
static constexpr bool IsControlOpcode(WasmOpcode);
static constexpr bool IsExternRefOpcode(WasmOpcode);
static constexpr bool IsThrowingOpcode(WasmOpcode);
static constexpr bool IsSimdPostMvpOpcode(WasmOpcode);
// Check whether the given opcode always jumps, i.e. all instructions after
// this one in the current block are dead. Returns false for |end|.
static bool IsUnconditionalJump(WasmOpcode);
static bool IsBreakable(WasmOpcode);
static constexpr bool IsUnconditionalJump(WasmOpcode);
static constexpr bool IsBreakable(WasmOpcode);
static MessageTemplate TrapReasonToMessageId(TrapReason);
static const char* TrapReasonMessage(TrapReason);
static constexpr MessageTemplate TrapReasonToMessageId(TrapReason);
static inline const char* TrapReasonMessage(TrapReason);
};
// Representation of an initializer expression.
......
......@@ -11,6 +11,7 @@
#include "src/base/platform/elapsed-timer.h"
#include "src/codegen/assembler-inl.h"
#include "src/utils/utils.h"
#include "src/wasm/wasm-opcodes-inl.h"
#include "test/cctest/cctest.h"
#include "test/cctest/compiler/value-helper.h"
#include "test/cctest/wasm/wasm-run-utils.h"
......
......@@ -26,7 +26,7 @@
#include "src/wasm/wasm-limits.h"
#include "src/wasm/wasm-module.h"
#include "src/wasm/wasm-objects-inl.h"
#include "src/wasm/wasm-opcodes.h"
#include "src/wasm/wasm-opcodes-inl.h"
#include "src/zone/accounting-allocator.h"
#include "src/zone/zone-containers.h"
......
......@@ -15,7 +15,7 @@
#include "src/utils/ostreams.h"
#include "src/wasm/wasm-module-builder.h"
#include "src/wasm/wasm-module.h"
#include "src/wasm/wasm-opcodes.h"
#include "src/wasm/wasm-opcodes-inl.h"
#include "test/common/wasm/flag-utils.h"
#include "test/common/wasm/test-signatures.h"
#include "test/common/wasm/wasm-module-runner.h"
......
......@@ -2,24 +2,23 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/wasm/leb-helper.h"
#include "test/unittests/test-utils.h"
#include "src/wasm/function-body-decoder.h"
#include "src/init/v8.h"
#include "src/objects/objects-inl.h"
#include "src/objects/objects.h"
#include "src/utils/ostreams.h"
#include "src/wasm/function-body-decoder-impl.h"
#include "src/wasm/function-body-decoder.h"
#include "src/wasm/leb-helper.h"
#include "src/wasm/local-decl-encoder.h"
#include "src/wasm/signature-map.h"
#include "src/wasm/wasm-limits.h"
#include "src/wasm/wasm-module.h"
#include "src/wasm/wasm-opcodes.h"
#include "src/wasm/wasm-opcodes-inl.h"
#include "test/common/wasm/flag-utils.h"
#include "test/common/wasm/test-signatures.h"
#include "test/common/wasm/wasm-macro-gen.h"
#include "test/unittests/test-utils.h"
#include "testing/gmock-support.h"
namespace v8 {
......
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