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/base/atomic-utils.h" | 7 #include "src/base/atomic-utils.h" |
8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 | 9 |
10 #include "src/macro-assembler.h" | 10 #include "src/macro-assembler.h" |
(...skipping 1215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1226 DCHECK(wasm::IsWasmInstance(*instance)); | 1226 DCHECK(wasm::IsWasmInstance(*instance)); |
1227 Handle<Object> memory_object(instance->GetInternalField(kWasmMemObject), | 1227 Handle<Object> memory_object(instance->GetInternalField(kWasmMemObject), |
1228 isolate_); | 1228 isolate_); |
1229 WasmJs::SetWasmMemoryInstance(isolate_, memory_object, instance); | 1229 WasmJs::SetWasmMemoryInstance(isolate_, memory_object, instance); |
1230 | 1230 |
1231 //-------------------------------------------------------------------------- | 1231 //-------------------------------------------------------------------------- |
1232 // Run the start function if one was specified. | 1232 // Run the start function if one was specified. |
1233 //-------------------------------------------------------------------------- | 1233 //-------------------------------------------------------------------------- |
1234 if (module_->start_function_index >= 0) { | 1234 if (module_->start_function_index >= 0) { |
1235 HandleScope scope(isolate_); | 1235 HandleScope scope(isolate_); |
| 1236 ModuleEnv module_env; |
| 1237 module_env.module = module_; |
| 1238 module_env.instance = nullptr; |
| 1239 module_env.origin = module_->origin; |
1236 int start_index = module_->start_function_index; | 1240 int start_index = module_->start_function_index; |
1237 Handle<Code> startup_code = | 1241 Handle<Code> startup_code = |
1238 code_table->GetValueChecked<Code>(isolate_, start_index); | 1242 code_table->GetValueChecked<Code>(isolate_, start_index); |
1239 FunctionSig* sig = module_->functions[start_index].sig; | 1243 FunctionSig* sig = module_->functions[start_index].sig; |
| 1244 Handle<Code> wrapper_code = compiler::CompileJSToWasmWrapper( |
| 1245 isolate_, &module_env, startup_code, start_index); |
1240 Handle<JSFunction> startup_fct = WrapExportCodeAsJSFunction( | 1246 Handle<JSFunction> startup_fct = WrapExportCodeAsJSFunction( |
1241 isolate_, startup_code, factory->InternalizeUtf8String("start"), sig, | 1247 isolate_, wrapper_code, factory->InternalizeUtf8String("start"), sig, |
1242 start_index, instance); | 1248 start_index, instance); |
1243 RecordStats(isolate_, *startup_code); | 1249 RecordStats(isolate_, *startup_code); |
1244 // Call the JS function. | 1250 // Call the JS function. |
1245 Handle<Object> undefined = factory->undefined_value(); | 1251 Handle<Object> undefined = factory->undefined_value(); |
1246 MaybeHandle<Object> retval = | 1252 MaybeHandle<Object> retval = |
1247 Execution::Call(isolate_, startup_fct, undefined, 0, nullptr); | 1253 Execution::Call(isolate_, startup_fct, undefined, 0, nullptr); |
1248 | 1254 |
1249 if (retval.is_null()) { | 1255 if (retval.is_null()) { |
1250 DCHECK(isolate_->has_pending_exception()); | 1256 DCHECK(isolate_->has_pending_exception()); |
1251 isolate_->OptionalRescheduleException(false); | 1257 isolate_->OptionalRescheduleException(false); |
(...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2240 CHECK_NOT_NULL(result.val); | 2246 CHECK_NOT_NULL(result.val); |
2241 module = const_cast<WasmModule*>(result.val); | 2247 module = const_cast<WasmModule*>(result.val); |
2242 } | 2248 } |
2243 | 2249 |
2244 Handle<WasmModuleWrapper> module_wrapper = | 2250 Handle<WasmModuleWrapper> module_wrapper = |
2245 WasmModuleWrapper::New(isolate, module); | 2251 WasmModuleWrapper::New(isolate, module); |
2246 | 2252 |
2247 compiled_module->set_module_wrapper(module_wrapper); | 2253 compiled_module->set_module_wrapper(module_wrapper); |
2248 DCHECK(WasmCompiledModule::IsWasmCompiledModule(*compiled_module)); | 2254 DCHECK(WasmCompiledModule::IsWasmCompiledModule(*compiled_module)); |
2249 } | 2255 } |
OLD | NEW |