Commit 073b6ea6 authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[turbofan] Replace two bool arguments with a new flags type

Also const-ify and refactor a few things in BytecodeAnalysis.

Change-Id: Ibd261bb67d8c035b1f818e9114d09db08737000d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1587384
Commit-Queue: Georg Neis <neis@chromium.org>
Reviewed-by: 's avatarSigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61088}
parent 7e677b2e
......@@ -538,6 +538,12 @@ void BytecodeAnalysis::Analyze(BailoutId osr_bailout_id) {
}
}
DCHECK(do_liveness_analysis_);
if (FLAG_trace_environment_liveness) {
StdoutStream of;
PrintLivenessTo(of);
}
DCHECK(LivenessIsValid());
}
......
......@@ -35,8 +35,8 @@ class V8_EXPORT_PRIVATE BytecodeLoopAssignments {
int local_count() const { return bit_vector_->length() - parameter_count_; }
private:
int parameter_count_;
BitVector* bit_vector_;
int const parameter_count_;
BitVector* const bit_vector_;
};
// Jump targets for resuming a suspended generator.
......@@ -129,8 +129,6 @@ class V8_EXPORT_PRIVATE BytecodeAnalysis {
// Gets the out-liveness for the bytecode at {offset}.
const BytecodeLivenessState* GetOutLivenessFor(int offset) const;
std::ostream& PrintLivenessTo(std::ostream& os) const;
private:
struct LoopStackEntry {
int header_offset;
......@@ -152,10 +150,11 @@ class V8_EXPORT_PRIVATE BytecodeAnalysis {
Zone* zone() const { return zone_; }
Handle<BytecodeArray> bytecode_array() const { return bytecode_array_; }
private:
Handle<BytecodeArray> bytecode_array_;
bool do_liveness_analysis_;
Zone* zone_;
std::ostream& PrintLivenessTo(std::ostream& os) const;
Handle<BytecodeArray> const bytecode_array_;
bool const do_liveness_analysis_;
Zone* const zone_;
ZoneStack<LoopStackEntry> loop_stack_;
ZoneVector<int> loop_end_index_queue_;
......
......@@ -38,9 +38,7 @@ class BytecodeGraphBuilder {
CallFrequency invocation_frequency,
SourcePositionTable* source_positions,
Handle<Context> native_context, int inlining_id,
JSTypeHintLowering::Flags flags,
bool skip_first_stack_check,
bool analyze_environment_liveness);
BytecodeGraphBuilderFlags flags);
// Creates a graph by visiting bytecodes.
void CreateGraph();
......@@ -354,10 +352,6 @@ class BytecodeGraphBuilder {
void unset_skip_next_stack_check() { skip_next_stack_check_ = false; }
bool analyze_environment_liveness() const {
return analyze_environment_liveness_;
}
int current_exception_handler() { return current_exception_handler_; }
void set_current_exception_handler(int index) {
......@@ -391,7 +385,6 @@ class BytecodeGraphBuilder {
BailoutId const osr_offset_;
int currently_peeled_loop_offset_;
bool skip_next_stack_check_;
bool const analyze_environment_liveness_;
// Merge environments are snapshots of the environment at points where the
// control flow merges. This models a forward data flow propagation of all
......@@ -942,14 +935,17 @@ BytecodeGraphBuilder::BytecodeGraphBuilder(
Handle<FeedbackVector> feedback_vector, BailoutId osr_offset,
JSGraph* jsgraph, CallFrequency invocation_frequency,
SourcePositionTable* source_positions, Handle<Context> native_context,
int inlining_id, JSTypeHintLowering::Flags flags,
bool skip_first_stack_check, bool analyze_environment_liveness)
int inlining_id, BytecodeGraphBuilderFlags flags)
: local_zone_(local_zone),
jsgraph_(jsgraph),
invocation_frequency_(invocation_frequency),
bytecode_array_(bytecode_array),
feedback_vector_(feedback_vector),
type_hint_lowering_(jsgraph, feedback_vector, flags),
type_hint_lowering_(
jsgraph, feedback_vector,
(flags & BytecodeGraphBuilderFlag::kBailoutOnUninitialized)
? JSTypeHintLowering::kBailoutOnUninitialized
: JSTypeHintLowering::kNoFlags),
frame_state_function_info_(common()->CreateFrameStateFunctionInfo(
FrameStateType::kInterpretedFunction,
bytecode_array->parameter_count(), bytecode_array->register_count(),
......@@ -957,13 +953,14 @@ BytecodeGraphBuilder::BytecodeGraphBuilder(
source_position_iterator_(
handle(bytecode_array->SourcePositionTableIfCollected(), isolate())),
bytecode_iterator_(bytecode_array),
bytecode_analysis_(bytecode_array, local_zone,
analyze_environment_liveness),
bytecode_analysis_(
bytecode_array, local_zone,
flags & BytecodeGraphBuilderFlag::kAnalyzeEnvironmentLiveness),
environment_(nullptr),
osr_offset_(osr_offset),
currently_peeled_loop_offset_(-1),
skip_next_stack_check_(skip_first_stack_check),
analyze_environment_liveness_(analyze_environment_liveness),
skip_next_stack_check_(flags &
BytecodeGraphBuilderFlag::kSkipFirstStackCheck),
merge_environments_(local_zone),
generator_merge_environments_(local_zone),
exception_handlers_(local_zone),
......@@ -1295,11 +1292,6 @@ void BytecodeGraphBuilder::VisitSingleBytecode() {
void BytecodeGraphBuilder::VisitBytecodes() {
RunBytecodeAnalysis();
if (analyze_environment_liveness() && FLAG_trace_environment_liveness) {
StdoutStream of;
bytecode_analysis().PrintLivenessTo(of);
}
if (!bytecode_analysis().resume_jump_targets().empty()) {
environment()->BindGeneratorState(
jsgraph()->SmiConstant(JSGeneratorObject::kGeneratorExecuting));
......@@ -4044,12 +4036,11 @@ void BuildGraphFromBytecode(
Handle<SharedFunctionInfo> shared, Handle<FeedbackVector> feedback_vector,
BailoutId osr_offset, JSGraph* jsgraph, CallFrequency invocation_frequency,
SourcePositionTable* source_positions, Handle<Context> native_context,
int inlining_id, JSTypeHintLowering::Flags flags,
bool skip_first_stack_check, bool analyze_environment_liveness) {
BytecodeGraphBuilder builder(
local_zone, bytecode_array, shared, feedback_vector, osr_offset, jsgraph,
invocation_frequency, source_positions, native_context, inlining_id,
flags, skip_first_stack_check, analyze_environment_liveness);
int inlining_id, BytecodeGraphBuilderFlags flags) {
BytecodeGraphBuilder builder(local_zone, bytecode_array, shared,
feedback_vector, osr_offset, jsgraph,
invocation_frequency, source_positions,
native_context, inlining_id, flags);
builder.CreateGraph();
}
......
......@@ -9,7 +9,6 @@
#include "src/compiler/js-type-hint-lowering.h"
#include "src/handles.h"
#include "src/utils.h"
#include "src/zone/zone.h"
namespace v8 {
namespace internal {
......@@ -17,19 +16,26 @@ namespace internal {
class BytecodeArray;
class FeedbackVector;
class SharedFunctionInfo;
class Zone;
namespace compiler {
class JSGraph;
class SourcePositionTable;
enum class BytecodeGraphBuilderFlag : uint8_t {
kSkipFirstStackCheck = 1 << 0,
kAnalyzeEnvironmentLiveness = 1 << 1,
kBailoutOnUninitialized = 1 << 2,
};
using BytecodeGraphBuilderFlags = base::Flags<BytecodeGraphBuilderFlag>;
void BuildGraphFromBytecode(
Zone* local_zone, Handle<BytecodeArray> bytecode_array,
Handle<SharedFunctionInfo> shared, Handle<FeedbackVector> feedback_vector,
BailoutId osr_offset, JSGraph* jsgraph, CallFrequency invocation_frequency,
SourcePositionTable* source_positions, Handle<Context> native_context,
int inlining_id, JSTypeHintLowering::Flags flags,
bool skip_first_stack_check, bool analyze_environment_liveness);
int inlining_id, BytecodeGraphBuilderFlags flags);
} // namespace compiler
} // namespace internal
......
......@@ -488,14 +488,18 @@ Reduction JSInliner::ReduceJSCall(Node* node) {
{
// Run the BytecodeGraphBuilder to create the subgraph.
Graph::SubgraphScope scope(graph());
JSTypeHintLowering::Flags flags = JSTypeHintLowering::kNoFlags;
BytecodeGraphBuilderFlags flags(
BytecodeGraphBuilderFlag::kSkipFirstStackCheck);
if (info_->is_analyze_environment_liveness()) {
flags |= BytecodeGraphBuilderFlag::kAnalyzeEnvironmentLiveness;
}
if (info_->is_bailout_on_uninitialized()) {
flags |= JSTypeHintLowering::kBailoutOnUninitialized;
flags |= BytecodeGraphBuilderFlag::kBailoutOnUninitialized;
}
BuildGraphFromBytecode(
zone(), bytecode_array, shared_info, feedback_vector, BailoutId::None(),
jsgraph(), call.frequency(), source_positions_, native_context(),
inlining_id, flags, true, info_->is_analyze_environment_liveness());
BuildGraphFromBytecode(zone(), bytecode_array, shared_info, feedback_vector,
BailoutId::None(), jsgraph(), call.frequency(),
source_positions_, native_context(), inlining_id,
flags);
// Extract the inlinee start/end nodes.
start = graph()->start();
......
......@@ -1061,17 +1061,19 @@ struct GraphBuilderPhase {
static const char* phase_name() { return "V8.TFBytecodeGraphBuilder"; }
void Run(PipelineData* data, Zone* temp_zone) {
JSTypeHintLowering::Flags flags = JSTypeHintLowering::kNoFlags;
BytecodeGraphBuilderFlags flags;
if (data->info()->is_analyze_environment_liveness()) {
flags |= BytecodeGraphBuilderFlag::kAnalyzeEnvironmentLiveness;
}
if (data->info()->is_bailout_on_uninitialized()) {
flags |= JSTypeHintLowering::kBailoutOnUninitialized;
flags |= BytecodeGraphBuilderFlag::kBailoutOnUninitialized;
}
BuildGraphFromBytecode(
temp_zone, data->info()->bytecode_array(), data->info()->shared_info(),
handle(data->info()->closure()->feedback_vector(), data->isolate()),
data->info()->osr_offset(), data->jsgraph(), CallFrequency(1.0f),
data->source_positions(), data->native_context(),
SourcePosition::kNotInlined, flags, false,
data->info()->is_analyze_environment_liveness());
SourcePosition::kNotInlined, flags);
}
};
......
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