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 3076 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3087 module_env->module->GetName(function.name_offset, function.name_length); | 3087 module_env->module->GetName(function.name_offset, function.name_length); |
3088 SNPrintF(buffer, "WASM_function_#%d:%.*s", function.func_index, name.length, | 3088 SNPrintF(buffer, "WASM_function_#%d:%.*s", function.func_index, name.length, |
3089 name.name); | 3089 name.name); |
3090 func_name = buffer.start(); | 3090 func_name = buffer.start(); |
3091 } | 3091 } |
3092 CompilationInfo info(func_name, isolate, jsgraph->graph()->zone(), flags); | 3092 CompilationInfo info(func_name, isolate, jsgraph->graph()->zone(), flags); |
3093 compiler::ZonePool::Scope pipeline_zone_scope(&zone_pool); | 3093 compiler::ZonePool::Scope pipeline_zone_scope(&zone_pool); |
3094 Pipeline pipeline(&info); | 3094 Pipeline pipeline(&info); |
3095 pipeline.InitializeWasmCompilation(pipeline_zone_scope.zone(), &zone_pool, | 3095 pipeline.InitializeWasmCompilation(pipeline_zone_scope.zone(), &zone_pool, |
3096 jsgraph->graph()); | 3096 jsgraph->graph()); |
3097 Handle<Code> code = pipeline.ScheduleAndGenerateCode(descriptor); | 3097 Handle<Code> code; |
3098 pipeline.FinalizeWasmCompilation(); | 3098 if (pipeline.ExecuteWasmCompilation(descriptor)) { |
3099 pipeline_zone_scope.Destroy(); | 3099 code = pipeline.FinalizeWasmCompilation(descriptor); |
| 3100 } else { |
| 3101 code = Handle<Code>::null(); |
| 3102 } |
| 3103 |
3100 if (debugging) { | 3104 if (debugging) { |
3101 buffer.Dispose(); | 3105 buffer.Dispose(); |
3102 } | 3106 } |
3103 if (!code.is_null()) { | 3107 if (!code.is_null()) { |
3104 RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, "WASM_function", | 3108 RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, "WASM_function", |
3105 function.func_index, | 3109 function.func_index, |
3106 module_env->module->GetName( | 3110 module_env->module->GetName( |
3107 function.name_offset, function.name_length)); | 3111 function.name_offset, function.name_length)); |
3108 } | 3112 } |
3109 | 3113 |
3110 if (FLAG_trace_wasm_decode_time) { | 3114 if (FLAG_trace_wasm_decode_time) { |
3111 double compile_ms = compile_timer.Elapsed().InMillisecondsF(); | 3115 double compile_ms = compile_timer.Elapsed().InMillisecondsF(); |
3112 PrintF( | 3116 PrintF( |
3113 "wasm-compile ok: %d bytes, %0.3f ms decode, %d nodes, %0.3f ms " | 3117 "wasm-compile ok: %d bytes, %0.3f ms decode, %d nodes, %0.3f ms " |
3114 "compile\n", | 3118 "compile\n", |
3115 static_cast<int>(function.code_end_offset - function.code_start_offset), | 3119 static_cast<int>(function.code_end_offset - function.code_start_offset), |
3116 decode_ms, static_cast<int>(jsgraph->graph()->NodeCount()), compile_ms); | 3120 decode_ms, static_cast<int>(jsgraph->graph()->NodeCount()), compile_ms); |
3117 } | 3121 } |
3118 // TODO(bradnelson): Improve histogram handling of size_t. | 3122 // TODO(bradnelson): Improve histogram handling of size_t. |
3119 isolate->counters()->wasm_compile_function_peak_memory_bytes()->AddSample( | 3123 isolate->counters()->wasm_compile_function_peak_memory_bytes()->AddSample( |
3120 static_cast<int>(jsgraph->graph()->zone()->allocation_size())); | 3124 static_cast<int>(jsgraph->graph()->zone()->allocation_size())); |
3121 graph_zone_scope.Destroy(); | 3125 graph_zone_scope.Destroy(); |
3122 return code; | 3126 return code; |
3123 } | 3127 } |
3124 | 3128 |
3125 | 3129 |
3126 } // namespace compiler | 3130 } // namespace compiler |
3127 } // namespace internal | 3131 } // namespace internal |
3128 } // namespace v8 | 3132 } // namespace v8 |
OLD | NEW |