Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/wasm/wasm-opcodes.h

Issue 1880493002: Move TrapReason messages over to messages.h (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@include-objects-in-messages
Patch Set: rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/messages.h ('k') | src/wasm/wasm-opcodes.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_WASM_OPCODES_H_ 5 #ifndef V8_WASM_OPCODES_H_
6 #define V8_WASM_OPCODES_H_ 6 #define V8_WASM_OPCODES_H_
7 7
8 #include "src/machine-type.h" 8 #include "src/machine-type.h"
9 #include "src/signature.h" 9 #include "src/signature.h"
10 10
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 V(l_il, kAstI64, kAstI32, kAstI64) 323 V(l_il, kAstI64, kAstI32, kAstI64)
324 324
325 enum WasmOpcode { 325 enum WasmOpcode {
326 // Declare expression opcodes. 326 // Declare expression opcodes.
327 #define DECLARE_NAMED_ENUM(name, opcode, sig) kExpr##name = opcode, 327 #define DECLARE_NAMED_ENUM(name, opcode, sig) kExpr##name = opcode,
328 FOREACH_OPCODE(DECLARE_NAMED_ENUM) 328 FOREACH_OPCODE(DECLARE_NAMED_ENUM)
329 #undef DECLARE_NAMED_ENUM 329 #undef DECLARE_NAMED_ENUM
330 }; 330 };
331 331
332 // The reason for a trap. 332 // The reason for a trap.
333 #define FOREACH_WASM_TRAPREASON(V) \
334 V(TrapUnreachable) \
335 V(TrapMemOutOfBounds) \
336 V(TrapDivByZero) \
337 V(TrapDivUnrepresentable) \
338 V(TrapRemByZero) \
339 V(TrapFloatUnrepresentable) \
340 V(TrapFuncInvalid) \
341 V(TrapFuncSigMismatch)
342
333 enum TrapReason { 343 enum TrapReason {
334 kTrapUnreachable, 344 #define DECLARE_ENUM(name) k##name,
335 kTrapMemOutOfBounds, 345 FOREACH_WASM_TRAPREASON(DECLARE_ENUM)
336 kTrapDivByZero,
337 kTrapDivUnrepresentable,
338 kTrapRemByZero,
339 kTrapFloatUnrepresentable,
340 kTrapFuncInvalid,
341 kTrapFuncSigMismatch,
342 kTrapCount 346 kTrapCount
347 #undef DECLARE_ENUM
343 }; 348 };
344 349
345 // A collection of opcode-related static methods. 350 // A collection of opcode-related static methods.
346 class WasmOpcodes { 351 class WasmOpcodes {
347 public: 352 public:
348 static bool IsSupported(WasmOpcode opcode); 353 static bool IsSupported(WasmOpcode opcode);
349 static const char* OpcodeName(WasmOpcode opcode); 354 static const char* OpcodeName(WasmOpcode opcode);
350 static FunctionSig* Signature(WasmOpcode opcode); 355 static FunctionSig* Signature(WasmOpcode opcode);
351 356
357 static int TrapReasonToMessageId(TrapReason reason);
358 static const char* TrapReasonMessage(TrapReason reason);
359
352 static byte MemSize(MachineType type) { 360 static byte MemSize(MachineType type) {
353 return 1 << ElementSizeLog2Of(type.representation()); 361 return 1 << ElementSizeLog2Of(type.representation());
354 } 362 }
355 363
356 static LocalTypeCode LocalTypeCodeFor(LocalType type) { 364 static LocalTypeCode LocalTypeCodeFor(LocalType type) {
357 switch (type) { 365 switch (type) {
358 case kAstI32: 366 case kAstI32:
359 return kLocalI32; 367 return kLocalI32;
360 case kAstI64: 368 case kAstI64:
361 return kLocalI64; 369 return kLocalI64;
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 case kAstF64: 509 case kAstF64:
502 return "f64"; 510 return "f64";
503 case kAstStmt: 511 case kAstStmt:
504 return "<stmt>"; 512 return "<stmt>";
505 case kAstEnd: 513 case kAstEnd:
506 return "<end>"; 514 return "<end>";
507 default: 515 default:
508 return "<unknown>"; 516 return "<unknown>";
509 } 517 }
510 } 518 }
511
512 static const char* TrapReasonName(TrapReason reason) {
513 switch (reason) {
514 case kTrapUnreachable:
515 return "unreachable";
516 case kTrapMemOutOfBounds:
517 return "memory access out of bounds";
518 case kTrapDivByZero:
519 return "divide by zero";
520 case kTrapDivUnrepresentable:
521 return "divide result unrepresentable";
522 case kTrapRemByZero:
523 return "remainder by zero";
524 case kTrapFloatUnrepresentable:
525 return "integer result unrepresentable";
526 case kTrapFuncInvalid:
527 return "invalid function";
528 case kTrapFuncSigMismatch:
529 return "function signature mismatch";
530 default:
531 return "<?>";
532 }
533 }
534 }; 519 };
535 } // namespace wasm 520 } // namespace wasm
536 } // namespace internal 521 } // namespace internal
537 } // namespace v8 522 } // namespace v8
538 523
539 #endif // V8_WASM_OPCODES_H_ 524 #endif // V8_WASM_OPCODES_H_
OLDNEW
« no previous file with comments | « src/messages.h ('k') | src/wasm/wasm-opcodes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698