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 rng.NextBytes(raw, end - raw); | 161 rng.NextBytes(raw, end - raw); |
162 } | 162 } |
163 | 163 |
164 uint32_t AddFunction(FunctionSig* sig, Handle<Code> code) { | 164 uint32_t AddFunction(FunctionSig* sig, Handle<Code> code) { |
165 if (module->functions.size() == 0) { | 165 if (module->functions.size() == 0) { |
166 // TODO(titzer): Reserving space here to avoid the underlying WasmFunction | 166 // TODO(titzer): Reserving space here to avoid the underlying WasmFunction |
167 // structs from moving. | 167 // structs from moving. |
168 module->functions.reserve(kMaxFunctions); | 168 module->functions.reserve(kMaxFunctions); |
169 } | 169 } |
170 uint32_t index = static_cast<uint32_t>(module->functions.size()); | 170 uint32_t index = static_cast<uint32_t>(module->functions.size()); |
171 module->functions.push_back({sig, index, 0, 0, 0, 0, 0, 0, 0, 0, 0, false}); | 171 module->functions.push_back({sig, index, 0, 0, 0, 0, 0, false}); |
172 instance->function_code.push_back(code); | 172 instance->function_code.push_back(code); |
173 DCHECK_LT(index, kMaxFunctions); // limited for testing. | 173 DCHECK_LT(index, kMaxFunctions); // limited for testing. |
174 return index; | 174 return index; |
175 } | 175 } |
176 | 176 |
177 uint32_t AddJsFunction(FunctionSig* sig, const char* source) { | 177 uint32_t AddJsFunction(FunctionSig* sig, const char* source) { |
178 Handle<JSFunction> jsfunc = Handle<JSFunction>::cast(v8::Utils::OpenHandle( | 178 Handle<JSFunction> jsfunc = Handle<JSFunction>::cast(v8::Utils::OpenHandle( |
179 *v8::Local<v8::Function>::Cast(CompileRun(source)))); | 179 *v8::Local<v8::Function>::Cast(CompileRun(source)))); |
180 uint32_t index = AddFunction(sig, Handle<Code>::null()); | 180 uint32_t index = AddFunction(sig, Handle<Code>::null()); |
181 Isolate* isolate = module->shared_isolate; | 181 Isolate* isolate = module->shared_isolate; |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 if (p1 == MachineType::None()) return 1; | 653 if (p1 == MachineType::None()) return 1; |
654 if (p2 == MachineType::None()) return 2; | 654 if (p2 == MachineType::None()) return 2; |
655 if (p3 == MachineType::None()) return 3; | 655 if (p3 == MachineType::None()) return 3; |
656 return 4; | 656 return 4; |
657 } | 657 } |
658 }; | 658 }; |
659 | 659 |
660 } // namespace | 660 } // namespace |
661 | 661 |
662 #endif | 662 #endif |
OLD | NEW |