summaryrefslogtreecommitdiff
path: root/deps/v8/src/compiler/pipeline.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/compiler/pipeline.cc')
-rw-r--r--deps/v8/src/compiler/pipeline.cc105
1 files changed, 73 insertions, 32 deletions
diff --git a/deps/v8/src/compiler/pipeline.cc b/deps/v8/src/compiler/pipeline.cc
index 5ec5d085f7..b1d7fda9a3 100644
--- a/deps/v8/src/compiler/pipeline.cc
+++ b/deps/v8/src/compiler/pipeline.cc
@@ -8,7 +8,6 @@
#include <sstream>
#include "src/base/platform/elapsed-timer.h"
-#include "src/bootstrapper.h" // TODO(mstarzinger): Only temporary.
#include "src/compiler/ast-graph-builder.h"
#include "src/compiler/ast-loop-assignment-analyzer.h"
#include "src/compiler/basic-block-instrumentor.h"
@@ -26,6 +25,7 @@
#include "src/compiler/js-generic-lowering.h"
#include "src/compiler/js-inlining.h"
#include "src/compiler/js-intrinsic-lowering.h"
+#include "src/compiler/js-type-feedback.h"
#include "src/compiler/js-typed-lowering.h"
#include "src/compiler/jump-threading.h"
#include "src/compiler/load-elimination.h"
@@ -47,6 +47,7 @@
#include "src/compiler/verifier.h"
#include "src/compiler/zone-pool.h"
#include "src/ostreams.h"
+#include "src/type-info.h"
#include "src/utils.h"
namespace v8 {
@@ -73,6 +74,7 @@ class PipelineData {
common_(nullptr),
javascript_(nullptr),
jsgraph_(nullptr),
+ js_type_feedback_(nullptr),
typer_(nullptr),
schedule_(nullptr),
instruction_zone_scope_(zone_pool_),
@@ -112,6 +114,7 @@ class PipelineData {
common_(nullptr),
javascript_(nullptr),
jsgraph_(nullptr),
+ js_type_feedback_(nullptr),
typer_(nullptr),
schedule_(schedule),
instruction_zone_scope_(zone_pool_),
@@ -138,6 +141,7 @@ class PipelineData {
common_(nullptr),
javascript_(nullptr),
jsgraph_(nullptr),
+ js_type_feedback_(nullptr),
typer_(nullptr),
schedule_(nullptr),
instruction_zone_scope_(zone_pool_),
@@ -175,6 +179,10 @@ class PipelineData {
CommonOperatorBuilder* common() const { return common_; }
JSOperatorBuilder* javascript() const { return javascript_; }
JSGraph* jsgraph() const { return jsgraph_; }
+ JSTypeFeedbackTable* js_type_feedback() { return js_type_feedback_; }
+ void set_js_type_feedback(JSTypeFeedbackTable* js_type_feedback) {
+ js_type_feedback_ = js_type_feedback;
+ }
Typer* typer() const { return typer_.get(); }
LoopAssignmentAnalysis* loop_assignment() const { return loop_assignment_; }
@@ -208,6 +216,7 @@ class PipelineData {
common_ = nullptr;
javascript_ = nullptr;
jsgraph_ = nullptr;
+ js_type_feedback_ = nullptr;
schedule_ = nullptr;
}
@@ -260,6 +269,7 @@ class PipelineData {
CommonOperatorBuilder* common_;
JSOperatorBuilder* javascript_;
JSGraph* jsgraph_;
+ JSTypeFeedbackTable* js_type_feedback_;
// TODO(dcarney): make this into a ZoneObject.
SmartPointer<Typer> typer_;
Schedule* schedule_;
@@ -292,20 +302,17 @@ static void TraceSchedule(Schedule* schedule) {
static SmartArrayPointer<char> GetDebugName(CompilationInfo* info) {
- SmartArrayPointer<char> name;
- if (info->IsStub()) {
- if (info->code_stub() != NULL) {
- CodeStub::Major major_key = info->code_stub()->MajorKey();
- const char* major_name = CodeStub::MajorName(major_key, false);
- size_t len = strlen(major_name);
- name.Reset(new char[len]);
- memcpy(name.get(), major_name, len);
- }
+ if (info->code_stub() != NULL) {
+ CodeStub::Major major_key = info->code_stub()->MajorKey();
+ const char* major_name = CodeStub::MajorName(major_key, false);
+ size_t len = strlen(major_name) + 1;
+ SmartArrayPointer<char> name(new char[len]);
+ memcpy(name.get(), major_name, len);
+ return name;
} else {
AllowHandleDereference allow_deref;
- name = info->function()->debug_name()->ToCString();
+ return info->function()->debug_name()->ToCString();
}
- return name;
}
@@ -314,14 +321,16 @@ class AstGraphBuilderWithPositions : public AstGraphBuilder {
AstGraphBuilderWithPositions(Zone* local_zone, CompilationInfo* info,
JSGraph* jsgraph,
LoopAssignmentAnalysis* loop_assignment,
+ JSTypeFeedbackTable* js_type_feedback,
SourcePositionTable* source_positions)
- : AstGraphBuilder(local_zone, info, jsgraph, loop_assignment),
+ : AstGraphBuilder(local_zone, info, jsgraph, loop_assignment,
+ js_type_feedback),
source_positions_(source_positions),
start_position_(info->shared_info()->start_position()) {}
- bool CreateGraph(bool constant_context) {
+ bool CreateGraph(bool constant_context, bool stack_check) {
SourcePositionTable::Scope pos_scope(source_positions_, start_position_);
- return AstGraphBuilder::CreateGraph(constant_context);
+ return AstGraphBuilder::CreateGraph(constant_context, stack_check);
}
#define DEF_VISIT(type) \
@@ -423,8 +432,9 @@ struct GraphBuilderPhase {
void Run(PipelineData* data, Zone* temp_zone, bool constant_context) {
AstGraphBuilderWithPositions graph_builder(
temp_zone, data->info(), data->jsgraph(), data->loop_assignment(),
- data->source_positions());
- if (!graph_builder.CreateGraph(constant_context)) {
+ data->js_type_feedback(), data->source_positions());
+ bool stack_check = !data->info()->IsStub();
+ if (!graph_builder.CreateGraph(constant_context, stack_check)) {
data->set_compilation_failed();
}
}
@@ -451,7 +461,10 @@ struct InliningPhase {
void Run(PipelineData* data, Zone* temp_zone) {
SourcePositionTable::Scope pos(data->source_positions(),
SourcePosition::Unknown());
- JSInliner inliner(temp_zone, data->info(), data->jsgraph());
+ JSInliner inliner(data->info()->is_inlining_enabled()
+ ? JSInliner::kGeneralInlining
+ : JSInliner::kBuiltinsInlining,
+ temp_zone, data->info(), data->jsgraph());
GraphReducer graph_reducer(data->graph(), temp_zone);
AddReducer(data, &graph_reducer, &inliner);
graph_reducer.ReduceGraph();
@@ -480,21 +493,38 @@ struct OsrDeconstructionPhase {
};
+struct JSTypeFeedbackPhase {
+ static const char* phase_name() { return "type feedback specializing"; }
+
+ void Run(PipelineData* data, Zone* temp_zone) {
+ SourcePositionTable::Scope pos(data->source_positions(),
+ SourcePosition::Unknown());
+ Handle<Context> native_context(data->info()->context()->native_context());
+ TypeFeedbackOracle oracle(data->isolate(), temp_zone,
+ data->info()->unoptimized_code(),
+ data->info()->feedback_vector(), native_context);
+ GraphReducer graph_reducer(data->graph(), temp_zone);
+ JSTypeFeedbackSpecializer specializer(data->jsgraph(),
+ data->js_type_feedback(), &oracle);
+ AddReducer(data, &graph_reducer, &specializer);
+ graph_reducer.ReduceGraph();
+ }
+};
+
+
struct TypedLoweringPhase {
static const char* phase_name() { return "typed lowering"; }
void Run(PipelineData* data, Zone* temp_zone) {
SourcePositionTable::Scope pos(data->source_positions(),
SourcePosition::Unknown());
- ValueNumberingReducer vn_reducer(temp_zone);
LoadElimination load_elimination;
JSBuiltinReducer builtin_reducer(data->jsgraph());
JSTypedLowering typed_lowering(data->jsgraph(), temp_zone);
JSIntrinsicLowering intrinsic_lowering(data->jsgraph());
SimplifiedOperatorReducer simple_reducer(data->jsgraph());
- CommonOperatorReducer common_reducer;
+ CommonOperatorReducer common_reducer(data->jsgraph());
GraphReducer graph_reducer(data->graph(), temp_zone);
- AddReducer(data, &graph_reducer, &vn_reducer);
AddReducer(data, &graph_reducer, &builtin_reducer);
AddReducer(data, &graph_reducer, &typed_lowering);
AddReducer(data, &graph_reducer, &intrinsic_lowering);
@@ -518,7 +548,7 @@ struct SimplifiedLoweringPhase {
ValueNumberingReducer vn_reducer(temp_zone);
SimplifiedOperatorReducer simple_reducer(data->jsgraph());
MachineOperatorReducer machine_reducer(data->jsgraph());
- CommonOperatorReducer common_reducer;
+ CommonOperatorReducer common_reducer(data->jsgraph());
GraphReducer graph_reducer(data->graph(), temp_zone);
AddReducer(data, &graph_reducer, &vn_reducer);
AddReducer(data, &graph_reducer, &simple_reducer);
@@ -533,6 +563,8 @@ struct ControlFlowOptimizationPhase {
static const char* phase_name() { return "control flow optimization"; }
void Run(PipelineData* data, Zone* temp_zone) {
+ SourcePositionTable::Scope pos(data->source_positions(),
+ SourcePosition::Unknown());
ControlFlowOptimizer optimizer(data->jsgraph(), temp_zone);
optimizer.Optimize();
}
@@ -549,7 +581,7 @@ struct ChangeLoweringPhase {
SimplifiedOperatorReducer simple_reducer(data->jsgraph());
ChangeLowering lowering(data->jsgraph());
MachineOperatorReducer machine_reducer(data->jsgraph());
- CommonOperatorReducer common_reducer;
+ CommonOperatorReducer common_reducer(data->jsgraph());
GraphReducer graph_reducer(data->graph(), temp_zone);
AddReducer(data, &graph_reducer, &vn_reducer);
AddReducer(data, &graph_reducer, &simple_reducer);
@@ -744,7 +776,7 @@ struct JumpThreadingPhase {
static const char* phase_name() { return "jump threading"; }
void Run(PipelineData* data, Zone* temp_zone) {
- ZoneVector<BasicBlock::RpoNumber> result(temp_zone);
+ ZoneVector<RpoNumber> result(temp_zone);
if (JumpThreading::ComputeForwarding(temp_zone, result, data->sequence())) {
JumpThreading::ApplyForwarding(result, data->sequence());
}
@@ -835,11 +867,10 @@ Handle<Code> Pipeline::GenerateCode() {
// the correct solution is to restore the context register after invoking
// builtins from full-codegen.
Handle<SharedFunctionInfo> shared = info()->shared_info();
- if (isolate()->bootstrapper()->IsActive() ||
- shared->disable_optimization_reason() ==
- kBuiltinFunctionCannotBeOptimized) {
- shared->DisableOptimization(kBuiltinFunctionCannotBeOptimized);
- return Handle<Code>::null();
+ for (int i = 0; i < Builtins::NumberOfJavaScriptBuiltins(); i++) {
+ Builtins::JavaScript id = static_cast<Builtins::JavaScript>(i);
+ Object* builtin = isolate()->js_builtins_object()->javascript_builtin(id);
+ if (*info()->closure() == builtin) return Handle<Code>::null();
}
// TODO(dslomov): support turbo optimization of subclass constructors.
@@ -885,6 +916,11 @@ Handle<Code> Pipeline::GenerateCode() {
PipelineData data(&zone_pool, info(), pipeline_statistics.get());
this->data_ = &data;
+ if (info()->is_type_feedback_enabled()) {
+ data.set_js_type_feedback(new (data.graph_zone())
+ JSTypeFeedbackTable(data.graph_zone()));
+ }
+
BeginPhaseKind("graph creation");
if (FLAG_trace_turbo) {
@@ -915,7 +951,7 @@ Handle<Code> Pipeline::GenerateCode() {
RunPrintAndVerify("Context specialized", true);
}
- if (info()->is_inlining_enabled()) {
+ if (info()->is_builtin_inlining_enabled() || info()->is_inlining_enabled()) {
Run<InliningPhase>();
RunPrintAndVerify("Inlined", true);
}
@@ -952,19 +988,24 @@ Handle<Code> Pipeline::GenerateCode() {
RunPrintAndVerify("OSR deconstruction");
}
+ if (info()->is_type_feedback_enabled()) {
+ Run<JSTypeFeedbackPhase>();
+ RunPrintAndVerify("JSType feedback");
+ }
+
// Lower simplified operators and insert changes.
Run<SimplifiedLoweringPhase>();
RunPrintAndVerify("Lowered simplified");
// Optimize control flow.
- if (FLAG_turbo_switch) {
+ if (FLAG_turbo_cf_optimization) {
Run<ControlFlowOptimizationPhase>();
RunPrintAndVerify("Control flow optimized");
}
// Lower changes that have been inserted before.
Run<ChangeLoweringPhase>();
- // // TODO(jarin, rossberg): Remove UNTYPED once machine typing works.
+ // TODO(jarin, rossberg): Remove UNTYPED once machine typing works.
RunPrintAndVerify("Lowered changes", true);
Run<LateControlReductionPhase>();