Merge V8 5.2.361.47 DO NOT MERGE
https://chromium.googlesource.com/v8/v8/+/5.2.361.47
FPIIM-449
Change-Id: Ibec421b85a9b88cb3a432ada642e469fe7e78346
(cherry picked from commit bcf72ee8e3b26f1d0726869c7ddb3921c68b09a8)
diff --git a/src/wasm/wasm-opcodes.cc b/src/wasm/wasm-opcodes.cc
index 736c4d9..a08fa8d 100644
--- a/src/wasm/wasm-opcodes.cc
+++ b/src/wasm/wasm-opcodes.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "src/wasm/wasm-opcodes.h"
+#include "src/messages.h"
#include "src/signature.h"
namespace v8 {
@@ -24,6 +25,18 @@
return "Unknown";
}
+const char* WasmOpcodes::ShortOpcodeName(WasmOpcode opcode) {
+ switch (opcode) {
+#define DECLARE_NAME_CASE(name, opcode, sig) \
+ case kExpr##name: \
+ return #name;
+ FOREACH_OPCODE(DECLARE_NAME_CASE)
+#undef DECLARE_NAME_CASE
+ default:
+ break;
+ }
+ return "Unknown";
+}
std::ostream& operator<<(std::ostream& os, const FunctionSig& sig) {
if (sig.return_count() == 0) os << "v";
@@ -38,13 +51,10 @@
return os;
}
-
#define DECLARE_SIG_ENUM(name, ...) kSigEnum_##name,
-
enum WasmOpcodeSig { FOREACH_SIGNATURE(DECLARE_SIG_ENUM) };
-
// TODO(titzer): not static-initializer safe. Wrap in LazyInstance.
#define DECLARE_SIG(name, ...) \
static LocalType kTypes_##name[] = {__VA_ARGS__}; \
@@ -60,7 +70,6 @@
static byte kSimpleExprSigTable[256];
-
// Initialize the signature table.
static void InitSigTable() {
#define SET_SIG_TABLE(name, opcode, sig) \
@@ -70,15 +79,24 @@
#undef SET_SIG_TABLE
}
+class SigTable {
+ public:
+ SigTable() {
+ // TODO(ahaas): Move {InitSigTable} into the class.
+ InitSigTable();
+ }
+ FunctionSig* Signature(WasmOpcode opcode) const {
+ return const_cast<FunctionSig*>(
+ kSimpleExprSigs[kSimpleExprSigTable[static_cast<byte>(opcode)]]);
+ }
+};
+
+static base::LazyInstance<SigTable>::type sig_table = LAZY_INSTANCE_INITIALIZER;
FunctionSig* WasmOpcodes::Signature(WasmOpcode opcode) {
- // TODO(titzer): use LazyInstance to make this thread safe.
- if (kSimpleExprSigTable[kExprI32Add] == 0) InitSigTable();
- return const_cast<FunctionSig*>(
- kSimpleExprSigs[kSimpleExprSigTable[static_cast<byte>(opcode)]]);
+ return sig_table.Get().Signature(opcode);
}
-
// TODO(titzer): pull WASM_64 up to a common header.
#if !V8_TARGET_ARCH_32_BIT || V8_TARGET_ARCH_X64
#define WASM_64 1
@@ -86,64 +104,20 @@
#define WASM_64 0
#endif
-
-bool WasmOpcodes::IsSupported(WasmOpcode opcode) {
-#if !WASM_64
- switch (opcode) {
- // Opcodes not supported on 32-bit platforms.
- case kExprI64Add:
- case kExprI64Sub:
- case kExprI64Mul:
- case kExprI64DivS:
- case kExprI64DivU:
- case kExprI64RemS:
- case kExprI64RemU:
- case kExprI64And:
- case kExprI64Ior:
- case kExprI64Xor:
- case kExprI64Shl:
- case kExprI64ShrU:
- case kExprI64ShrS:
- case kExprI64Ror:
- case kExprI64Rol:
- case kExprI64Eq:
- case kExprI64Ne:
- case kExprI64LtS:
- case kExprI64LeS:
- case kExprI64LtU:
- case kExprI64LeU:
- case kExprI64GtS:
- case kExprI64GeS:
- case kExprI64GtU:
- case kExprI64GeU:
-
- case kExprI32ConvertI64:
- case kExprI64SConvertI32:
- case kExprI64UConvertI32:
-
- case kExprF64ReinterpretI64:
- case kExprI64ReinterpretF64:
-
- case kExprI64Clz:
- case kExprI64Ctz:
- case kExprI64Popcnt:
-
- case kExprF32SConvertI64:
- case kExprF32UConvertI64:
- case kExprF64SConvertI64:
- case kExprF64UConvertI64:
- case kExprI64SConvertF32:
- case kExprI64SConvertF64:
- case kExprI64UConvertF32:
- case kExprI64UConvertF64:
-
- return false;
+int WasmOpcodes::TrapReasonToMessageId(TrapReason reason) {
+ switch (reason) {
+#define TRAPREASON_TO_MESSAGE(name) \
+ case k##name: \
+ return MessageTemplate::kWasm##name;
+ FOREACH_WASM_TRAPREASON(TRAPREASON_TO_MESSAGE)
+#undef TRAPREASON_TO_MESSAGE
default:
- return true;
+ return MessageTemplate::kNone;
}
-#else
- return true;
-#endif
+}
+
+const char* WasmOpcodes::TrapReasonMessage(TrapReason reason) {
+ return MessageTemplate::TemplateString(TrapReasonToMessageId(reason));
}
} // namespace wasm
} // namespace internal