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 @@
#include "src/codegen/code-factory.h"
#include "src/compiler/common-operator.h"
#include "src/compiler/js-graph.h"
#include "src/compiler/js-heap-broker.h"
#include "src/compiler/machine-operator.h"
#include "src/compiler/node-matchers.h"
#include "src/compiler/node-properties.h"
#include "src/compiler/operator-properties.h"
#include "src/compiler/processed-feedback.h"
#include "src/objects/feedback-cell.h"
#include "src/objects/feedback-vector.h"
#include "src/objects/scope-info.h"
......@@ -31,8 +33,9 @@ CallDescriptor::Flags FrameStateFlagForCall(Node* node) {
} // namespace
JSGenericLowering::JSGenericLowering(JSGraph* jsgraph, Editor* editor)
: AdvancedReducer(editor), jsgraph_(jsgraph) {}
JSGenericLowering::JSGenericLowering(JSGraph* jsgraph, Editor* editor,
JSHeapBroker* broker)
: AdvancedReducer(editor), jsgraph_(jsgraph), broker_(broker) {}
JSGenericLowering::~JSGenericLowering() = default;
......@@ -144,6 +147,26 @@ void JSGenericLowering::LowerJSStrictEqual(Node* node) {
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) {
CallDescriptor::Flags flags = FrameStateFlagForCall(node);
const PropertyAccess& p = PropertyAccessOf(node->op());
......@@ -152,13 +175,13 @@ void JSGenericLowering::LowerJSLoadProperty(Node* node) {
node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index()));
if (outer_state->opcode() != IrOpcode::kFrameState) {
Callable callable = Builtins::CallableFor(
isolate(), p.feedback().ic_state() == MEGAMORPHIC
isolate(), ShouldUseMegamorphicLoadBuiltin(p.feedback(), broker())
? Builtins::kKeyedLoadICTrampoline_Megamorphic
: Builtins::kKeyedLoadICTrampoline);
ReplaceWithStubCall(node, callable, flags);
} else {
Callable callable = Builtins::CallableFor(
isolate(), p.feedback().ic_state() == MEGAMORPHIC
isolate(), ShouldUseMegamorphicLoadBuiltin(p.feedback(), broker())
? Builtins::kKeyedLoadIC_Megamorphic
: Builtins::kKeyedLoadIC);
Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
......@@ -182,15 +205,15 @@ void JSGenericLowering::LowerJSLoadNamed(Node* node) {
node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index()));
if (outer_state->opcode() != IrOpcode::kFrameState) {
Callable callable = Builtins::CallableFor(
isolate(), p.feedback().ic_state() == MEGAMORPHIC
isolate(), ShouldUseMegamorphicLoadBuiltin(p.feedback(), broker())
? Builtins::kLoadICTrampoline_Megamorphic
: Builtins::kLoadICTrampoline);
ReplaceWithStubCall(node, callable, flags);
} else {
Callable callable =
Builtins::CallableFor(isolate(), p.feedback().ic_state() == MEGAMORPHIC
? Builtins::kLoadIC_Megamorphic
: Builtins::kLoadIC);
Callable callable = Builtins::CallableFor(
isolate(), ShouldUseMegamorphicLoadBuiltin(p.feedback(), broker())
? Builtins::kLoadIC_Megamorphic
: Builtins::kLoadIC);
Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
node->InsertInput(zone(), 3, vector);
ReplaceWithStubCall(node, callable, flags);
......
......@@ -23,7 +23,7 @@ class Linkage;
// Lowers JS-level operators to runtime and IC calls in the "generic" case.
class JSGenericLowering final : public AdvancedReducer {
public:
JSGenericLowering(JSGraph* jsgraph, Editor* editor);
JSGenericLowering(JSGraph* jsgraph, Editor* editor, JSHeapBroker* broker);
~JSGenericLowering() final;
const char* reducer_name() const override { return "JSGenericLowering"; }
......@@ -48,9 +48,11 @@ class JSGenericLowering final : public AdvancedReducer {
Graph* graph() const;
CommonOperatorBuilder* common() const;
MachineOperatorBuilder* machine() const;
JSHeapBroker* broker() const { return broker_; }
private:
JSGraph* const jsgraph_;
JSHeapBroker* const broker_;
};
} // namespace compiler
......
......@@ -1497,7 +1497,8 @@ struct GenericLoweringPhase {
GraphReducer graph_reducer(temp_zone, data->graph(),
&data->info()->tick_counter(),
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);
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