OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 #include <memory> | 5 #include <memory> |
6 | 6 |
7 #include "src/assembler-inl.h" | 7 #include "src/assembler-inl.h" |
8 #include "src/base/adapters.h" | 8 #include "src/base/adapters.h" |
9 #include "src/base/atomic-utils.h" | 9 #include "src/base/atomic-utils.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 3020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3031 // If no more work, then this job is done. Predictable mode is handled | 3031 // If no more work, then this job is done. Predictable mode is handled |
3032 // specially though, see above. | 3032 // specially though, see above. |
3033 if (!FLAG_verify_predictable) delete job_; | 3033 if (!FLAG_verify_predictable) delete job_; |
3034 } | 3034 } |
3035 } | 3035 } |
3036 }; | 3036 }; |
3037 }; | 3037 }; |
3038 | 3038 |
3039 void wasm::AsyncCompile(Isolate* isolate, Handle<JSPromise> promise, | 3039 void wasm::AsyncCompile(Isolate* isolate, Handle<JSPromise> promise, |
3040 const ModuleWireBytes& bytes) { | 3040 const ModuleWireBytes& bytes) { |
| 3041 if (!FLAG_wasm_async_compilation) { |
| 3042 ErrorThrower thrower(isolate, "WasmCompile"); |
| 3043 // Compile the module. |
| 3044 MaybeHandle<WasmModuleObject> module_object = |
| 3045 SyncCompile(isolate, &thrower, bytes); |
| 3046 if (thrower.error()) { |
| 3047 RejectPromise(isolate, handle(isolate->context()), &thrower, promise); |
| 3048 return; |
| 3049 } |
| 3050 Handle<WasmModuleObject> module = module_object.ToHandleChecked(); |
| 3051 ResolvePromise(isolate, handle(isolate->context()), promise, module); |
| 3052 return; |
| 3053 } |
| 3054 |
3041 // Make a copy of the wire bytes in case the user program changes them | 3055 // Make a copy of the wire bytes in case the user program changes them |
3042 // during asynchronous compilation. | 3056 // during asynchronous compilation. |
3043 std::unique_ptr<byte[]> copy(new byte[bytes.length()]); | 3057 std::unique_ptr<byte[]> copy(new byte[bytes.length()]); |
3044 memcpy(copy.get(), bytes.start(), bytes.length()); | 3058 memcpy(copy.get(), bytes.start(), bytes.length()); |
3045 auto job = new AsyncCompileJob(isolate, std::move(copy), bytes.length(), | 3059 auto job = new AsyncCompileJob(isolate, std::move(copy), bytes.length(), |
3046 handle(isolate->context()), promise); | 3060 handle(isolate->context()), promise); |
3047 job->Start(); | 3061 job->Start(); |
3048 // Special handling for predictable mode, see above. | 3062 // Special handling for predictable mode, see above. |
3049 if (FLAG_verify_predictable) delete job; | 3063 if (FLAG_verify_predictable) delete job; |
3050 } | 3064 } |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3306 callee_compiled->instruction_start()); | 3320 callee_compiled->instruction_start()); |
3307 } | 3321 } |
3308 DCHECK_EQ(non_compiled_functions.size(), idx); | 3322 DCHECK_EQ(non_compiled_functions.size(), idx); |
3309 } | 3323 } |
3310 | 3324 |
3311 Code* ret = | 3325 Code* ret = |
3312 Code::cast(compiled_module->code_table()->get(func_to_return_idx)); | 3326 Code::cast(compiled_module->code_table()->get(func_to_return_idx)); |
3313 DCHECK_EQ(Code::WASM_FUNCTION, ret->kind()); | 3327 DCHECK_EQ(Code::WASM_FUNCTION, ret->kind()); |
3314 return handle(ret, isolate); | 3328 return handle(ret, isolate); |
3315 } | 3329 } |
OLD | NEW |