Chromium Code Reviews| Index: src/runtime/runtime-internal.cc |
| diff --git a/src/runtime/runtime-internal.cc b/src/runtime/runtime-internal.cc |
| index 6ffb667f2df52d1324f574f138ef4a3f4eab9123..5bf4c02f1aaf18225c4f9c58574b14f41a87f72a 100644 |
| --- a/src/runtime/runtime-internal.cc |
| +++ b/src/runtime/runtime-internal.cc |
| @@ -7,6 +7,7 @@ |
| #include "src/arguments.h" |
| #include "src/ast/prettyprinter.h" |
| #include "src/bootstrapper.h" |
| +#include "src/compiler/wasm-compiler.h" |
| #include "src/conversions.h" |
| #include "src/debug/debug.h" |
| #include "src/frames-inl.h" |
| @@ -152,6 +153,56 @@ RUNTIME_FUNCTION(Runtime_ThrowWasmError) { |
| return isolate->Throw(*error_obj); |
| } |
| +RUNTIME_FUNCTION(Runtime_JITSingleFunction) { |
| + HandleScope scope(isolate); |
| + DCHECK_LE(7, args.length()); |
|
Mircea Trofin
2016/07/12 02:49:12
same comment as before about numbers - if possible
ritesht
2016/07/13 23:58:45
Done.
|
| + CONVERT_SMI_ARG_CHECKED(base, 0); |
| + CONVERT_SMI_ARG_CHECKED(length, 1); |
| + CONVERT_SMI_ARG_CHECKED(index, 2); |
| + CONVERT_INTPTR_ARG_CHECKED(start, 3); |
| + CONVERT_ARG_HANDLE_CHECKED(FixedArray, function_table, 4); |
| + CONVERT_SMI_ARG_CHECKED(sig_index, 5); |
| + CONVERT_UINT32_ARG_CHECKED(return_count, 6); |
| + |
| + wasm::WasmModule module(reinterpret_cast<byte*>(start)); |
| + wasm::ErrorThrower thrower(isolate, "JITSingleFunction"); |
| + wasm::ModuleEnv module_env; |
| + module_env.module = &module; |
| + module_env.instance = nullptr; |
| + module_env.origin = wasm::kWasmOrigin; |
| + |
| + uint32_t signature_size = args.length() - 7; |
| + wasm::LocalType* sig_types = new wasm::LocalType[signature_size]; |
| + |
| + for (uint32_t i = 0; i < signature_size; ++i) { |
| + CONVERT_SMI_ARG_CHECKED(sig_type, i + 7); |
| + sig_types[i] = static_cast<wasm::LocalType>(sig_type); |
| + } |
| + wasm::FunctionSig sig(return_count, signature_size - return_count, sig_types); |
| + |
| + wasm::WasmFunction func; |
| + func.sig = &sig; |
| + func.func_index = index; |
| + func.sig_index = sig_index; |
| + func.name_offset = 0; |
| + func.name_length = 0; |
| + func.code_start_offset = base; |
| + func.code_end_offset = base + length; |
| + |
| + Handle<Code> code = compiler::WasmCompilationUnit::CompileWasmFunction( |
| + &thrower, isolate, &module_env, &func); |
| + |
| + delete[] sig_types; |
| + if (thrower.error()) { |
| + return isolate->heap()->undefined_value(); |
| + } |
| + |
| + function_table->set(index, Smi::FromInt(sig_index)); |
| + function_table->set(index + function_table->length() / 2, *code); |
|
Mircea Trofin
2016/07/12 02:49:13
do you want to check that index < function_table->
ritesht
2016/07/13 23:58:45
Done.
|
| + |
| + return isolate->heap()->undefined_value(); |
| +} |
| + |
| RUNTIME_FUNCTION(Runtime_UnwindAndFindExceptionHandler) { |
| SealHandleScope shs(isolate); |
| DCHECK(args.length() == 0); |