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/zone-containers.h" | 9 #include "src/zone/zone-containers.h" |
10 | 10 |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 if (pos != signature_map_.end()) { | 264 if (pos != signature_map_.end()) { |
265 return pos->second; | 265 return pos->second; |
266 } else { | 266 } else { |
267 uint32_t index = static_cast<uint32_t>(signatures_.size()); | 267 uint32_t index = static_cast<uint32_t>(signatures_.size()); |
268 signature_map_[sig] = index; | 268 signature_map_[sig] = index; |
269 signatures_.push_back(sig); | 269 signatures_.push_back(sig); |
270 return index; | 270 return index; |
271 } | 271 } |
272 } | 272 } |
273 | 273 |
274 void WasmModuleBuilder::AddIndirectFunction(uint32_t index) { | 274 uint32_t WasmModuleBuilder::AllocateIndirectFunctions(uint32_t count) { |
275 indirect_functions_.push_back(index); | 275 uint32_t ret = static_cast<uint32_t>(indirect_functions_.size()); |
| 276 indirect_functions_.resize(indirect_functions_.size() + count); |
| 277 return ret; |
| 278 } |
| 279 |
| 280 void WasmModuleBuilder::SetIndirectFunction(uint32_t indirect, |
| 281 uint32_t direct) { |
| 282 indirect_functions_[indirect] = direct; |
276 } | 283 } |
277 | 284 |
278 uint32_t WasmModuleBuilder::AddImport(const char* name, int name_length, | 285 uint32_t WasmModuleBuilder::AddImport(const char* name, int name_length, |
279 FunctionSig* sig) { | 286 FunctionSig* sig) { |
280 imports_.push_back({AddSignature(sig), name, name_length}); | 287 imports_.push_back({AddSignature(sig), name, name_length}); |
281 return static_cast<uint32_t>(imports_.size() - 1); | 288 return static_cast<uint32_t>(imports_.size() - 1); |
282 } | 289 } |
283 | 290 |
284 void WasmModuleBuilder::MarkStartFunction(WasmFunctionBuilder* function) { | 291 void WasmModuleBuilder::MarkStartFunction(WasmFunctionBuilder* function) { |
285 start_function_index_ = function->func_index(); | 292 start_function_index_ = function->func_index(); |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 // Emit the offset table per function. | 540 // Emit the offset table per function. |
534 for (auto function : functions_) { | 541 for (auto function : functions_) { |
535 function->WriteAsmWasmOffsetTable(buffer); | 542 function->WriteAsmWasmOffsetTable(buffer); |
536 } | 543 } |
537 // Append a 0 to indicate that this is an encoded table. | 544 // Append a 0 to indicate that this is an encoded table. |
538 buffer.write_u8(0); | 545 buffer.write_u8(0); |
539 } | 546 } |
540 } // namespace wasm | 547 } // namespace wasm |
541 } // namespace internal | 548 } // namespace internal |
542 } // namespace v8 | 549 } // namespace v8 |
OLD | NEW |