Commit cf87e94c authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

Move CompilationDependencies into compiler.

- Move the CompilationDependencies member of OptimizedCompilationInfo
  to Turbofan's PipelineData (and thus into the compiler namespace).
- Move compilation-dependencies.{cc,h} to the compiler directory.

Bug: v8:7902
Change-Id: I5471d0923daf83abe975357325db5bc5ad0a8571
Reviewed-on: https://chromium-review.googlesource.com/1127793
Commit-Queue: Georg Neis <neis@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54295}
parent 30b7345f
......@@ -1605,8 +1605,6 @@ v8_source_set("v8_base") {
"src/collector.h",
"src/compilation-cache.cc",
"src/compilation-cache.h",
"src/compilation-dependencies.cc",
"src/compilation-dependencies.h",
"src/compilation-statistics.cc",
"src/compilation-statistics.h",
"src/compiler-dispatcher/compiler-dispatcher-job.cc",
......@@ -1652,6 +1650,8 @@ v8_source_set("v8_base") {
"src/compiler/common-operator-reducer.h",
"src/compiler/common-operator.cc",
"src/compiler/common-operator.h",
"src/compiler/compilation-dependencies.cc",
"src/compiler/compilation-dependencies.h",
"src/compiler/compiler-source-position-table.cc",
"src/compiler/compiler-source-position-table.h",
"src/compiler/constant-folding-reducer.cc",
......
......@@ -4,9 +4,10 @@
#include <ostream>
#include "src/accessors.h"
#include "src/compilation-dependencies.h"
#include "src/compiler/access-info.h"
#include "src/accessors.h"
#include "src/compiler/compilation-dependencies.h"
#include "src/compiler/type-cache.h"
#include "src/field-index-inl.h"
#include "src/field-type.h"
......
......@@ -18,12 +18,12 @@ namespace v8 {
namespace internal {
// Forward declarations.
class CompilationDependencies;
class Factory;
namespace compiler {
// Forward declarations.
class CompilationDependencies;
class Type;
class TypeCache;
......
......@@ -2,13 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/compilation-dependencies.h"
#include "src/compiler/compilation-dependencies.h"
#include "src/handles-inl.h"
#include "src/objects-inl.h"
namespace v8 {
namespace internal {
namespace compiler {
// TODO(neis): Move these to the DependentCode class.
namespace {
......@@ -384,5 +385,6 @@ void CompilationDependencies::DependOnElementsKinds(
CHECK_EQ(site->nested_site(), Smi::kZero);
}
} // namespace compiler
} // namespace internal
} // namespace v8
......@@ -2,17 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_COMPILATION_DEPENDENCIES_H_
#define V8_COMPILATION_DEPENDENCIES_H_
#ifndef V8_COMPILER_COMPILATION_DEPENDENCIES_H_
#define V8_COMPILER_COMPILATION_DEPENDENCIES_H_
#include "src/objects.h"
#include "src/zone/zone-containers.h"
namespace v8 {
namespace internal {
namespace compiler {
// Collects and installs dependencies of the code that is being generated.
class V8_EXPORT_PRIVATE CompilationDependencies {
class V8_EXPORT_PRIVATE CompilationDependencies : public ZoneObject {
public:
CompilationDependencies(Isolate* isolate, Zone* zone);
......@@ -69,7 +70,8 @@ class V8_EXPORT_PRIVATE CompilationDependencies {
ZoneForwardList<Dependency*> dependencies_;
};
} // namespace compiler
} // namespace internal
} // namespace v8
#endif // V8_COMPILATION_DEPENDENCIES_H_
#endif // V8_COMPILER_COMPILATION_DEPENDENCIES_H_
......@@ -9,10 +9,10 @@
#include "src/builtins/builtins-utils.h"
#include "src/code-factory.h"
#include "src/code-stubs.h"
#include "src/compilation-dependencies.h"
#include "src/compiler/access-builder.h"
#include "src/compiler/access-info.h"
#include "src/compiler/allocation-builder.h"
#include "src/compiler/compilation-dependencies.h"
#include "src/compiler/js-graph.h"
#include "src/compiler/linkage.h"
#include "src/compiler/node-matchers.h"
......
......@@ -14,7 +14,6 @@ namespace v8 {
namespace internal {
// Forward declarations.
class CompilationDependencies;
class Factory;
class VectorSlotPair;
......@@ -23,6 +22,7 @@ namespace compiler {
// Forward declarations.
class CallFrequency;
class CommonOperatorBuilder;
class CompilationDependencies;
struct FieldAccess;
class JSGraph;
class JSHeapBroker;
......
......@@ -5,10 +5,10 @@
#include "src/compiler/js-create-lowering.h"
#include "src/code-factory.h"
#include "src/compilation-dependencies.h"
#include "src/compiler/access-builder.h"
#include "src/compiler/allocation-builder.h"
#include "src/compiler/common-operator.h"
#include "src/compiler/compilation-dependencies.h"
#include "src/compiler/js-graph.h"
#include "src/compiler/js-operator.h"
#include "src/compiler/linkage.h"
......
......@@ -14,7 +14,6 @@ namespace internal {
// Forward declarations.
class AllocationSiteUsageContext;
class CompilationDependencies;
class Factory;
class JSRegExp;
......@@ -22,6 +21,7 @@ namespace compiler {
// Forward declarations.
class CommonOperatorBuilder;
class CompilationDependencies;
class JSGraph;
class JSOperatorBuilder;
class MachineOperatorBuilder;
......
......@@ -7,10 +7,10 @@
#include "src/accessors.h"
#include "src/api.h"
#include "src/code-factory.h"
#include "src/compilation-dependencies.h"
#include "src/compiler/access-builder.h"
#include "src/compiler/access-info.h"
#include "src/compiler/allocation-builder.h"
#include "src/compiler/compilation-dependencies.h"
#include "src/compiler/js-graph.h"
#include "src/compiler/js-operator.h"
#include "src/compiler/linkage.h"
......
......@@ -14,7 +14,6 @@ namespace v8 {
namespace internal {
// Forward declarations.
class CompilationDependencies;
class Factory;
class FeedbackNexus;
......@@ -23,6 +22,7 @@ namespace compiler {
// Forward declarations.
enum class AccessMode;
class CommonOperatorBuilder;
class CompilationDependencies;
class ElementAccessInfo;
class JSGraph;
class JSHeapBroker;
......
......@@ -21,6 +21,7 @@
#include "src/compiler/checkpoint-elimination.h"
#include "src/compiler/code-generator.h"
#include "src/compiler/common-operator-reducer.h"
#include "src/compiler/compilation-dependencies.h"
#include "src/compiler/compiler-source-position-table.h"
#include "src/compiler/constant-folding-reducer.h"
#include "src/compiler/control-flow-optimizer.h"
......@@ -133,6 +134,8 @@ class PipelineData {
jsgraph_ = new (graph_zone_)
JSGraph(isolate_, graph_, common_, javascript_, simplified_, machine_);
js_heap_broker_ = new (graph_zone_) JSHeapBroker(isolate_);
dependencies_ =
new (codegen_zone_) CompilationDependencies(isolate_, codegen_zone_);
}
// For WebAssembly compile entry point.
......@@ -220,6 +223,7 @@ class PipelineData {
Isolate* isolate() const { return isolate_; }
OptimizedCompilationInfo* info() const { return info_; }
ZoneStats* zone_stats() const { return zone_stats_; }
CompilationDependencies* dependencies() const { return dependencies_; }
PipelineStatistics* pipeline_statistics() { return pipeline_statistics_; }
OsrHelper* osr_helper() { return &(*osr_helper_); }
bool compilation_failed() const { return compilation_failed_; }
......@@ -317,6 +321,7 @@ class PipelineData {
if (codegen_zone_ == nullptr) return;
codegen_zone_scope_.Destroy();
codegen_zone_ = nullptr;
dependencies_ = nullptr;
frame_ = nullptr;
}
......@@ -442,6 +447,7 @@ class PipelineData {
// is destroyed.
ZoneStats::Scope codegen_zone_scope_;
Zone* codegen_zone_;
CompilationDependencies* dependencies_ = nullptr;
Frame* frame_ = nullptr;
// All objects in the following group of fields are allocated in
......@@ -495,6 +501,9 @@ class PipelineImpl final {
// Step D. Run the code finalization pass.
MaybeHandle<Code> FinalizeCode();
// Step E. Install any code dependencies.
bool CommitDependencies(Handle<Code> code);
void VerifyGeneratedCodeIsIdempotent();
void RunPrintAndVerify(const char* phase, bool untyped = false);
MaybeHandle<Code> GenerateCode(CallDescriptor* call_descriptor);
......@@ -926,11 +935,11 @@ PipelineCompilationJob::Status PipelineCompilationJob::FinalizeJobImpl(
}
return FAILED;
}
if (!compilation_info()->dependencies()->Commit(code)) {
if (!pipeline_.CommitDependencies(code)) {
return RetryOptimization(BailoutReason::kBailedOutDueToDependencyChange);
}
compilation_info()->SetCode(code);
compilation_info()->SetCode(code);
compilation_info()->context()->native_context()->AddOptimizedCode(*code);
RegisterWeakObjectsInOptimizedCode(code, isolate);
return SUCCEEDED;
......@@ -1169,12 +1178,12 @@ struct InliningPhase {
CommonOperatorReducer common_reducer(isolate, &graph_reducer, data->graph(),
data->common(), data->machine(),
temp_zone);
JSCallReducer call_reducer(
&graph_reducer, data->jsgraph(), data->js_heap_broker(),
data->info()->is_bailout_on_uninitialized()
? JSCallReducer::kBailoutOnUninitialized
: JSCallReducer::kNoFlags,
data->native_context(), data->info()->dependencies());
JSCallReducer call_reducer(&graph_reducer, data->jsgraph(),
data->js_heap_broker(),
data->info()->is_bailout_on_uninitialized()
? JSCallReducer::kBailoutOnUninitialized
: JSCallReducer::kNoFlags,
data->native_context(), data->dependencies());
JSContextSpecialization context_specialization(
&graph_reducer, data->jsgraph(), data->js_heap_broker(),
ChooseSpecializationContext(isolate, data->info()),
......@@ -1191,7 +1200,7 @@ struct InliningPhase {
}
JSNativeContextSpecialization native_context_specialization(
&graph_reducer, data->jsgraph(), data->js_heap_broker(), flags,
data->native_context(), data->info()->dependencies(), temp_zone);
data->native_context(), data->dependencies(), temp_zone);
JSInliningHeuristic inlining(
&graph_reducer, data->info()->is_inlining_enabled()
? JSInliningHeuristic::kGeneralInlining
......@@ -1262,16 +1271,16 @@ struct TypedLoweringPhase {
data->jsgraph()->Dead());
DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(),
data->common(), temp_zone);
JSCreateLowering create_lowering(
&graph_reducer, data->info()->dependencies(), data->jsgraph(),
data->js_heap_broker(), data->native_context(), temp_zone);
JSCreateLowering create_lowering(&graph_reducer, data->dependencies(),
data->jsgraph(), data->js_heap_broker(),
data->native_context(), temp_zone);
JSTypedLowering typed_lowering(&graph_reducer, data->jsgraph(),
data->js_heap_broker(), temp_zone);
ConstantFoldingReducer constant_folding_reducer(&graph_reducer,
data->jsgraph());
TypedOptimization typed_optimization(
&graph_reducer, data->info()->dependencies(), data->jsgraph(),
data->js_heap_broker());
TypedOptimization typed_optimization(&graph_reducer, data->dependencies(),
data->jsgraph(),
data->js_heap_broker());
SimplifiedOperatorReducer simple_reducer(&graph_reducer, data->jsgraph());
CheckpointElimination checkpoint_elimination(&graph_reducer);
CommonOperatorReducer common_reducer(data->isolate(), &graph_reducer,
......@@ -2161,7 +2170,12 @@ MaybeHandle<Code> Pipeline::GenerateCodeForTesting(
if (!pipeline.CreateGraph()) return MaybeHandle<Code>();
if (!pipeline.OptimizeGraph(&linkage)) return MaybeHandle<Code>();
pipeline.AssembleCode(&linkage);
return pipeline.FinalizeCode();
Handle<Code> code;
if (pipeline.FinalizeCode().ToHandle(&code) &&
pipeline.CommitDependencies(code)) {
return code;
}
return MaybeHandle<Code>();
}
// static
......@@ -2201,7 +2215,12 @@ MaybeHandle<Code> Pipeline::GenerateCodeForTesting(
pipeline.ComputeScheduledGraph();
}
return pipeline.GenerateCode(call_descriptor);
Handle<Code> code;
if (pipeline.GenerateCode(call_descriptor).ToHandle(&code) &&
pipeline.CommitDependencies(code)) {
return code;
}
return MaybeHandle<Code>();
}
// static
......@@ -2504,6 +2523,11 @@ MaybeHandle<Code> PipelineImpl::GenerateCode(CallDescriptor* call_descriptor) {
return FinalizeCode();
}
bool PipelineImpl::CommitDependencies(Handle<Code> code) {
return data_->dependencies() == nullptr ||
data_->dependencies()->Commit(code);
}
void PipelineImpl::AllocateRegisters(const RegisterConfiguration* config,
CallDescriptor* call_descriptor,
bool run_verifier) {
......
......@@ -4,9 +4,9 @@
#include "src/compiler/property-access-builder.h"
#include "src/compilation-dependencies.h"
#include "src/compiler/access-builder.h"
#include "src/compiler/access-info.h"
#include "src/compiler/compilation-dependencies.h"
#include "src/compiler/js-graph.h"
#include "src/compiler/node-matchers.h"
#include "src/compiler/simplified-operator.h"
......
......@@ -13,12 +13,10 @@
namespace v8 {
namespace internal {
class CompilationDependencies;
namespace compiler {
class CommonOperatorBuilder;
class CompilationDependencies;
class Graph;
class JSGraph;
class Node;
......
......@@ -4,7 +4,7 @@
#include "src/compiler/typed-optimization.h"
#include "src/compilation-dependencies.h"
#include "src/compiler/compilation-dependencies.h"
#include "src/compiler/js-graph.h"
#include "src/compiler/node-matchers.h"
#include "src/compiler/node-properties.h"
......
......@@ -13,13 +13,13 @@ namespace v8 {
namespace internal {
// Forward declarations.
class CompilationDependencies;
class Factory;
class Isolate;
namespace compiler {
// Forward declarations.
class CompilationDependencies;
class JSGraph;
class SimplifiedOperatorBuilder;
class TypeCache;
......
......@@ -23,7 +23,6 @@ OptimizedCompilationInfo::OptimizedCompilationInfo(
shared_info_ = shared;
closure_ = closure;
optimization_id_ = isolate->NextOptimizationId();
dependencies_.reset(new CompilationDependencies(isolate, zone));
SetFlag(kCalledWithCodeStartRegister);
if (FLAG_function_context_specialization) MarkAsFunctionContextSpecializing();
......@@ -78,7 +77,6 @@ OptimizedCompilationInfo::OptimizedCompilationInfo(
osr_offset_(BailoutId::None()),
zone_(zone),
deferred_handles_(nullptr),
dependencies_(nullptr),
bailout_reason_(BailoutReason::kNoReason),
optimization_id_(-1),
debug_name_(debug_name) {}
......
......@@ -9,7 +9,6 @@
#include "src/bailout-reason.h"
#include "src/code-reference.h"
#include "src/compilation-dependencies.h"
#include "src/feedback-vector.h"
#include "src/frames.h"
#include "src/globals.h"
......@@ -230,8 +229,6 @@ class V8_EXPORT_PRIVATE OptimizedCompilationInfo final {
BailoutReason bailout_reason() const { return bailout_reason_; }
CompilationDependencies* dependencies() { return dependencies_.get(); }
int optimization_id() const {
DCHECK(IsOptimizing());
return optimization_id_;
......@@ -308,10 +305,6 @@ class V8_EXPORT_PRIVATE OptimizedCompilationInfo final {
std::shared_ptr<DeferredHandles> deferred_handles_;
// Dependencies for this compilation, e.g. stable maps.
// TODO(neis): Move this to PipelineData.
std::unique_ptr<CompilationDependencies> dependencies_;
BailoutReason bailout_reason_;
InlinedFunctionList inlined_functions_;
......
......@@ -153,7 +153,6 @@ Handle<JSFunction> FunctionTester::Compile(Handle<JSFunction> function) {
Handle<Code> code =
Pipeline::GenerateCodeForTesting(&info, isolate).ToHandleChecked();
CHECK(info.dependencies()->Commit(code));
info.context()->native_context()->AddOptimizedCode(*code);
function->set_code(*code);
return function;
......
......@@ -10,7 +10,7 @@
#include "src/v8.h"
#include "src/compilation-cache.h"
#include "src/compilation-dependencies.h"
#include "src/compiler/compilation-dependencies.h"
#include "src/execution.h"
#include "src/field-type.h"
#include "src/global-handles.h"
......@@ -24,6 +24,7 @@
namespace v8 {
namespace internal {
namespace compiler {
namespace test_field_type_tracking {
// TODO(ishell): fix this once TransitionToPrototype stops generalizing
......@@ -2814,5 +2815,6 @@ TEST(HoleyMutableHeapNumber) {
}
} // namespace test_field_type_tracking
} // namespace compiler
} // namespace internal
} // namespace v8
......@@ -4,8 +4,8 @@
#include "src/compiler/constant-folding-reducer.h"
#include "src/code-factory.h"
#include "src/compilation-dependencies.h"
#include "src/compiler/access-builder.h"
#include "src/compiler/compilation-dependencies.h"
#include "src/compiler/js-graph.h"
#include "src/compiler/js-operator.h"
#include "src/compiler/machine-operator.h"
......
......@@ -4,7 +4,7 @@
#include <cctype>
#include "src/compilation-dependencies.h"
#include "src/compiler/compilation-dependencies.h"
#include "src/compiler/js-call-reducer.h"
#include "src/compiler/js-graph.h"
#include "src/compiler/simplified-operator.h"
......
......@@ -4,8 +4,8 @@
#include "src/compiler/js-create-lowering.h"
#include "src/code-factory.h"
#include "src/compilation-dependencies.h"
#include "src/compiler/access-builder.h"
#include "src/compiler/compilation-dependencies.h"
#include "src/compiler/js-graph.h"
#include "src/compiler/js-operator.h"
#include "src/compiler/machine-operator.h"
......
......@@ -4,8 +4,8 @@
#include "src/compiler/typed-optimization.h"
#include "src/code-factory.h"
#include "src/compilation-dependencies.h"
#include "src/compiler/access-builder.h"
#include "src/compiler/compilation-dependencies.h"
#include "src/compiler/js-graph.h"
#include "src/compiler/js-operator.h"
#include "src/compiler/machine-operator.h"
......
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