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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 uint32_t WasmModuleBuilder::AddImport(const char* name, int name_length, | 240 uint32_t WasmModuleBuilder::AddImport(const char* name, int name_length, |
241 FunctionSig* sig) { | 241 FunctionSig* sig) { |
242 imports_.push_back({AddSignature(sig), name, name_length}); | 242 imports_.push_back({AddSignature(sig), name, name_length}); |
243 return static_cast<uint32_t>(imports_.size() - 1); | 243 return static_cast<uint32_t>(imports_.size() - 1); |
244 } | 244 } |
245 | 245 |
246 void WasmModuleBuilder::MarkStartFunction(uint32_t index) { | 246 void WasmModuleBuilder::MarkStartFunction(uint32_t index) { |
247 start_function_index_ = index; | 247 start_function_index_ = index; |
248 } | 248 } |
249 | 249 |
250 uint32_t WasmModuleBuilder::AddGlobal(MachineType type, bool exported) { | 250 uint32_t WasmModuleBuilder::AddGlobal(LocalType type, bool exported) { |
251 globals_.push_back(std::make_pair(type, exported)); | 251 globals_.push_back(std::make_pair(type, exported)); |
252 return static_cast<uint32_t>(globals_.size() - 1); | 252 return static_cast<uint32_t>(globals_.size() - 1); |
253 } | 253 } |
254 | 254 |
255 void WasmModuleBuilder::WriteTo(ZoneBuffer& buffer) const { | 255 void WasmModuleBuilder::WriteTo(ZoneBuffer& buffer) const { |
256 uint32_t exports = 0; | 256 uint32_t exports = 0; |
257 | 257 |
258 // == Emit magic ============================================================= | 258 // == Emit magic ============================================================= |
259 TRACE("emit magic\n"); | 259 TRACE("emit magic\n"); |
260 buffer.write_u32(kWasmMagic); | 260 buffer.write_u32(kWasmMagic); |
(...skipping 18 matching lines...) Expand all Loading... |
279 FixupSection(buffer, start); | 279 FixupSection(buffer, start); |
280 } | 280 } |
281 | 281 |
282 // == Emit globals =========================================================== | 282 // == Emit globals =========================================================== |
283 if (globals_.size() > 0) { | 283 if (globals_.size() > 0) { |
284 size_t start = EmitSection(WasmSection::Code::Globals, buffer); | 284 size_t start = EmitSection(WasmSection::Code::Globals, buffer); |
285 buffer.write_size(globals_.size()); | 285 buffer.write_size(globals_.size()); |
286 | 286 |
287 for (auto global : globals_) { | 287 for (auto global : globals_) { |
288 buffer.write_u32v(0); // Length of the global name. | 288 buffer.write_u32v(0); // Length of the global name. |
289 buffer.write_u8(WasmOpcodes::MemTypeCodeFor(global.first)); | 289 buffer.write_u8(WasmOpcodes::LocalTypeCodeFor(global.first)); |
290 buffer.write_u8(global.second); | 290 buffer.write_u8(global.second); |
291 } | 291 } |
292 FixupSection(buffer, start); | 292 FixupSection(buffer, start); |
293 } | 293 } |
294 | 294 |
295 // == Emit imports =========================================================== | 295 // == Emit imports =========================================================== |
296 if (imports_.size() > 0) { | 296 if (imports_.size() > 0) { |
297 size_t start = EmitSection(WasmSection::Code::ImportTable, buffer); | 297 size_t start = EmitSection(WasmSection::Code::ImportTable, buffer); |
298 buffer.write_size(imports_.size()); | 298 buffer.write_size(imports_.size()); |
299 for (auto import : imports_) { | 299 for (auto import : imports_) { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 | 373 |
374 for (auto segment : data_segments_) { | 374 for (auto segment : data_segments_) { |
375 segment->Write(buffer); | 375 segment->Write(buffer); |
376 } | 376 } |
377 FixupSection(buffer, start); | 377 FixupSection(buffer, start); |
378 } | 378 } |
379 } | 379 } |
380 } // namespace wasm | 380 } // namespace wasm |
381 } // namespace internal | 381 } // namespace internal |
382 } // namespace v8 | 382 } // namespace v8 |
OLD | NEW |