| 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 2171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2182 // Helper function to compile a single function. | 2182 // Helper function to compile a single function. |
| 2183 Handle<Code> CompileWasmFunction(wasm::ErrorThrower& thrower, Isolate* isolate, | 2183 Handle<Code> CompileWasmFunction(wasm::ErrorThrower& thrower, Isolate* isolate, |
| 2184 wasm::ModuleEnv* module_env, | 2184 wasm::ModuleEnv* module_env, |
| 2185 const wasm::WasmFunction& function) { | 2185 const wasm::WasmFunction& function) { |
| 2186 if (FLAG_trace_wasm_compiler || FLAG_trace_wasm_decode_time) { | 2186 if (FLAG_trace_wasm_compiler || FLAG_trace_wasm_decode_time) { |
| 2187 OFStream os(stdout); | 2187 OFStream os(stdout); |
| 2188 os << "Compiling WASM function " | 2188 os << "Compiling WASM function " |
| 2189 << wasm::WasmFunctionName(&function, module_env) << std::endl; | 2189 << wasm::WasmFunctionName(&function, module_env) << std::endl; |
| 2190 os << std::endl; | 2190 os << std::endl; |
| 2191 } | 2191 } |
| 2192 // Initialize the function environment for decoding. | |
| 2193 wasm::FunctionEnv env; | |
| 2194 env.module = module_env; | |
| 2195 env.sig = function.sig; | |
| 2196 env.local_i32_count = function.local_i32_count; | |
| 2197 env.local_i64_count = function.local_i64_count; | |
| 2198 env.local_f32_count = function.local_f32_count; | |
| 2199 env.local_f64_count = function.local_f64_count; | |
| 2200 env.SumLocals(); | |
| 2201 | 2192 |
| 2202 // Create a TF graph during decoding. | 2193 // Create a TF graph during decoding. |
| 2203 Zone zone; | 2194 Zone zone; |
| 2204 Graph graph(&zone); | 2195 Graph graph(&zone); |
| 2205 CommonOperatorBuilder common(&zone); | 2196 CommonOperatorBuilder common(&zone); |
| 2206 MachineOperatorBuilder machine( | 2197 MachineOperatorBuilder machine( |
| 2207 &zone, MachineType::PointerRepresentation(), | 2198 &zone, MachineType::PointerRepresentation(), |
| 2208 InstructionSelector::SupportedMachineOperatorFlags()); | 2199 InstructionSelector::SupportedMachineOperatorFlags()); |
| 2209 JSGraph jsgraph(isolate, &graph, &common, nullptr, nullptr, &machine); | 2200 JSGraph jsgraph(isolate, &graph, &common, nullptr, nullptr, &machine); |
| 2210 WasmGraphBuilder builder(&zone, &jsgraph, function.sig); | 2201 WasmGraphBuilder builder(&zone, &jsgraph, function.sig); |
| 2211 wasm::TreeResult result = wasm::BuildTFGraph( | 2202 wasm::FunctionBody body = { |
| 2212 &builder, &env, // -- | 2203 module_env, function.sig, module_env->module->module_start, |
| 2213 module_env->module->module_start, // -- | 2204 module_env->module->module_start + function.code_start_offset, |
| 2214 module_env->module->module_start + function.code_start_offset, // -- | 2205 module_env->module->module_start + function.code_end_offset}; |
| 2215 module_env->module->module_start + function.code_end_offset); // -- | 2206 wasm::TreeResult result = wasm::BuildTFGraph(&builder, body); |
| 2216 | 2207 |
| 2217 if (result.failed()) { | 2208 if (result.failed()) { |
| 2218 if (FLAG_trace_wasm_compiler) { | 2209 if (FLAG_trace_wasm_compiler) { |
| 2219 OFStream os(stdout); | 2210 OFStream os(stdout); |
| 2220 os << "Compilation failed: " << result << std::endl; | 2211 os << "Compilation failed: " << result << std::endl; |
| 2221 } | 2212 } |
| 2222 // Add the function as another context for the exception | 2213 // Add the function as another context for the exception |
| 2223 ScopedVector<char> buffer(128); | 2214 ScopedVector<char> buffer(128); |
| 2224 SNPrintF(buffer, "Compiling WASM function #%d:%s failed:", | 2215 SNPrintF(buffer, "Compiling WASM function #%d:%s failed:", |
| 2225 function.func_index, | 2216 function.func_index, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2263 module_env->module->GetName(function.name_offset)); | 2254 module_env->module->GetName(function.name_offset)); |
| 2264 } | 2255 } |
| 2265 | 2256 |
| 2266 return code; | 2257 return code; |
| 2267 } | 2258 } |
| 2268 | 2259 |
| 2269 | 2260 |
| 2270 } // namespace compiler | 2261 } // namespace compiler |
| 2271 } // namespace internal | 2262 } // namespace internal |
| 2272 } // namespace v8 | 2263 } // namespace v8 |
| OLD | NEW |