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 #include "src/signature.h" | 5 #include "src/signature.h" |
6 | 6 |
7 #include "src/handles.h" | 7 #include "src/handles.h" |
8 #include "src/objects-inl.h" | 8 #include "src/objects-inl.h" |
9 #include "src/v8.h" | 9 #include "src/v8.h" |
10 #include "src/zone/zone-containers.h" | 10 #include "src/zone/zone-containers.h" |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 DCHECK_EQ(0, asm_offsets_.size()); | 183 DCHECK_EQ(0, asm_offsets_.size()); |
184 asm_func_start_source_position_ = position; | 184 asm_func_start_source_position_ = position; |
185 last_asm_source_position_ = position; | 185 last_asm_source_position_ = position; |
186 } | 186 } |
187 | 187 |
188 void WasmFunctionBuilder::StashCode(std::vector<byte>* dst, size_t position) { | 188 void WasmFunctionBuilder::StashCode(std::vector<byte>* dst, size_t position) { |
189 if (dst == nullptr) { | 189 if (dst == nullptr) { |
190 body_.resize(position); | 190 body_.resize(position); |
191 return; | 191 return; |
192 } | 192 } |
| 193 DCHECK_LE(position, body_.size()); |
193 size_t len = body_.size() - position; | 194 size_t len = body_.size() - position; |
194 dst->resize(len); | 195 dst->resize(len); |
195 memcpy(dst->data(), &body_[position], len); | 196 memcpy(dst->data(), body_.data() + position, len); |
196 body_.resize(position); | 197 body_.resize(position); |
197 } | 198 } |
198 | 199 |
199 void WasmFunctionBuilder::WriteSignature(ZoneBuffer& buffer) const { | 200 void WasmFunctionBuilder::WriteSignature(ZoneBuffer& buffer) const { |
200 buffer.write_u32v(signature_index_); | 201 buffer.write_u32v(signature_index_); |
201 } | 202 } |
202 | 203 |
203 void WasmFunctionBuilder::WriteExports(ZoneBuffer& buffer) const { | 204 void WasmFunctionBuilder::WriteExports(ZoneBuffer& buffer) const { |
204 for (auto name : exported_names_) { | 205 for (auto name : exported_names_) { |
205 buffer.write_size(name.size()); | 206 buffer.write_size(name.size()); |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 // Emit the offset table per function. | 588 // Emit the offset table per function. |
588 for (auto function : functions_) { | 589 for (auto function : functions_) { |
589 function->WriteAsmWasmOffsetTable(buffer); | 590 function->WriteAsmWasmOffsetTable(buffer); |
590 } | 591 } |
591 // Append a 0 to indicate that this is an encoded table. | 592 // Append a 0 to indicate that this is an encoded table. |
592 buffer.write_u8(0); | 593 buffer.write_u8(0); |
593 } | 594 } |
594 } // namespace wasm | 595 } // namespace wasm |
595 } // namespace internal | 596 } // namespace internal |
596 } // namespace v8 | 597 } // namespace v8 |
OLD | NEW |