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

Unified Diff: src/compiler/wasm-compiler.cc

Issue 1890803002: [wasm] Generate source position information (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@wasm-throw-error
Patch Set: minor 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 side-by-side diff with in-line comments
Download patch
Index: src/compiler/wasm-compiler.cc
diff --git a/src/compiler/wasm-compiler.cc b/src/compiler/wasm-compiler.cc
index 9dfaa6a72a998fe1f4cc6d4e1a5dbef22f1a4186..e60d47ed902ecc19ec47d2db9d0722d051fab2ce 100644
--- a/src/compiler/wasm-compiler.cc
+++ b/src/compiler/wasm-compiler.cc
@@ -244,8 +244,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),
@@ -257,8 +258,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());
}
@@ -2670,6 +2674,12 @@ void WasmGraphBuilder::Int64LoweringForTesting() {
}
}
+void WasmGraphBuilder::SetSourcePosition(Node* node, int position) {
+ compiler::SourcePosition pos(position);
+ if (source_position_table_)
+ source_position_table_->SetSourcePosition(node, pos);
+}
+
static void RecordFunctionCompilation(Logger::LogEventsAndTags tag,
CompilationInfo* info,
const char* message, uint32_t index,
@@ -2762,7 +2772,7 @@ Handle<JSFunction> CompileJSToWasmWrapper(
CompilationInfo info(func_name, isolate, &zone, flags);
Handle<Code> code =
- Pipeline::GenerateCodeForTesting(&info, incoming, &graph, nullptr);
+ Pipeline::GenerateCodeForTesting(&info, incoming, &graph);
#ifdef ENABLE_DISASSEMBLER
if (FLAG_print_opt_code && !code.is_null()) {
OFStream os(stdout);
@@ -2881,11 +2891,14 @@ 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};
+
wasm::TreeResult result =
wasm::BuildTFGraph(isolate->allocator(), &builder, body);
@@ -2928,6 +2941,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 =
@@ -2948,8 +2962,8 @@ Handle<Code> CompileWasmFunction(wasm::ErrorThrower& thrower, Isolate* isolate,
}
CompilationInfo info(func_name, isolate, &zone, flags);
- Handle<Code> code =
- Pipeline::GenerateCodeForTesting(&info, descriptor, &graph);
+ Handle<Code> code = Pipeline::GenerateWASMCode(&info, descriptor, &graph,
+ &source_position_table);
if (debugging) {
buffer.Dispose();
}

Powered by Google App Engine
This is Rietveld 408576698