Commit c3bdc076 authored by Jakob Gruber's avatar Jakob Gruber Committed by V8 LUCI CQ

[compiler] Make (Native)Context never-ever serialized

Bug: v8:7790
Change-Id: If558b6db7feed50bd0325a814bcab9e98ebd9493
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2991239
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarSantiago Aboy Solanes <solanes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75463}
parent 55b66b72
......@@ -893,94 +893,23 @@ class HeapNumberData : public HeapObjectData {
class ContextData : public HeapObjectData {
public:
ContextData(JSHeapBroker* broker, ObjectData** storage,
Handle<Context> object);
ObjectData* previous(
JSHeapBroker* broker,
SerializationPolicy policy = SerializationPolicy::kAssumeSerialized);
// Returns nullptr if the slot index isn't valid or wasn't serialized,
// unless {policy} is {kSerializeIfNeeded}.
ObjectData* GetSlot(
JSHeapBroker* broker, int index,
SerializationPolicy policy = SerializationPolicy::kAssumeSerialized);
private:
ZoneMap<int, ObjectData*> slots_;
ObjectData* previous_ = nullptr;
};
ContextData::ContextData(JSHeapBroker* broker, ObjectData** storage,
Handle<Context> object)
: HeapObjectData(broker, storage, object), slots_(broker->zone()) {}
ObjectData* ContextData::previous(JSHeapBroker* broker,
SerializationPolicy policy) {
if (policy == SerializationPolicy::kSerializeIfNeeded &&
previous_ == nullptr) {
TraceScope tracer(broker, this, "ContextData::previous");
Handle<Context> context = Handle<Context>::cast(object());
previous_ = broker->GetOrCreateData(context->unchecked_previous());
}
return previous_;
}
ObjectData* ContextData::GetSlot(JSHeapBroker* broker, int index,
SerializationPolicy policy) {
DCHECK_GE(index, 0);
auto search = slots_.find(index);
if (search != slots_.end()) {
return search->second;
}
if (policy == SerializationPolicy::kSerializeIfNeeded) {
Handle<Context> context = Handle<Context>::cast(object());
if (index < context->length()) {
TraceScope tracer(broker, this, "ContextData::GetSlot");
TRACE(broker, "Serializing context slot " << index);
ObjectData* odata = broker->GetOrCreateData(context->get(index));
slots_.insert(std::make_pair(index, odata));
return odata;
}
Handle<Context> object)
: HeapObjectData(broker, storage, object) {
// TODO(v8:7790): Remove this class once all kNeverSerialized types are
// NeverEverSerialize.
UNREACHABLE();
}
return nullptr;
}
};
class NativeContextData : public ContextData {
public:
#define DECL_ACCESSOR(type, name) \
ObjectData* name() const { return name##_; }
BROKER_NATIVE_CONTEXT_FIELDS(DECL_ACCESSOR)
#undef DECL_ACCESSOR
const ZoneVector<ObjectData*>& function_maps() const {
CHECK_NE(state_, State::kUnserialized);
return function_maps_;
}
ObjectData* scope_info() const {
CHECK_NE(state_, State::kUnserialized);
return scope_info_;
}
NativeContextData(JSHeapBroker* broker, ObjectData** storage,
Handle<NativeContext> object);
void Serialize(JSHeapBroker* broker);
void SerializeOnBackground(JSHeapBroker* broker);
private:
// After Serialize is called the class is partially serialized and it the
// kSerializedOnMainThread state. It then becomes kFullySerialized once
// SerializeOnBackground is called.
enum class State { kUnserialized, kSerializedOnMainThread, kFullySerialized };
State state_;
#define DECL_MEMBER(type, name) ObjectData* name##_ = nullptr;
BROKER_NATIVE_CONTEXT_FIELDS(DECL_MEMBER)
#undef DECL_MEMBER
ZoneVector<ObjectData*> function_maps_;
ObjectData* scope_info_ = nullptr;
Handle<NativeContext> object)
: ContextData(broker, storage, object) {
// TODO(v8:7790): Remove this class once all kNeverSerialized types are
// NeverEverSerialize.
UNREACHABLE();
}
};
class NameData : public HeapObjectData {
......@@ -2322,12 +2251,12 @@ class CodeDataContainerData : public HeapObjectData {
HEAP_BROKER_OBJECT_LIST(DEFINE_IS)
#undef DEFINE_IS
#define DEFINE_AS(Name, Kind) \
Name##Data* ObjectData::As##Name() { \
CHECK(Is##Name()); \
CHECK(kind_ == kSerializedHeapObject || \
kind_ == kBackgroundSerializedHeapObject); \
return static_cast<Name##Data*>(this); \
#define DEFINE_AS(Name, Kind) \
Name##Data* ObjectData::As##Name() { \
CHECK(Is##Name()); \
CHECK(kind_ == kSerializedHeapObject || \
kind_ == kBackgroundSerializedHeapObject); \
return static_cast<Name##Data*>(this); \
}
HEAP_BROKER_OBJECT_LIST(DEFINE_AS)
#undef DEFINE_AS
......@@ -2572,51 +2501,34 @@ bool ObjectRef::equals(const ObjectRef& other) const {
Isolate* ObjectRef::isolate() const { return broker()->isolate(); }
ContextRef ContextRef::previous(size_t* depth,
SerializationPolicy policy) const {
ContextRef ContextRef::previous(size_t* depth) const {
DCHECK_NOT_NULL(depth);
if (data_->should_access_heap()) {
Context current = *object();
while (*depth != 0 && current.unchecked_previous().IsContext()) {
current = Context::cast(current.unchecked_previous());
(*depth)--;
}
return MakeRef(broker(), current);
Context current = *object();
while (*depth != 0 && current.unchecked_previous().IsContext()) {
current = Context::cast(current.unchecked_previous());
(*depth)--;
}
if (*depth == 0) return *this;
ObjectData* previous_data = data()->AsContext()->previous(broker(), policy);
if (previous_data == nullptr || !previous_data->IsContext()) return *this;
*depth = *depth - 1;
return ContextRef(broker(), previous_data).previous(depth, policy);
return MakeRef(broker(), current);
}
base::Optional<ObjectRef> ContextRef::get(int index,
SerializationPolicy policy) const {
base::Optional<ObjectRef> ContextRef::get(int index) const {
CHECK_LE(0, index);
if (data_->should_access_heap()) {
if (index >= object()->length()) return {};
return TryMakeRef(broker(), object()->get(index));
}
ObjectData* optional_slot =
data()->AsContext()->GetSlot(broker(), index, policy);
if (optional_slot == nullptr) return {};
return ObjectRef(broker(), optional_slot);
if (index >= object()->length()) return {};
return TryMakeRef(broker(), object()->get(index));
}
SourceTextModuleRef ContextRef::GetModule(SerializationPolicy policy) const {
SourceTextModuleRef ContextRef::GetModule() const {
// Only called by the serializer.
// TODO(v8:7790): Remove this method once the serialization phase is gone.
CHECK(broker()->IsMainThread());
ContextRef current = *this;
while (current.map().instance_type() != MODULE_CONTEXT_TYPE) {
size_t depth = 1;
current = current.previous(&depth, policy);
current = current.previous(&depth);
CHECK_EQ(depth, 0);
}
return current.get(Context::EXTENSION_INDEX, policy)
.value()
.AsSourceTextModule();
return current.get(Context::EXTENSION_INDEX).value().AsSourceTextModule();
}
#ifdef DEBUG
......@@ -2717,11 +2629,6 @@ void JSHeapBroker::InitializeAndStartSerializing() {
SetTargetNativeContextRef(target_native_context().object());
target_native_context().Serialize();
if (!is_concurrent_inlining()) {
// Perform full native context serialization now if we can't do it later on
// the background thread.
target_native_context().SerializeOnBackground();
}
Factory* const f = isolate()->factory();
if (!is_concurrent_inlining()) {
......@@ -2756,9 +2663,8 @@ namespace {
template <RefSerializationKind Kind, class DataT, class ObjectT>
struct CreateDataFunctor {
bool operator()(JSHeapBroker* broker, RefsMap* refs,
Handle<Object> object, RefsMap::Entry** entry_out,
ObjectData** object_data_out) {
bool operator()(JSHeapBroker* broker, RefsMap* refs, Handle<Object> object,
RefsMap::Entry** entry_out, ObjectData** object_data_out) {
USE(broker, refs, object, entry_out, object_data_out);
UNREACHABLE();
}
......@@ -2766,9 +2672,8 @@ struct CreateDataFunctor {
template <class DataT, class ObjectT>
struct CreateDataFunctor<RefSerializationKind::kSerialized, DataT, ObjectT> {
bool operator()(JSHeapBroker* broker, RefsMap* refs,
Handle<Object> object, RefsMap::Entry** entry_out,
ObjectData** object_data_out) {
bool operator()(JSHeapBroker* broker, RefsMap* refs, Handle<Object> object,
RefsMap::Entry** entry_out, ObjectData** object_data_out) {
if (broker->mode() == JSHeapBroker::kSerializing) {
RefsMap::Entry* entry = refs->LookupOrInsert(object.address());
*object_data_out = broker->zone()->New<DataT>(
......@@ -2783,9 +2688,8 @@ struct CreateDataFunctor<RefSerializationKind::kSerialized, DataT, ObjectT> {
template <class DataT, class ObjectT>
struct CreateDataFunctor<RefSerializationKind::kBackgroundSerialized, DataT,
ObjectT> {
bool operator()(JSHeapBroker* broker, RefsMap* refs,
Handle<Object> object, RefsMap::Entry** entry_out,
ObjectData** object_data_out) {
bool operator()(JSHeapBroker* broker, RefsMap* refs, Handle<Object> object,
RefsMap::Entry** entry_out, ObjectData** object_data_out) {
if (broker->is_concurrent_inlining()) {
RefsMap::Entry* entry = refs->LookupOrInsert(object.address());
*object_data_out = broker->zone()->New<DataT>(
......@@ -2823,6 +2727,8 @@ bool NeverEverSerialize() {
NEVER_EVER_SERIALIZE(ArrayBoilerplateDescription)
NEVER_EVER_SERIALIZE(BytecodeArray)
NEVER_EVER_SERIALIZE(Cell)
NEVER_EVER_SERIALIZE(Context)
NEVER_EVER_SERIALIZE(NativeContext)
NEVER_EVER_SERIALIZE(ObjectBoilerplateDescription)
NEVER_EVER_SERIALIZE(RegExpBoilerplateDescription)
NEVER_EVER_SERIALIZE(TemplateObjectDescription)
......@@ -3803,7 +3709,6 @@ void NativeContextRef::Serialize() {
// then, we *must* iterate them and create refs at serialization-time (even
// though NativeContextRef itself is never-serialized).
CHECK_EQ(broker()->mode(), JSHeapBroker::kSerializing);
if (data_->should_access_heap()) {
#define SERIALIZE_MEMBER(type, name) \
{ \
ObjectData* member_data = broker()->GetOrCreateData(object()->name()); \
......@@ -3815,44 +3720,29 @@ void NativeContextRef::Serialize() {
member_data->AsJSFunction()->Serialize(broker()); \
} \
}
BROKER_COMPULSORY_NATIVE_CONTEXT_FIELDS(SERIALIZE_MEMBER)
BROKER_OPTIONAL_NATIVE_CONTEXT_FIELDS(SERIALIZE_MEMBER)
BROKER_NATIVE_CONTEXT_FIELDS(SERIALIZE_MEMBER)
#undef SERIALIZE_MEMBER
} else {
data()->AsNativeContext()->Serialize(broker());
}
}
void NativeContextRef::SerializeOnBackground() {
if (data_->should_access_heap()) return;
CHECK(broker()->mode() == JSHeapBroker::kSerializing ||
broker()->mode() == JSHeapBroker::kSerialized);
data()->AsNativeContext()->SerializeOnBackground(broker());
}
bool NativeContextRef::is_unserialized_heap_object() const {
return data_->kind() == kUnserializedHeapObject;
for (int i = Context::FIRST_FUNCTION_MAP_INDEX;
i <= Context::LAST_FUNCTION_MAP_INDEX; i++) {
MapData* member_data = broker()->GetOrCreateData(object()->get(i))->AsMap();
if (!InstanceTypeChecker::IsContext(member_data->instance_type())) {
member_data->SerializeConstructor(broker());
}
}
}
ScopeInfoRef NativeContextRef::scope_info() const {
if (data_->should_access_heap()) {
// The scope_info is immutable after initialization.
return MakeRefAssumeMemoryFence(broker(), object()->scope_info());
}
return ScopeInfoRef(broker(), data()->AsNativeContext()->scope_info());
// The scope_info is immutable after initialization.
return MakeRefAssumeMemoryFence(broker(), object()->scope_info());
}
MapRef NativeContextRef::GetFunctionMapFromIndex(int index) const {
DCHECK_GE(index, Context::FIRST_FUNCTION_MAP_INDEX);
DCHECK_LE(index, Context::LAST_FUNCTION_MAP_INDEX);
if (data_->should_access_heap()) {
CHECK_LT(index, object()->length());
return MakeRefAssumeMemoryFence(broker(),
object()->get(index, kAcquireLoad))
.AsMap();
}
return MapRef(broker(), data()->AsNativeContext()->function_maps().at(
index - Context::FIRST_FUNCTION_MAP_INDEX));
CHECK_LT(index, object()->length());
return MakeRefAssumeMemoryFence(
broker(), Map::cast(object()->get(index, kAcquireLoad)));
}
MapRef NativeContextRef::GetInitialJSArrayMap(ElementsKind kind) const {
......@@ -3874,14 +3764,10 @@ MapRef NativeContextRef::GetInitialJSArrayMap(ElementsKind kind) const {
}
}
#define DEF_NATIVE_CONTEXT_ACCESSOR(ResultType, Name) \
ResultType##Ref NativeContextRef::Name() const { \
if (data_->should_access_heap()) { \
return MakeRefAssumeMemoryFence( \
broker(), ResultType::cast(object()->Name(kAcquireLoad))); \
} \
return ResultType##Ref(broker(), \
ObjectRef::data()->AsNativeContext()->Name()); \
#define DEF_NATIVE_CONTEXT_ACCESSOR(ResultType, Name) \
ResultType##Ref NativeContextRef::Name() const { \
return MakeRefAssumeMemoryFence( \
broker(), ResultType::cast(object()->Name(kAcquireLoad))); \
}
BROKER_NATIVE_CONTEXT_FIELDS(DEF_NATIVE_CONTEXT_ACCESSOR)
#undef DEF_NATIVE_CONTEXT_ACCESSOR
......@@ -4373,80 +4259,6 @@ Reduction NoChangeBecauseOfMissingData(JSHeapBroker* broker,
return AdvancedReducer::NoChange();
}
NativeContextData::NativeContextData(JSHeapBroker* broker, ObjectData** storage,
Handle<NativeContext> object)
: ContextData(broker, storage, object),
state_(State::kUnserialized),
function_maps_(broker->zone()) {}
void NativeContextData::Serialize(JSHeapBroker* broker) {
if (state_ != State::kUnserialized) return;
state_ = State::kSerializedOnMainThread;
TraceScope tracer(broker, this, "NativeContextData::Serialize");
Handle<NativeContext> context = Handle<NativeContext>::cast(object());
#define SERIALIZE_MEMBER(type, name) \
DCHECK_NULL(name##_); \
name##_ = broker->GetOrCreateData(context->name()); \
if (!name##_->should_access_heap()) { \
if (name##_->IsMap() && \
!InstanceTypeChecker::IsContext(name##_->AsMap()->instance_type())) { \
name##_->AsMap()->SerializeConstructor(broker); \
} \
if (name##_->IsJSFunction()) { \
name##_->AsJSFunction()->Serialize(broker); \
} \
}
BROKER_COMPULSORY_NATIVE_CONTEXT_FIELDS(SERIALIZE_MEMBER)
if (!broker->is_isolate_bootstrapping()) {
BROKER_OPTIONAL_NATIVE_CONTEXT_FIELDS(SERIALIZE_MEMBER)
}
#undef SERIALIZE_MEMBER
if (!bound_function_with_constructor_map_->should_access_heap()) {
bound_function_with_constructor_map_->AsMap()->SerializePrototype(broker);
}
if (!bound_function_without_constructor_map_->should_access_heap()) {
bound_function_without_constructor_map_->AsMap()->SerializePrototype(
broker);
}
scope_info_ = broker->GetOrCreateData(context->scope_info());
}
void NativeContextData::SerializeOnBackground(JSHeapBroker* broker) {
if (state_ == State::kFullySerialized) return;
DCHECK_EQ(state_, State::kSerializedOnMainThread);
state_ = State::kSerializedOnMainThread;
UnparkedScopeIfNeeded unparked_scope(broker);
TraceScope tracer(broker, this, "NativeContextData::SerializeOnBackground");
Handle<NativeContext> context = Handle<NativeContext>::cast(object());
#define SERIALIZE_MEMBER(type, name) \
DCHECK_NULL(name##_); \
name##_ = broker->GetOrCreateData(context->name(kAcquireLoad), \
kAssumeMemoryFence); \
if (!name##_->should_access_heap()) { \
DCHECK(!name##_->IsJSFunction()); \
}
BROKER_COMPULSORY_BACKGROUND_NATIVE_CONTEXT_FIELDS(SERIALIZE_MEMBER)
if (!broker->is_isolate_bootstrapping()) {
BROKER_OPTIONAL_BACKGROUND_NATIVE_CONTEXT_FIELDS(SERIALIZE_MEMBER)
}
#undef SERIALIZE_MEMBER
DCHECK(function_maps_.empty());
int const first = Context::FIRST_FUNCTION_MAP_INDEX;
int const last = Context::LAST_FUNCTION_MAP_INDEX;
function_maps_.reserve(last + 1 - first);
for (int i = first; i <= last; ++i) {
function_maps_.push_back(broker->GetOrCreateData(
context->get(i, kAcquireLoad), kAssumeMemoryFence));
}
}
void JSFunctionRef::Serialize() {
if (data_->should_access_heap()) return;
CHECK_EQ(broker()->mode(), JSHeapBroker::kSerializing);
......
......@@ -464,91 +464,69 @@ class ContextRef : public HeapObjectRef {
// {previous} decrements {depth} by 1 for each previous link successfully
// followed. If {depth} != 0 on function return, then it only got partway to
// the desired depth. If {serialize} is true, then {previous} will cache its
// findings (unless concurrent inlining is enabled).
ContextRef previous(size_t* depth,
SerializationPolicy policy =
SerializationPolicy::kAssumeSerialized) const;
// the desired depth.
ContextRef previous(size_t* depth) const;
// Only returns a value if the index is valid for this ContextRef.
base::Optional<ObjectRef> get(
int index, SerializationPolicy policy =
SerializationPolicy::kAssumeSerialized) const;
base::Optional<ObjectRef> get(int index) const;
SourceTextModuleRef GetModule(SerializationPolicy policy) const;
SourceTextModuleRef GetModule() const;
};
// TODO(jgruber): Don't serialize NativeContext fields once all refs can be
// created concurrently.
#define BROKER_COMPULSORY_NATIVE_CONTEXT_FIELDS(V) \
V(JSFunction, array_function) \
V(JSFunction, function_prototype_apply) \
V(JSFunction, boolean_function) \
V(JSFunction, bigint_function) \
V(JSFunction, number_function) \
V(JSFunction, object_function) \
V(JSFunction, promise_function) \
V(JSFunction, promise_then) \
V(JSFunction, regexp_function) \
V(JSFunction, string_function) \
V(JSFunction, symbol_function) \
V(JSGlobalObject, global_object) \
V(JSGlobalProxy, global_proxy_object) \
V(JSObject, promise_prototype) \
V(Map, bound_function_with_constructor_map) \
V(Map, bound_function_without_constructor_map) \
V(Map, js_array_holey_double_elements_map) \
V(Map, js_array_holey_elements_map) \
V(Map, js_array_holey_smi_elements_map) \
V(Map, js_array_packed_double_elements_map) \
V(Map, js_array_packed_elements_map) \
V(Map, js_array_packed_smi_elements_map) \
#define BROKER_NATIVE_CONTEXT_FIELDS(V) \
V(JSFunction, array_function) \
V(JSFunction, bigint_function) \
V(JSFunction, boolean_function) \
V(JSFunction, function_prototype_apply) \
V(JSFunction, number_function) \
V(JSFunction, object_function) \
V(JSFunction, promise_function) \
V(JSFunction, promise_then) \
V(JSFunction, regexp_exec_function) \
V(JSFunction, regexp_function) \
V(JSFunction, string_function) \
V(JSFunction, symbol_function) \
V(JSGlobalObject, global_object) \
V(JSGlobalProxy, global_proxy_object) \
V(JSObject, promise_prototype) \
V(Map, async_function_object_map) \
V(Map, block_context_map) \
V(Map, bound_function_with_constructor_map) \
V(Map, bound_function_without_constructor_map) \
V(Map, catch_context_map) \
V(Map, eval_context_map) \
V(Map, fast_aliased_arguments_map) \
V(Map, function_context_map) \
V(Map, initial_array_iterator_map) \
V(Map, initial_string_iterator_map) \
V(Map, iterator_result_map) \
V(Map, js_array_holey_double_elements_map) \
V(Map, js_array_holey_elements_map) \
V(Map, js_array_holey_smi_elements_map) \
V(Map, js_array_packed_double_elements_map) \
V(Map, js_array_packed_elements_map) \
V(Map, js_array_packed_smi_elements_map) \
V(Map, map_key_iterator_map) \
V(Map, map_key_value_iterator_map) \
V(Map, map_value_iterator_map) \
V(Map, set_key_value_iterator_map) \
V(Map, set_value_iterator_map) \
V(Map, sloppy_arguments_map) \
V(Map, slow_object_with_null_prototype_map) \
V(Map, strict_arguments_map) \
V(Map, with_context_map) \
V(ScriptContextTable, script_context_table)
#define BROKER_OPTIONAL_NATIVE_CONTEXT_FIELDS(V) \
V(JSFunction, regexp_exec_function)
#define BROKER_COMPULSORY_BACKGROUND_NATIVE_CONTEXT_FIELDS(V) \
V(Map, block_context_map) \
V(Map, catch_context_map) \
V(Map, eval_context_map) \
V(Map, fast_aliased_arguments_map) \
V(Map, function_context_map) \
V(Map, initial_array_iterator_map) \
V(Map, initial_string_iterator_map) \
V(Map, iterator_result_map) \
V(Map, sloppy_arguments_map) \
V(Map, slow_object_with_null_prototype_map) \
V(Map, strict_arguments_map) \
V(Map, with_context_map)
// Those are set by Bootstrapper::ExportFromRuntime, which may not yet have
// happened when Turbofan is invoked via --always-opt.
#define BROKER_OPTIONAL_BACKGROUND_NATIVE_CONTEXT_FIELDS(V) \
V(Map, async_function_object_map) \
V(Map, map_key_iterator_map) \
V(Map, map_key_value_iterator_map) \
V(Map, map_value_iterator_map) \
V(Map, set_key_value_iterator_map) \
V(Map, set_value_iterator_map)
#define BROKER_NATIVE_CONTEXT_FIELDS(V) \
BROKER_COMPULSORY_NATIVE_CONTEXT_FIELDS(V) \
BROKER_OPTIONAL_NATIVE_CONTEXT_FIELDS(V) \
BROKER_COMPULSORY_BACKGROUND_NATIVE_CONTEXT_FIELDS(V) \
BROKER_OPTIONAL_BACKGROUND_NATIVE_CONTEXT_FIELDS(V)
class NativeContextRef : public ContextRef {
public:
DEFINE_REF_CONSTRUCTOR(NativeContext, ContextRef)
bool is_unserialized_heap_object() const;
Handle<NativeContext> object() const;
void Serialize();
void SerializeOnBackground();
#define DECL_ACCESSOR(type, name) type##Ref name() const;
BROKER_NATIVE_CONTEXT_FIELDS(DECL_ACCESSOR)
......
......@@ -257,9 +257,10 @@ Reduction JSContextSpecialization::ReduceJSGetImportMeta(Node* node) {
if (!maybe_context.has_value()) return NoChange();
ContextRef context = maybe_context.value();
SourceTextModuleRef module =
context.get(Context::EXTENSION_INDEX).value().AsSourceTextModule();
base::Optional<ObjectRef> import_meta = module.import_meta();
base::Optional<ObjectRef> module = context.get(Context::EXTENSION_INDEX);
if (!module.has_value()) return NoChange();
base::Optional<ObjectRef> import_meta =
module->AsSourceTextModule().import_meta();
if (!import_meta.has_value()) return NoChange();
if (!import_meta->IsJSObject()) {
DCHECK(import_meta->IsTheHole());
......
......@@ -102,12 +102,6 @@ void JSHeapBroker::AttachLocalIsolate(OptimizedCompilationInfo* info,
DCHECK_NOT_NULL(local_isolate_);
local_isolate_->heap()->AttachPersistentHandles(
info->DetachPersistentHandles());
if (is_concurrent_inlining()) {
// Ensure any serialization that happens on the background has been
// performed.
target_native_context().SerializeOnBackground();
}
}
void JSHeapBroker::DetachLocalIsolate(OptimizedCompilationInfo* info) {
......@@ -140,8 +134,7 @@ void JSHeapBroker::SetTargetNativeContextRef(
Handle<NativeContext> native_context) {
DCHECK((mode() == kDisabled && !target_native_context_.has_value()) ||
(mode() == kSerializing &&
target_native_context_->object().is_identical_to(native_context) &&
target_native_context_->is_unserialized_heap_object()));
target_native_context_->object().is_identical_to(native_context)));
target_native_context_ = MakeRef(this, *native_context);
}
......@@ -700,8 +693,7 @@ ProcessedFeedback const& JSHeapBroker::ReadFeedbackForGlobalAccess(
}
ContextRef context_ref = MakeRef(this, context);
if (immutable) {
context_ref.get(context_slot_index,
SerializationPolicy::kSerializeIfNeeded);
context_ref.get(context_slot_index);
}
return *zone()->New<GlobalAccessFeedback>(context_ref, context_slot_index,
immutable, nexus.kind());
......
......@@ -1498,13 +1498,11 @@ void SerializerForBackgroundCompilation::VisitInvokeIntrinsic(
case Runtime::kInlineGetImportMetaObject: {
Hints const& context_hints = environment()->current_context_hints();
for (auto x : context_hints.constants()) {
MakeRef(broker(), Handle<Context>::cast(x))
.GetModule(SerializationPolicy::kSerializeIfNeeded)
.Serialize();
MakeRef(broker(), Handle<Context>::cast(x)).GetModule().Serialize();
}
for (auto x : context_hints.virtual_contexts()) {
MakeRef(broker(), Handle<Context>::cast(x.context))
.GetModule(SerializationPolicy::kSerializeIfNeeded)
.GetModule()
.Serialize();
}
break;
......@@ -1546,8 +1544,7 @@ void SerializerForBackgroundCompilation::ProcessImmutableLoad(
ContextRef const& context_ref, int slot, ContextProcessingMode mode,
Hints* result_hints) {
DCHECK_EQ(mode, kSerializeSlot);
base::Optional<ObjectRef> slot_value =
context_ref.get(slot, SerializationPolicy::kSerializeIfNeeded);
base::Optional<ObjectRef> slot_value = context_ref.get(slot);
// If requested, record the object as a hint for the result value.
if (result_hints != nullptr && slot_value.has_value()) {
......@@ -1568,8 +1565,7 @@ void SerializerForBackgroundCompilation::ProcessContextAccess(
// Walk this context to the given depth and serialize the slot found.
ContextRef context_ref = MakeRef(broker(), Handle<Context>::cast(x));
size_t remaining_depth = depth;
context_ref = context_ref.previous(
&remaining_depth, SerializationPolicy::kSerializeIfNeeded);
context_ref = context_ref.previous(&remaining_depth);
if (remaining_depth == 0 && mode != kIgnoreSlot) {
ProcessImmutableLoad(context_ref, slot, mode, result_hints);
}
......@@ -1580,8 +1576,7 @@ void SerializerForBackgroundCompilation::ProcessContextAccess(
ContextRef context_ref =
MakeRef(broker(), Handle<Context>::cast(x.context));
size_t remaining_depth = depth - x.distance;
context_ref = context_ref.previous(
&remaining_depth, SerializationPolicy::kSerializeIfNeeded);
context_ref = context_ref.previous(&remaining_depth);
if (remaining_depth == 0 && mode != kIgnoreSlot) {
ProcessImmutableLoad(context_ref, slot, mode, result_hints);
}
......@@ -1994,10 +1989,7 @@ void SerializerForBackgroundCompilation::VisitCallJSRuntime(
BytecodeArrayIterator* iterator) {
const int runtime_index = iterator->GetNativeContextIndexOperand(0);
ObjectRef constant =
broker()
->target_native_context()
.get(runtime_index, SerializationPolicy::kSerializeIfNeeded)
.value();
broker()->target_native_context().get(runtime_index).value();
Hints const callee = Hints::SingleConstant(constant.object(), zone());
interpreter::Register first_reg = iterator->GetRegisterOperand(1);
int reg_count = static_cast<int>(iterator->GetRegisterCountOperand(2));
......
......@@ -694,7 +694,7 @@ class NativeContext : public Context {
// initialization. This function should *not* be used from anywhere other
// than heap-refs.cc.
// TODO(jgruber): Remove this function after NativeContextRef is actually
// never serialized and BROKER_COMPULSORY_NATIVE_CONTEXT_FIELDS is removed.
// never serialized and BROKER_NATIVE_CONTEXT_FIELDS is removed.
JSGlobalObject global_object() { return Context::global_object(); }
JSGlobalObject global_object(AcquireLoadTag) {
return Context::global_object();
......
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