Chromium Code Reviews| Index: src/builtins.cc |
| diff --git a/src/builtins.cc b/src/builtins.cc |
| index dcbeb2a6287eb8d3f09d30f6737e7aad9850b8a5..6e045eb9828665fa60556410d12c383f98c5e6e1 100644 |
| --- a/src/builtins.cc |
| +++ b/src/builtins.cc |
| @@ -28,6 +28,7 @@ |
| #include "src/string-builder.h" |
| #include "src/uri.h" |
| #include "src/vm-state-inl.h" |
| +#include "src/wasm/wasm-js.h" |
| namespace v8 { |
| namespace internal { |
| @@ -5351,6 +5352,35 @@ BUILTIN(HandleApiCallAsConstructor) { |
| return HandleApiCallAsFunctionOrConstructor(isolate, true, args); |
| } |
| +BUILTIN(CompileAsmJs) { |
|
Michael Starzinger
2016/06/13 14:10:43
nit: Could we call this InstantiateAsmJs (or simil
bradnelson
2016/06/27 07:56:10
Done.
|
| + HandleScope handleScope(isolate); |
| + Handle<JSObject> foreign; |
| + if (args.length() > 2) { |
| + foreign = args.at<i::JSObject>(2); |
| + } |
| + Handle<JSArrayBuffer> memory; |
| + if (args.length() > 3 && args[3]->IsJSArrayBuffer()) { |
| + memory = args.at<i::JSArrayBuffer>(3); |
| + } |
| + Handle<JSFunction> function = args.target<i::JSFunction>(); |
| + Handle<Object> result; |
| + if (args.length() > 1 && |
| + WasmJs::InstantiateAsmWasm(isolate, |
| + handle(function->shared()->asm_wasm_data()), |
| + memory, foreign, &result)) { |
| + return *result; |
| + } else { |
| + function->shared()->ClearAsmWasmData(); |
| + StackLimitCheck check(isolate); |
| + if (check.JsHasOverflowed(1 * KB)) return isolate->StackOverflow(); |
| + if (!Compiler::CompileBaseline(function)) { |
| + return isolate->heap()->exception(); |
| + } |
| + DCHECK(function->is_compiled()); |
| + return function->code(); |
|
Michael Starzinger
2016/06/13 14:10:43
This will return the compiled code to JavaScript.
bradnelson
2016/06/27 07:56:10
Struggled with this a bit.
I don't believe it can
|
| + } |
| +} |
| + |
| namespace { |
| void Generate_LoadIC_Miss(CodeStubAssembler* assembler) { |