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

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

Issue 1961973002: [wasm] Implement parallel compilation. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Make the implementation thread-safe. Created 4 years, 7 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 | « src/compiler/wasm-compiler.h ('k') | src/flag-definitions.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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 Node* trap_reason_smi = builder_->BuildChangeInt32ToSmi(trap_reason_); 225 Node* trap_reason_smi = builder_->BuildChangeInt32ToSmi(trap_reason_);
226 Node* trap_position_smi = builder_->BuildChangeInt32ToSmi(trap_position_); 226 Node* trap_position_smi = builder_->BuildChangeInt32ToSmi(trap_position_);
227 227
228 if (module && !module->instance->context.is_null()) { 228 if (module && !module->instance->context.is_null()) {
229 // Use the module context to call the runtime to throw an exception. 229 // Use the module context to call the runtime to throw an exception.
230 Runtime::FunctionId f = Runtime::kThrowWasmError; 230 Runtime::FunctionId f = Runtime::kThrowWasmError;
231 const Runtime::Function* fun = Runtime::FunctionForId(f); 231 const Runtime::Function* fun = Runtime::FunctionForId(f);
232 CallDescriptor* desc = Linkage::GetRuntimeCallDescriptor( 232 CallDescriptor* desc = Linkage::GetRuntimeCallDescriptor(
233 jsgraph()->zone(), f, fun->nargs, Operator::kNoProperties, 233 jsgraph()->zone(), f, fun->nargs, Operator::kNoProperties,
234 CallDescriptor::kNoFlags); 234 CallDescriptor::kNoFlags);
235 // CEntryStubConstant nodes have to be created and cached in the main
236 // thread. At the moment this is only done for CEntryStubConstant(1).
237 DCHECK_EQ(1, fun->result_size);
235 Node* inputs[] = { 238 Node* inputs[] = {
236 jsgraph()->CEntryStubConstant(fun->result_size), // C entry 239 jsgraph()->CEntryStubConstant(fun->result_size), // C entry
237 trap_reason_smi, // message id 240 trap_reason_smi, // message id
238 trap_position_smi, // byte position 241 trap_position_smi, // byte position
239 jsgraph()->ExternalConstant( 242 jsgraph()->ExternalConstant(
240 ExternalReference(f, jsgraph()->isolate())), // ref 243 ExternalReference(f, jsgraph()->isolate())), // ref
241 jsgraph()->Int32Constant(fun->nargs), // arity 244 jsgraph()->Int32Constant(fun->nargs), // arity
242 jsgraph()->Constant(module->instance->context), // context 245 builder_->HeapConstant(module->instance->context), // context
243 *effect_ptr, 246 *effect_ptr,
244 *control_ptr}; 247 *control_ptr};
245 248
246 Node* node = graph()->NewNode( 249 Node* node = graph()->NewNode(
247 common()->Call(desc), static_cast<int>(arraysize(inputs)), inputs); 250 common()->Call(desc), static_cast<int>(arraysize(inputs)), inputs);
248 *control_ptr = node; 251 *control_ptr = node;
249 *effect_ptr = node; 252 *effect_ptr = node;
250 } 253 }
251 if (false) { 254 if (false) {
252 // End the control flow with a throw 255 // End the control flow with a throw
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 } 886 }
884 887
885 Node* WasmGraphBuilder::Float32Constant(float value) { 888 Node* WasmGraphBuilder::Float32Constant(float value) {
886 return jsgraph()->Float32Constant(value); 889 return jsgraph()->Float32Constant(value);
887 } 890 }
888 891
889 Node* WasmGraphBuilder::Float64Constant(double value) { 892 Node* WasmGraphBuilder::Float64Constant(double value) {
890 return jsgraph()->Float64Constant(value); 893 return jsgraph()->Float64Constant(value);
891 } 894 }
892 895
893 Node* WasmGraphBuilder::Constant(Handle<Object> value) { 896 Node* WasmGraphBuilder::HeapConstant(Handle<HeapObject> value) {
894 return jsgraph()->Constant(value); 897 return jsgraph()->HeapConstant(value);
895 } 898 }
896 899
897 Node* WasmGraphBuilder::Branch(Node* cond, Node** true_node, 900 Node* WasmGraphBuilder::Branch(Node* cond, Node** true_node,
898 Node** false_node) { 901 Node** false_node) {
899 DCHECK_NOT_NULL(cond); 902 DCHECK_NOT_NULL(cond);
900 DCHECK_NOT_NULL(*control_); 903 DCHECK_NOT_NULL(*control_);
901 Node* branch = 904 Node* branch =
902 graph()->NewNode(jsgraph()->common()->Branch(), cond, *control_); 905 graph()->NewNode(jsgraph()->common()->Branch(), cond, *control_);
903 *true_node = graph()->NewNode(jsgraph()->common()->IfTrue(), branch); 906 *true_node = graph()->NewNode(jsgraph()->common()->IfTrue(), branch);
904 *false_node = graph()->NewNode(jsgraph()->common()->IfFalse(), branch); 907 *false_node = graph()->NewNode(jsgraph()->common()->IfFalse(), branch);
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after
1886 1889
1887 *effect_ = call; 1890 *effect_ = call;
1888 return call; 1891 return call;
1889 } 1892 }
1890 1893
1891 Node* WasmGraphBuilder::CallDirect(uint32_t index, Node** args, 1894 Node* WasmGraphBuilder::CallDirect(uint32_t index, Node** args,
1892 wasm::WasmCodePosition position) { 1895 wasm::WasmCodePosition position) {
1893 DCHECK_NULL(args[0]); 1896 DCHECK_NULL(args[0]);
1894 1897
1895 // Add code object as constant. 1898 // Add code object as constant.
1896 args[0] = Constant(module_->GetFunctionCode(index)); 1899 args[0] = HeapConstant(module_->GetFunctionCode(index));
1897 wasm::FunctionSig* sig = module_->GetFunctionSignature(index); 1900 wasm::FunctionSig* sig = module_->GetFunctionSignature(index);
1898 1901
1899 return BuildWasmCall(sig, args, position); 1902 return BuildWasmCall(sig, args, position);
1900 } 1903 }
1901 1904
1902 Node* WasmGraphBuilder::CallImport(uint32_t index, Node** args, 1905 Node* WasmGraphBuilder::CallImport(uint32_t index, Node** args,
1903 wasm::WasmCodePosition position) { 1906 wasm::WasmCodePosition position) {
1904 DCHECK_NULL(args[0]); 1907 DCHECK_NULL(args[0]);
1905 1908
1906 // Add code object as constant. 1909 // Add code object as constant.
1907 args[0] = Constant(module_->GetImportCode(index)); 1910 args[0] = HeapConstant(module_->GetImportCode(index));
1908 wasm::FunctionSig* sig = module_->GetImportSignature(index); 1911 wasm::FunctionSig* sig = module_->GetImportSignature(index);
1909 1912
1910 return BuildWasmCall(sig, args, position); 1913 return BuildWasmCall(sig, args, position);
1911 } 1914 }
1912 1915
1913 Node* WasmGraphBuilder::CallIndirect(uint32_t index, Node** args, 1916 Node* WasmGraphBuilder::CallIndirect(uint32_t index, Node** args,
1914 wasm::WasmCodePosition position) { 1917 wasm::WasmCodePosition position) {
1915 DCHECK_NOT_NULL(args[0]); 1918 DCHECK_NOT_NULL(args[0]);
1916 DCHECK(module_ && module_->instance); 1919 DCHECK(module_ && module_->instance);
1917 1920
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
2375 Node* start = Start(param_count + 5); 2378 Node* start = Start(param_count + 5);
2376 *control_ = start; 2379 *control_ = start;
2377 *effect_ = start; 2380 *effect_ = start;
2378 // Create the context parameter 2381 // Create the context parameter
2379 Node* context = graph()->NewNode( 2382 Node* context = graph()->NewNode(
2380 jsgraph()->common()->Parameter( 2383 jsgraph()->common()->Parameter(
2381 Linkage::GetJSCallContextParamIndex(wasm_count + 1), "%context"), 2384 Linkage::GetJSCallContextParamIndex(wasm_count + 1), "%context"),
2382 graph()->start()); 2385 graph()->start());
2383 2386
2384 int pos = 0; 2387 int pos = 0;
2385 args[pos++] = Constant(wasm_code); 2388 args[pos++] = HeapConstant(wasm_code);
2386 2389
2387 // Convert JS parameters to WASM numbers. 2390 // Convert JS parameters to WASM numbers.
2388 for (int i = 0; i < wasm_count; i++) { 2391 for (int i = 0; i < wasm_count; i++) {
2389 Node* param = 2392 Node* param =
2390 graph()->NewNode(jsgraph()->common()->Parameter(i + 1), start); 2393 graph()->NewNode(jsgraph()->common()->Parameter(i + 1), start);
2391 Node* wasm_param = FromJS(param, context, sig->GetParam(i)); 2394 Node* wasm_param = FromJS(param, context, sig->GetParam(i));
2392 args[pos++] = wasm_param; 2395 args[pos++] = wasm_param;
2393 if (jsgraph()->machine()->Is32() && sig->GetParam(i) == wasm::kAstI64) { 2396 if (jsgraph()->machine()->Is32() && sig->GetParam(i) == wasm::kAstI64) {
2394 // We make up the high word with SAR to get the proper sign extension. 2397 // We make up the high word with SAR to get the proper sign extension.
2395 args[pos++] = graph()->NewNode(jsgraph()->machine()->Word32Sar(), 2398 args[pos++] = graph()->NewNode(jsgraph()->machine()->Word32Sar(),
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2433 param_count = Int64Lowering::GetParameterCountAfterLowering(sig); 2436 param_count = Int64Lowering::GetParameterCountAfterLowering(sig);
2434 } 2437 }
2435 2438
2436 // Build the start and the parameter nodes. 2439 // Build the start and the parameter nodes.
2437 Isolate* isolate = jsgraph()->isolate(); 2440 Isolate* isolate = jsgraph()->isolate();
2438 CallDescriptor* desc; 2441 CallDescriptor* desc;
2439 Node* start = Start(param_count + 3); 2442 Node* start = Start(param_count + 3);
2440 *effect_ = start; 2443 *effect_ = start;
2441 *control_ = start; 2444 *control_ = start;
2442 // JS context is the last parameter. 2445 // JS context is the last parameter.
2443 Node* context = Constant(Handle<Context>(function->context(), isolate)); 2446 Node* context = HeapConstant(Handle<Context>(function->context(), isolate));
2444 Node** args = Buffer(wasm_count + 7); 2447 Node** args = Buffer(wasm_count + 7);
2445 2448
2446 bool arg_count_before_args = false; 2449 bool arg_count_before_args = false;
2447 bool add_new_target_undefined = false; 2450 bool add_new_target_undefined = false;
2448 2451
2449 int pos = 0; 2452 int pos = 0;
2450 if (js_count == wasm_count) { 2453 if (js_count == wasm_count) {
2451 // exact arity match, just call the function directly. 2454 // exact arity match, just call the function directly.
2452 desc = Linkage::GetJSCallDescriptor(graph()->zone(), false, wasm_count + 1, 2455 desc = Linkage::GetJSCallDescriptor(graph()->zone(), false, wasm_count + 1,
2453 CallDescriptor::kNoFlags); 2456 CallDescriptor::kNoFlags);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
2538 return mem_size_; 2541 return mem_size_;
2539 } else { 2542 } else {
2540 return jsgraph()->Int32Constant(size + offset); 2543 return jsgraph()->Int32Constant(size + offset);
2541 } 2544 }
2542 } 2545 }
2543 2546
2544 Node* WasmGraphBuilder::FunctionTable() { 2547 Node* WasmGraphBuilder::FunctionTable() {
2545 DCHECK(module_ && module_->instance && 2548 DCHECK(module_ && module_->instance &&
2546 !module_->instance->function_table.is_null()); 2549 !module_->instance->function_table.is_null());
2547 if (!function_table_) { 2550 if (!function_table_) {
2548 function_table_ = jsgraph()->Constant(module_->instance->function_table); 2551 function_table_ = HeapConstant(module_->instance->function_table);
2549 } 2552 }
2550 return function_table_; 2553 return function_table_;
2551 } 2554 }
2552 2555
2553 Node* WasmGraphBuilder::LoadGlobal(uint32_t index) { 2556 Node* WasmGraphBuilder::LoadGlobal(uint32_t index) {
2554 DCHECK(module_ && module_->instance && module_->instance->globals_start); 2557 DCHECK(module_ && module_->instance && module_->instance->globals_start);
2555 MachineType mem_type = module_->GetGlobalType(index); 2558 MachineType mem_type = module_->GetGlobalType(index);
2556 Node* addr = jsgraph()->IntPtrConstant( 2559 Node* addr = jsgraph()->IntPtrConstant(
2557 reinterpret_cast<uintptr_t>(module_->instance->globals_start + 2560 reinterpret_cast<uintptr_t>(module_->instance->globals_start +
2558 module_->module->globals[index].offset)); 2561 module_->module->globals[index].offset));
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
2878 buffer.Dispose(); 2881 buffer.Dispose();
2879 } 2882 }
2880 2883
2881 RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, "wasm-to-js", 0, 2884 RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, "wasm-to-js", 0,
2882 module_name); 2885 module_name);
2883 } 2886 }
2884 return code; 2887 return code;
2885 } 2888 }
2886 2889
2887 std::pair<JSGraph*, SourcePositionTable*> BuildGraphForWasmFunction( 2890 std::pair<JSGraph*, SourcePositionTable*> BuildGraphForWasmFunction(
2888 Zone* zone, wasm::ErrorThrower* thrower, Isolate* isolate, 2891 JSGraph* jsgraph, wasm::ErrorThrower* thrower, Isolate* isolate,
2889 wasm::ModuleEnv*& module_env, const wasm::WasmFunction* function, 2892 wasm::ModuleEnv*& module_env, const wasm::WasmFunction* function,
2890 double* decode_ms) { 2893 double* decode_ms) {
2891 base::ElapsedTimer decode_timer; 2894 base::ElapsedTimer decode_timer;
2892 if (FLAG_trace_wasm_decode_time) { 2895 if (FLAG_trace_wasm_decode_time) {
2893 decode_timer.Start(); 2896 decode_timer.Start();
2894 } 2897 }
2895 // Create a TF graph during decoding. 2898 // Create a TF graph during decoding.
2896 Graph* graph = new (zone) Graph(zone); 2899 Graph* graph = jsgraph->graph();
2897 CommonOperatorBuilder* common = new (zone) CommonOperatorBuilder(zone); 2900 CommonOperatorBuilder* common = jsgraph->common();
2898 MachineOperatorBuilder* machine = new (zone) MachineOperatorBuilder( 2901 MachineOperatorBuilder* machine = jsgraph->machine();
2899 zone, MachineType::PointerRepresentation(),
2900 InstructionSelector::SupportedMachineOperatorFlags());
2901 JSGraph* jsgraph =
2902 new (zone) JSGraph(isolate, graph, common, nullptr, nullptr, machine);
2903 SourcePositionTable* source_position_table = 2902 SourcePositionTable* source_position_table =
2904 new (zone) SourcePositionTable(graph); 2903 new (jsgraph->zone()) SourcePositionTable(graph);
2905 WasmGraphBuilder builder(zone, jsgraph, function->sig, source_position_table); 2904 WasmGraphBuilder builder(jsgraph->zone(), jsgraph, function->sig,
2905 source_position_table);
2906 wasm::FunctionBody body = { 2906 wasm::FunctionBody body = {
2907 module_env, function->sig, module_env->module->module_start, 2907 module_env, function->sig, module_env->module->module_start,
2908 module_env->module->module_start + function->code_start_offset, 2908 module_env->module->module_start + function->code_start_offset,
2909 module_env->module->module_start + function->code_end_offset}; 2909 module_env->module->module_start + function->code_end_offset};
2910 wasm::TreeResult result = 2910 wasm::TreeResult result =
2911 wasm::BuildTFGraph(isolate->allocator(), &builder, body); 2911 wasm::BuildTFGraph(isolate->allocator(), &builder, body);
2912 2912
2913 if (machine->Is32()) { 2913 if (machine->Is32()) {
2914 Int64Lowering r(graph, machine, common, zone, function->sig); 2914 Int64Lowering r(graph, machine, common, jsgraph->zone(), function->sig);
2915 r.LowerGraph(); 2915 r.LowerGraph();
2916 } 2916 }
2917 2917
2918 if (result.failed()) { 2918 if (result.failed()) {
2919 if (FLAG_trace_wasm_compiler) { 2919 if (FLAG_trace_wasm_compiler) {
2920 OFStream os(stdout); 2920 OFStream os(stdout);
2921 os << "Compilation failed: " << result << std::endl; 2921 os << "Compilation failed: " << result << std::endl;
2922 } 2922 }
2923 // Add the function as another context for the exception 2923 // Add the function as another context for the exception
2924 ScopedVector<char> buffer(128); 2924 ScopedVector<char> buffer(128);
(...skipping 16 matching lines...) Expand all
2941 2941
2942 class WasmCompilationUnit { 2942 class WasmCompilationUnit {
2943 public: 2943 public:
2944 WasmCompilationUnit(wasm::ErrorThrower* thrower, Isolate* isolate, 2944 WasmCompilationUnit(wasm::ErrorThrower* thrower, Isolate* isolate,
2945 wasm::ModuleEnv* module_env, 2945 wasm::ModuleEnv* module_env,
2946 const wasm::WasmFunction* function, uint32_t index) 2946 const wasm::WasmFunction* function, uint32_t index)
2947 : thrower_(thrower), 2947 : thrower_(thrower),
2948 isolate_(isolate), 2948 isolate_(isolate),
2949 module_env_(module_env), 2949 module_env_(module_env),
2950 function_(function), 2950 function_(function),
2951 graph_zone_(new Zone(isolate->allocator())),
2952 jsgraph_(new (graph_zone()) JSGraph(
2953 isolate, new (graph_zone()) Graph(graph_zone()),
2954 new (graph_zone()) CommonOperatorBuilder(graph_zone()), nullptr,
2955 nullptr,
2956 new (graph_zone()) MachineOperatorBuilder(
2957 graph_zone(), MachineType::PointerRepresentation(),
2958 InstructionSelector::SupportedMachineOperatorFlags()))),
2951 compilation_zone_(isolate->allocator()), 2959 compilation_zone_(isolate->allocator()),
2952 info_(function->name_length != 0 2960 info_(function->name_length != 0
2953 ? module_env->module->GetNameOrNull(function->name_offset, 2961 ? module_env->module->GetNameOrNull(function->name_offset,
2954 function->name_length) 2962 function->name_length)
2955 : ArrayVector("wasm"), 2963 : ArrayVector("wasm"),
2956 isolate, &compilation_zone_, 2964 isolate, &compilation_zone_,
2957 Code::ComputeFlags(Code::WASM_FUNCTION)), 2965 Code::ComputeFlags(Code::WASM_FUNCTION)),
2958 job_(), 2966 job_(),
2959 index_(index), 2967 index_(index),
2960 ok_(true) {} 2968 ok_(true) {
2969 // Create and cache this node in the main thread.
2970 jsgraph_->CEntryStubConstant(1);
2971 }
2972
2973 Zone* graph_zone() { return graph_zone_.get(); }
2961 2974
2962 void ExecuteCompilation() { 2975 void ExecuteCompilation() {
2963 HistogramTimerScope wasm_compile_function_time_scope( 2976 // TODO(ahaas): The counters are not thread-safe at the moment.
2964 isolate_->counters()->wasm_compile_function_time()); 2977 // HistogramTimerScope wasm_compile_function_time_scope(
2978 // isolate_->counters()->wasm_compile_function_time());
2965 if (FLAG_trace_wasm_compiler) { 2979 if (FLAG_trace_wasm_compiler) {
2966 OFStream os(stdout); 2980 OFStream os(stdout);
2967 os << "Compiling WASM function " 2981 os << "Compiling WASM function "
2968 << wasm::WasmFunctionName(function_, module_env_) << std::endl; 2982 << wasm::WasmFunctionName(function_, module_env_) << std::endl;
2969 os << std::endl; 2983 os << std::endl;
2970 } 2984 }
2971 2985
2972 double decode_ms = 0; 2986 double decode_ms = 0;
2973 size_t node_count = 0; 2987 size_t node_count = 0;
2974 2988
2975 Zone zone(isolate_->allocator()); 2989 base::SmartPointer<Zone> graph_zone(graph_zone_.Detach());
2976 std::pair<JSGraph*, SourcePositionTable*> graph_result = 2990 std::pair<JSGraph*, SourcePositionTable*> graph_result =
2977 BuildGraphForWasmFunction(&zone, thrower_, isolate_, module_env_, 2991 BuildGraphForWasmFunction(jsgraph_, thrower_, isolate_, module_env_,
2978 function_, &decode_ms); 2992 function_, &decode_ms);
2979 JSGraph* jsgraph = graph_result.first; 2993 JSGraph* jsgraph = graph_result.first;
2980 SourcePositionTable* source_positions = graph_result.second; 2994 SourcePositionTable* source_positions = graph_result.second;
2981 2995
2982 if (jsgraph == nullptr) { 2996 if (jsgraph == nullptr) {
2983 ok_ = false; 2997 ok_ = false;
2984 return; 2998 return;
2985 } 2999 }
2986 3000
2987 base::ElapsedTimer pipeline_timer; 3001 base::ElapsedTimer pipeline_timer;
2988 if (FLAG_trace_wasm_decode_time) { 3002 if (FLAG_trace_wasm_decode_time) {
2989 node_count = jsgraph->graph()->NodeCount(); 3003 node_count = jsgraph->graph()->NodeCount();
2990 pipeline_timer.Start(); 3004 pipeline_timer.Start();
2991 } 3005 }
2992 3006
2993 // Run the compiler pipeline to generate machine code. 3007 // Run the compiler pipeline to generate machine code.
2994 CallDescriptor* descriptor = wasm::ModuleEnv::GetWasmCallDescriptor( 3008 CallDescriptor* descriptor = wasm::ModuleEnv::GetWasmCallDescriptor(
2995 &compilation_zone_, function_->sig); 3009 &compilation_zone_, function_->sig);
2996 if (jsgraph->machine()->Is32()) { 3010 if (jsgraph->machine()->Is32()) {
2997 descriptor = 3011 descriptor =
2998 module_env_->GetI32WasmCallDescriptor(&compilation_zone_, descriptor); 3012 module_env_->GetI32WasmCallDescriptor(&compilation_zone_, descriptor);
2999 } 3013 }
3000 job_.Reset(Pipeline::NewWasmCompilationJob(&info_, jsgraph->graph(), 3014 job_.Reset(Pipeline::NewWasmCompilationJob(&info_, jsgraph->graph(),
3001 descriptor, source_positions)); 3015 descriptor, source_positions));
3002 ok_ = job_->OptimizeGraph() == CompilationJob::SUCCEEDED; 3016 ok_ = job_->OptimizeGraph() == CompilationJob::SUCCEEDED;
3003 // TODO(bradnelson): Improve histogram handling of size_t. 3017 // TODO(bradnelson): Improve histogram handling of size_t.
3004 isolate_->counters()->wasm_compile_function_peak_memory_bytes()->AddSample( 3018 // TODO(ahaas): The counters are not thread-safe at the moment.
3005 static_cast<int>(jsgraph->graph()->zone()->allocation_size())); 3019 // isolate_->counters()->wasm_compile_function_peak_memory_bytes()->AddSa mple(
3020 // static_cast<int>(jsgraph->graph()->zone()->allocation_size()));
3006 3021
3007 if (FLAG_trace_wasm_decode_time) { 3022 if (FLAG_trace_wasm_decode_time) {
3008 double pipeline_ms = pipeline_timer.Elapsed().InMillisecondsF(); 3023 double pipeline_ms = pipeline_timer.Elapsed().InMillisecondsF();
3009 PrintF( 3024 PrintF(
3010 "wasm-compilation phase 1 ok: %d bytes, %0.3f ms decode, %zu nodes, " 3025 "wasm-compilation phase 1 ok: %d bytes, %0.3f ms decode, %zu nodes, "
3011 "%0.3f ms pipeline\n", 3026 "%0.3f ms pipeline\n",
3012 static_cast<int>(function_->code_end_offset - 3027 static_cast<int>(function_->code_end_offset -
3013 function_->code_start_offset), 3028 function_->code_start_offset),
3014 decode_ms, node_count, pipeline_ms); 3029 decode_ms, node_count, pipeline_ms);
3015 } 3030 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
3052 compile_ms); 3067 compile_ms);
3053 } 3068 }
3054 3069
3055 return code; 3070 return code;
3056 } 3071 }
3057 3072
3058 wasm::ErrorThrower* thrower_; 3073 wasm::ErrorThrower* thrower_;
3059 Isolate* isolate_; 3074 Isolate* isolate_;
3060 wasm::ModuleEnv* module_env_; 3075 wasm::ModuleEnv* module_env_;
3061 const wasm::WasmFunction* function_; 3076 const wasm::WasmFunction* function_;
3077 // The graph zone is deallocated at the end of ExecuteCompilation.
3078 base::SmartPointer<Zone> graph_zone_;
3079 JSGraph* jsgraph_;
3062 Zone compilation_zone_; 3080 Zone compilation_zone_;
3063 CompilationInfo info_; 3081 CompilationInfo info_;
3064 base::SmartPointer<CompilationJob> job_; 3082 base::SmartPointer<CompilationJob> job_;
3065 uint32_t index_; 3083 uint32_t index_;
3066 bool ok_; 3084 bool ok_;
3067 }; 3085 };
3068 3086
3069 WasmCompilationUnit* CreateWasmCompilationUnit( 3087 WasmCompilationUnit* CreateWasmCompilationUnit(
3070 wasm::ErrorThrower* thrower, Isolate* isolate, wasm::ModuleEnv* module_env, 3088 wasm::ErrorThrower* thrower, Isolate* isolate, wasm::ModuleEnv* module_env,
3071 const wasm::WasmFunction* function, uint32_t index) { 3089 const wasm::WasmFunction* function, uint32_t index) {
(...skipping 20 matching lines...) Expand all
3092 const wasm::WasmFunction* function) { 3110 const wasm::WasmFunction* function) {
3093 WasmCompilationUnit* unit = 3111 WasmCompilationUnit* unit =
3094 CreateWasmCompilationUnit(thrower, isolate, module_env, function, 0); 3112 CreateWasmCompilationUnit(thrower, isolate, module_env, function, 0);
3095 ExecuteCompilation(unit); 3113 ExecuteCompilation(unit);
3096 return FinishCompilation(unit); 3114 return FinishCompilation(unit);
3097 } 3115 }
3098 3116
3099 } // namespace compiler 3117 } // namespace compiler
3100 } // namespace internal 3118 } // namespace internal
3101 } // namespace v8 3119 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/wasm-compiler.h ('k') | src/flag-definitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698