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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 DCHECK_LT(index, kMaxFunctions); // limited for testing. | 181 DCHECK_LT(index, kMaxFunctions); // limited for testing. |
182 return index; | 182 return index; |
183 } | 183 } |
184 | 184 |
185 uint32_t AddJsFunction(FunctionSig* sig, const char* source) { | 185 uint32_t AddJsFunction(FunctionSig* sig, const char* source) { |
186 Handle<JSFunction> jsfunc = Handle<JSFunction>::cast(v8::Utils::OpenHandle( | 186 Handle<JSFunction> jsfunc = Handle<JSFunction>::cast(v8::Utils::OpenHandle( |
187 *v8::Local<v8::Function>::Cast(CompileRun(source)))); | 187 *v8::Local<v8::Function>::Cast(CompileRun(source)))); |
188 uint32_t index = AddFunction(sig, Handle<Code>::null()); | 188 uint32_t index = AddFunction(sig, Handle<Code>::null()); |
189 WasmName module_name = ArrayVector("test"); | 189 WasmName module_name = ArrayVector("test"); |
190 WasmName function_name; | 190 WasmName function_name; |
191 Handle<Code> code = CompileWasmToJSWrapper(isolate_, this, jsfunc, sig, | 191 Handle<Code> code = CompileWasmToJSWrapper(isolate_, jsfunc, sig, |
192 module_name, function_name); | 192 module_name, function_name); |
193 instance->function_code[index] = code; | 193 instance->function_code[index] = code; |
194 return index; | 194 return index; |
195 } | 195 } |
196 | 196 |
197 Handle<JSFunction> WrapCode(uint32_t index) { | 197 Handle<JSFunction> WrapCode(uint32_t index) { |
198 // Wrap the code so it can be called as a JS function. | 198 // Wrap the code so it can be called as a JS function. |
199 Handle<String> name = isolate_->factory()->NewStringFromStaticChars("main"); | 199 Handle<String> name = isolate_->factory()->NewStringFromStaticChars("main"); |
200 Handle<JSObject> module_object = Handle<JSObject>(0, isolate_); | 200 Handle<JSObject> module_object = Handle<JSObject>(0, isolate_); |
201 Handle<Code> code = instance->function_code[index]; | 201 Handle<Code> code = instance->function_code[index]; |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
754 // interpreter. | 754 // interpreter. |
755 #define WASM_EXEC_TEST(name) \ | 755 #define WASM_EXEC_TEST(name) \ |
756 void RunWasm_##name(WasmExecutionMode execution_mode); \ | 756 void RunWasm_##name(WasmExecutionMode execution_mode); \ |
757 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ | 757 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ |
758 TEST(RunWasmInterpreted_##name) { RunWasm_##name(kExecuteInterpreted); } \ | 758 TEST(RunWasmInterpreted_##name) { RunWasm_##name(kExecuteInterpreted); } \ |
759 void RunWasm_##name(WasmExecutionMode execution_mode) | 759 void RunWasm_##name(WasmExecutionMode execution_mode) |
760 | 760 |
761 } // namespace | 761 } // namespace |
762 | 762 |
763 #endif | 763 #endif |
OLD | NEW |