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 "src/compiler/wasm-compiler.h" | 5 #include "src/compiler/wasm-compiler.h" |
6 | 6 |
7 #include "src/isolate-inl.h" | 7 #include "src/isolate-inl.h" |
8 | 8 |
9 #include "src/base/platform/platform.h" | 9 #include "src/base/platform/platform.h" |
10 | 10 |
(...skipping 2391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2402 // Helper function to compile a single function. | 2402 // Helper function to compile a single function. |
2403 Handle<Code> CompileWasmFunction(wasm::ErrorThrower& thrower, Isolate* isolate, | 2403 Handle<Code> CompileWasmFunction(wasm::ErrorThrower& thrower, Isolate* isolate, |
2404 wasm::ModuleEnv* module_env, | 2404 wasm::ModuleEnv* module_env, |
2405 const wasm::WasmFunction& function) { | 2405 const wasm::WasmFunction& function) { |
2406 if (FLAG_trace_wasm_compiler || FLAG_trace_wasm_decode_time) { | 2406 if (FLAG_trace_wasm_compiler || FLAG_trace_wasm_decode_time) { |
2407 OFStream os(stdout); | 2407 OFStream os(stdout); |
2408 os << "Compiling WASM function " | 2408 os << "Compiling WASM function " |
2409 << wasm::WasmFunctionName(&function, module_env) << std::endl; | 2409 << wasm::WasmFunctionName(&function, module_env) << std::endl; |
2410 os << std::endl; | 2410 os << std::endl; |
2411 } | 2411 } |
2412 // Initialize the function environment for decoding. | |
2413 wasm::FunctionEnv env; | |
2414 env.module = module_env; | |
2415 env.sig = function.sig; | |
2416 env.local_i32_count = function.local_i32_count; | |
2417 env.local_i64_count = function.local_i64_count; | |
2418 env.local_f32_count = function.local_f32_count; | |
2419 env.local_f64_count = function.local_f64_count; | |
2420 env.SumLocals(); | |
2421 | 2412 |
2422 // Create a TF graph during decoding. | 2413 // Create a TF graph during decoding. |
2423 Zone zone; | 2414 Zone zone; |
2424 Graph graph(&zone); | 2415 Graph graph(&zone); |
2425 CommonOperatorBuilder common(&zone); | 2416 CommonOperatorBuilder common(&zone); |
2426 MachineOperatorBuilder machine( | 2417 MachineOperatorBuilder machine( |
2427 &zone, MachineType::PointerRepresentation(), | 2418 &zone, MachineType::PointerRepresentation(), |
2428 InstructionSelector::SupportedMachineOperatorFlags()); | 2419 InstructionSelector::SupportedMachineOperatorFlags()); |
2429 JSGraph jsgraph(isolate, &graph, &common, nullptr, nullptr, &machine); | 2420 JSGraph jsgraph(isolate, &graph, &common, nullptr, nullptr, &machine); |
2430 WasmGraphBuilder builder(&zone, &jsgraph, function.sig); | 2421 WasmGraphBuilder builder(&zone, &jsgraph, function.sig); |
2431 wasm::TreeResult result = wasm::BuildTFGraph( | 2422 wasm::FunctionBody body = { |
2432 &builder, &env, // -- | 2423 module_env, function.sig, module_env->module->module_start, |
2433 module_env->module->module_start, // -- | 2424 module_env->module->module_start + function.code_start_offset, |
2434 module_env->module->module_start + function.code_start_offset, // -- | 2425 module_env->module->module_start + function.code_end_offset}; |
2435 module_env->module->module_start + function.code_end_offset); // -- | 2426 wasm::TreeResult result = wasm::BuildTFGraph(&builder, body); |
2436 | 2427 |
2437 if (result.failed()) { | 2428 if (result.failed()) { |
2438 if (FLAG_trace_wasm_compiler) { | 2429 if (FLAG_trace_wasm_compiler) { |
2439 OFStream os(stdout); | 2430 OFStream os(stdout); |
2440 os << "Compilation failed: " << result << std::endl; | 2431 os << "Compilation failed: " << result << std::endl; |
2441 } | 2432 } |
2442 // Add the function as another context for the exception | 2433 // Add the function as another context for the exception |
2443 ScopedVector<char> buffer(128); | 2434 ScopedVector<char> buffer(128); |
2444 SNPrintF(buffer, "Compiling WASM function #%d:%s failed:", | 2435 SNPrintF(buffer, "Compiling WASM function #%d:%s failed:", |
2445 function.func_index, | 2436 function.func_index, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2483 module_env->module->GetName(function.name_offset)); | 2474 module_env->module->GetName(function.name_offset)); |
2484 } | 2475 } |
2485 | 2476 |
2486 return code; | 2477 return code; |
2487 } | 2478 } |
2488 | 2479 |
2489 | 2480 |
2490 } // namespace compiler | 2481 } // namespace compiler |
2491 } // namespace internal | 2482 } // namespace internal |
2492 } // namespace v8 | 2483 } // namespace v8 |
OLD | NEW |