@@ -135,8 +135,8 @@ int32_t ByteCodeEmitter::getOffset(LabelTy Label) {
135135// / Helper to write bytecode and bail out if 32-bit offsets become invalid.
136136// / Pointers will be automatically marshalled as 32-bit IDs.
137137template <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) {
140140 size_t ValPos = Code.size ();
141141 size_t Size;
142142
@@ -153,7 +153,7 @@ static void emit(Program &P, std::vector<std::byte> &Code, const T &Val,
153153 // Access must be aligned!
154154 assert (aligned (ValPos));
155155 assert (aligned (ValPos + Size));
156- Code.resize (ValPos + Size);
156+ Code.resize_for_overwrite (ValPos + Size);
157157
158158 if constexpr (!std::is_pointer_v<T>) {
159159 new (Code.data () + ValPos) T (Val);
@@ -166,7 +166,7 @@ static void emit(Program &P, std::vector<std::byte> &Code, const T &Val,
166166// / Emits a serializable value. These usually (potentially) contain
167167// / heap-allocated memory and aren't trivially copyable.
168168template <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,
170170 bool &Success) {
171171 size_t ValPos = Code.size ();
172172 size_t Size = align (Val.bytesToSerialize ());
@@ -179,32 +179,32 @@ static void emitSerialized(std::vector<std::byte> &Code, const T &Val,
179179 // Access must be aligned!
180180 assert (aligned (ValPos));
181181 assert (aligned (ValPos + Size));
182- Code.resize (ValPos + Size);
182+ Code.resize_for_overwrite (ValPos + Size);
183183
184184 Val.serialize (Code.data () + ValPos);
185185}
186186
187187template <>
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) {
190190 emitSerialized (Code, Val, Success);
191191}
192192
193193template <>
194- void emit (Program &P, std::vector <std::byte> &Code,
194+ void emit (Program &P, llvm::SmallVectorImpl <std::byte> &Code,
195195 const IntegralAP<false > &Val, bool &Success) {
196196 emitSerialized (Code, Val, Success);
197197}
198198
199199template <>
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) {
202202 emitSerialized (Code, Val, Success);
203203}
204204
205205template <>
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) {
208208 emitSerialized (Code, Val, Success);
209209}
210210
0 commit comments