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

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: nicer bounds check 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
« no previous file with comments | « no previous file | src/wasm/wasm-module.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2662 matching lines...) Expand 10 before | Expand all | Expand 10 after
2673 } 2673 }
2674 2674
2675 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, 2675 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag,
2676 CompilationInfo* info, 2676 CompilationInfo* info,
2677 const char* message, uint32_t index, 2677 const char* message, uint32_t index,
2678 wasm::WasmName func_name) { 2678 wasm::WasmName func_name) {
2679 Isolate* isolate = info->isolate(); 2679 Isolate* isolate = info->isolate();
2680 if (isolate->logger()->is_logging_code_events() || 2680 if (isolate->logger()->is_logging_code_events() ||
2681 isolate->cpu_profiler()->is_profiling()) { 2681 isolate->cpu_profiler()->is_profiling()) {
2682 ScopedVector<char> buffer(128); 2682 ScopedVector<char> buffer(128);
2683 SNPrintF(buffer, "%s#%d:%.*s", message, index, func_name.length, 2683 SNPrintF(buffer, "%s#%d:%.*s", message, index, func_name.length(),
2684 func_name.name); 2684 func_name.start());
2685 Handle<String> name_str = 2685 Handle<String> name_str =
2686 isolate->factory()->NewStringFromAsciiChecked(buffer.start()); 2686 isolate->factory()->NewStringFromAsciiChecked(buffer.start());
2687 Handle<String> script_str = 2687 Handle<String> script_str =
2688 isolate->factory()->NewStringFromAsciiChecked("(WASM)"); 2688 isolate->factory()->NewStringFromAsciiChecked("(WASM)");
2689 Handle<Code> code = info->code(); 2689 Handle<Code> code = info->code();
2690 Handle<SharedFunctionInfo> shared = 2690 Handle<SharedFunctionInfo> shared =
2691 isolate->factory()->NewSharedFunctionInfo(name_str, code, false); 2691 isolate->factory()->NewSharedFunctionInfo(name_str, code, false);
2692 PROFILE(isolate, CodeCreateEvent(tag, AbstractCode::cast(*code), *shared, 2692 PROFILE(isolate, CodeCreateEvent(tag, AbstractCode::cast(*code), *shared,
2693 info, *script_str, 0, 0)); 2693 info, *script_str, 0, 0));
2694 } 2694 }
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
2889 if (result.failed()) { 2889 if (result.failed()) {
2890 if (FLAG_trace_wasm_compiler) { 2890 if (FLAG_trace_wasm_compiler) {
2891 OFStream os(stdout); 2891 OFStream os(stdout);
2892 os << "Compilation failed: " << result << std::endl; 2892 os << "Compilation failed: " << result << std::endl;
2893 } 2893 }
2894 // Add the function as another context for the exception 2894 // Add the function as another context for the exception
2895 ScopedVector<char> buffer(128); 2895 ScopedVector<char> buffer(128);
2896 wasm::WasmName name = 2896 wasm::WasmName name =
2897 module_env->module->GetName(function.name_offset, function.name_length); 2897 module_env->module->GetName(function.name_offset, function.name_length);
2898 SNPrintF(buffer, "Compiling WASM function #%d:%.*s failed:", 2898 SNPrintF(buffer, "Compiling WASM function #%d:%.*s failed:",
2899 function.func_index, name.length, name.name); 2899 function.func_index, name.length(), name.start());
2900 thrower.Failed(buffer.start(), result); 2900 thrower.Failed(buffer.start(), result);
2901 return std::make_pair(nullptr, nullptr); 2901 return std::make_pair(nullptr, nullptr);
2902 } 2902 }
2903 int index = static_cast<int>(function.func_index); 2903 int index = static_cast<int>(function.func_index);
2904 if (index >= FLAG_trace_wasm_ast_start && index < FLAG_trace_wasm_ast_end) { 2904 if (index >= FLAG_trace_wasm_ast_start && index < FLAG_trace_wasm_ast_end) {
2905 PrintAst(isolate->allocator(), body); 2905 PrintAst(isolate->allocator(), body);
2906 } 2906 }
2907 if (FLAG_trace_wasm_decode_time) { 2907 if (FLAG_trace_wasm_decode_time) {
2908 *decode_ms = decode_timer.Elapsed().InMillisecondsF(); 2908 *decode_ms = decode_timer.Elapsed().InMillisecondsF();
2909 } 2909 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2948 descriptor); 2948 descriptor);
2949 } 2949 }
2950 Code::Flags flags = Code::ComputeFlags(Code::WASM_FUNCTION); 2950 Code::Flags flags = Code::ComputeFlags(Code::WASM_FUNCTION);
2951 // add flags here if a meaningful name is helpful for debugging. 2951 // add flags here if a meaningful name is helpful for debugging.
2952 bool debugging = 2952 bool debugging =
2953 #if DEBUG 2953 #if DEBUG
2954 true; 2954 true;
2955 #else 2955 #else
2956 FLAG_print_opt_code || FLAG_trace_turbo || FLAG_trace_turbo_graph; 2956 FLAG_print_opt_code || FLAG_trace_turbo || FLAG_trace_turbo_graph;
2957 #endif 2957 #endif
2958 Vector<const char> func_name = 2958 Vector<const char> func_name = module_env->module->GetNameOrNull(
2959 module_env->module 2959 function.name_offset, function.name_length);
2960 ->GetNameOrNull(function.name_offset, function.name_length)
2961 .toVec();
2962 Vector<char> buffer; 2960 Vector<char> buffer;
2963 if (func_name.is_empty()) { 2961 if (func_name.is_empty()) {
2964 if (debugging) { 2962 if (debugging) {
2965 buffer = Vector<char>::New(128); 2963 buffer = Vector<char>::New(128);
2966 int chars = SNPrintF(buffer, "WASM_function_#%d", function.func_index); 2964 int chars = SNPrintF(buffer, "WASM_function_#%d", function.func_index);
2967 func_name = Vector<const char>::cast(buffer.SubVector(0, chars)); 2965 func_name = Vector<const char>::cast(buffer.SubVector(0, chars));
2968 } else { 2966 } else {
2969 func_name = ArrayVector("wasm"); 2967 func_name = ArrayVector("wasm");
2970 } 2968 }
2971 } 2969 }
(...skipping 29 matching lines...) Expand all
3001 isolate->counters()->wasm_compile_function_peak_memory_bytes()->AddSample( 2999 isolate->counters()->wasm_compile_function_peak_memory_bytes()->AddSample(
3002 static_cast<int>(jsgraph->graph()->zone()->allocation_size())); 3000 static_cast<int>(jsgraph->graph()->zone()->allocation_size()));
3003 graph_zone_scope.Destroy(); 3001 graph_zone_scope.Destroy();
3004 return code; 3002 return code;
3005 } 3003 }
3006 3004
3007 3005
3008 } // namespace compiler 3006 } // namespace compiler
3009 } // namespace internal 3007 } // namespace internal
3010 } // namespace v8 3008 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/wasm/wasm-module.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698