| 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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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; |
| 182 WasmName module_name = {"test", 4}; | 182 WasmName module_name = ArrayVector("test"); |
| 183 WasmName function_name = {nullptr, 0}; | 183 WasmName function_name; |
| 184 Handle<Code> code = CompileWasmToJSWrapper(isolate, this, jsfunc, sig, | 184 Handle<Code> code = CompileWasmToJSWrapper(isolate, this, jsfunc, sig, |
| 185 module_name, function_name); | 185 module_name, function_name); |
| 186 instance->function_code[index] = code; | 186 instance->function_code[index] = code; |
| 187 return index; | 187 return index; |
| 188 } | 188 } |
| 189 | 189 |
| 190 Handle<JSFunction> WrapCode(uint32_t index) { | 190 Handle<JSFunction> WrapCode(uint32_t index) { |
| 191 Isolate* isolate = module->shared_isolate; | 191 Isolate* isolate = module->shared_isolate; |
| 192 // Wrap the code so it can be called as a JS function. | 192 // Wrap the code so it can be called as a JS function. |
| 193 Handle<String> name = isolate->factory()->NewStringFromStaticChars("main"); | 193 Handle<String> name = isolate->factory()->NewStringFromStaticChars("main"); |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 if (p1 == MachineType::None()) return 1; | 647 if (p1 == MachineType::None()) return 1; |
| 648 if (p2 == MachineType::None()) return 2; | 648 if (p2 == MachineType::None()) return 2; |
| 649 if (p3 == MachineType::None()) return 3; | 649 if (p3 == MachineType::None()) return 3; |
| 650 return 4; | 650 return 4; |
| 651 } | 651 } |
| 652 }; | 652 }; |
| 653 | 653 |
| 654 } // namespace | 654 } // namespace |
| 655 | 655 |
| 656 #endif | 656 #endif |
| OLD | NEW |