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/elapsed-timer.h" | 9 #include "src/base/platform/elapsed-timer.h" |
10 #include "src/base/platform/platform.h" | 10 #include "src/base/platform/platform.h" |
(...skipping 2950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2961 if (func_name.is_empty()) { | 2961 if (func_name.is_empty()) { |
2962 if (debugging) { | 2962 if (debugging) { |
2963 buffer = Vector<char>::New(128); | 2963 buffer = Vector<char>::New(128); |
2964 int chars = SNPrintF(buffer, "WASM_function_#%d", function.func_index); | 2964 int chars = SNPrintF(buffer, "WASM_function_#%d", function.func_index); |
2965 func_name = Vector<const char>::cast(buffer.SubVector(0, chars)); | 2965 func_name = Vector<const char>::cast(buffer.SubVector(0, chars)); |
2966 } else { | 2966 } else { |
2967 func_name = ArrayVector("wasm"); | 2967 func_name = ArrayVector("wasm"); |
2968 } | 2968 } |
2969 } | 2969 } |
2970 CompilationInfo info(func_name, isolate, jsgraph->graph()->zone(), flags); | 2970 CompilationInfo info(func_name, isolate, jsgraph->graph()->zone(), flags); |
2971 compiler::ZonePool::Scope pipeline_zone_scope(&zone_pool); | 2971 base::SmartPointer<OptimizedCompileJob> job(Pipeline::NewWasmCompilationJob( |
2972 Pipeline pipeline(&info); | 2972 &info, jsgraph->graph(), descriptor, source_positions)); |
2973 pipeline.InitializeWasmCompilation(pipeline_zone_scope.zone(), &zone_pool, | 2973 Handle<Code> code = Handle<Code>::null(); |
2974 jsgraph->graph(), source_positions); | 2974 if (job->OptimizeGraph() == OptimizedCompileJob::SUCCEEDED && |
2975 Handle<Code> code; | 2975 job->GenerateCode() == OptimizedCompileJob::SUCCEEDED) { |
2976 if (pipeline.ExecuteWasmCompilation(descriptor)) { | 2976 code = info.code(); |
2977 code = pipeline.FinalizeWasmCompilation(descriptor); | |
2978 } else { | |
2979 code = Handle<Code>::null(); | |
2980 } | 2977 } |
2981 | 2978 |
2982 buffer.Dispose(); | 2979 buffer.Dispose(); |
2983 if (!code.is_null()) { | 2980 if (!code.is_null()) { |
2984 RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, "WASM_function", | 2981 RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, "WASM_function", |
2985 function.func_index, | 2982 function.func_index, |
2986 module_env->module->GetName( | 2983 module_env->module->GetName( |
2987 function.name_offset, function.name_length)); | 2984 function.name_offset, function.name_length)); |
2988 } | 2985 } |
2989 | 2986 |
2990 if (FLAG_trace_wasm_decode_time) { | 2987 if (FLAG_trace_wasm_decode_time) { |
2991 double compile_ms = compile_timer.Elapsed().InMillisecondsF(); | 2988 double compile_ms = compile_timer.Elapsed().InMillisecondsF(); |
2992 PrintF( | 2989 PrintF( |
2993 "wasm-compile ok: %d bytes, %0.3f ms decode, %d nodes, %0.3f ms " | 2990 "wasm-compile ok: %d bytes, %0.3f ms decode, %d nodes, %0.3f ms " |
2994 "compile\n", | 2991 "compile\n", |
2995 static_cast<int>(function.code_end_offset - function.code_start_offset), | 2992 static_cast<int>(function.code_end_offset - function.code_start_offset), |
2996 decode_ms, static_cast<int>(jsgraph->graph()->NodeCount()), compile_ms); | 2993 decode_ms, static_cast<int>(jsgraph->graph()->NodeCount()), compile_ms); |
2997 } | 2994 } |
2998 // TODO(bradnelson): Improve histogram handling of size_t. | 2995 // TODO(bradnelson): Improve histogram handling of size_t. |
2999 isolate->counters()->wasm_compile_function_peak_memory_bytes()->AddSample( | 2996 isolate->counters()->wasm_compile_function_peak_memory_bytes()->AddSample( |
3000 static_cast<int>(jsgraph->graph()->zone()->allocation_size())); | 2997 static_cast<int>(jsgraph->graph()->zone()->allocation_size())); |
3001 graph_zone_scope.Destroy(); | 2998 graph_zone_scope.Destroy(); |
3002 return code; | 2999 return code; |
3003 } | 3000 } |
3004 | 3001 |
3005 | 3002 |
3006 } // namespace compiler | 3003 } // namespace compiler |
3007 } // namespace internal | 3004 } // namespace internal |
3008 } // namespace v8 | 3005 } // namespace v8 |
OLD | NEW |