Merge V8 5.3.332.45. DO NOT MERGE
Test: Manual
FPIIM-449
Change-Id: Id3254828b068abdea3cb10442e0172a8c9a98e03
(cherry picked from commit 13e2dadd00298019ed862f2b2fc5068bba730bcf)
diff --git a/src/compiler/pipeline.cc b/src/compiler/pipeline.cc
index 82583e9..d592000 100644
--- a/src/compiler/pipeline.cc
+++ b/src/compiler/pipeline.cc
@@ -14,6 +14,7 @@
#include "src/compiler/basic-block-instrumentor.h"
#include "src/compiler/branch-elimination.h"
#include "src/compiler/bytecode-graph-builder.h"
+#include "src/compiler/checkpoint-elimination.h"
#include "src/compiler/code-generator.h"
#include "src/compiler/common-operator-reducer.h"
#include "src/compiler/control-flow-optimizer.h"
@@ -25,7 +26,6 @@
#include "src/compiler/graph-replay.h"
#include "src/compiler/graph-trimmer.h"
#include "src/compiler/graph-visualizer.h"
-#include "src/compiler/greedy-allocator.h"
#include "src/compiler/instruction-selector.h"
#include "src/compiler/instruction.h"
#include "src/compiler/js-builtin-reducer.h"
@@ -49,6 +49,7 @@
#include "src/compiler/move-optimizer.h"
#include "src/compiler/osr.h"
#include "src/compiler/pipeline-statistics.h"
+#include "src/compiler/redundancy-elimination.h"
#include "src/compiler/register-allocator-verifier.h"
#include "src/compiler/register-allocator.h"
#include "src/compiler/schedule.h"
@@ -57,6 +58,7 @@
#include "src/compiler/simplified-lowering.h"
#include "src/compiler/simplified-operator-reducer.h"
#include "src/compiler/simplified-operator.h"
+#include "src/compiler/store-store-elimination.h"
#include "src/compiler/tail-call-optimization.h"
#include "src/compiler/type-hint-analyzer.h"
#include "src/compiler/typer.h"
@@ -521,7 +523,7 @@
ZonePool* zone_pool) {
PipelineStatistics* pipeline_statistics = nullptr;
- if (FLAG_turbo_stats) {
+ if (FLAG_turbo_stats || FLAG_turbo_stats_nvp) {
pipeline_statistics = new PipelineStatistics(info, zone_pool);
pipeline_statistics->BeginPhaseKind("initializing");
}
@@ -533,7 +535,9 @@
int pos = info->shared_info()->start_position();
json_of << "{\"function\":\"" << function_name.get()
<< "\", \"sourcePosition\":" << pos << ", \"source\":\"";
- if (!script->IsUndefined() && !script->source()->IsUndefined()) {
+ Isolate* isolate = info->isolate();
+ if (!script->IsUndefined(isolate) &&
+ !script->source()->IsUndefined(isolate)) {
DisallowHeapAllocation no_allocation;
int start = info->shared_info()->start_position();
int len = info->shared_info()->end_position() - start;
@@ -597,6 +601,9 @@
info()->MarkAsDeoptimizationEnabled();
}
if (!info()->is_optimizing_from_bytecode()) {
+ if (info()->is_deoptimization_enabled() && FLAG_turbo_type_feedback) {
+ info()->MarkAsTypeFeedbackEnabled();
+ }
if (!Compiler::EnsureDeoptimizationSupport(info())) return FAILED;
}
@@ -718,7 +725,7 @@
static const char* phase_name() { return "type hint analysis"; }
void Run(PipelineData* data, Zone* temp_zone) {
- if (!data->info()->is_optimizing_from_bytecode()) {
+ if (data->info()->is_type_feedback_enabled()) {
TypeHintAnalyzer analyzer(data->graph_zone());
Handle<Code> code(data->info()->shared_info()->code(), data->isolate());
TypeHintAnalysis* type_hint_analysis = analyzer.Analyze(code);
@@ -804,7 +811,9 @@
AddReducer(data, &graph_reducer, &native_context_specialization);
AddReducer(data, &graph_reducer, &context_specialization);
AddReducer(data, &graph_reducer, &call_reducer);
- AddReducer(data, &graph_reducer, &inlining);
+ if (!data->info()->is_optimizing_from_bytecode()) {
+ AddReducer(data, &graph_reducer, &inlining);
+ }
graph_reducer.ReduceGraph();
}
};
@@ -880,6 +889,9 @@
if (data->info()->shared_info()->HasBytecodeArray()) {
typed_lowering_flags |= JSTypedLowering::kDisableBinaryOpReduction;
}
+ if (data->info()->is_type_feedback_enabled()) {
+ typed_lowering_flags |= JSTypedLowering::kTypeFeedbackEnabled;
+ }
JSTypedLowering typed_lowering(&graph_reducer, data->info()->dependencies(),
typed_lowering_flags, data->jsgraph(),
temp_zone);
@@ -888,7 +900,8 @@
data->info()->is_deoptimization_enabled()
? JSIntrinsicLowering::kDeoptimizationEnabled
: JSIntrinsicLowering::kDeoptimizationDisabled);
- SimplifiedOperatorReducer simple_reducer(data->jsgraph());
+ SimplifiedOperatorReducer simple_reducer(&graph_reducer, data->jsgraph());
+ CheckpointElimination checkpoint_elimination(&graph_reducer);
CommonOperatorReducer common_reducer(&graph_reducer, data->graph(),
data->common(), data->machine());
AddReducer(data, &graph_reducer, &dead_code_elimination);
@@ -900,6 +913,7 @@
AddReducer(data, &graph_reducer, &intrinsic_lowering);
AddReducer(data, &graph_reducer, &load_elimination);
AddReducer(data, &graph_reducer, &simple_reducer);
+ AddReducer(data, &graph_reducer, &checkpoint_elimination);
AddReducer(data, &graph_reducer, &common_reducer);
graph_reducer.ReduceGraph();
}
@@ -942,8 +956,12 @@
static const char* phase_name() { return "representation selection"; }
void Run(PipelineData* data, Zone* temp_zone) {
+ SimplifiedLowering::Flags flags =
+ data->info()->is_type_feedback_enabled()
+ ? SimplifiedLowering::kTypeFeedbackEnabled
+ : SimplifiedLowering::kNoFlag;
SimplifiedLowering lowering(data->jsgraph(), temp_zone,
- data->source_positions());
+ data->source_positions(), flags);
lowering.LowerAllNodes();
}
};
@@ -956,13 +974,15 @@
JSGenericLowering generic_lowering(data->jsgraph());
DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(),
data->common());
- SimplifiedOperatorReducer simple_reducer(data->jsgraph());
+ SimplifiedOperatorReducer simple_reducer(&graph_reducer, data->jsgraph());
+ RedundancyElimination redundancy_elimination(&graph_reducer, temp_zone);
ValueNumberingReducer value_numbering(temp_zone);
MachineOperatorReducer machine_reducer(data->jsgraph());
CommonOperatorReducer common_reducer(&graph_reducer, data->graph(),
data->common(), data->machine());
AddReducer(data, &graph_reducer, &dead_code_elimination);
AddReducer(data, &graph_reducer, &simple_reducer);
+ AddReducer(data, &graph_reducer, &redundancy_elimination);
AddReducer(data, &graph_reducer, &generic_lowering);
AddReducer(data, &graph_reducer, &value_numbering);
AddReducer(data, &graph_reducer, &machine_reducer);
@@ -1012,10 +1032,26 @@
}
};
+struct StoreStoreEliminationPhase {
+ static const char* phase_name() { return "Store-store elimination"; }
+
+ void Run(PipelineData* data, Zone* temp_zone) {
+ StoreStoreElimination store_store_elimination(data->jsgraph(), temp_zone);
+ store_store_elimination.Run();
+ }
+};
+
struct MemoryOptimizationPhase {
static const char* phase_name() { return "memory optimization"; }
void Run(PipelineData* data, Zone* temp_zone) {
+ // The memory optimizer requires the graphs to be trimmed, so trim now.
+ GraphTrimmer trimmer(temp_zone, data->graph());
+ NodeVector roots(temp_zone);
+ data->jsgraph()->GetCachedNodes(&roots);
+ trimmer.TrimGraph(roots.begin(), roots.end());
+
+ // Optimize allocations and load/store operations.
MemoryOptimizer optimizer(data->jsgraph(), temp_zone);
optimizer.Optimize();
}
@@ -1411,11 +1447,7 @@
// Select representations.
Run<RepresentationSelectionPhase>();
- RunPrintAndVerify("Representations selected");
-
- // Run early optimization pass.
- Run<EarlyOptimizationPhase>();
- RunPrintAndVerify("Early optimized");
+ RunPrintAndVerify("Representations selected", true);
}
#ifdef DEBUG
@@ -1435,6 +1467,10 @@
RunPrintAndVerify("Untyped", true);
#endif
+ // Run early optimization pass.
+ Run<EarlyOptimizationPhase>();
+ RunPrintAndVerify("Early optimized", true);
+
data->EndPhaseKind();
return true;
@@ -1448,6 +1484,11 @@
Run<EffectControlLinearizationPhase>();
RunPrintAndVerify("Effect and control linearized", true);
+ if (FLAG_turbo_store_elimination) {
+ Run<StoreStoreEliminationPhase>();
+ RunPrintAndVerify("Store-store elimination", true);
+ }
+
Run<BranchEliminationPhase>();
RunPrintAndVerify("Branch conditions eliminated", true);
@@ -1487,7 +1528,7 @@
ZonePool zone_pool(isolate->allocator());
PipelineData data(&zone_pool, &info, graph, schedule);
base::SmartPointer<PipelineStatistics> pipeline_statistics;
- if (FLAG_turbo_stats) {
+ if (FLAG_turbo_stats || FLAG_turbo_stats_nvp) {
pipeline_statistics.Reset(new PipelineStatistics(&info, &zone_pool));
pipeline_statistics->BeginPhaseKind("stub codegen");
}
@@ -1496,9 +1537,11 @@
DCHECK_NOT_NULL(data.schedule());
if (FLAG_trace_turbo) {
- TurboJsonFile json_of(&info, std::ios_base::trunc);
- json_of << "{\"function\":\"" << info.GetDebugName().get()
- << "\", \"source\":\"\",\n\"phases\":[";
+ {
+ TurboJsonFile json_of(&info, std::ios_base::trunc);
+ json_of << "{\"function\":\"" << info.GetDebugName().get()
+ << "\", \"source\":\"\",\n\"phases\":[";
+ }
pipeline.Run<PrintGraphPhase>("Machine");
}
@@ -1539,7 +1582,7 @@
ZonePool zone_pool(info->isolate()->allocator());
PipelineData data(&zone_pool, info, graph, schedule);
base::SmartPointer<PipelineStatistics> pipeline_statistics;
- if (FLAG_turbo_stats) {
+ if (FLAG_turbo_stats || FLAG_turbo_stats_nvp) {
pipeline_statistics.Reset(new PipelineStatistics(info, &zone_pool));
pipeline_statistics->BeginPhaseKind("test codegen");
}
@@ -1624,9 +1667,8 @@
bool run_verifier = FLAG_turbo_verify_allocation;
// Allocate registers.
- AllocateRegisters(
- RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN),
- call_descriptor, run_verifier);
+ AllocateRegisters(RegisterConfiguration::Turbofan(), call_descriptor,
+ run_verifier);
Run<FrameElisionPhase>();
if (data->compilation_failed()) {
info()->AbortOptimization(kNotEnoughVirtualRegistersRegalloc);
@@ -1747,13 +1789,8 @@
Run<SplinterLiveRangesPhase>();
}
- if (FLAG_turbo_greedy_regalloc) {
- Run<AllocateGeneralRegistersPhase<GreedyAllocator>>();
- Run<AllocateFPRegistersPhase<GreedyAllocator>>();
- } else {
- Run<AllocateGeneralRegistersPhase<LinearScanAllocator>>();
- Run<AllocateFPRegistersPhase<LinearScanAllocator>>();
- }
+ Run<AllocateGeneralRegistersPhase<LinearScanAllocator>>();
+ Run<AllocateFPRegistersPhase<LinearScanAllocator>>();
if (FLAG_turbo_preprocess_ranges) {
Run<MergeSplintersPhase>();