Commit 2105d237 authored by Santiago Aboy Solanes's avatar Santiago Aboy Solanes Committed by V8 LUCI CQ

[compiler] Mark SourceTextModule as NeverEverSerialized

Bug: v8:7790
Change-Id: I7a658215ba2dbb12e90b651bce7ff08109b03b8e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2987831
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarMichael Stanton <mvstanton@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75703}
parent ee8b9efc
...@@ -1705,87 +1705,14 @@ class SharedFunctionInfoData : public HeapObjectData { ...@@ -1705,87 +1705,14 @@ class SharedFunctionInfoData : public HeapObjectData {
class SourceTextModuleData : public HeapObjectData { class SourceTextModuleData : public HeapObjectData {
public: public:
SourceTextModuleData(JSHeapBroker* broker, ObjectData** storage, SourceTextModuleData(JSHeapBroker* broker, ObjectData** storage,
Handle<SourceTextModule> object);
void Serialize(JSHeapBroker* broker);
ObjectData* GetCell(JSHeapBroker* broker, int cell_index) const;
ObjectData* GetImportMeta(JSHeapBroker* broker) const;
private:
bool serialized_ = false;
ZoneVector<ObjectData*> imports_;
ZoneVector<ObjectData*> exports_;
ObjectData* import_meta_;
};
SourceTextModuleData::SourceTextModuleData(JSHeapBroker* broker,
ObjectData** storage,
Handle<SourceTextModule> object) Handle<SourceTextModule> object)
: HeapObjectData(broker, storage, object), : HeapObjectData(broker, storage, object) {
imports_(broker->zone()), // SourceTextModuleData is NeverEverSerialize.
exports_(broker->zone()), // TODO(solanes, v8:7790): Remove this class once all kNeverSerialized types
import_meta_(nullptr) {} // are NeverEverSerialize.
ObjectData* SourceTextModuleData::GetCell(JSHeapBroker* broker,
int cell_index) const {
if (!serialized_) {
DCHECK(imports_.empty());
TRACE_BROKER_MISSING(broker,
"module cell " << cell_index << " on " << this);
return nullptr;
}
ObjectData* cell;
switch (SourceTextModuleDescriptor::GetCellIndexKind(cell_index)) {
case SourceTextModuleDescriptor::kImport:
cell = imports_.at(SourceTextModule::ImportIndex(cell_index));
break;
case SourceTextModuleDescriptor::kExport:
cell = exports_.at(SourceTextModule::ExportIndex(cell_index));
break;
case SourceTextModuleDescriptor::kInvalid:
UNREACHABLE(); UNREACHABLE();
} }
CHECK_NOT_NULL(cell); };
return cell;
}
ObjectData* SourceTextModuleData::GetImportMeta(JSHeapBroker* broker) const {
CHECK(serialized_);
return import_meta_;
}
void SourceTextModuleData::Serialize(JSHeapBroker* broker) {
if (serialized_) return;
serialized_ = true;
TraceScope tracer(broker, this, "SourceTextModuleData::Serialize");
Handle<SourceTextModule> module = Handle<SourceTextModule>::cast(object());
// TODO(neis): We could be smarter and only serialize the cells we care about.
// TODO(neis): Define a helper for serializing a FixedArray into a ZoneVector.
DCHECK(imports_.empty());
Handle<FixedArray> imports(module->regular_imports(), broker->isolate());
int const imports_length = imports->length();
imports_.reserve(imports_length);
for (int i = 0; i < imports_length; ++i) {
imports_.push_back(broker->GetOrCreateData(imports->get(i)));
}
TRACE(broker, "Copied " << imports_.size() << " imports");
DCHECK(exports_.empty());
Handle<FixedArray> exports(module->regular_exports(), broker->isolate());
int const exports_length = exports->length();
exports_.reserve(exports_length);
for (int i = 0; i < exports_length; ++i) {
exports_.push_back(broker->GetOrCreateData(exports->get(i)));
}
TRACE(broker, "Copied " << exports_.size() << " exports");
DCHECK_NULL(import_meta_);
import_meta_ = broker->GetOrCreateData(module->import_meta(kAcquireLoad));
TRACE(broker, "Copied import_meta");
}
class CellData : public HeapObjectData { class CellData : public HeapObjectData {
public: public:
...@@ -2203,19 +2130,6 @@ base::Optional<ObjectRef> ContextRef::get(int index) const { ...@@ -2203,19 +2130,6 @@ base::Optional<ObjectRef> ContextRef::get(int index) const {
return TryMakeRef(broker(), object()->get(index)); return TryMakeRef(broker(), object()->get(index));
} }
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);
CHECK_EQ(depth, 0);
}
return current.get(Context::EXTENSION_INDEX).value().AsSourceTextModule();
}
#ifdef DEBUG #ifdef DEBUG
void JSHeapBroker::PrintRefsAnalysis() const { void JSHeapBroker::PrintRefsAnalysis() const {
// Usage counts // Usage counts
...@@ -2423,6 +2337,7 @@ NEVER_EVER_SERIALIZE(ObjectBoilerplateDescription) ...@@ -2423,6 +2337,7 @@ NEVER_EVER_SERIALIZE(ObjectBoilerplateDescription)
NEVER_EVER_SERIALIZE(RegExpBoilerplateDescription) NEVER_EVER_SERIALIZE(RegExpBoilerplateDescription)
NEVER_EVER_SERIALIZE(SharedFunctionInfo) NEVER_EVER_SERIALIZE(SharedFunctionInfo)
NEVER_EVER_SERIALIZE(ScopeInfo) NEVER_EVER_SERIALIZE(ScopeInfo)
NEVER_EVER_SERIALIZE(SourceTextModule)
NEVER_EVER_SERIALIZE(String) NEVER_EVER_SERIALIZE(String)
NEVER_EVER_SERIALIZE(Symbol) NEVER_EVER_SERIALIZE(Symbol)
NEVER_EVER_SERIALIZE(TemplateObjectDescription) NEVER_EVER_SERIALIZE(TemplateObjectDescription)
...@@ -3660,21 +3575,11 @@ base::Optional<ObjectRef> JSArrayRef::GetOwnCowElement( ...@@ -3660,21 +3575,11 @@ base::Optional<ObjectRef> JSArrayRef::GetOwnCowElement(
} }
base::Optional<CellRef> SourceTextModuleRef::GetCell(int cell_index) const { base::Optional<CellRef> SourceTextModuleRef::GetCell(int cell_index) const {
if (data_->should_access_heap()) {
return TryMakeRef(broker(), object()->GetCell(cell_index)); return TryMakeRef(broker(), object()->GetCell(cell_index));
}
ObjectData* cell =
data()->AsSourceTextModule()->GetCell(broker(), cell_index);
if (cell == nullptr) return base::nullopt;
return CellRef(broker(), cell);
} }
base::Optional<ObjectRef> SourceTextModuleRef::import_meta() const { base::Optional<ObjectRef> SourceTextModuleRef::import_meta() const {
if (data_->should_access_heap()) {
return TryMakeRef(broker(), object()->import_meta(kAcquireLoad)); return TryMakeRef(broker(), object()->import_meta(kAcquireLoad));
}
return ObjectRef(broker(),
data()->AsSourceTextModule()->GetImportMeta(broker()));
} }
base::Optional<MapRef> HeapObjectRef::map_direct_read() const { base::Optional<MapRef> HeapObjectRef::map_direct_read() const {
...@@ -4036,12 +3941,6 @@ bool MapRef::TrySerializePrototype() { ...@@ -4036,12 +3941,6 @@ bool MapRef::TrySerializePrototype() {
void MapRef::SerializePrototype() { CHECK(TrySerializePrototype()); } void MapRef::SerializePrototype() { CHECK(TrySerializePrototype()); }
void SourceTextModuleRef::Serialize() {
if (data_->should_access_heap()) return;
CHECK_EQ(broker()->mode(), JSHeapBroker::kSerializing);
data()->AsSourceTextModule()->Serialize(broker());
}
void JSTypedArrayRef::Serialize() { void JSTypedArrayRef::Serialize() {
if (data_->should_access_heap() || broker()->is_concurrent_inlining()) { if (data_->should_access_heap() || broker()->is_concurrent_inlining()) {
// Nothing to do. // Nothing to do.
......
...@@ -474,8 +474,6 @@ class ContextRef : public HeapObjectRef { ...@@ -474,8 +474,6 @@ class ContextRef : public HeapObjectRef {
// Only returns a value if the index is valid for this ContextRef. // Only returns a value if the index is valid for this ContextRef.
base::Optional<ObjectRef> get(int index) const; base::Optional<ObjectRef> get(int index) const;
SourceTextModuleRef GetModule() const;
}; };
// TODO(jgruber): Don't serialize NativeContext fields once all refs can be // TODO(jgruber): Don't serialize NativeContext fields once all refs can be
...@@ -964,8 +962,6 @@ class SourceTextModuleRef : public HeapObjectRef { ...@@ -964,8 +962,6 @@ class SourceTextModuleRef : public HeapObjectRef {
Handle<SourceTextModule> object() const; Handle<SourceTextModule> object() const;
void Serialize();
base::Optional<CellRef> GetCell(int cell_index) const; base::Optional<CellRef> GetCell(int cell_index) const;
base::Optional<ObjectRef> import_meta() const; base::Optional<ObjectRef> import_meta() const;
}; };
......
...@@ -41,9 +41,6 @@ Reduction JSHeapCopyReducer::Reduce(Node* node) { ...@@ -41,9 +41,6 @@ Reduction JSHeapCopyReducer::Reduce(Node* node) {
if (object.IsJSObject()) { if (object.IsJSObject()) {
object.AsJSObject().SerializeObjectCreateMap(); object.AsJSObject().SerializeObjectCreateMap();
} }
if (object.IsSourceTextModule()) {
object.AsSourceTextModule().Serialize();
}
break; break;
} }
case IrOpcode::kJSCreateArray: { case IrOpcode::kJSCreateArray: {
......
...@@ -1495,18 +1495,6 @@ void SerializerForBackgroundCompilation::VisitInvokeIntrinsic( ...@@ -1495,18 +1495,6 @@ void SerializerForBackgroundCompilation::VisitInvokeIntrinsic(
Builtin::kCopyDataProperties)); Builtin::kCopyDataProperties));
break; break;
} }
case Runtime::kInlineGetImportMetaObject: {
Hints const& context_hints = environment()->current_context_hints();
for (auto x : context_hints.constants()) {
MakeRef(broker(), Handle<Context>::cast(x)).GetModule().Serialize();
}
for (auto x : context_hints.virtual_contexts()) {
MakeRef(broker(), Handle<Context>::cast(x.context))
.GetModule()
.Serialize();
}
break;
}
default: { default: {
break; break;
} }
...@@ -1638,9 +1626,7 @@ void SerializerForBackgroundCompilation::ProcessModuleVariableAccess( ...@@ -1638,9 +1626,7 @@ void SerializerForBackgroundCompilation::ProcessModuleVariableAccess(
ProcessContextAccess(context_hints, slot, depth, kSerializeSlot, ProcessContextAccess(context_hints, slot, depth, kSerializeSlot,
&result_hints); &result_hints);
for (Handle<Object> constant : result_hints.constants()) { for (Handle<Object> constant : result_hints.constants()) {
ObjectRef object = MakeRef(broker(), constant); MakeRef(broker(), constant);
// For JSTypedLowering::BuildGetModuleCell.
if (object.IsSourceTextModule()) object.AsSourceTextModule().Serialize();
} }
} }
......
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