Commit c2f029af authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[turbofan] Teach serializer about soft deopts

When encountering uninitialized feedback, mark the environment as dead
such that we skip over the following bytecodes. Start full processing
again when we reach a bytecode that is either a jump target or an
exception handler entry. For now, don't support this optimization when
compiling for OSR.

Bug: v8:7790
Change-Id: I8177b7fa31ea43d205a2708310b0b0e67302001e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1621930
Commit-Queue: Georg Neis <neis@chromium.org>
Reviewed-by: 's avatarMichael Stanton <mvstanton@chromium.org>
Reviewed-by: 's avatarMaya Lekova <mslekova@chromium.org>
Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61781}
parent d5688b1f
......@@ -81,6 +81,8 @@ class Flags final {
constexpr operator mask_type() const { return mask_; }
constexpr bool operator!() const { return !mask_; }
Flags without(flag_type flag) { return *this & (~Flags(flag)); }
friend size_t hash_value(const Flags& flags) { return flags.mask_; }
private:
......
......@@ -1249,9 +1249,19 @@ struct SerializationPhase {
static const char* phase_name() { return "V8.TFSerializeBytecode"; }
void Run(PipelineData* data, Zone* temp_zone) {
SerializerForBackgroundCompilationFlags flags;
if (data->info()->is_bailout_on_uninitialized()) {
flags |= SerializerForBackgroundCompilationFlag::kBailoutOnUninitialized;
}
if (data->info()->is_source_positions_enabled()) {
flags |= SerializerForBackgroundCompilationFlag::kCollectSourcePositions;
}
if (data->info()->is_osr()) {
flags |= SerializerForBackgroundCompilationFlag::kOsr;
}
SerializerForBackgroundCompilation serializer(
data->broker(), data->dependencies(), temp_zone,
data->info()->closure(), data->info()->is_source_positions_enabled());
data->info()->closure(), flags);
serializer.Run();
}
};
......
......@@ -263,29 +263,37 @@ class Hints {
MapsSet maps_;
BlueprintsSet function_blueprints_;
};
using HintsVector = ZoneVector<Hints>;
enum class SerializerForBackgroundCompilationFlag : uint8_t {
kBailoutOnUninitialized = 1 << 0,
kCollectSourcePositions = 1 << 1,
kOsr = 1 << 2,
};
using SerializerForBackgroundCompilationFlags =
base::Flags<SerializerForBackgroundCompilationFlag>;
// The SerializerForBackgroundCompilation makes sure that the relevant function
// data such as bytecode, SharedFunctionInfo and FeedbackVector, used by later
// optimizations in the compiler, is copied to the heap broker.
class SerializerForBackgroundCompilation {
public:
SerializerForBackgroundCompilation(JSHeapBroker* broker,
CompilationDependencies* dependencies,
Zone* zone, Handle<JSFunction> closure,
bool collect_source_positions);
SerializerForBackgroundCompilation(
JSHeapBroker* broker, CompilationDependencies* dependencies, Zone* zone,
Handle<JSFunction> closure,
SerializerForBackgroundCompilationFlags flags);
Hints Run(); // NOTE: Returns empty for an already-serialized function.
class Environment;
private:
SerializerForBackgroundCompilation(JSHeapBroker* broker,
CompilationDependencies* dependencies,
Zone* zone, CompilationSubject function,
base::Optional<Hints> new_target,
const HintsVector& arguments,
bool collect_source_positions);
SerializerForBackgroundCompilation(
JSHeapBroker* broker, CompilationDependencies* dependencies, Zone* zone,
CompilationSubject function, base::Optional<Hints> new_target,
const HintsVector& arguments,
SerializerForBackgroundCompilationFlags flags);
bool BailoutOnUninitialized(FeedbackSlot slot);
void TraverseBytecode();
......@@ -327,17 +335,15 @@ class SerializerForBackgroundCompilation {
JSHeapBroker* broker() const { return broker_; }
CompilationDependencies* dependencies() const { return dependencies_; }
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_; }
SerializerForBackgroundCompilationFlags flags() const { return flags_; }
JSHeapBroker* const broker_;
CompilationDependencies* const dependencies_;
Zone* const zone_;
bool const collect_source_positions_;
Environment* const environment_;
ZoneUnorderedMap<int, Environment*> stashed_environments_;
SerializerForBackgroundCompilationFlags const flags_;
};
} // namespace compiler
......
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