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
: public NON_EXPORTED_BASE(AdvancedReducer) {
public:
JSCreateLowering(Editor* editor, CompilationDependencies* dependencies,
JSGraph* jsgraph, JSHeapBroker* js_heap_broker,
Handle<Context> native_context, Zone* zone)
JSGraph* jsgraph, JSHeapBroker* js_heap_broker, Zone* zone)
: AdvancedReducer(editor),
dependencies_(dependencies),
jsgraph_(jsgraph),
js_heap_broker_(js_heap_broker),
native_context_(native_context),
zone_(zone) {}
~JSCreateLowering() final = default;
......@@ -116,8 +114,7 @@ class V8_EXPORT_PRIVATE JSCreateLowering final
Graph* graph() const;
JSGraph* jsgraph() const { return jsgraph_; }
Isolate* isolate() const;
Handle<Context> native_context() const { return native_context_; }
NativeContextRef native_context_ref() const;
NativeContextRef native_context() const;
CommonOperatorBuilder* common() const;
SimplifiedOperatorBuilder* simplified() const;
CompilationDependencies* dependencies() const { return dependencies_; }
......@@ -127,7 +124,6 @@ class V8_EXPORT_PRIVATE JSCreateLowering final
CompilationDependencies* const dependencies_;
JSGraph* const jsgraph_;
JSHeapBroker* const js_heap_broker_;
Handle<Context> const native_context_;
Zone* const zone_;
};
......
......@@ -1219,6 +1219,11 @@ bool JSHeapBroker::SerializingAllowed() const {
}
void JSHeapBroker::SerializeStandardObjects() {
if (!native_context_.has_value()) {
native_context_ = NativeContextRef(this, isolate()->native_context());
native_context_->Serialize();
}
if (mode() == kDisabled) return;
Trace("Serializing standard objects.\n");
......@@ -1332,8 +1337,6 @@ void JSHeapBroker::SerializeStandardObjects() {
}
}
GetOrCreateData(isolate()->native_context())->AsNativeContext()->Serialize();
Trace("Finished serializing standard objects.\n");
}
......@@ -1397,11 +1400,6 @@ int ObjectRef::AsSmi() const {
return object<Smi>()->value();
}
NativeContextRef JSHeapBroker::native_context() {
AllowHandleAllocation handle_allocation;
return NativeContextRef(this, isolate()->native_context());
}
base::Optional<MapRef> JSObjectRef::GetObjectCreateMap() const {
if (broker()->mode() == JSHeapBroker::kDisabled) {
AllowHandleAllocation handle_allocation;
......@@ -2120,6 +2118,12 @@ void ContextRef::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_B
#undef BIMODAL_ACCESSOR_C
......
......@@ -256,6 +256,7 @@ class ContextRef : public HeapObjectRef {
class NativeContextRef : public ContextRef {
public:
using ContextRef::ContextRef;
void Serialize();
#define DECL_ACCESSOR(type, name) type##Ref name() const;
BROKER_NATIVE_CONTEXT_FIELDS(DECL_ACCESSOR)
......@@ -468,8 +469,7 @@ class V8_EXPORT_PRIVATE JSHeapBroker : public NON_EXPORTED_BASE(ZoneObject) {
Isolate* isolate() const { return isolate_; }
Zone* zone() const { return zone_; }
NativeContextRef native_context();
NativeContextRef native_context() const { return native_context_.value(); }
enum BrokerMode { kDisabled, kSerializing, kSerialized };
BrokerMode mode() const { return mode_; }
......@@ -497,6 +497,7 @@ class V8_EXPORT_PRIVATE JSHeapBroker : public NON_EXPORTED_BASE(ZoneObject) {
Isolate* const isolate_;
Zone* const zone_;
base::Optional<NativeContextRef> native_context_;
ZoneUnorderedMap<Address, ObjectData*> refs_;
BrokerMode mode_;
};
......
......@@ -1307,7 +1307,7 @@ struct TypedLoweringPhase {
data->common(), temp_zone);
JSCreateLowering create_lowering(&graph_reducer, data->dependencies(),
data->jsgraph(), data->js_heap_broker(),
data->native_context(), temp_zone);
temp_zone);
JSTypedLowering typed_lowering(&graph_reducer, data->jsgraph(),
data->js_heap_broker(), temp_zone);
ConstantFoldingReducer constant_folding_reducer(
......
......@@ -34,9 +34,7 @@ class JSCreateLoweringTest : public TypedGraphTest {
javascript_(zone()),
deps_(isolate(), zone()),
handle_scope_(isolate()) {
if (FLAG_concurrent_compiler_frontend) {
js_heap_broker()->SerializeStandardObjects();
}
js_heap_broker()->SerializeStandardObjects();
}
~JSCreateLoweringTest() override = default;
......@@ -49,7 +47,7 @@ class JSCreateLoweringTest : public TypedGraphTest {
// TODO(titzer): mock the GraphReducer here for better unit testing.
GraphReducer graph_reducer(zone(), graph());
JSCreateLowering reducer(&graph_reducer, &deps_, &jsgraph, js_heap_broker(),
native_context(), zone());
zone());
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