Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Unified Diff: src/compiler/js-inlining.cc

Issue 1135483004: [turbofan] Add AdvancedReducer::ReplaceWithValue() method and convert JSInlining to an AdvancedRedu… (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/js-inlining.h ('k') | src/compiler/pipeline.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/js-inlining.cc
diff --git a/src/compiler/js-inlining.cc b/src/compiler/js-inlining.cc
index 6d8824fbea52ecc4c1e508bb8a55199d839ab3cd..af47cb81a4dfdab00201e6d1eca3b47a3c70c1ab 100644
--- a/src/compiler/js-inlining.cc
+++ b/src/compiler/js-inlining.cc
@@ -59,13 +59,10 @@ class JSCallFunctionAccessor {
};
-namespace {
-
// A facade on a JSFunction's graph to facilitate inlining. It assumes
// that the function graph has only one return statement, and provides
// {UnifyReturn} to convert a function graph to that end.
-class Inlinee {
- public:
+struct Inlinee {
Inlinee(Node* start, Node* end) : start_(start), end_(end) {}
// Returns the last regular control node, that is
@@ -103,14 +100,9 @@ class Inlinee {
return total_parameters() - 3;
}
- // Inline this graph at {call}, use {jsgraph} and its zone to create
- // any new nodes.
- Reduction InlineAtCall(JSGraph* jsgraph, Node* call);
-
// Ensure that only a single return reaches the end node.
static void UnifyReturn(JSGraph* jsgraph);
- private:
Node* start_;
Node* end_;
};
@@ -218,7 +210,7 @@ class CopyVisitor {
};
-Reduction Inlinee::InlineAtCall(JSGraph* jsgraph, Node* call) {
+Reduction JSInliner::InlineCall(Node* call, Inlinee& inlinee) {
// The scheduler is smart enough to place our code; we just ensure {control}
// becomes the control input of the start of the inlinee, and {effect} becomes
// the effect input of the start of the inlinee.
@@ -226,12 +218,12 @@ Reduction Inlinee::InlineAtCall(JSGraph* jsgraph, Node* call) {
Node* effect = NodeProperties::GetEffectInput(call);
// Context is last argument.
- int inlinee_context_index = static_cast<int>(total_parameters()) - 1;
+ int inlinee_context_index = static_cast<int>(inlinee.total_parameters()) - 1;
// {inliner_inputs} counts JSFunction, Receiver, arguments, but not
// context, effect, control.
int inliner_inputs = call->op()->ValueInputCount();
// Iterate over all uses of the start node.
- for (Edge edge : start_->use_edges()) {
+ for (Edge edge : inlinee.start_->use_edges()) {
Node* use = edge.from();
switch (use->opcode()) {
case IrOpcode::kParameter: {
@@ -239,14 +231,14 @@ Reduction Inlinee::InlineAtCall(JSGraph* jsgraph, Node* call) {
if (index < inliner_inputs && index < inlinee_context_index) {
// There is an input from the call, and the index is a value
// projection but not the context, so rewire the input.
- NodeProperties::ReplaceWithValue(use, call->InputAt(index));
+ ReplaceWithValue(use, call->InputAt(index));
} else if (index == inlinee_context_index) {
// TODO(turbofan): We always context specialize inlinees currently, so
// we should never get here.
UNREACHABLE();
} else if (index < inlinee_context_index) {
// Call has fewer arguments than required, fill with undefined.
- NodeProperties::ReplaceWithValue(use, jsgraph->UndefinedConstant());
+ ReplaceWithValue(use, jsgraph_->UndefinedConstant());
} else {
// We got too many arguments, discard for now.
// TODO(sigurds): Fix to treat arguments array correctly.
@@ -265,14 +257,12 @@ Reduction Inlinee::InlineAtCall(JSGraph* jsgraph, Node* call) {
}
}
- NodeProperties::ReplaceWithValue(call, value_output(), effect_output(),
- control_output());
+ ReplaceWithValue(call, inlinee.value_output(), inlinee.effect_output(),
+ inlinee.control_output());
- return Reducer::Replace(value_output());
+ return Replace(inlinee.value_output());
}
-} // namespace
-
void JSInliner::AddClosureToFrameState(Node* frame_state,
Handle<JSFunction> jsfunction) {
@@ -381,7 +371,7 @@ Reduction JSInliner::Reduce(Node* node) {
}
}
- return inlinee.InlineAtCall(jsgraph_, node);
+ return InlineCall(node, inlinee);
}
} // namespace compiler
« no previous file with comments | « src/compiler/js-inlining.h ('k') | src/compiler/pipeline.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698