Commit 78dd1d0c authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[turbofan] Move typer into the background.

... if FLAG_concurrent_compiler_frontend is enabled.

Bug: v8:7790
Change-Id: I448560b21d54c8907e8cbf68bdaf8bbdf2b034df
Reviewed-on: https://chromium-review.googlesource.com/1241959Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56205}
parent 19bad28d
...@@ -1358,9 +1358,10 @@ void JSHeapBroker::SerializeStandardObjects() { ...@@ -1358,9 +1358,10 @@ void JSHeapBroker::SerializeStandardObjects() {
Factory* const f = isolate()->factory(); Factory* const f = isolate()->factory();
// Maps, strings, oddballs // Maps, strings, oddballs
GetOrCreateData(f->NaN_string()); GetOrCreateData(f->arguments_marker_map());
GetOrCreateData(f->bigint_string()); GetOrCreateData(f->bigint_string());
GetOrCreateData(f->block_context_map()); GetOrCreateData(f->block_context_map());
GetOrCreateData(f->boolean_map());
GetOrCreateData(f->boolean_string()); GetOrCreateData(f->boolean_string());
GetOrCreateData(f->catch_context_map()); GetOrCreateData(f->catch_context_map());
GetOrCreateData(f->empty_fixed_array()); GetOrCreateData(f->empty_fixed_array());
...@@ -1379,23 +1380,32 @@ void JSHeapBroker::SerializeStandardObjects() { ...@@ -1379,23 +1380,32 @@ void JSHeapBroker::SerializeStandardObjects() {
GetOrCreateData(f->minus_zero_value()); GetOrCreateData(f->minus_zero_value());
GetOrCreateData(f->mutable_heap_number_map()); GetOrCreateData(f->mutable_heap_number_map());
GetOrCreateData(f->name_dictionary_map()); GetOrCreateData(f->name_dictionary_map());
GetOrCreateData(f->NaN_string());
GetOrCreateData(f->null_map());
GetOrCreateData(f->null_string()); GetOrCreateData(f->null_string());
GetOrCreateData(f->null_value()); GetOrCreateData(f->null_value());
GetOrCreateData(f->number_string()); GetOrCreateData(f->number_string());
GetOrCreateData(f->object_string()); GetOrCreateData(f->object_string());
GetOrCreateData(f->one_pointer_filler_map()); GetOrCreateData(f->one_pointer_filler_map());
GetOrCreateData(f->optimized_out()); GetOrCreateData(f->optimized_out());
GetOrCreateData(f->optimized_out_map());
GetOrCreateData(f->property_array_map()); GetOrCreateData(f->property_array_map());
GetOrCreateData(f->sloppy_arguments_elements_map()); GetOrCreateData(f->sloppy_arguments_elements_map());
GetOrCreateData(f->stale_register()); GetOrCreateData(f->stale_register());
GetOrCreateData(f->stale_register_map());
GetOrCreateData(f->string_string()); GetOrCreateData(f->string_string());
GetOrCreateData(f->symbol_string()); GetOrCreateData(f->symbol_string());
GetOrCreateData(f->termination_exception_map());
GetOrCreateData(f->the_hole_map());
GetOrCreateData(f->the_hole_value()); GetOrCreateData(f->the_hole_value());
GetOrCreateData(f->true_string()); GetOrCreateData(f->true_string());
GetOrCreateData(f->true_value()); GetOrCreateData(f->true_value());
GetOrCreateData(f->undefined_map());
GetOrCreateData(f->undefined_string()); GetOrCreateData(f->undefined_string());
GetOrCreateData(f->undefined_value()); GetOrCreateData(f->undefined_value());
GetOrCreateData(f->uninitialized_map());
GetOrCreateData(f->with_context_map()); GetOrCreateData(f->with_context_map());
GetOrCreateData(f->zero_string());
// Property cells // Property cells
GetOrCreateData(f->array_buffer_neutering_protector()) GetOrCreateData(f->array_buffer_neutering_protector())
......
...@@ -17,7 +17,7 @@ class JSHeapBroker; ...@@ -17,7 +17,7 @@ class JSHeapBroker;
// by handles embedded in the graph is copied to the heap broker. // by handles embedded in the graph is copied to the heap broker.
// TODO(jarin) This is just a temporary solution until the graph uses only // TODO(jarin) This is just a temporary solution until the graph uses only
// ObjetRef-derived reference to refer to the heap data. // ObjetRef-derived reference to refer to the heap data.
class JSHeapCopyReducer : public Reducer { class V8_EXPORT_PRIVATE JSHeapCopyReducer : public Reducer {
public: public:
explicit JSHeapCopyReducer(JSHeapBroker* broker); explicit JSHeapCopyReducer(JSHeapBroker* broker);
......
...@@ -20,10 +20,8 @@ OperationTyper::OperationTyper(Isolate* isolate, JSHeapBroker* js_heap_broker, ...@@ -20,10 +20,8 @@ OperationTyper::OperationTyper(Isolate* isolate, JSHeapBroker* js_heap_broker,
Zone* zone) Zone* zone)
: zone_(zone), cache_(TypeCache::Get()) { : zone_(zone), cache_(TypeCache::Get()) {
Factory* factory = isolate->factory(); Factory* factory = isolate->factory();
infinity_ = infinity_ = Type::NewConstant(V8_INFINITY, zone);
Type::NewConstant(js_heap_broker, factory->infinity_value(), zone); minus_infinity_ = Type::NewConstant(-V8_INFINITY, zone);
minus_infinity_ =
Type::NewConstant(js_heap_broker, factory->minus_infinity_value(), zone);
Type truncating_to_zero = Type::MinusZeroOrNaN(); Type truncating_to_zero = Type::MinusZeroOrNaN();
DCHECK(!truncating_to_zero.Maybe(Type::Integral32())); DCHECK(!truncating_to_zero.Maybe(Type::Integral32()));
......
...@@ -313,12 +313,17 @@ class PipelineData { ...@@ -313,12 +313,17 @@ class PipelineData {
: wasm_engine_->GetCodeTracer(); : wasm_engine_->GetCodeTracer();
} }
Typer* CreateTyper(Typer::Flags flags) { Typer* CreateTyper() {
CHECK_NULL(typer_); DCHECK_NULL(typer_);
typer_ = new Typer(isolate(), js_heap_broker(), flags, graph()); typer_ = new Typer(isolate(), js_heap_broker(), typer_flags_, graph());
return typer_; return typer_;
} }
void AddTyperFlag(Typer::Flag flag) {
DCHECK_NULL(typer_);
typer_flags_ |= flag;
}
void DeleteTyper() { void DeleteTyper() {
delete typer_; delete typer_;
typer_ = nullptr; typer_ = nullptr;
...@@ -448,6 +453,7 @@ class PipelineData { ...@@ -448,6 +453,7 @@ class PipelineData {
MaybeHandle<Code> code_; MaybeHandle<Code> code_;
CodeGenerator* code_generator_ = nullptr; CodeGenerator* code_generator_ = nullptr;
Typer* typer_ = nullptr; Typer* typer_ = nullptr;
Typer::Flags typer_flags_ = Typer::kNoFlags;
// All objects in the following group of fields are allocated in graph_zone_. // All objects in the following group of fields are allocated in graph_zone_.
// They are all set to nullptr when the graph_zone_ is destroyed. // They are all set to nullptr when the graph_zone_ is destroyed.
...@@ -1317,6 +1323,12 @@ struct CopyMetadataForConcurrentCompilePhase { ...@@ -1317,6 +1323,12 @@ struct CopyMetadataForConcurrentCompilePhase {
JSHeapCopyReducer heap_copy_reducer(data->js_heap_broker()); JSHeapCopyReducer heap_copy_reducer(data->js_heap_broker());
AddReducer(data, &graph_reducer, &heap_copy_reducer); AddReducer(data, &graph_reducer, &heap_copy_reducer);
graph_reducer.ReduceGraph(); graph_reducer.ReduceGraph();
// Some nodes that are no longer in the graph might still be in the cache.
NodeVector cached_nodes(temp_zone);
data->jsgraph()->GetCachedNodes(&cached_nodes);
for (Node* const node : cached_nodes) graph_reducer.ReduceNode(node);
data->js_heap_broker()->StopSerializing(); data->js_heap_broker()->StopSerializing();
} }
}; };
...@@ -2012,30 +2024,28 @@ bool PipelineImpl::CreateGraph() { ...@@ -2012,30 +2024,28 @@ bool PipelineImpl::CreateGraph() {
Run<EarlyGraphTrimmingPhase>(); Run<EarlyGraphTrimmingPhase>();
RunPrintAndVerify(EarlyGraphTrimmingPhase::phase_name(), true); RunPrintAndVerify(EarlyGraphTrimmingPhase::phase_name(), true);
// Run the type-sensitive lowerings and optimizations on the graph.
{
// Determine the Typer operation flags. // Determine the Typer operation flags.
Typer::Flags flags = Typer::kNoFlags; {
if (is_sloppy(info()->shared_info()->language_mode()) && if (is_sloppy(info()->shared_info()->language_mode()) &&
info()->shared_info()->IsUserJavaScript()) { info()->shared_info()->IsUserJavaScript()) {
// Sloppy mode functions always have an Object for this. // Sloppy mode functions always have an Object for this.
flags |= Typer::kThisIsReceiver; data->AddTyperFlag(Typer::kThisIsReceiver);
} }
if (IsClassConstructor(info()->shared_info()->kind())) { if (IsClassConstructor(info()->shared_info()->kind())) {
// Class constructors cannot be [[Call]]ed. // Class constructors cannot be [[Call]]ed.
flags |= Typer::kNewTargetIsReceiver; data->AddTyperFlag(Typer::kNewTargetIsReceiver);
}
} }
// Type the graph and keep the Typer running on newly created nodes within // Run the type-sensitive lowerings and optimizations on the graph.
// this scope; the Typer is automatically unlinked from the Graph once we {
// leave this scope below.
Run<TyperPhase>(data->CreateTyper(flags));
RunPrintAndVerify(TyperPhase::phase_name());
if (FLAG_concurrent_compiler_frontend) { if (FLAG_concurrent_compiler_frontend) {
Run<CopyMetadataForConcurrentCompilePhase>(); Run<CopyMetadataForConcurrentCompilePhase>();
} else { } else {
// Type the graph and keep the Typer running such that new nodes get
// automatically typed when they are created.
Run<TyperPhase>(data->CreateTyper());
RunPrintAndVerify(TyperPhase::phase_name());
Run<TypedLoweringPhase>(); Run<TypedLoweringPhase>();
RunPrintAndVerify(TypedLoweringPhase::phase_name()); RunPrintAndVerify(TypedLoweringPhase::phase_name());
data->DeleteTyper(); data->DeleteTyper();
...@@ -2053,6 +2063,10 @@ bool PipelineImpl::OptimizeGraph(Linkage* linkage) { ...@@ -2053,6 +2063,10 @@ bool PipelineImpl::OptimizeGraph(Linkage* linkage) {
data->BeginPhaseKind("lowering"); data->BeginPhaseKind("lowering");
if (FLAG_concurrent_compiler_frontend) { if (FLAG_concurrent_compiler_frontend) {
// Type the graph and keep the Typer running such that new nodes get
// automatically typed when they are created.
Run<TyperPhase>(data->CreateTyper());
RunPrintAndVerify(TyperPhase::phase_name());
Run<TypedLoweringPhase>(); Run<TypedLoweringPhase>();
RunPrintAndVerify(TypedLoweringPhase::phase_name()); RunPrintAndVerify(TypedLoweringPhase::phase_name());
data->DeleteTyper(); data->DeleteTyper();
......
...@@ -1420,7 +1420,6 @@ Type Typer::Visitor::JSCallTyper(Type fun, Typer* t) { ...@@ -1420,7 +1420,6 @@ Type Typer::Visitor::JSCallTyper(Type fun, Typer* t) {
return Type::NonInternal(); return Type::NonInternal();
} }
JSFunctionRef function = fun.AsHeapConstant()->Ref().AsJSFunction(); JSFunctionRef function = fun.AsHeapConstant()->Ref().AsJSFunction();
function.Serialize();
if (!function.shared().HasBuiltinFunctionId()) { if (!function.shared().HasBuiltinFunctionId()) {
return Type::NonInternal(); return Type::NonInternal();
} }
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "test/unittests/compiler/graph-unittest.h" #include "test/unittests/compiler/graph-unittest.h"
#include "src/compiler/js-heap-copy-reducer.h"
#include "src/compiler/node-properties.h" #include "src/compiler/node-properties.h"
#include "src/heap/factory.h" #include "src/heap/factory.h"
#include "src/objects-inl.h" // TODO(everyone): Make typer.h IWYU compliant. #include "src/objects-inl.h" // TODO(everyone): Make typer.h IWYU compliant.
...@@ -69,6 +70,8 @@ Node* GraphTest::HeapConstant(const Handle<HeapObject>& value) { ...@@ -69,6 +70,8 @@ Node* GraphTest::HeapConstant(const Handle<HeapObject>& value) {
Node* node = graph()->NewNode(common()->HeapConstant(value)); Node* node = graph()->NewNode(common()->HeapConstant(value));
Type type = Type::NewConstant(js_heap_broker(), value, zone()); Type type = Type::NewConstant(js_heap_broker(), value, zone());
NodeProperties::SetType(node, type); NodeProperties::SetType(node, type);
JSHeapCopyReducer heap_copy_reducer(js_heap_broker());
heap_copy_reducer.Reduce(node);
return node; return node;
} }
......
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