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 12 matching lines...) Expand all Loading... |
23 #include "src/compiler/machine-operator.h" | 23 #include "src/compiler/machine-operator.h" |
24 #include "src/compiler/node-matchers.h" | 24 #include "src/compiler/node-matchers.h" |
25 #include "src/compiler/pipeline.h" | 25 #include "src/compiler/pipeline.h" |
26 #include "src/compiler/source-position.h" | 26 #include "src/compiler/source-position.h" |
27 #include "src/compiler/zone-pool.h" | 27 #include "src/compiler/zone-pool.h" |
28 | 28 |
29 #include "src/code-factory.h" | 29 #include "src/code-factory.h" |
30 #include "src/code-stubs.h" | 30 #include "src/code-stubs.h" |
31 #include "src/factory.h" | 31 #include "src/factory.h" |
32 #include "src/log-inl.h" | 32 #include "src/log-inl.h" |
33 #include "src/profiler/cpu-profiler.h" | |
34 | 33 |
35 #include "src/wasm/ast-decoder.h" | 34 #include "src/wasm/ast-decoder.h" |
36 #include "src/wasm/wasm-module.h" | 35 #include "src/wasm/wasm-module.h" |
37 #include "src/wasm/wasm-opcodes.h" | 36 #include "src/wasm/wasm-opcodes.h" |
38 | 37 |
39 // TODO(titzer): pull WASM_64 up to a common header. | 38 // TODO(titzer): pull WASM_64 up to a common header. |
40 #if !V8_TARGET_ARCH_32_BIT || V8_TARGET_ARCH_X64 | 39 #if !V8_TARGET_ARCH_32_BIT || V8_TARGET_ARCH_X64 |
41 #define WASM_64 1 | 40 #define WASM_64 1 |
42 #else | 41 #else |
43 #define WASM_64 0 | 42 #define WASM_64 0 |
(...skipping 2894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2938 } | 2937 } |
2939 | 2938 |
2940 void WasmGraphBuilder::SetSourcePosition(Node* node, | 2939 void WasmGraphBuilder::SetSourcePosition(Node* node, |
2941 wasm::WasmCodePosition position) { | 2940 wasm::WasmCodePosition position) { |
2942 DCHECK_NE(position, wasm::kNoCodePosition); | 2941 DCHECK_NE(position, wasm::kNoCodePosition); |
2943 compiler::SourcePosition pos(position); | 2942 compiler::SourcePosition pos(position); |
2944 if (source_position_table_) | 2943 if (source_position_table_) |
2945 source_position_table_->SetSourcePosition(node, pos); | 2944 source_position_table_->SetSourcePosition(node, pos); |
2946 } | 2945 } |
2947 | 2946 |
2948 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, | 2947 static void RecordFunctionCompilation(CodeEventListener::LogEventsAndTags tag, |
2949 CompilationInfo* info, | 2948 CompilationInfo* info, |
2950 const char* message, uint32_t index, | 2949 const char* message, uint32_t index, |
2951 wasm::WasmName func_name) { | 2950 wasm::WasmName func_name) { |
2952 Isolate* isolate = info->isolate(); | 2951 Isolate* isolate = info->isolate(); |
2953 if (isolate->logger()->is_logging_code_events() || isolate->is_profiling()) { | 2952 if (isolate->logger()->is_logging_code_events() || isolate->is_profiling()) { |
2954 ScopedVector<char> buffer(128); | 2953 ScopedVector<char> buffer(128); |
2955 SNPrintF(buffer, "%s#%d:%.*s", message, index, func_name.length(), | 2954 SNPrintF(buffer, "%s#%d:%.*s", message, index, func_name.length(), |
2956 func_name.start()); | 2955 func_name.start()); |
2957 Handle<String> name_str = | 2956 Handle<String> name_str = |
2958 isolate->factory()->NewStringFromAsciiChecked(buffer.start()); | 2957 isolate->factory()->NewStringFromAsciiChecked(buffer.start()); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3041 if (FLAG_print_opt_code && !code.is_null()) { | 3040 if (FLAG_print_opt_code && !code.is_null()) { |
3042 OFStream os(stdout); | 3041 OFStream os(stdout); |
3043 code->Disassemble(buffer.start(), os); | 3042 code->Disassemble(buffer.start(), os); |
3044 } | 3043 } |
3045 #endif | 3044 #endif |
3046 if (debugging) { | 3045 if (debugging) { |
3047 buffer.Dispose(); | 3046 buffer.Dispose(); |
3048 } | 3047 } |
3049 | 3048 |
3050 RecordFunctionCompilation( | 3049 RecordFunctionCompilation( |
3051 Logger::FUNCTION_TAG, &info, "js-to-wasm", index, | 3050 CodeEventListener::FUNCTION_TAG, &info, "js-to-wasm", index, |
3052 module->module->GetName(func->name_offset, func->name_length)); | 3051 module->module->GetName(func->name_offset, func->name_length)); |
3053 // Set the JSFunction's machine code. | 3052 // Set the JSFunction's machine code. |
3054 function->set_code(*code); | 3053 function->set_code(*code); |
3055 } | 3054 } |
3056 return function; | 3055 return function; |
3057 } | 3056 } |
3058 | 3057 |
3059 Handle<Code> CompileWasmToJSWrapper(Isolate* isolate, wasm::ModuleEnv* module, | 3058 Handle<Code> CompileWasmToJSWrapper(Isolate* isolate, wasm::ModuleEnv* module, |
3060 Handle<JSFunction> function, | 3059 Handle<JSFunction> function, |
3061 wasm::FunctionSig* sig, | 3060 wasm::FunctionSig* sig, |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3114 #ifdef ENABLE_DISASSEMBLER | 3113 #ifdef ENABLE_DISASSEMBLER |
3115 if (FLAG_print_opt_code && !code.is_null()) { | 3114 if (FLAG_print_opt_code && !code.is_null()) { |
3116 OFStream os(stdout); | 3115 OFStream os(stdout); |
3117 code->Disassemble(buffer.start(), os); | 3116 code->Disassemble(buffer.start(), os); |
3118 } | 3117 } |
3119 #endif | 3118 #endif |
3120 if (debugging) { | 3119 if (debugging) { |
3121 buffer.Dispose(); | 3120 buffer.Dispose(); |
3122 } | 3121 } |
3123 | 3122 |
3124 RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, "wasm-to-js", 0, | 3123 RecordFunctionCompilation(CodeEventListener::FUNCTION_TAG, &info, |
3125 module_name); | 3124 "wasm-to-js", 0, module_name); |
3126 } | 3125 } |
3127 return code; | 3126 return code; |
3128 } | 3127 } |
3129 | 3128 |
3130 SourcePositionTable* WasmCompilationUnit::BuildGraphForWasmFunction( | 3129 SourcePositionTable* WasmCompilationUnit::BuildGraphForWasmFunction( |
3131 double* decode_ms) { | 3130 double* decode_ms) { |
3132 base::ElapsedTimer decode_timer; | 3131 base::ElapsedTimer decode_timer; |
3133 if (FLAG_trace_wasm_decode_time) { | 3132 if (FLAG_trace_wasm_decode_time) { |
3134 decode_timer.Start(); | 3133 decode_timer.Start(); |
3135 } | 3134 } |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3279 return Handle<Code>::null(); | 3278 return Handle<Code>::null(); |
3280 } | 3279 } |
3281 base::ElapsedTimer compile_timer; | 3280 base::ElapsedTimer compile_timer; |
3282 if (FLAG_trace_wasm_decode_time) { | 3281 if (FLAG_trace_wasm_decode_time) { |
3283 compile_timer.Start(); | 3282 compile_timer.Start(); |
3284 } | 3283 } |
3285 Handle<Code> code = info_.code(); | 3284 Handle<Code> code = info_.code(); |
3286 DCHECK(!code.is_null()); | 3285 DCHECK(!code.is_null()); |
3287 | 3286 |
3288 RecordFunctionCompilation( | 3287 RecordFunctionCompilation( |
3289 Logger::FUNCTION_TAG, &info_, "WASM_function", function_->func_index, | 3288 CodeEventListener::FUNCTION_TAG, &info_, "WASM_function", |
| 3289 function_->func_index, |
3290 module_env_->module->GetName(function_->name_offset, | 3290 module_env_->module->GetName(function_->name_offset, |
3291 function_->name_length)); | 3291 function_->name_length)); |
3292 | 3292 |
3293 if (FLAG_trace_wasm_decode_time) { | 3293 if (FLAG_trace_wasm_decode_time) { |
3294 double compile_ms = compile_timer.Elapsed().InMillisecondsF(); | 3294 double compile_ms = compile_timer.Elapsed().InMillisecondsF(); |
3295 PrintF("wasm-code-generation ok: %d bytes, %0.3f ms code generation\n", | 3295 PrintF("wasm-code-generation ok: %d bytes, %0.3f ms code generation\n", |
3296 static_cast<int>(function_->code_end_offset - | 3296 static_cast<int>(function_->code_end_offset - |
3297 function_->code_start_offset), | 3297 function_->code_start_offset), |
3298 compile_ms); | 3298 compile_ms); |
3299 } | 3299 } |
3300 | 3300 |
3301 return code; | 3301 return code; |
3302 } | 3302 } |
3303 | 3303 |
3304 } // namespace compiler | 3304 } // namespace compiler |
3305 } // namespace internal | 3305 } // namespace internal |
3306 } // namespace v8 | 3306 } // namespace v8 |
OLD | NEW |