Skip to content

Commit fd3b3e5

Browse files
authored
Refactor interpreter (WebAssembly#1508)
* Move more logic to the Literal class. We now leave all the work to there, except for handling traps. * Avoid switching on the type, then the opcode, then Literal method usually switches on the type again - instead, do one big switch for the opcodes (then the Literal method is unchanged) which is shorter and clearer, and avoids that first switching.
1 parent 7a8273a commit fd3b3e5

3 files changed

Lines changed: 220 additions & 199 deletions

File tree

src/literal.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,6 @@ class Literal {
3838
int64_t i64;
3939
};
4040

41-
// The RHS of shl/shru/shrs must be masked by bitwidth.
42-
template <typename T>
43-
static T shiftMask(T val) {
44-
return val & (sizeof(T) * 8 - 1);
45-
}
46-
4741
public:
4842
Literal() : type(Type::none), i64(0) {}
4943
explicit Literal(Type type) : type(type), i64(0) {}
@@ -98,6 +92,9 @@ class Literal {
9892
Literal extendToSI64() const;
9993
Literal extendToUI64() const;
10094
Literal extendToF64() const;
95+
Literal extendS8() const;
96+
Literal extendS16() const;
97+
Literal extendS32() const;
10198
Literal truncateToI32() const;
10299
Literal truncateToF32() const;
103100

@@ -106,13 +103,15 @@ class Literal {
106103
Literal convertSToF64() const;
107104
Literal convertUToF64() const;
108105

106+
Literal eqz() const;
109107
Literal neg() const;
110108
Literal abs() const;
111109
Literal ceil() const;
112110
Literal floor() const;
113111
Literal trunc() const;
114112
Literal nearbyint() const;
115113
Literal sqrt() const;
114+
Literal demote() const;
116115

117116
Literal add(const Literal& other) const;
118117
Literal sub(const Literal& other) const;

0 commit comments

Comments
 (0)