@@ -135,8 +135,8 @@ int32_t ByteCodeEmitter::getOffset(LabelTy Label) {
135
135
// / Helper to write bytecode and bail out if 32-bit offsets become invalid.
136
136
// / Pointers will be automatically marshalled as 32-bit IDs.
137
137
template <typename T>
138
- static void emit (Program &P, std::vector <std::byte> &Code, const T &Val ,
139
- bool &Success) {
138
+ static void emit (Program &P, llvm::SmallVectorImpl <std::byte> &Code,
139
+ const T &Val, bool &Success) {
140
140
size_t ValPos = Code.size ();
141
141
size_t Size;
142
142
@@ -153,7 +153,7 @@ static void emit(Program &P, std::vector<std::byte> &Code, const T &Val,
153
153
// Access must be aligned!
154
154
assert (aligned (ValPos));
155
155
assert (aligned (ValPos + Size));
156
- Code.resize (ValPos + Size);
156
+ Code.resize_for_overwrite (ValPos + Size);
157
157
158
158
if constexpr (!std::is_pointer_v<T>) {
159
159
new (Code.data () + ValPos) T (Val);
@@ -166,7 +166,7 @@ static void emit(Program &P, std::vector<std::byte> &Code, const T &Val,
166
166
// / Emits a serializable value. These usually (potentially) contain
167
167
// / heap-allocated memory and aren't trivially copyable.
168
168
template <typename T>
169
- static void emitSerialized (std::vector <std::byte> &Code, const T &Val,
169
+ static void emitSerialized (llvm::SmallVectorImpl <std::byte> &Code, const T &Val,
170
170
bool &Success) {
171
171
size_t ValPos = Code.size ();
172
172
size_t Size = align (Val.bytesToSerialize ());
@@ -179,32 +179,32 @@ static void emitSerialized(std::vector<std::byte> &Code, const T &Val,
179
179
// Access must be aligned!
180
180
assert (aligned (ValPos));
181
181
assert (aligned (ValPos + Size));
182
- Code.resize (ValPos + Size);
182
+ Code.resize_for_overwrite (ValPos + Size);
183
183
184
184
Val.serialize (Code.data () + ValPos);
185
185
}
186
186
187
187
template <>
188
- void emit (Program &P, std::vector <std::byte> &Code, const Floating &Val ,
189
- bool &Success) {
188
+ void emit (Program &P, llvm::SmallVectorImpl <std::byte> &Code,
189
+ const Floating &Val, bool &Success) {
190
190
emitSerialized (Code, Val, Success);
191
191
}
192
192
193
193
template <>
194
- void emit (Program &P, std::vector <std::byte> &Code,
194
+ void emit (Program &P, llvm::SmallVectorImpl <std::byte> &Code,
195
195
const IntegralAP<false > &Val, bool &Success) {
196
196
emitSerialized (Code, Val, Success);
197
197
}
198
198
199
199
template <>
200
- void emit (Program &P, std::vector <std::byte> &Code, const IntegralAP< true > &Val ,
201
- bool &Success) {
200
+ void emit (Program &P, llvm::SmallVectorImpl <std::byte> &Code,
201
+ const IntegralAP< true > &Val, bool &Success) {
202
202
emitSerialized (Code, Val, Success);
203
203
}
204
204
205
205
template <>
206
- void emit (Program &P, std::vector <std::byte> &Code, const FixedPoint &Val ,
207
- bool &Success) {
206
+ void emit (Program &P, llvm::SmallVectorImpl <std::byte> &Code,
207
+ const FixedPoint &Val, bool &Success) {
208
208
emitSerialized (Code, Val, Success);
209
209
}
210
210
0 commit comments