Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(289)

Side by Side Diff: src/compiler/wasm-compiler.cc

Issue 1911313002: Pass debug name as Vector instead of const char* (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@wasm-offset-table-1
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 2742 matching lines...) Expand 10 before | Expand all | Expand 10 after
2753 module->GetFunctionSignature(index)->parameter_count()); 2753 module->GetFunctionSignature(index)->parameter_count());
2754 CallDescriptor* incoming = Linkage::GetJSCallDescriptor( 2754 CallDescriptor* incoming = Linkage::GetJSCallDescriptor(
2755 &zone, false, params + 1, CallDescriptor::kNoFlags); 2755 &zone, false, params + 1, CallDescriptor::kNoFlags);
2756 Code::Flags flags = Code::ComputeFlags(Code::JS_TO_WASM_FUNCTION); 2756 Code::Flags flags = Code::ComputeFlags(Code::JS_TO_WASM_FUNCTION);
2757 bool debugging = 2757 bool debugging =
2758 #if DEBUG 2758 #if DEBUG
2759 true; 2759 true;
2760 #else 2760 #else
2761 FLAG_print_opt_code || FLAG_trace_turbo || FLAG_trace_turbo_graph; 2761 FLAG_print_opt_code || FLAG_trace_turbo || FLAG_trace_turbo_graph;
2762 #endif 2762 #endif
2763 const char* func_name = "js-to-wasm"; 2763 Vector<const char> func_name = ArrayVector("js-to-wasm");
2764 2764
2765 static unsigned id = 0; 2765 static unsigned id = 0;
2766 Vector<char> buffer; 2766 Vector<char> buffer;
2767 if (debugging) { 2767 if (debugging) {
2768 buffer = Vector<char>::New(128); 2768 buffer = Vector<char>::New(128);
2769 SNPrintF(buffer, "js-to-wasm#%d", id); 2769 int chars = SNPrintF(buffer, "js-to-wasm#%d", id);
2770 func_name = buffer.start(); 2770 func_name = Vector<const char>::cast(buffer.SubVector(0, chars));
2771 } 2771 }
2772 2772
2773 CompilationInfo info(func_name, isolate, &zone, flags); 2773 CompilationInfo info(func_name, isolate, &zone, flags);
2774 Handle<Code> code = 2774 Handle<Code> code =
2775 Pipeline::GenerateCodeForTesting(&info, incoming, &graph); 2775 Pipeline::GenerateCodeForTesting(&info, incoming, &graph);
2776 #ifdef ENABLE_DISASSEMBLER 2776 #ifdef ENABLE_DISASSEMBLER
2777 if (FLAG_print_opt_code && !code.is_null()) { 2777 if (FLAG_print_opt_code && !code.is_null()) {
2778 OFStream os(stdout); 2778 OFStream os(stdout);
2779 code->Disassemble(buffer.start(), os); 2779 code->Disassemble(buffer.start(), os);
2780 } 2780 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2829 if (machine.Is32()) { 2829 if (machine.Is32()) {
2830 incoming = wasm::ModuleEnv::GetI32WasmCallDescriptor(&zone, incoming); 2830 incoming = wasm::ModuleEnv::GetI32WasmCallDescriptor(&zone, incoming);
2831 } 2831 }
2832 Code::Flags flags = Code::ComputeFlags(Code::WASM_TO_JS_FUNCTION); 2832 Code::Flags flags = Code::ComputeFlags(Code::WASM_TO_JS_FUNCTION);
2833 bool debugging = 2833 bool debugging =
2834 #if DEBUG 2834 #if DEBUG
2835 true; 2835 true;
2836 #else 2836 #else
2837 FLAG_print_opt_code || FLAG_trace_turbo || FLAG_trace_turbo_graph; 2837 FLAG_print_opt_code || FLAG_trace_turbo || FLAG_trace_turbo_graph;
2838 #endif 2838 #endif
2839 const char* func_name = "wasm-to-js"; 2839 Vector<const char> func_name = ArrayVector("wasm-to-js");
2840 static unsigned id = 0; 2840 static unsigned id = 0;
2841 Vector<char> buffer; 2841 Vector<char> buffer;
2842 if (debugging) { 2842 if (debugging) {
2843 buffer = Vector<char>::New(128); 2843 buffer = Vector<char>::New(128);
2844 SNPrintF(buffer, "wasm-to-js#%d", id); 2844 int chars = SNPrintF(buffer, "wasm-to-js#%d", id);
2845 func_name = buffer.start(); 2845 func_name = Vector<const char>::cast(buffer.SubVector(0, chars));
2846 } 2846 }
2847 2847
2848 CompilationInfo info(func_name, isolate, &zone, flags); 2848 CompilationInfo info(func_name, isolate, &zone, flags);
2849 code = Pipeline::GenerateCodeForTesting(&info, incoming, &graph, nullptr); 2849 code = Pipeline::GenerateCodeForTesting(&info, incoming, &graph, nullptr);
2850 #ifdef ENABLE_DISASSEMBLER 2850 #ifdef ENABLE_DISASSEMBLER
2851 if (FLAG_print_opt_code && !code.is_null()) { 2851 if (FLAG_print_opt_code && !code.is_null()) {
2852 OFStream os(stdout); 2852 OFStream os(stdout);
2853 code->Disassemble(buffer.start(), os); 2853 code->Disassemble(buffer.start(), os);
2854 } 2854 }
2855 #endif 2855 #endif
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
2943 } 2943 }
2944 2944
2945 Code::Flags flags = Code::ComputeFlags(Code::WASM_FUNCTION); 2945 Code::Flags flags = Code::ComputeFlags(Code::WASM_FUNCTION);
2946 // add flags here if a meaningful name is helpful for debugging. 2946 // add flags here if a meaningful name is helpful for debugging.
2947 bool debugging = 2947 bool debugging =
2948 #if DEBUG 2948 #if DEBUG
2949 true; 2949 true;
2950 #else 2950 #else
2951 FLAG_print_opt_code || FLAG_trace_turbo || FLAG_trace_turbo_graph; 2951 FLAG_print_opt_code || FLAG_trace_turbo || FLAG_trace_turbo_graph;
2952 #endif 2952 #endif
2953 const char* func_name = "wasm"; 2953 Vector<const char> func_name =
2954 module_env->module
2955 ->GetNameOrNull(function.name_offset, function.name_length)
titzer 2016/04/22 11:46:30 You should probably just make this method return V
Clemens Hammacher 2016/04/22 13:47:54 Done in https://codereview.chromium.org/1910213004
2956 .toVec();
2954 Vector<char> buffer; 2957 Vector<char> buffer;
2955 if (debugging) { 2958 if (func_name.is_empty()) {
2956 buffer = Vector<char>::New(128); 2959 if (debugging) {
2957 wasm::WasmName name = 2960 buffer = Vector<char>::New(128);
2958 module_env->module->GetName(function.name_offset, function.name_length); 2961 int chars = SNPrintF(buffer, "WASM_function_#%d", function.func_index);
2959 SNPrintF(buffer, "WASM_function_#%d:%.*s", function.func_index, name.length, 2962 func_name = Vector<const char>::cast(buffer.SubVector(0, chars));
2960 name.name); 2963 } else {
2961 func_name = buffer.start(); 2964 func_name = ArrayVector("wasm");
2965 }
2962 } 2966 }
2963 CompilationInfo info(func_name, isolate, &zone, flags); 2967 CompilationInfo info(func_name, isolate, &zone, flags);
2964 2968
2965 Handle<Code> code = Pipeline::GenerateWASMCode(&info, descriptor, &graph, 2969 Handle<Code> code = Pipeline::GenerateWASMCode(&info, descriptor, &graph,
2966 &source_position_table); 2970 &source_position_table);
2967 if (debugging) { 2971
2968 buffer.Dispose(); 2972 buffer.Dispose();
2969 } 2973
2970 if (!code.is_null()) { 2974 if (!code.is_null()) {
2971 RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, "WASM_function", 2975 RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, "WASM_function",
2972 function.func_index, 2976 function.func_index,
2973 module_env->module->GetName( 2977 module_env->module->GetName(
2974 function.name_offset, function.name_length)); 2978 function.name_offset, function.name_length));
2975 } 2979 }
2976 2980
2977 if (FLAG_trace_wasm_decode_time) { 2981 if (FLAG_trace_wasm_decode_time) {
2978 double compile_ms = compile_timer.Elapsed().InMillisecondsF(); 2982 double compile_ms = compile_timer.Elapsed().InMillisecondsF();
2979 PrintF( 2983 PrintF(
2980 "wasm-compile ok: %d bytes, %0.3f ms decode, %d nodes, %0.3f ms " 2984 "wasm-compile ok: %d bytes, %0.3f ms decode, %d nodes, %0.3f ms "
2981 "compile\n", 2985 "compile\n",
2982 static_cast<int>(function.code_end_offset - function.code_start_offset), 2986 static_cast<int>(function.code_end_offset - function.code_start_offset),
2983 decode_ms, static_cast<int>(graph.NodeCount()), compile_ms); 2987 decode_ms, static_cast<int>(graph.NodeCount()), compile_ms);
2984 } 2988 }
2985 // TODO(bradnelson): Improve histogram handling of size_t. 2989 // TODO(bradnelson): Improve histogram handling of size_t.
2986 isolate->counters()->wasm_compile_function_peak_memory_bytes()->AddSample( 2990 isolate->counters()->wasm_compile_function_peak_memory_bytes()->AddSample(
2987 static_cast<int>(zone.allocation_size())); 2991 static_cast<int>(zone.allocation_size()));
2988 return code; 2992 return code;
2989 } 2993 }
2990 2994
2991 2995
2992 } // namespace compiler 2996 } // namespace compiler
2993 } // namespace internal 2997 } // namespace internal
2994 } // namespace v8 2998 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698