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

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

Issue 1910213004: [wasm] Replace WasmName by Vector<const char> (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@wasm-offset-table-2
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 2665 matching lines...) Expand 10 before | Expand all | Expand 10 after
2676 2676
2677 void WasmGraphBuilder::SetSourcePosition(Node* node, int position) { 2677 void WasmGraphBuilder::SetSourcePosition(Node* node, int position) {
2678 compiler::SourcePosition pos(position); 2678 compiler::SourcePosition pos(position);
2679 if (source_position_table_) 2679 if (source_position_table_)
2680 source_position_table_->SetSourcePosition(node, pos); 2680 source_position_table_->SetSourcePosition(node, pos);
2681 } 2681 }
2682 2682
2683 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, 2683 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag,
2684 CompilationInfo* info, 2684 CompilationInfo* info,
2685 const char* message, uint32_t index, 2685 const char* message, uint32_t index,
2686 wasm::WasmName func_name) { 2686 Vector<const char> func_name) {
2687 Isolate* isolate = info->isolate(); 2687 Isolate* isolate = info->isolate();
2688 if (isolate->logger()->is_logging_code_events() || 2688 if (isolate->logger()->is_logging_code_events() ||
2689 isolate->cpu_profiler()->is_profiling()) { 2689 isolate->cpu_profiler()->is_profiling()) {
2690 ScopedVector<char> buffer(128); 2690 ScopedVector<char> buffer(128);
2691 SNPrintF(buffer, "%s#%d:%.*s", message, index, func_name.length, 2691 SNPrintF(buffer, "%s#%d:%.*s", message, index, func_name.length(),
2692 func_name.name); 2692 func_name.start());
2693 Handle<String> name_str = 2693 Handle<String> name_str =
2694 isolate->factory()->NewStringFromAsciiChecked(buffer.start()); 2694 isolate->factory()->NewStringFromAsciiChecked(buffer.start());
2695 Handle<String> script_str = 2695 Handle<String> script_str =
2696 isolate->factory()->NewStringFromAsciiChecked("(WASM)"); 2696 isolate->factory()->NewStringFromAsciiChecked("(WASM)");
2697 Handle<Code> code = info->code(); 2697 Handle<Code> code = info->code();
2698 Handle<SharedFunctionInfo> shared = 2698 Handle<SharedFunctionInfo> shared =
2699 isolate->factory()->NewSharedFunctionInfo(name_str, code, false); 2699 isolate->factory()->NewSharedFunctionInfo(name_str, code, false);
2700 PROFILE(isolate, CodeCreateEvent(tag, AbstractCode::cast(*code), *shared, 2700 PROFILE(isolate, CodeCreateEvent(tag, AbstractCode::cast(*code), *shared,
2701 info, *script_str, 0, 0)); 2701 info, *script_str, 0, 0));
2702 } 2702 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
2788 module->module->GetName(func->name_offset, func->name_length)); 2788 module->module->GetName(func->name_offset, func->name_length));
2789 // Set the JSFunction's machine code. 2789 // Set the JSFunction's machine code.
2790 function->set_code(*code); 2790 function->set_code(*code);
2791 } 2791 }
2792 return function; 2792 return function;
2793 } 2793 }
2794 2794
2795 Handle<Code> CompileWasmToJSWrapper(Isolate* isolate, wasm::ModuleEnv* module, 2795 Handle<Code> CompileWasmToJSWrapper(Isolate* isolate, wasm::ModuleEnv* module,
2796 Handle<JSFunction> function, 2796 Handle<JSFunction> function,
2797 wasm::FunctionSig* sig, 2797 wasm::FunctionSig* sig,
2798 wasm::WasmName module_name, 2798 Vector<const char> module_name,
2799 wasm::WasmName function_name) { 2799 Vector<const char> function_name) {
2800 //---------------------------------------------------------------------------- 2800 //----------------------------------------------------------------------------
2801 // Create the Graph 2801 // Create the Graph
2802 //---------------------------------------------------------------------------- 2802 //----------------------------------------------------------------------------
2803 Zone zone(isolate->allocator()); 2803 Zone zone(isolate->allocator());
2804 Graph graph(&zone); 2804 Graph graph(&zone);
2805 CommonOperatorBuilder common(&zone); 2805 CommonOperatorBuilder common(&zone);
2806 MachineOperatorBuilder machine(&zone); 2806 MachineOperatorBuilder machine(&zone);
2807 JSGraph jsgraph(isolate, &graph, &common, nullptr, nullptr, &machine); 2807 JSGraph jsgraph(isolate, &graph, &common, nullptr, nullptr, &machine);
2808 2808
2809 Node* control = nullptr; 2809 Node* control = nullptr;
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
2907 r.LowerGraph(); 2907 r.LowerGraph();
2908 } 2908 }
2909 2909
2910 if (result.failed()) { 2910 if (result.failed()) {
2911 if (FLAG_trace_wasm_compiler) { 2911 if (FLAG_trace_wasm_compiler) {
2912 OFStream os(stdout); 2912 OFStream os(stdout);
2913 os << "Compilation failed: " << result << std::endl; 2913 os << "Compilation failed: " << result << std::endl;
2914 } 2914 }
2915 // Add the function as another context for the exception 2915 // Add the function as another context for the exception
2916 ScopedVector<char> buffer(128); 2916 ScopedVector<char> buffer(128);
2917 wasm::WasmName name = 2917 Vector<const char> name =
2918 module_env->module->GetName(function.name_offset, function.name_length); 2918 module_env->module->GetName(function.name_offset, function.name_length);
2919 SNPrintF(buffer, "Compiling WASM function #%d:%.*s failed:", 2919 SNPrintF(buffer, "Compiling WASM function #%d:%.*s failed:",
2920 function.func_index, name.length, name.name); 2920 function.func_index, name.length(), name.start());
2921 thrower.Failed(buffer.start(), result); 2921 thrower.Failed(buffer.start(), result);
2922 return Handle<Code>::null(); 2922 return Handle<Code>::null();
2923 } 2923 }
2924 2924
2925 int index = static_cast<int>(function.func_index); 2925 int index = static_cast<int>(function.func_index);
2926 if (index >= FLAG_trace_wasm_ast_start && index < FLAG_trace_wasm_ast_end) { 2926 if (index >= FLAG_trace_wasm_ast_start && index < FLAG_trace_wasm_ast_end) {
2927 PrintAst(isolate->allocator(), body); 2927 PrintAst(isolate->allocator(), body);
2928 } 2928 }
2929 2929
2930 if (FLAG_trace_wasm_decode_time) { 2930 if (FLAG_trace_wasm_decode_time) {
(...skipping 12 matching lines...) Expand all
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 Vector<const char> func_name = 2953 Vector<const char> func_name = module_env->module->GetNameOrNull(
2954 module_env->module 2954 function.name_offset, function.name_length);
2955 ->GetNameOrNull(function.name_offset, function.name_length)
2956 .toVec();
2957 Vector<char> buffer; 2955 Vector<char> buffer;
2958 if (func_name.is_empty()) { 2956 if (func_name.is_empty()) {
2959 if (debugging) { 2957 if (debugging) {
2960 buffer = Vector<char>::New(128); 2958 buffer = Vector<char>::New(128);
2961 int chars = SNPrintF(buffer, "WASM_function_#%d", function.func_index); 2959 int chars = SNPrintF(buffer, "WASM_function_#%d", function.func_index);
2962 func_name = Vector<const char>::cast(buffer.SubVector(0, chars)); 2960 func_name = Vector<const char>::cast(buffer.SubVector(0, chars));
2963 } else { 2961 } else {
2964 func_name = ArrayVector("wasm"); 2962 func_name = ArrayVector("wasm");
2965 } 2963 }
2966 } 2964 }
(...skipping 22 matching lines...) Expand all
2989 // TODO(bradnelson): Improve histogram handling of size_t. 2987 // TODO(bradnelson): Improve histogram handling of size_t.
2990 isolate->counters()->wasm_compile_function_peak_memory_bytes()->AddSample( 2988 isolate->counters()->wasm_compile_function_peak_memory_bytes()->AddSample(
2991 static_cast<int>(zone.allocation_size())); 2989 static_cast<int>(zone.allocation_size()));
2992 return code; 2990 return code;
2993 } 2991 }
2994 2992
2995 2993
2996 } // namespace compiler 2994 } // namespace compiler
2997 } // namespace internal 2995 } // namespace internal
2998 } // namespace v8 2996 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/wasm-compiler.h ('k') | src/wasm/wasm-module.h » ('j') | src/wasm/wasm-opcodes.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698