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

[turbofan] Introduce broker modes.

Also define some infrastructure for serialization.

Bug: v8:7790
Change-Id: Icaa3d5b877dca41dfd5554683d05667fda115e80
Reviewed-on: https://chromium-review.googlesource.com/1150531
Commit-Queue: Georg Neis <neis@chromium.org>
Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54804}
parent 0fc61eca
This diff is collapsed.
...@@ -91,7 +91,7 @@ HEAP_BROKER_OBJECT_LIST(FORWARD_DECL) ...@@ -91,7 +91,7 @@ HEAP_BROKER_OBJECT_LIST(FORWARD_DECL)
class ObjectRef { class ObjectRef {
public: public:
ObjectRef(JSHeapBroker* broker, Handle<Object> object); ObjectRef(JSHeapBroker* broker, Handle<Object> object);
explicit ObjectRef(ObjectData* data) : data_(data) { CHECK_NOT_NULL(data); } explicit ObjectRef(ObjectData* data) : data_(data) { CHECK_NOT_NULL(data_); }
bool equals(const ObjectRef& other) const; bool equals(const ObjectRef& other) const;
...@@ -408,6 +408,7 @@ class InternalizedStringRef : public StringRef { ...@@ -408,6 +408,7 @@ class InternalizedStringRef : public StringRef {
class V8_EXPORT_PRIVATE JSHeapBroker : public NON_EXPORTED_BASE(ZoneObject) { class V8_EXPORT_PRIVATE JSHeapBroker : public NON_EXPORTED_BASE(ZoneObject) {
public: public:
JSHeapBroker(Isolate* isolate, Zone* zone); JSHeapBroker(Isolate* isolate, Zone* zone);
void SerializeStandardObjects();
HeapObjectType HeapObjectTypeFromMap(Handle<Map> map) const { HeapObjectType HeapObjectTypeFromMap(Handle<Map> map) const {
AllowHandleDereference handle_dereference; AllowHandleDereference handle_dereference;
...@@ -415,15 +416,32 @@ class V8_EXPORT_PRIVATE JSHeapBroker : public NON_EXPORTED_BASE(ZoneObject) { ...@@ -415,15 +416,32 @@ class V8_EXPORT_PRIVATE JSHeapBroker : public NON_EXPORTED_BASE(ZoneObject) {
} }
Isolate* isolate() const { return isolate_; } Isolate* isolate() const { return isolate_; }
Zone* zone() const { return zone_; }
enum BrokerMode { kDisabled, kSerializing, kSerialized };
BrokerMode mode() const { return mode_; }
void StopSerializing() {
CHECK_EQ(mode_, kSerializing);
mode_ = kSerialized;
}
// Returns nullptr iff handle unknown.
ObjectData* GetData(Handle<Object>) const;
// Never returns nullptr.
ObjectData* GetOrCreateData(Handle<Object>);
void AddData(Handle<Object> object, ObjectData* data);
private: private:
friend class ObjectRef;
friend class HeapObjectRef; friend class HeapObjectRef;
friend class ObjectRef;
// TODO(neis): Remove eventually.
HeapObjectType HeapObjectTypeFromMap(Map* map) const; HeapObjectType HeapObjectTypeFromMap(Map* map) const;
Isolate* const isolate_; Isolate* const isolate_;
Zone* const zone_; Zone* const zone_;
ZoneUnorderedMap<Address, ObjectData*> refs_; ZoneUnorderedMap<Address, ObjectData*> refs_;
BrokerMode mode_;
}; };
} // namespace compiler } // namespace compiler
......
...@@ -3,13 +3,21 @@ ...@@ -3,13 +3,21 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "src/compiler/js-heap-copy-reducer.h" #include "src/compiler/js-heap-copy-reducer.h"
#include "src/compiler/common-operator.h" #include "src/compiler/common-operator.h"
#include "src/compiler/js-heap-broker.h" #include "src/compiler/js-heap-broker.h"
#include "src/compiler/js-operator.h"
#include "src/heap/factory-inl.h"
#include "src/objects/map.h"
#include "src/objects/scope-info.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
namespace compiler { namespace compiler {
// In the functions below, we call the ObjectRef (or subclass) constructor in
// order to trigger serialization if not yet done.
JSHeapCopyReducer::JSHeapCopyReducer(JSHeapBroker* broker) : broker_(broker) {} JSHeapCopyReducer::JSHeapCopyReducer(JSHeapBroker* broker) : broker_(broker) {}
JSHeapBroker* JSHeapCopyReducer::broker() { return broker_; } JSHeapBroker* JSHeapCopyReducer::broker() { return broker_; }
...@@ -17,10 +25,28 @@ JSHeapBroker* JSHeapCopyReducer::broker() { return broker_; } ...@@ -17,10 +25,28 @@ JSHeapBroker* JSHeapCopyReducer::broker() { return broker_; }
Reduction JSHeapCopyReducer::Reduce(Node* node) { Reduction JSHeapCopyReducer::Reduce(Node* node) {
switch (node->opcode()) { switch (node->opcode()) {
case IrOpcode::kHeapConstant: { case IrOpcode::kHeapConstant: {
// Call the constructor to make sure the broker copies the data.
ObjectRef(broker(), HeapConstantOf(node->op())); ObjectRef(broker(), HeapConstantOf(node->op()));
break; break;
} }
case IrOpcode::kJSCreateFunctionContext: {
CreateFunctionContextParameters const& p =
CreateFunctionContextParametersOf(node->op());
ScopeInfoRef(broker(), p.scope_info());
break;
}
case IrOpcode::kJSCreateClosure: {
CreateClosureParameters const& p = CreateClosureParametersOf(node->op());
SharedFunctionInfoRef(broker(), p.shared_info());
HeapObjectRef(broker(), p.feedback_cell());
HeapObjectRef(broker(), p.code());
break;
}
case IrOpcode::kJSLoadNamed:
case IrOpcode::kJSStoreNamed: {
NamedAccess const& p = NamedAccessOf(node->op());
NameRef(broker(), p.name());
break;
}
default: default:
break; break;
} }
......
...@@ -1294,6 +1294,7 @@ struct CopyMetadataForConcurrentCompilePhase { ...@@ -1294,6 +1294,7 @@ 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();
data->js_heap_broker()->StopSerializing();
} }
}; };
...@@ -2038,6 +2039,7 @@ bool PipelineImpl::CreateGraph() { ...@@ -2038,6 +2039,7 @@ bool PipelineImpl::CreateGraph() {
Run<ConcurrentOptimizationPrepPhase>(); Run<ConcurrentOptimizationPrepPhase>();
if (FLAG_concurrent_compiler_frontend) { if (FLAG_concurrent_compiler_frontend) {
data->js_heap_broker()->SerializeStandardObjects();
Run<CopyMetadataForConcurrentCompilePhase>(); Run<CopyMetadataForConcurrentCompilePhase>();
} }
......
...@@ -383,6 +383,7 @@ DEFINE_BOOL(block_concurrent_recompilation, false, ...@@ -383,6 +383,7 @@ DEFINE_BOOL(block_concurrent_recompilation, false,
"block queued jobs until released") "block queued jobs until released")
DEFINE_BOOL(concurrent_compiler_frontend, false, DEFINE_BOOL(concurrent_compiler_frontend, false,
"run optimizing compiler's frontend phases on a separate thread") "run optimizing compiler's frontend phases on a separate thread")
DEFINE_BOOL(trace_heap_broker, false, "trace the heap broker")
// Flags for stress-testing the compiler. // Flags for stress-testing the compiler.
DEFINE_INT(stress_runs, 0, "number of stress runs") DEFINE_INT(stress_runs, 0, "number of stress runs")
......
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