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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 private: | 171 private: |
172 size_t mem_size; | 172 size_t mem_size; |
173 uint32_t global_offset; | 173 uint32_t global_offset; |
174 byte global_data[kMaxGlobalsSize]; | 174 V8_ALIGNED(8) byte global_data[kMaxGlobalsSize]; |
175 | 175 |
176 WasmGlobal* AddGlobal(MachineType mem_type) { | 176 WasmGlobal* AddGlobal(MachineType mem_type) { |
177 AllocModule(); | 177 AllocModule(); |
178 if (globals_area == 0) { | 178 if (globals_area == 0) { |
179 globals_area = reinterpret_cast<uintptr_t>(global_data); | 179 globals_area = reinterpret_cast<uintptr_t>(global_data); |
180 module->globals = new std::vector<WasmGlobal>(); | 180 module->globals = new std::vector<WasmGlobal>(); |
181 } | 181 } |
182 byte size = WasmOpcodes::MemSize(mem_type); | 182 byte size = WasmOpcodes::MemSize(mem_type); |
183 global_offset = (global_offset + size - 1) & ~(size - 1); // align | 183 global_offset = (global_offset + size - 1) & ~(size - 1); // align |
184 module->globals->push_back({0, mem_type, global_offset, false}); | 184 module->globals->push_back({0, mem_type, global_offset, false}); |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 if (p1 == MachineType::None()) return 1; | 382 if (p1 == MachineType::None()) return 1; |
383 if (p2 == MachineType::None()) return 2; | 383 if (p2 == MachineType::None()) return 2; |
384 if (p3 == MachineType::None()) return 3; | 384 if (p3 == MachineType::None()) return 3; |
385 return 4; | 385 return 4; |
386 } | 386 } |
387 }; | 387 }; |
388 | 388 |
389 } // namespace | 389 } // namespace |
390 | 390 |
391 #endif | 391 #endif |
OLD | NEW |