Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef WASM_RUN_UTILS_H | 5 #ifndef WASM_RUN_UTILS_H |
| 6 #define WASM_RUN_UTILS_H | 6 #define WASM_RUN_UTILS_H |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <stdlib.h> | 9 #include <stdlib.h> |
| 10 #include <string.h> | 10 #include <string.h> |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 161 AllocModule(); | 161 AllocModule(); |
| 162 if (module->functions == nullptr) { | 162 if (module->functions == nullptr) { |
| 163 module->functions = new std::vector<WasmFunction>(); | 163 module->functions = new std::vector<WasmFunction>(); |
| 164 function_code = new std::vector<Handle<Code>>(); | 164 function_code = new std::vector<Handle<Code>>(); |
| 165 } | 165 } |
| 166 module->functions->push_back({sig, 0, 0, 0, 0, 0, 0, 0, false, false}); | 166 module->functions->push_back({sig, 0, 0, 0, 0, 0, 0, 0, false, false}); |
| 167 function_code->push_back(code); | 167 function_code->push_back(code); |
| 168 return &module->functions->back(); | 168 return &module->functions->back(); |
| 169 } | 169 } |
| 170 | 170 |
| 171 void AddIndirectFunctionTable(int* functions, int table_size) { | |
|
ahaas
2016/01/21 15:47:28
This function is only used with the parameters "nu
| |
| 172 AllocModule(); | |
| 173 Isolate* isolate = module->shared_isolate; | |
| 174 Handle<FixedArray> fixed = | |
| 175 isolate->factory()->NewFixedArray(2 * table_size); | |
| 176 function_table = fixed; | |
| 177 module->function_table = new std::vector<uint16_t>(); | |
| 178 for (int i = 0; i < table_size; i++) { | |
| 179 module->function_table->push_back(functions[i]); | |
| 180 } | |
| 181 } | |
| 182 | |
| 183 void PopulateIndirectFunctionTable() { | |
|
ahaas
2016/01/21 15:47:28
This function is not used anywhere. Does it have t
| |
| 184 if (function_table.is_null()) return; | |
| 185 int table_size = static_cast<int>(module->function_table->size()); | |
| 186 for (int i = 0; i < table_size; i++) { | |
| 187 int function = module->function_table->at(i); | |
| 188 function_table->set(i, Smi::FromInt(function)); | |
| 189 function_table->set(i + table_size, *function_code->at(function)); | |
| 190 } | |
| 191 } | |
| 192 | |
| 193 | |
| 171 private: | 194 private: |
| 172 size_t mem_size; | 195 size_t mem_size; |
| 173 uint32_t global_offset; | 196 uint32_t global_offset; |
| 174 byte global_data[kMaxGlobalsSize]; | 197 byte global_data[kMaxGlobalsSize]; |
| 175 | 198 |
| 176 WasmGlobal* AddGlobal(MachineType mem_type) { | 199 WasmGlobal* AddGlobal(MachineType mem_type) { |
| 177 AllocModule(); | 200 AllocModule(); |
| 178 if (globals_area == 0) { | 201 if (globals_area == 0) { |
| 179 globals_area = reinterpret_cast<uintptr_t>(global_data); | 202 globals_area = reinterpret_cast<uintptr_t>(global_data); |
| 180 module->globals = new std::vector<WasmGlobal>(); | 203 module->globals = new std::vector<WasmGlobal>(); |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 382 if (p1 == MachineType::None()) return 1; | 405 if (p1 == MachineType::None()) return 1; |
| 383 if (p2 == MachineType::None()) return 2; | 406 if (p2 == MachineType::None()) return 2; |
| 384 if (p3 == MachineType::None()) return 3; | 407 if (p3 == MachineType::None()) return 3; |
| 385 return 4; | 408 return 4; |
| 386 } | 409 } |
| 387 }; | 410 }; |
| 388 | 411 |
| 389 } // namespace | 412 } // namespace |
| 390 | 413 |
| 391 #endif | 414 #endif |
| OLD | NEW |