| Index: src/compiler/wasm-compiler.cc | 
| diff --git a/src/compiler/wasm-compiler.cc b/src/compiler/wasm-compiler.cc | 
| index 395f2e8103c43eb829a96a4e273c0a8f6227cb11..5ba177b89c9ed838b512e86fb935f38eef506362 100644 | 
| --- a/src/compiler/wasm-compiler.cc | 
| +++ b/src/compiler/wasm-compiler.cc | 
| @@ -248,8 +248,9 @@ class WasmTrapHelper : public ZoneObject { | 
| } | 
| }; | 
|  | 
| -WasmGraphBuilder::WasmGraphBuilder(Zone* zone, JSGraph* jsgraph, | 
| -                                   wasm::FunctionSig* function_signature) | 
| +WasmGraphBuilder::WasmGraphBuilder( | 
| +    Zone* zone, JSGraph* jsgraph, wasm::FunctionSig* function_signature, | 
| +    compiler::SourcePositionTable* source_position_table) | 
| : zone_(zone), | 
| jsgraph_(jsgraph), | 
| module_(nullptr), | 
| @@ -261,8 +262,11 @@ WasmGraphBuilder::WasmGraphBuilder(Zone* zone, JSGraph* jsgraph, | 
| cur_buffer_(def_buffer_), | 
| cur_bufsize_(kDefaultBufferSize), | 
| trap_(new (zone) WasmTrapHelper(this)), | 
| -      function_signature_(function_signature) { | 
| +      function_signature_(function_signature), | 
| +      source_position_table_(source_position_table) { | 
| DCHECK_NOT_NULL(jsgraph_); | 
| +  DCHECK_IMPLIES(source_position_table != nullptr, | 
| +                 source_position_table->GetGraph() == graph()); | 
| } | 
|  | 
|  | 
| @@ -2479,6 +2483,27 @@ void WasmGraphBuilder::Int64LoweringForTesting() { | 
| } | 
| } | 
|  | 
| +void WasmGraphBuilder::EnterSourcePositionScope() { | 
| +  DCHECK_NULL(source_position_scope_); | 
| +  if (source_position_table_) { | 
| +    source_position_table_->AddDecorator(); | 
| +    source_position_scope_ = new SourcePositionScope(source_position_table_); | 
| +  } | 
| +} | 
| + | 
| +void WasmGraphBuilder::LeaveSourcePositionScope() { | 
| +  DCHECK_EQ(!!source_position_table_, !!source_position_scope_); | 
| +  if (!source_position_scope_) return; | 
| +  delete source_position_scope_; | 
| +  source_position_scope_ = nullptr; | 
| +  source_position_table_->RemoveDecorator(); | 
| +} | 
| + | 
| +void WasmGraphBuilder::SetCurrentSourcePosition(int position) { | 
| +  if (source_position_scope_) | 
| +    source_position_scope_->SetCurrentPosition(SourcePosition(position)); | 
| +} | 
| + | 
| static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, | 
| CompilationInfo* info, | 
| const char* message, uint32_t index, | 
| @@ -2711,13 +2736,18 @@ Handle<Code> CompileWasmFunction(wasm::ErrorThrower& thrower, Isolate* isolate, | 
| &zone, MachineType::PointerRepresentation(), | 
| InstructionSelector::SupportedMachineOperatorFlags()); | 
| JSGraph jsgraph(isolate, &graph, &common, nullptr, nullptr, &machine); | 
| -  WasmGraphBuilder builder(&zone, &jsgraph, function.sig); | 
| +  SourcePositionTable source_position_table(&graph); | 
| +  WasmGraphBuilder builder(&zone, &jsgraph, function.sig, | 
| +                           &source_position_table); | 
| wasm::FunctionBody body = { | 
| module_env, function.sig, module_env->module->module_start, | 
| module_env->module->module_start + function.code_start_offset, | 
| module_env->module->module_start + function.code_end_offset}; | 
| + | 
| +  builder.EnterSourcePositionScope(); | 
| wasm::TreeResult result = | 
| wasm::BuildTFGraph(isolate->allocator(), &builder, body); | 
| +  builder.LeaveSourcePositionScope(); | 
|  | 
| if (result.failed()) { | 
| if (FLAG_trace_wasm_compiler) { | 
| @@ -2753,6 +2783,7 @@ Handle<Code> CompileWasmFunction(wasm::ErrorThrower& thrower, Isolate* isolate, | 
| if (machine.Is32()) { | 
| descriptor = module_env->GetI32WasmCallDescriptor(&zone, descriptor); | 
| } | 
| + | 
| Code::Flags flags = Code::ComputeFlags(Code::WASM_FUNCTION); | 
| // add flags here if a meaningful name is helpful for debugging. | 
| bool debugging = | 
| @@ -2772,6 +2803,9 @@ Handle<Code> CompileWasmFunction(wasm::ErrorThrower& thrower, Isolate* isolate, | 
| func_name = buffer.start(); | 
| } | 
| CompilationInfo info(func_name, isolate, &zone, flags); | 
| +  // TODO(clemensh): make source position tracking optional | 
| +  info.MarkAsSourcePositionsEnabled(); | 
| +  info.SetSourcePositionTable(&source_position_table); | 
|  | 
| Handle<Code> code = | 
| Pipeline::GenerateCodeForTesting(&info, descriptor, &graph); | 
|  |