Commit c696f7fd authored by Jaroslav Sevcik's avatar Jaroslav Sevcik Committed by Commit Bot

[turbofan] Brokerization prep for bytecode graph builder.

Bug: v8:7790
Change-Id: I513c3ba048eafb7ca5bfa2fb63e35143f49643ec
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1596736
Commit-Queue: Jaroslav Sevcik <jarin@chromium.org>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61246}
parent 226b5834
...@@ -31,7 +31,8 @@ namespace compiler { ...@@ -31,7 +31,8 @@ namespace compiler {
class BytecodeGraphBuilder { class BytecodeGraphBuilder {
public: public:
BytecodeGraphBuilder(Zone* local_zone, Handle<BytecodeArray> bytecode_array, BytecodeGraphBuilder(JSHeapBroker* broker, Zone* local_zone,
Handle<BytecodeArray> bytecode_array,
Handle<SharedFunctionInfo> shared, Handle<SharedFunctionInfo> shared,
Handle<FeedbackVector> feedback_vector, Handle<FeedbackVector> feedback_vector,
BailoutId osr_offset, JSGraph* jsgraph, BailoutId osr_offset, JSGraph* jsgraph,
...@@ -371,10 +372,13 @@ class BytecodeGraphBuilder { ...@@ -371,10 +372,13 @@ class BytecodeGraphBuilder {
Handle<Context> native_context() const { return native_context_; } Handle<Context> native_context() const { return native_context_; }
JSHeapBroker* broker() const { return broker_; }
#define DECLARE_VISIT_BYTECODE(name, ...) void Visit##name(); #define DECLARE_VISIT_BYTECODE(name, ...) void Visit##name();
BYTECODE_LIST(DECLARE_VISIT_BYTECODE) BYTECODE_LIST(DECLARE_VISIT_BYTECODE)
#undef DECLARE_VISIT_BYTECODE #undef DECLARE_VISIT_BYTECODE
JSHeapBroker* const broker_;
Zone* const local_zone_; Zone* const local_zone_;
JSGraph* const jsgraph_; JSGraph* const jsgraph_;
CallFrequency const invocation_frequency_; CallFrequency const invocation_frequency_;
...@@ -934,13 +938,15 @@ Node* BytecodeGraphBuilder::Environment::Checkpoint( ...@@ -934,13 +938,15 @@ Node* BytecodeGraphBuilder::Environment::Checkpoint(
} }
BytecodeGraphBuilder::BytecodeGraphBuilder( BytecodeGraphBuilder::BytecodeGraphBuilder(
Zone* local_zone, Handle<BytecodeArray> bytecode_array, JSHeapBroker* broker, Zone* local_zone,
Handle<BytecodeArray> bytecode_array,
Handle<SharedFunctionInfo> shared_info, Handle<SharedFunctionInfo> shared_info,
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, BytecodeGraphBuilderFlags flags) int inlining_id, BytecodeGraphBuilderFlags flags)
: local_zone_(local_zone), : broker_(broker),
local_zone_(local_zone),
jsgraph_(jsgraph), jsgraph_(jsgraph),
invocation_frequency_(invocation_frequency), invocation_frequency_(invocation_frequency),
bytecode_array_(bytecode_array), bytecode_array_(bytecode_array),
...@@ -1005,18 +1011,21 @@ VectorSlotPair BytecodeGraphBuilder::CreateVectorSlotPair(int slot_id) { ...@@ -1005,18 +1011,21 @@ VectorSlotPair BytecodeGraphBuilder::CreateVectorSlotPair(int slot_id) {
} }
void BytecodeGraphBuilder::CreateGraph() { void BytecodeGraphBuilder::CreateGraph() {
BytecodeArrayRef bytecode_array_ref(broker(), bytecode_array());
SourcePositionTable::Scope pos_scope(source_positions_, start_position_); SourcePositionTable::Scope pos_scope(source_positions_, start_position_);
// Set up the basic structure of the graph. Outputs for {Start} are the formal // Set up the basic structure of the graph. Outputs for {Start} are the formal
// parameters (including the receiver) plus new target, number of arguments, // parameters (including the receiver) plus new target, number of arguments,
// context and closure. // context and closure.
int actual_parameter_count = bytecode_array()->parameter_count() + 4; int actual_parameter_count = bytecode_array_ref.parameter_count() + 4;
graph()->SetStart(graph()->NewNode(common()->Start(actual_parameter_count))); graph()->SetStart(graph()->NewNode(common()->Start(actual_parameter_count)));
Environment env(this, bytecode_array()->register_count(), Environment env(
bytecode_array()->parameter_count(), this, bytecode_array_ref.register_count(),
bytecode_array()->incoming_new_target_or_generator_register(), bytecode_array_ref.parameter_count(),
graph()->start()); bytecode_array_ref.incoming_new_target_or_generator_register(),
graph()->start());
set_environment(&env); set_environment(&env);
VisitBytecodes(); VisitBytecodes();
...@@ -4023,13 +4032,16 @@ void BytecodeGraphBuilder::UpdateSourcePosition(int offset) { ...@@ -4023,13 +4032,16 @@ void BytecodeGraphBuilder::UpdateSourcePosition(int offset) {
} }
} }
void BuildGraphFromBytecode( void BuildGraphFromBytecode(JSHeapBroker* broker, Zone* local_zone,
Zone* local_zone, Handle<BytecodeArray> bytecode_array, Handle<BytecodeArray> bytecode_array,
Handle<SharedFunctionInfo> shared, Handle<FeedbackVector> feedback_vector, Handle<SharedFunctionInfo> shared,
BailoutId osr_offset, JSGraph* jsgraph, CallFrequency invocation_frequency, Handle<FeedbackVector> feedback_vector,
SourcePositionTable* source_positions, Handle<Context> native_context, BailoutId osr_offset, JSGraph* jsgraph,
int inlining_id, BytecodeGraphBuilderFlags flags) { CallFrequency invocation_frequency,
BytecodeGraphBuilder builder(local_zone, bytecode_array, shared, SourcePositionTable* source_positions,
Handle<Context> native_context, int inlining_id,
BytecodeGraphBuilderFlags flags) {
BytecodeGraphBuilder builder(broker, local_zone, bytecode_array, shared,
feedback_vector, osr_offset, jsgraph, feedback_vector, osr_offset, jsgraph,
invocation_frequency, source_positions, invocation_frequency, source_positions,
native_context, inlining_id, flags); native_context, inlining_id, flags);
......
...@@ -30,12 +30,15 @@ enum class BytecodeGraphBuilderFlag : uint8_t { ...@@ -30,12 +30,15 @@ enum class BytecodeGraphBuilderFlag : uint8_t {
}; };
using BytecodeGraphBuilderFlags = base::Flags<BytecodeGraphBuilderFlag>; using BytecodeGraphBuilderFlags = base::Flags<BytecodeGraphBuilderFlag>;
void BuildGraphFromBytecode( void BuildGraphFromBytecode(JSHeapBroker* broker, Zone* local_zone,
Zone* local_zone, Handle<BytecodeArray> bytecode_array, Handle<BytecodeArray> bytecode_array,
Handle<SharedFunctionInfo> shared, Handle<FeedbackVector> feedback_vector, Handle<SharedFunctionInfo> shared,
BailoutId osr_offset, JSGraph* jsgraph, CallFrequency invocation_frequency, Handle<FeedbackVector> feedback_vector,
SourcePositionTable* source_positions, Handle<Context> native_context, BailoutId osr_offset, JSGraph* jsgraph,
int inlining_id, BytecodeGraphBuilderFlags flags); CallFrequency invocation_frequency,
SourcePositionTable* source_positions,
Handle<Context> native_context, int inlining_id,
BytecodeGraphBuilderFlags flags);
} // namespace compiler } // namespace compiler
} // namespace internal } // namespace internal
......
...@@ -1277,14 +1277,23 @@ void FixedDoubleArrayData::SerializeContents(JSHeapBroker* broker) { ...@@ -1277,14 +1277,23 @@ void FixedDoubleArrayData::SerializeContents(JSHeapBroker* broker) {
class BytecodeArrayData : public FixedArrayBaseData { class BytecodeArrayData : public FixedArrayBaseData {
public: public:
int register_count() const { return register_count_; } int register_count() const { return register_count_; }
int parameter_count() const { return parameter_count_; }
interpreter::Register incoming_new_target_or_generator_register() const {
return incoming_new_target_or_generator_register_;
}
BytecodeArrayData(JSHeapBroker* broker, ObjectData** storage, BytecodeArrayData(JSHeapBroker* broker, ObjectData** storage,
Handle<BytecodeArray> object) Handle<BytecodeArray> object)
: FixedArrayBaseData(broker, storage, object), : FixedArrayBaseData(broker, storage, object),
register_count_(object->register_count()) {} register_count_(object->register_count()),
parameter_count_(object->parameter_count()),
incoming_new_target_or_generator_register_(
object->incoming_new_target_or_generator_register()) {}
private: private:
int const register_count_; int const register_count_;
int const parameter_count_;
interpreter::Register const incoming_new_target_or_generator_register_;
}; };
class JSArrayData : public JSObjectData { class JSArrayData : public JSObjectData {
...@@ -2575,6 +2584,9 @@ BIMODAL_ACCESSOR_C(AllocationSite, ElementsKind, GetElementsKind) ...@@ -2575,6 +2584,9 @@ BIMODAL_ACCESSOR_C(AllocationSite, ElementsKind, GetElementsKind)
BIMODAL_ACCESSOR_C(AllocationSite, AllocationType, GetAllocationType) BIMODAL_ACCESSOR_C(AllocationSite, AllocationType, GetAllocationType)
BIMODAL_ACCESSOR_C(BytecodeArray, int, register_count) BIMODAL_ACCESSOR_C(BytecodeArray, int, register_count)
BIMODAL_ACCESSOR_C(BytecodeArray, int, parameter_count)
BIMODAL_ACCESSOR_C(BytecodeArray, interpreter::Register,
incoming_new_target_or_generator_register)
BIMODAL_ACCESSOR(Cell, Object, value) BIMODAL_ACCESSOR(Cell, Object, value)
......
...@@ -558,6 +558,8 @@ class BytecodeArrayRef : public FixedArrayBaseRef { ...@@ -558,6 +558,8 @@ class BytecodeArrayRef : public FixedArrayBaseRef {
Handle<BytecodeArray> object() const; Handle<BytecodeArray> object() const;
int register_count() const; int register_count() const;
int parameter_count() const;
interpreter::Register incoming_new_target_or_generator_register() const;
}; };
class JSArrayRef : public JSObjectRef { class JSArrayRef : public JSObjectRef {
......
...@@ -496,10 +496,10 @@ Reduction JSInliner::ReduceJSCall(Node* node) { ...@@ -496,10 +496,10 @@ Reduction JSInliner::ReduceJSCall(Node* node) {
if (info_->is_bailout_on_uninitialized()) { if (info_->is_bailout_on_uninitialized()) {
flags |= BytecodeGraphBuilderFlag::kBailoutOnUninitialized; flags |= BytecodeGraphBuilderFlag::kBailoutOnUninitialized;
} }
BuildGraphFromBytecode(zone(), bytecode_array, shared_info, feedback_vector, BuildGraphFromBytecode(broker(), zone(), bytecode_array, shared_info,
BailoutId::None(), jsgraph(), call.frequency(), feedback_vector, BailoutId::None(), jsgraph(),
source_positions_, native_context(), inlining_id, call.frequency(), source_positions_,
flags); native_context(), inlining_id, flags);
// Extract the inlinee start/end nodes. // Extract the inlinee start/end nodes.
start = graph()->start(); start = graph()->start();
......
...@@ -1072,7 +1072,8 @@ struct GraphBuilderPhase { ...@@ -1072,7 +1072,8 @@ struct GraphBuilderPhase {
flags |= BytecodeGraphBuilderFlag::kBailoutOnUninitialized; flags |= BytecodeGraphBuilderFlag::kBailoutOnUninitialized;
} }
BuildGraphFromBytecode( BuildGraphFromBytecode(
temp_zone, data->info()->bytecode_array(), data->info()->shared_info(), data->broker(), 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(),
......
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