Commit ac377868 authored by Maya Lekova's avatar Maya Lekova Committed by Commit Bot

[turbofan] Move source positions generation out of inlining

The call to EnsureSourcePositionsAvailable for a given SharedFunctionInfo
is now done in the serializer for each SFI that is marked as serialized for
compilation. This will enable brokerization of the JSInliner class.

Change-Id: I7821a50fcac8a3e19386e98758f2b0dea3023bb6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1582400
Commit-Queue: Maya Lekova <mslekova@chromium.org>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61260}
parent 7bc1af3d
...@@ -447,10 +447,6 @@ Reduction JSInliner::ReduceJSCall(Node* node) { ...@@ -447,10 +447,6 @@ Reduction JSInliner::ReduceJSCall(Node* node) {
// it never gets flushed, so the following check should always hold true. // it never gets flushed, so the following check should always hold true.
CHECK(is_compiled_scope.is_compiled()); CHECK(is_compiled_scope.is_compiled());
if (info_->is_source_positions_enabled()) {
SharedFunctionInfo::EnsureSourcePositionsAvailable(isolate(), shared_info);
}
TRACE("Inlining %s into %s%s\n", shared_info->DebugName()->ToCString().get(), TRACE("Inlining %s into %s%s\n", shared_info->DebugName()->ToCString().get(),
info_->shared_info()->DebugName()->ToCString().get(), info_->shared_info()->DebugName()->ToCString().get(),
(exception_target != nullptr) ? " (inside try-block)" : ""); (exception_target != nullptr) ? " (inside try-block)" : "");
......
...@@ -1247,8 +1247,9 @@ struct SerializationPhase { ...@@ -1247,8 +1247,9 @@ struct SerializationPhase {
static const char* phase_name() { return "V8.TFSerializeBytecode"; } static const char* phase_name() { return "V8.TFSerializeBytecode"; }
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
SerializerForBackgroundCompilation serializer(data->broker(), temp_zone, SerializerForBackgroundCompilation serializer(
data->info()->closure()); data->broker(), temp_zone, data->info()->closure(),
data->info()->is_source_positions_enabled());
serializer.Run(); serializer.Run();
} }
}; };
......
...@@ -247,9 +247,11 @@ int SerializerForBackgroundCompilation::Environment::RegisterToLocalIndex( ...@@ -247,9 +247,11 @@ int SerializerForBackgroundCompilation::Environment::RegisterToLocalIndex(
} }
SerializerForBackgroundCompilation::SerializerForBackgroundCompilation( SerializerForBackgroundCompilation::SerializerForBackgroundCompilation(
JSHeapBroker* broker, Zone* zone, Handle<JSFunction> closure) JSHeapBroker* broker, Zone* zone, Handle<JSFunction> closure,
bool collect_source_positions)
: broker_(broker), : broker_(broker),
zone_(zone), zone_(zone),
collect_source_positions_(collect_source_positions),
environment_(new (zone) Environment(zone, {closure, broker_->isolate()})), environment_(new (zone) Environment(zone, {closure, broker_->isolate()})),
stashed_environments_(zone) { stashed_environments_(zone) {
JSFunctionRef(broker, closure).Serialize(); JSFunctionRef(broker, closure).Serialize();
...@@ -257,9 +259,11 @@ SerializerForBackgroundCompilation::SerializerForBackgroundCompilation( ...@@ -257,9 +259,11 @@ SerializerForBackgroundCompilation::SerializerForBackgroundCompilation(
SerializerForBackgroundCompilation::SerializerForBackgroundCompilation( SerializerForBackgroundCompilation::SerializerForBackgroundCompilation(
JSHeapBroker* broker, Zone* zone, CompilationSubject function, JSHeapBroker* broker, Zone* zone, CompilationSubject function,
base::Optional<Hints> new_target, const HintsVector& arguments) base::Optional<Hints> new_target, const HintsVector& arguments,
bool collect_source_positions)
: broker_(broker), : broker_(broker),
zone_(zone), zone_(zone),
collect_source_positions_(collect_source_positions),
environment_(new (zone) Environment(zone, broker_->isolate(), function, environment_(new (zone) Environment(zone, broker_->isolate(), function,
new_target, arguments)), new_target, arguments)),
stashed_environments_(zone) { stashed_environments_(zone) {
...@@ -277,6 +281,15 @@ Hints SerializerForBackgroundCompilation::Run() { ...@@ -277,6 +281,15 @@ Hints SerializerForBackgroundCompilation::Run() {
return Hints(zone()); return Hints(zone());
} }
shared.SetSerializedForCompilation(feedback_vector); shared.SetSerializedForCompilation(feedback_vector);
// We eagerly call the {EnsureSourcePositionsAvailable} for all serialized
// SFIs while still on the main thread. Source positions will later be used
// by JSInliner::ReduceJSCall.
if (collect_source_positions()) {
SharedFunctionInfo::EnsureSourcePositionsAvailable(broker()->isolate(),
shared.object());
}
feedback_vector.SerializeSlots(); feedback_vector.SerializeSlots();
TraverseBytecode(); TraverseBytecode();
return environment()->return_value_hints(); return environment()->return_value_hints();
...@@ -565,7 +578,8 @@ Hints SerializerForBackgroundCompilation::RunChildSerializer( ...@@ -565,7 +578,8 @@ Hints SerializerForBackgroundCompilation::RunChildSerializer(
<< *environment()); << *environment());
SerializerForBackgroundCompilation child_serializer( SerializerForBackgroundCompilation child_serializer(
broker(), zone(), function, new_target, arguments); broker(), zone(), function, new_target, arguments,
collect_source_positions());
return child_serializer.Run(); return child_serializer.Run();
} }
......
...@@ -271,7 +271,8 @@ using HintsVector = ZoneVector<Hints>; ...@@ -271,7 +271,8 @@ using HintsVector = ZoneVector<Hints>;
class SerializerForBackgroundCompilation { class SerializerForBackgroundCompilation {
public: public:
SerializerForBackgroundCompilation(JSHeapBroker* broker, Zone* zone, SerializerForBackgroundCompilation(JSHeapBroker* broker, Zone* zone,
Handle<JSFunction> closure); Handle<JSFunction> closure,
bool collect_source_positions);
Hints Run(); // NOTE: Returns empty for an already-serialized function. Hints Run(); // NOTE: Returns empty for an already-serialized function.
class Environment; class Environment;
...@@ -280,7 +281,8 @@ class SerializerForBackgroundCompilation { ...@@ -280,7 +281,8 @@ class SerializerForBackgroundCompilation {
SerializerForBackgroundCompilation(JSHeapBroker* broker, Zone* zone, SerializerForBackgroundCompilation(JSHeapBroker* broker, Zone* zone,
CompilationSubject function, CompilationSubject function,
base::Optional<Hints> new_target, base::Optional<Hints> new_target,
const HintsVector& arguments); const HintsVector& arguments,
bool collect_source_positions);
void TraverseBytecode(); void TraverseBytecode();
...@@ -319,10 +321,14 @@ class SerializerForBackgroundCompilation { ...@@ -319,10 +321,14 @@ class SerializerForBackgroundCompilation {
JSHeapBroker* broker() const { return broker_; } JSHeapBroker* broker() const { return broker_; }
Zone* zone() const { return zone_; } Zone* zone() const { return zone_; }
// The following flag is initialized from OptimizedCompilationInfo's
// {is_source_positions_enabled}.
bool collect_source_positions() const { return collect_source_positions_; }
Environment* environment() const { return environment_; } Environment* environment() const { return environment_; }
JSHeapBroker* const broker_; JSHeapBroker* const broker_;
Zone* const zone_; Zone* const zone_;
bool const collect_source_positions_;
Environment* const environment_; Environment* const environment_;
ZoneUnorderedMap<int, Environment*> stashed_environments_; ZoneUnorderedMap<int, Environment*> stashed_environments_;
}; };
......
...@@ -26,7 +26,6 @@ GraphTest::GraphTest(int num_parameters) ...@@ -26,7 +26,6 @@ GraphTest::GraphTest(int num_parameters)
broker()->SetNativeContextRef(); broker()->SetNativeContextRef();
} }
GraphTest::~GraphTest() = default; GraphTest::~GraphTest() = default;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment