| 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/v8.h" | 8 #include "src/v8.h" |
| 9 #include "src/zone-containers.h" | 9 #include "src/zone-containers.h" |
| 10 | 10 |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 } | 362 } |
| 363 | 363 |
| 364 | 364 |
| 365 uint32_t WasmDataSegmentEncoder::BodySize() const { | 365 uint32_t WasmDataSegmentEncoder::BodySize() const { |
| 366 return static_cast<uint32_t>(data_.size()); | 366 return static_cast<uint32_t>(data_.size()); |
| 367 } | 367 } |
| 368 | 368 |
| 369 | 369 |
| 370 void WasmDataSegmentEncoder::Serialize(byte* buffer, byte** header, | 370 void WasmDataSegmentEncoder::Serialize(byte* buffer, byte** header, |
| 371 byte** body) const { | 371 byte** body) const { |
| 372 uint32_t body_offset = static_cast<uint32_t>(*body - buffer); | 372 EmitVarInt(header, dest_); |
| 373 EmitUint32(header, dest_); | 373 EmitVarInt(header, static_cast<uint32_t>(data_.size())); |
| 374 EmitUint32(header, body_offset); | |
| 375 EmitUint32(header, static_cast<uint32_t>(data_.size())); | |
| 376 EmitUint8(header, 1); // init | |
| 377 | 374 |
| 378 std::memcpy(*body, &data_[0], data_.size()); | 375 std::memcpy(*header, &data_[0], data_.size()); |
| 379 (*body) += data_.size(); | 376 (*header) += data_.size(); |
| 380 } | 377 } |
| 381 | 378 |
| 382 WasmModuleBuilder::WasmModuleBuilder(Zone* zone) | 379 WasmModuleBuilder::WasmModuleBuilder(Zone* zone) |
| 383 : zone_(zone), | 380 : zone_(zone), |
| 384 signatures_(zone), | 381 signatures_(zone), |
| 385 functions_(zone), | 382 functions_(zone), |
| 386 data_segments_(zone), | 383 data_segments_(zone), |
| 387 indirect_functions_(zone), | 384 indirect_functions_(zone), |
| 388 globals_(zone), | 385 globals_(zone), |
| 389 signature_map_(zone), | 386 signature_map_(zone), |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 next = next | 0x80; | 640 next = next | 0x80; |
| 644 } | 641 } |
| 645 output.push_back(next); | 642 output.push_back(next); |
| 646 shift += 7; | 643 shift += 7; |
| 647 } while ((next & 0x80) != 0); | 644 } while ((next & 0x80) != 0); |
| 648 return output; | 645 return output; |
| 649 } | 646 } |
| 650 } // namespace wasm | 647 } // namespace wasm |
| 651 } // namespace internal | 648 } // namespace internal |
| 652 } // namespace v8 | 649 } // namespace v8 |
| OLD | NEW |