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