Chromium Code Reviews| 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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 size_t len = body_.size() - position; | 193 size_t len = body_.size() - position; |
| 194 if (len == 0) { | |
| 195 // TODO(bradnelson): Figure out why the memcpy crashes if len == 0. | |
|
Michael Starzinger
2017/03/24 11:56:05
It is not the memcpy that crashes but the accessor
bradnelson
2017/03/28 04:34:31
Done.
| |
| 196 return; | |
| 197 } | |
| 194 dst->resize(len); | 198 dst->resize(len); |
| 195 memcpy(dst->data(), &body_[position], len); | 199 memcpy(dst->data(), &body_[position], len); |
| 196 body_.resize(position); | 200 body_.resize(position); |
| 197 } | 201 } |
| 198 | 202 |
| 199 void WasmFunctionBuilder::WriteSignature(ZoneBuffer& buffer) const { | 203 void WasmFunctionBuilder::WriteSignature(ZoneBuffer& buffer) const { |
| 200 buffer.write_u32v(signature_index_); | 204 buffer.write_u32v(signature_index_); |
| 201 } | 205 } |
| 202 | 206 |
| 203 void WasmFunctionBuilder::WriteExports(ZoneBuffer& buffer) const { | 207 void WasmFunctionBuilder::WriteExports(ZoneBuffer& buffer) const { |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 587 // Emit the offset table per function. | 591 // Emit the offset table per function. |
| 588 for (auto function : functions_) { | 592 for (auto function : functions_) { |
| 589 function->WriteAsmWasmOffsetTable(buffer); | 593 function->WriteAsmWasmOffsetTable(buffer); |
| 590 } | 594 } |
| 591 // Append a 0 to indicate that this is an encoded table. | 595 // Append a 0 to indicate that this is an encoded table. |
| 592 buffer.write_u8(0); | 596 buffer.write_u8(0); |
| 593 } | 597 } |
| 594 } // namespace wasm | 598 } // namespace wasm |
| 595 } // namespace internal | 599 } // namespace internal |
| 596 } // namespace v8 | 600 } // namespace v8 |
| OLD | NEW |