Commit 90cdb053 authored by Maya Lekova's avatar Maya Lekova Committed by Commit Bot

[turbofan] Brokerize JSGenericLowering

Bug: v8:7790
Change-Id: I42ef762bdc9340d4cb8f03186c1961eddf35e46b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1762516
Commit-Queue: Maya Lekova <mslekova@chromium.org>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63320}
parent 37d2c940
...@@ -9,10 +9,12 @@ ...@@ -9,10 +9,12 @@
#include "src/codegen/code-factory.h" #include "src/codegen/code-factory.h"
#include "src/compiler/common-operator.h" #include "src/compiler/common-operator.h"
#include "src/compiler/js-graph.h" #include "src/compiler/js-graph.h"
#include "src/compiler/js-heap-broker.h"
#include "src/compiler/machine-operator.h" #include "src/compiler/machine-operator.h"
#include "src/compiler/node-matchers.h" #include "src/compiler/node-matchers.h"
#include "src/compiler/node-properties.h" #include "src/compiler/node-properties.h"
#include "src/compiler/operator-properties.h" #include "src/compiler/operator-properties.h"
#include "src/compiler/processed-feedback.h"
#include "src/objects/feedback-cell.h" #include "src/objects/feedback-cell.h"
#include "src/objects/feedback-vector.h" #include "src/objects/feedback-vector.h"
#include "src/objects/scope-info.h" #include "src/objects/scope-info.h"
...@@ -31,8 +33,9 @@ CallDescriptor::Flags FrameStateFlagForCall(Node* node) { ...@@ -31,8 +33,9 @@ CallDescriptor::Flags FrameStateFlagForCall(Node* node) {
} // namespace } // namespace
JSGenericLowering::JSGenericLowering(JSGraph* jsgraph, Editor* editor) JSGenericLowering::JSGenericLowering(JSGraph* jsgraph, Editor* editor,
: AdvancedReducer(editor), jsgraph_(jsgraph) {} JSHeapBroker* broker)
: AdvancedReducer(editor), jsgraph_(jsgraph), broker_(broker) {}
JSGenericLowering::~JSGenericLowering() = default; JSGenericLowering::~JSGenericLowering() = default;
...@@ -144,6 +147,26 @@ void JSGenericLowering::LowerJSStrictEqual(Node* node) { ...@@ -144,6 +147,26 @@ void JSGenericLowering::LowerJSStrictEqual(Node* node) {
Operator::kEliminatable); Operator::kEliminatable);
} }
namespace {
bool ShouldUseMegamorphicLoadBuiltin(VectorSlotPair const& vector_slot_pair,
JSHeapBroker* broker) {
if (!FLAG_concurrent_inlining) {
return vector_slot_pair.ic_state() == MEGAMORPHIC;
}
ProcessedFeedback const& feedback =
broker->GetFeedback(FeedbackSource(vector_slot_pair));
if (feedback.kind() == ProcessedFeedback::kElementAccess) {
return !feedback.AsElementAccess().transition_groups().empty();
} else if (feedback.kind() == ProcessedFeedback::kNamedAccess) {
return !feedback.AsNamedAccess().maps().empty();
} else if (feedback.kind() == ProcessedFeedback::kInsufficient) {
return false;
}
UNREACHABLE();
}
} // namespace
void JSGenericLowering::LowerJSLoadProperty(Node* node) { void JSGenericLowering::LowerJSLoadProperty(Node* node) {
CallDescriptor::Flags flags = FrameStateFlagForCall(node); CallDescriptor::Flags flags = FrameStateFlagForCall(node);
const PropertyAccess& p = PropertyAccessOf(node->op()); const PropertyAccess& p = PropertyAccessOf(node->op());
...@@ -152,13 +175,13 @@ void JSGenericLowering::LowerJSLoadProperty(Node* node) { ...@@ -152,13 +175,13 @@ void JSGenericLowering::LowerJSLoadProperty(Node* node) {
node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index())); node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index()));
if (outer_state->opcode() != IrOpcode::kFrameState) { if (outer_state->opcode() != IrOpcode::kFrameState) {
Callable callable = Builtins::CallableFor( Callable callable = Builtins::CallableFor(
isolate(), p.feedback().ic_state() == MEGAMORPHIC isolate(), ShouldUseMegamorphicLoadBuiltin(p.feedback(), broker())
? Builtins::kKeyedLoadICTrampoline_Megamorphic ? Builtins::kKeyedLoadICTrampoline_Megamorphic
: Builtins::kKeyedLoadICTrampoline); : Builtins::kKeyedLoadICTrampoline);
ReplaceWithStubCall(node, callable, flags); ReplaceWithStubCall(node, callable, flags);
} else { } else {
Callable callable = Builtins::CallableFor( Callable callable = Builtins::CallableFor(
isolate(), p.feedback().ic_state() == MEGAMORPHIC isolate(), ShouldUseMegamorphicLoadBuiltin(p.feedback(), broker())
? Builtins::kKeyedLoadIC_Megamorphic ? Builtins::kKeyedLoadIC_Megamorphic
: Builtins::kKeyedLoadIC); : Builtins::kKeyedLoadIC);
Node* vector = jsgraph()->HeapConstant(p.feedback().vector()); Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
...@@ -182,13 +205,13 @@ void JSGenericLowering::LowerJSLoadNamed(Node* node) { ...@@ -182,13 +205,13 @@ void JSGenericLowering::LowerJSLoadNamed(Node* node) {
node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index())); node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index()));
if (outer_state->opcode() != IrOpcode::kFrameState) { if (outer_state->opcode() != IrOpcode::kFrameState) {
Callable callable = Builtins::CallableFor( Callable callable = Builtins::CallableFor(
isolate(), p.feedback().ic_state() == MEGAMORPHIC isolate(), ShouldUseMegamorphicLoadBuiltin(p.feedback(), broker())
? Builtins::kLoadICTrampoline_Megamorphic ? Builtins::kLoadICTrampoline_Megamorphic
: Builtins::kLoadICTrampoline); : Builtins::kLoadICTrampoline);
ReplaceWithStubCall(node, callable, flags); ReplaceWithStubCall(node, callable, flags);
} else { } else {
Callable callable = Callable callable = Builtins::CallableFor(
Builtins::CallableFor(isolate(), p.feedback().ic_state() == MEGAMORPHIC isolate(), ShouldUseMegamorphicLoadBuiltin(p.feedback(), broker())
? Builtins::kLoadIC_Megamorphic ? Builtins::kLoadIC_Megamorphic
: Builtins::kLoadIC); : Builtins::kLoadIC);
Node* vector = jsgraph()->HeapConstant(p.feedback().vector()); Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
......
...@@ -23,7 +23,7 @@ class Linkage; ...@@ -23,7 +23,7 @@ class Linkage;
// Lowers JS-level operators to runtime and IC calls in the "generic" case. // Lowers JS-level operators to runtime and IC calls in the "generic" case.
class JSGenericLowering final : public AdvancedReducer { class JSGenericLowering final : public AdvancedReducer {
public: public:
JSGenericLowering(JSGraph* jsgraph, Editor* editor); JSGenericLowering(JSGraph* jsgraph, Editor* editor, JSHeapBroker* broker);
~JSGenericLowering() final; ~JSGenericLowering() final;
const char* reducer_name() const override { return "JSGenericLowering"; } const char* reducer_name() const override { return "JSGenericLowering"; }
...@@ -48,9 +48,11 @@ class JSGenericLowering final : public AdvancedReducer { ...@@ -48,9 +48,11 @@ class JSGenericLowering final : public AdvancedReducer {
Graph* graph() const; Graph* graph() const;
CommonOperatorBuilder* common() const; CommonOperatorBuilder* common() const;
MachineOperatorBuilder* machine() const; MachineOperatorBuilder* machine() const;
JSHeapBroker* broker() const { return broker_; }
private: private:
JSGraph* const jsgraph_; JSGraph* const jsgraph_;
JSHeapBroker* const broker_;
}; };
} // namespace compiler } // namespace compiler
......
...@@ -1497,7 +1497,8 @@ struct GenericLoweringPhase { ...@@ -1497,7 +1497,8 @@ struct GenericLoweringPhase {
GraphReducer graph_reducer(temp_zone, data->graph(), GraphReducer graph_reducer(temp_zone, data->graph(),
&data->info()->tick_counter(), &data->info()->tick_counter(),
data->jsgraph()->Dead()); data->jsgraph()->Dead());
JSGenericLowering generic_lowering(data->jsgraph(), &graph_reducer); JSGenericLowering generic_lowering(data->jsgraph(), &graph_reducer,
data->broker());
AddReducer(data, &graph_reducer, &generic_lowering); AddReducer(data, &graph_reducer, &generic_lowering);
graph_reducer.ReduceGraph(); graph_reducer.ReduceGraph();
} }
......
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