OLD | NEW |
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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 V(f_if, kAstF32, kAstI32, kAstF32) \ | 322 V(f_if, kAstF32, kAstI32, kAstF32) \ |
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. |
| 333 enum TrapReason { |
| 334 kTrapUnreachable, |
| 335 kTrapMemOutOfBounds, |
| 336 kTrapDivByZero, |
| 337 kTrapDivUnrepresentable, |
| 338 kTrapRemByZero, |
| 339 kTrapFloatUnrepresentable, |
| 340 kTrapFuncInvalid, |
| 341 kTrapFuncSigMismatch, |
| 342 kTrapCount |
| 343 }; |
| 344 |
332 // A collection of opcode-related static methods. | 345 // A collection of opcode-related static methods. |
333 class WasmOpcodes { | 346 class WasmOpcodes { |
334 public: | 347 public: |
335 static bool IsSupported(WasmOpcode opcode); | 348 static bool IsSupported(WasmOpcode opcode); |
336 static const char* OpcodeName(WasmOpcode opcode); | 349 static const char* OpcodeName(WasmOpcode opcode); |
337 static FunctionSig* Signature(WasmOpcode opcode); | 350 static FunctionSig* Signature(WasmOpcode opcode); |
338 | 351 |
339 static byte MemSize(MachineType type) { | 352 static byte MemSize(MachineType type) { |
340 return 1 << ElementSizeLog2Of(type.representation()); | 353 return 1 << ElementSizeLog2Of(type.representation()); |
341 } | 354 } |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 case kAstF64: | 501 case kAstF64: |
489 return "f64"; | 502 return "f64"; |
490 case kAstStmt: | 503 case kAstStmt: |
491 return "<stmt>"; | 504 return "<stmt>"; |
492 case kAstEnd: | 505 case kAstEnd: |
493 return "<end>"; | 506 return "<end>"; |
494 default: | 507 default: |
495 return "<unknown>"; | 508 return "<unknown>"; |
496 } | 509 } |
497 } | 510 } |
| 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 } |
498 }; | 534 }; |
499 } // namespace wasm | 535 } // namespace wasm |
500 } // namespace internal | 536 } // namespace internal |
501 } // namespace v8 | 537 } // namespace v8 |
502 | 538 |
503 #endif // V8_WASM_OPCODES_H_ | 539 #endif // V8_WASM_OPCODES_H_ |
OLD | NEW |