| 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 2941 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2952         module_env->module->GetName(function.name_offset, function.name_length); | 2952         module_env->module->GetName(function.name_offset, function.name_length); | 
| 2953     SNPrintF(buffer, "WASM_function_#%d:%.*s", function.func_index, name.length, | 2953     SNPrintF(buffer, "WASM_function_#%d:%.*s", function.func_index, name.length, | 
| 2954              name.name); | 2954              name.name); | 
| 2955     func_name = buffer.start(); | 2955     func_name = buffer.start(); | 
| 2956   } | 2956   } | 
| 2957   CompilationInfo info(func_name, isolate, jsgraph->graph()->zone(), flags); | 2957   CompilationInfo info(func_name, isolate, jsgraph->graph()->zone(), flags); | 
| 2958   compiler::ZonePool::Scope pipeline_zone_scope(&zone_pool); | 2958   compiler::ZonePool::Scope pipeline_zone_scope(&zone_pool); | 
| 2959   Pipeline pipeline(&info); | 2959   Pipeline pipeline(&info); | 
| 2960   pipeline.InitializeWasmCompilation(pipeline_zone_scope.zone(), &zone_pool, | 2960   pipeline.InitializeWasmCompilation(pipeline_zone_scope.zone(), &zone_pool, | 
| 2961                                      jsgraph->graph()); | 2961                                      jsgraph->graph()); | 
| 2962   Handle<Code> code = pipeline.ScheduleAndGenerateCode(descriptor); | 2962   Handle<Code> code; | 
| 2963   pipeline.FinalizeWasmCompilation(); | 2963   if (pipeline.ExecuteWasmCompilation(descriptor)) { | 
| 2964   pipeline_zone_scope.Destroy(); | 2964     code = pipeline.FinalizeWasmCompilation(descriptor); | 
|  | 2965   } else { | 
|  | 2966     code = Handle<Code>::null(); | 
|  | 2967   } | 
|  | 2968 | 
| 2965   if (debugging) { | 2969   if (debugging) { | 
| 2966     buffer.Dispose(); | 2970     buffer.Dispose(); | 
| 2967   } | 2971   } | 
| 2968   if (!code.is_null()) { | 2972   if (!code.is_null()) { | 
| 2969     RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, "WASM_function", | 2973     RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, "WASM_function", | 
| 2970                               function.func_index, | 2974                               function.func_index, | 
| 2971                               module_env->module->GetName( | 2975                               module_env->module->GetName( | 
| 2972                                   function.name_offset, function.name_length)); | 2976                                   function.name_offset, function.name_length)); | 
| 2973   } | 2977   } | 
| 2974 | 2978 | 
| 2975   if (FLAG_trace_wasm_decode_time) { | 2979   if (FLAG_trace_wasm_decode_time) { | 
| 2976     double compile_ms = compile_timer.Elapsed().InMillisecondsF(); | 2980     double compile_ms = compile_timer.Elapsed().InMillisecondsF(); | 
| 2977     PrintF( | 2981     PrintF( | 
| 2978         "wasm-compile ok: %d bytes, %0.3f ms decode, %d nodes, %0.3f ms " | 2982         "wasm-compile ok: %d bytes, %0.3f ms decode, %d nodes, %0.3f ms " | 
| 2979         "compile\n", | 2983         "compile\n", | 
| 2980         static_cast<int>(function.code_end_offset - function.code_start_offset), | 2984         static_cast<int>(function.code_end_offset - function.code_start_offset), | 
| 2981         decode_ms, static_cast<int>(jsgraph->graph()->NodeCount()), compile_ms); | 2985         decode_ms, static_cast<int>(jsgraph->graph()->NodeCount()), compile_ms); | 
| 2982   } | 2986   } | 
| 2983   // TODO(bradnelson): Improve histogram handling of size_t. | 2987   // TODO(bradnelson): Improve histogram handling of size_t. | 
| 2984   isolate->counters()->wasm_compile_function_peak_memory_bytes()->AddSample( | 2988   isolate->counters()->wasm_compile_function_peak_memory_bytes()->AddSample( | 
| 2985       static_cast<int>(jsgraph->graph()->zone()->allocation_size())); | 2989       static_cast<int>(jsgraph->graph()->zone()->allocation_size())); | 
| 2986   graph_zone_scope.Destroy(); | 2990   graph_zone_scope.Destroy(); | 
| 2987   return code; | 2991   return code; | 
| 2988 } | 2992 } | 
| 2989 | 2993 | 
| 2990 | 2994 | 
| 2991 }  // namespace compiler | 2995 }  // namespace compiler | 
| 2992 }  // namespace internal | 2996 }  // namespace internal | 
| 2993 }  // namespace v8 | 2997 }  // namespace v8 | 
| OLD | NEW | 
|---|