Commit 3f661258 authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[turbofan] Don't create handle in JSHeapBroker::native_context.

Instead, remember the canonical handle during SerializeStandardObjects.

Bug: v8:7790
Change-Id: Id57d861e92088fbc64c05fbee1612376000c06c9
Reviewed-on: https://chromium-review.googlesource.com/1233494Reviewed-by: 's avatarMaya Lekova <mslekova@chromium.org>
Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56029}
parent 3bb5cb63
This diff is collapsed.
...@@ -33,13 +33,11 @@ class V8_EXPORT_PRIVATE JSCreateLowering final ...@@ -33,13 +33,11 @@ class V8_EXPORT_PRIVATE JSCreateLowering final
: public NON_EXPORTED_BASE(AdvancedReducer) { : public NON_EXPORTED_BASE(AdvancedReducer) {
public: public:
JSCreateLowering(Editor* editor, CompilationDependencies* dependencies, JSCreateLowering(Editor* editor, CompilationDependencies* dependencies,
JSGraph* jsgraph, JSHeapBroker* js_heap_broker, JSGraph* jsgraph, JSHeapBroker* js_heap_broker, Zone* zone)
Handle<Context> native_context, Zone* zone)
: AdvancedReducer(editor), : AdvancedReducer(editor),
dependencies_(dependencies), dependencies_(dependencies),
jsgraph_(jsgraph), jsgraph_(jsgraph),
js_heap_broker_(js_heap_broker), js_heap_broker_(js_heap_broker),
native_context_(native_context),
zone_(zone) {} zone_(zone) {}
~JSCreateLowering() final = default; ~JSCreateLowering() final = default;
...@@ -116,8 +114,7 @@ class V8_EXPORT_PRIVATE JSCreateLowering final ...@@ -116,8 +114,7 @@ class V8_EXPORT_PRIVATE JSCreateLowering final
Graph* graph() const; Graph* graph() const;
JSGraph* jsgraph() const { return jsgraph_; } JSGraph* jsgraph() const { return jsgraph_; }
Isolate* isolate() const; Isolate* isolate() const;
Handle<Context> native_context() const { return native_context_; } NativeContextRef native_context() const;
NativeContextRef native_context_ref() const;
CommonOperatorBuilder* common() const; CommonOperatorBuilder* common() const;
SimplifiedOperatorBuilder* simplified() const; SimplifiedOperatorBuilder* simplified() const;
CompilationDependencies* dependencies() const { return dependencies_; } CompilationDependencies* dependencies() const { return dependencies_; }
...@@ -127,7 +124,6 @@ class V8_EXPORT_PRIVATE JSCreateLowering final ...@@ -127,7 +124,6 @@ class V8_EXPORT_PRIVATE JSCreateLowering final
CompilationDependencies* const dependencies_; CompilationDependencies* const dependencies_;
JSGraph* const jsgraph_; JSGraph* const jsgraph_;
JSHeapBroker* const js_heap_broker_; JSHeapBroker* const js_heap_broker_;
Handle<Context> const native_context_;
Zone* const zone_; Zone* const zone_;
}; };
......
...@@ -1219,6 +1219,11 @@ bool JSHeapBroker::SerializingAllowed() const { ...@@ -1219,6 +1219,11 @@ bool JSHeapBroker::SerializingAllowed() const {
} }
void JSHeapBroker::SerializeStandardObjects() { void JSHeapBroker::SerializeStandardObjects() {
if (!native_context_.has_value()) {
native_context_ = NativeContextRef(this, isolate()->native_context());
native_context_->Serialize();
}
if (mode() == kDisabled) return; if (mode() == kDisabled) return;
Trace("Serializing standard objects.\n"); Trace("Serializing standard objects.\n");
...@@ -1332,8 +1337,6 @@ void JSHeapBroker::SerializeStandardObjects() { ...@@ -1332,8 +1337,6 @@ void JSHeapBroker::SerializeStandardObjects() {
} }
} }
GetOrCreateData(isolate()->native_context())->AsNativeContext()->Serialize();
Trace("Finished serializing standard objects.\n"); Trace("Finished serializing standard objects.\n");
} }
...@@ -1397,11 +1400,6 @@ int ObjectRef::AsSmi() const { ...@@ -1397,11 +1400,6 @@ int ObjectRef::AsSmi() const {
return object<Smi>()->value(); return object<Smi>()->value();
} }
NativeContextRef JSHeapBroker::native_context() {
AllowHandleAllocation handle_allocation;
return NativeContextRef(this, isolate()->native_context());
}
base::Optional<MapRef> JSObjectRef::GetObjectCreateMap() const { base::Optional<MapRef> JSObjectRef::GetObjectCreateMap() const {
if (broker()->mode() == JSHeapBroker::kDisabled) { if (broker()->mode() == JSHeapBroker::kDisabled) {
AllowHandleAllocation handle_allocation; AllowHandleAllocation handle_allocation;
...@@ -2120,6 +2118,12 @@ void ContextRef::Serialize() { ...@@ -2120,6 +2118,12 @@ void ContextRef::Serialize() {
data()->AsContext()->Serialize(); data()->AsContext()->Serialize();
} }
void NativeContextRef::Serialize() {
if (broker()->mode() == JSHeapBroker::kDisabled) return;
CHECK_EQ(broker()->mode(), JSHeapBroker::kSerializing);
data()->AsNativeContext()->Serialize();
}
#undef BIMODAL_ACCESSOR #undef BIMODAL_ACCESSOR
#undef BIMODAL_ACCESSOR_B #undef BIMODAL_ACCESSOR_B
#undef BIMODAL_ACCESSOR_C #undef BIMODAL_ACCESSOR_C
......
...@@ -256,6 +256,7 @@ class ContextRef : public HeapObjectRef { ...@@ -256,6 +256,7 @@ class ContextRef : public HeapObjectRef {
class NativeContextRef : public ContextRef { class NativeContextRef : public ContextRef {
public: public:
using ContextRef::ContextRef; using ContextRef::ContextRef;
void Serialize();
#define DECL_ACCESSOR(type, name) type##Ref name() const; #define DECL_ACCESSOR(type, name) type##Ref name() const;
BROKER_NATIVE_CONTEXT_FIELDS(DECL_ACCESSOR) BROKER_NATIVE_CONTEXT_FIELDS(DECL_ACCESSOR)
...@@ -468,8 +469,7 @@ class V8_EXPORT_PRIVATE JSHeapBroker : public NON_EXPORTED_BASE(ZoneObject) { ...@@ -468,8 +469,7 @@ 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_; } Zone* zone() const { return zone_; }
NativeContextRef native_context() const { return native_context_.value(); }
NativeContextRef native_context();
enum BrokerMode { kDisabled, kSerializing, kSerialized }; enum BrokerMode { kDisabled, kSerializing, kSerialized };
BrokerMode mode() const { return mode_; } BrokerMode mode() const { return mode_; }
...@@ -497,6 +497,7 @@ class V8_EXPORT_PRIVATE JSHeapBroker : public NON_EXPORTED_BASE(ZoneObject) { ...@@ -497,6 +497,7 @@ class V8_EXPORT_PRIVATE JSHeapBroker : public NON_EXPORTED_BASE(ZoneObject) {
Isolate* const isolate_; Isolate* const isolate_;
Zone* const zone_; Zone* const zone_;
base::Optional<NativeContextRef> native_context_;
ZoneUnorderedMap<Address, ObjectData*> refs_; ZoneUnorderedMap<Address, ObjectData*> refs_;
BrokerMode mode_; BrokerMode mode_;
}; };
......
...@@ -1307,7 +1307,7 @@ struct TypedLoweringPhase { ...@@ -1307,7 +1307,7 @@ struct TypedLoweringPhase {
data->common(), temp_zone); data->common(), temp_zone);
JSCreateLowering create_lowering(&graph_reducer, data->dependencies(), JSCreateLowering create_lowering(&graph_reducer, data->dependencies(),
data->jsgraph(), data->js_heap_broker(), data->jsgraph(), data->js_heap_broker(),
data->native_context(), temp_zone); temp_zone);
JSTypedLowering typed_lowering(&graph_reducer, data->jsgraph(), JSTypedLowering typed_lowering(&graph_reducer, data->jsgraph(),
data->js_heap_broker(), temp_zone); data->js_heap_broker(), temp_zone);
ConstantFoldingReducer constant_folding_reducer( ConstantFoldingReducer constant_folding_reducer(
......
...@@ -34,10 +34,8 @@ class JSCreateLoweringTest : public TypedGraphTest { ...@@ -34,10 +34,8 @@ class JSCreateLoweringTest : public TypedGraphTest {
javascript_(zone()), javascript_(zone()),
deps_(isolate(), zone()), deps_(isolate(), zone()),
handle_scope_(isolate()) { handle_scope_(isolate()) {
if (FLAG_concurrent_compiler_frontend) {
js_heap_broker()->SerializeStandardObjects(); js_heap_broker()->SerializeStandardObjects();
} }
}
~JSCreateLoweringTest() override = default; ~JSCreateLoweringTest() override = default;
protected: protected:
...@@ -49,7 +47,7 @@ class JSCreateLoweringTest : public TypedGraphTest { ...@@ -49,7 +47,7 @@ class JSCreateLoweringTest : public TypedGraphTest {
// TODO(titzer): mock the GraphReducer here for better unit testing. // TODO(titzer): mock the GraphReducer here for better unit testing.
GraphReducer graph_reducer(zone(), graph()); GraphReducer graph_reducer(zone(), graph());
JSCreateLowering reducer(&graph_reducer, &deps_, &jsgraph, js_heap_broker(), JSCreateLowering reducer(&graph_reducer, &deps_, &jsgraph, js_heap_broker(),
native_context(), zone()); zone());
return reducer.Reduce(node); return reducer.Reduce(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