[turbofan] Specialize to closure with function context specialization.
R=jarin@chromium.org BUG=v8:5267,v8:6181 Review-Url: https://codereview.chromium.org/2792553002 Cr-Commit-Position: refs/heads/master@{#44305}
This commit is contained in:
parent
143dcc6c41
commit
04f48a76c8
@ -7,6 +7,7 @@
|
|||||||
#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-operator.h"
|
#include "src/compiler/js-operator.h"
|
||||||
|
#include "src/compiler/linkage.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/contexts.h"
|
#include "src/contexts.h"
|
||||||
@ -18,6 +19,8 @@ namespace compiler {
|
|||||||
|
|
||||||
Reduction JSContextSpecialization::Reduce(Node* node) {
|
Reduction JSContextSpecialization::Reduce(Node* node) {
|
||||||
switch (node->opcode()) {
|
switch (node->opcode()) {
|
||||||
|
case IrOpcode::kParameter:
|
||||||
|
return ReduceParameter(node);
|
||||||
case IrOpcode::kJSLoadContext:
|
case IrOpcode::kJSLoadContext:
|
||||||
return ReduceJSLoadContext(node);
|
return ReduceJSLoadContext(node);
|
||||||
case IrOpcode::kJSStoreContext:
|
case IrOpcode::kJSStoreContext:
|
||||||
@ -28,6 +31,20 @@ Reduction JSContextSpecialization::Reduce(Node* node) {
|
|||||||
return NoChange();
|
return NoChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reduction JSContextSpecialization::ReduceParameter(Node* node) {
|
||||||
|
DCHECK_EQ(IrOpcode::kParameter, node->opcode());
|
||||||
|
int const index = ParameterIndexOf(node->op());
|
||||||
|
if (index == Linkage::kJSCallClosureParamIndex) {
|
||||||
|
// Constant-fold the function parameter {node}.
|
||||||
|
Handle<JSFunction> function;
|
||||||
|
if (closure().ToHandle(&function)) {
|
||||||
|
Node* value = jsgraph()->HeapConstant(function);
|
||||||
|
return Replace(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NoChange();
|
||||||
|
}
|
||||||
|
|
||||||
Reduction JSContextSpecialization::SimplifyJSLoadContext(Node* node,
|
Reduction JSContextSpecialization::SimplifyJSLoadContext(Node* node,
|
||||||
Node* new_context,
|
Node* new_context,
|
||||||
size_t new_depth) {
|
size_t new_depth) {
|
||||||
|
@ -21,12 +21,17 @@ class JSOperatorBuilder;
|
|||||||
class JSContextSpecialization final : public AdvancedReducer {
|
class JSContextSpecialization final : public AdvancedReducer {
|
||||||
public:
|
public:
|
||||||
JSContextSpecialization(Editor* editor, JSGraph* jsgraph,
|
JSContextSpecialization(Editor* editor, JSGraph* jsgraph,
|
||||||
MaybeHandle<Context> context)
|
MaybeHandle<Context> context,
|
||||||
: AdvancedReducer(editor), jsgraph_(jsgraph), context_(context) {}
|
MaybeHandle<JSFunction> closure)
|
||||||
|
: AdvancedReducer(editor),
|
||||||
|
jsgraph_(jsgraph),
|
||||||
|
context_(context),
|
||||||
|
closure_(closure) {}
|
||||||
|
|
||||||
Reduction Reduce(Node* node) final;
|
Reduction Reduce(Node* node) final;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Reduction ReduceParameter(Node* node);
|
||||||
Reduction ReduceJSLoadContext(Node* node);
|
Reduction ReduceJSLoadContext(Node* node);
|
||||||
Reduction ReduceJSStoreContext(Node* node);
|
Reduction ReduceJSStoreContext(Node* node);
|
||||||
|
|
||||||
@ -39,9 +44,11 @@ class JSContextSpecialization final : public AdvancedReducer {
|
|||||||
JSOperatorBuilder* javascript() const;
|
JSOperatorBuilder* javascript() const;
|
||||||
JSGraph* jsgraph() const { return jsgraph_; }
|
JSGraph* jsgraph() const { return jsgraph_; }
|
||||||
MaybeHandle<Context> context() const { return context_; }
|
MaybeHandle<Context> context() const { return context_; }
|
||||||
|
MaybeHandle<JSFunction> closure() const { return closure_; }
|
||||||
|
|
||||||
JSGraph* const jsgraph_;
|
JSGraph* const jsgraph_;
|
||||||
MaybeHandle<Context> context_;
|
MaybeHandle<Context> context_;
|
||||||
|
MaybeHandle<JSFunction> closure_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(JSContextSpecialization);
|
DISALLOW_COPY_AND_ASSIGN(JSContextSpecialization);
|
||||||
};
|
};
|
||||||
|
@ -799,7 +799,10 @@ struct InliningPhase {
|
|||||||
&graph_reducer, data->jsgraph(),
|
&graph_reducer, data->jsgraph(),
|
||||||
data->info()->is_function_context_specializing()
|
data->info()->is_function_context_specializing()
|
||||||
? handle(data->info()->context())
|
? handle(data->info()->context())
|
||||||
: MaybeHandle<Context>());
|
: MaybeHandle<Context>(),
|
||||||
|
data->info()->is_function_context_specializing()
|
||||||
|
? data->info()->closure()
|
||||||
|
: MaybeHandle<JSFunction>());
|
||||||
JSFrameSpecialization frame_specialization(
|
JSFrameSpecialization frame_specialization(
|
||||||
&graph_reducer, data->info()->osr_frame(), data->jsgraph());
|
&graph_reducer, data->info()->osr_frame(), data->jsgraph());
|
||||||
JSNativeContextSpecialization::Flags flags =
|
JSNativeContextSpecialization::Flags flags =
|
||||||
|
@ -30,7 +30,7 @@ class ContextSpecializationTester : public HandleAndZoneScope {
|
|||||||
jsgraph_(main_isolate(), graph(), common(), &javascript_, &simplified_,
|
jsgraph_(main_isolate(), graph(), common(), &javascript_, &simplified_,
|
||||||
&machine_),
|
&machine_),
|
||||||
reducer_(main_zone(), graph()),
|
reducer_(main_zone(), graph()),
|
||||||
spec_(&reducer_, jsgraph(), context) {}
|
spec_(&reducer_, jsgraph(), context, MaybeHandle<JSFunction>()) {}
|
||||||
|
|
||||||
JSContextSpecialization* spec() { return &spec_; }
|
JSContextSpecialization* spec() { return &spec_; }
|
||||||
Factory* factory() { return main_isolate()->factory(); }
|
Factory* factory() { return main_isolate()->factory(); }
|
||||||
|
Loading…
Reference in New Issue
Block a user