| 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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 instance->function_code.push_back(code); | 171 instance->function_code.push_back(code); |
| 172 DCHECK_LT(index, kMaxFunctions); // limited for testing. | 172 DCHECK_LT(index, kMaxFunctions); // limited for testing. |
| 173 return index; | 173 return index; |
| 174 } | 174 } |
| 175 | 175 |
| 176 uint32_t AddJsFunction(FunctionSig* sig, const char* source) { | 176 uint32_t AddJsFunction(FunctionSig* sig, const char* source) { |
| 177 Handle<JSFunction> jsfunc = Handle<JSFunction>::cast(v8::Utils::OpenHandle( | 177 Handle<JSFunction> jsfunc = Handle<JSFunction>::cast(v8::Utils::OpenHandle( |
| 178 *v8::Local<v8::Function>::Cast(CompileRun(source)))); | 178 *v8::Local<v8::Function>::Cast(CompileRun(source)))); |
| 179 uint32_t index = AddFunction(sig, Handle<Code>::null()); | 179 uint32_t index = AddFunction(sig, Handle<Code>::null()); |
| 180 Isolate* isolate = module->shared_isolate; | 180 Isolate* isolate = module->shared_isolate; |
| 181 WasmName module_name = {"test", 4}; | 181 Vector<const char> module_name = ArrayVector("test"); |
| 182 WasmName function_name = {nullptr, 0}; | 182 Vector<const char> function_name; |
| 183 Handle<Code> code = CompileWasmToJSWrapper(isolate, this, jsfunc, sig, | 183 Handle<Code> code = CompileWasmToJSWrapper(isolate, this, jsfunc, sig, |
| 184 module_name, function_name); | 184 module_name, function_name); |
| 185 instance->function_code[index] = code; | 185 instance->function_code[index] = code; |
| 186 return index; | 186 return index; |
| 187 } | 187 } |
| 188 | 188 |
| 189 Handle<JSFunction> WrapCode(uint32_t index) { | 189 Handle<JSFunction> WrapCode(uint32_t index) { |
| 190 Isolate* isolate = module->shared_isolate; | 190 Isolate* isolate = module->shared_isolate; |
| 191 // Wrap the code so it can be called as a JS function. | 191 // Wrap the code so it can be called as a JS function. |
| 192 Handle<String> name = isolate->factory()->NewStringFromStaticChars("main"); | 192 Handle<String> name = isolate->factory()->NewStringFromStaticChars("main"); |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 if (p1 == MachineType::None()) return 1; | 635 if (p1 == MachineType::None()) return 1; |
| 636 if (p2 == MachineType::None()) return 2; | 636 if (p2 == MachineType::None()) return 2; |
| 637 if (p3 == MachineType::None()) return 3; | 637 if (p3 == MachineType::None()) return 3; |
| 638 return 4; | 638 return 4; |
| 639 } | 639 } |
| 640 }; | 640 }; |
| 641 | 641 |
| 642 } // namespace | 642 } // namespace |
| 643 | 643 |
| 644 #endif | 644 #endif |
| OLD | NEW |