summaryrefslogtreecommitdiffstats
path: root/js/src/vm/Scope.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:27 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:27 +0000
commit40a355a42d4a9444dc753c04c6608dade2f06a23 (patch)
tree871fc667d2de662f171103ce5ec067014ef85e61 /js/src/vm/Scope.cpp
parentAdding upstream version 124.0.1. (diff)
downloadfirefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz
firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/vm/Scope.cpp')
-rw-r--r--js/src/vm/Scope.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/js/src/vm/Scope.cpp b/js/src/vm/Scope.cpp
index c48d0976d8..45cbeb6419 100644
--- a/js/src/vm/Scope.cpp
+++ b/js/src/vm/Scope.cpp
@@ -148,6 +148,33 @@ SharedShape* js::CreateEnvironmentShape(JSContext* cx, BindingIter& bi,
map, mapLength, objectFlags);
}
+SharedShape* js::CreateEnvironmentShapeForSyntheticModule(
+ JSContext* cx, const JSClass* cls, uint32_t numSlots,
+ Handle<ModuleObject*> module) {
+ Rooted<SharedPropMap*> map(cx);
+ uint32_t mapLength = 0;
+
+ PropertyFlags propFlags = {PropertyFlag::Enumerable};
+ ObjectFlags objectFlags = ModuleEnvironmentObject::OBJECT_FLAGS;
+
+ RootedId id(cx);
+ uint32_t slotIndex = numSlots;
+ for (JSAtom* exportName : module->syntheticExportNames()) {
+ id = NameToId(exportName->asPropertyName());
+ if (!SharedPropMap::addPropertyWithKnownSlot(cx, cls, &map, &mapLength, id,
+ propFlags, slotIndex,
+ &objectFlags)) {
+ return nullptr;
+ }
+ slotIndex++;
+ }
+
+ uint32_t numFixed = gc::GetGCKindSlots(gc::GetGCObjectKind(numSlots));
+ return SharedShape::getInitialOrPropMapShape(cx, cls, cx->realm(),
+ TaggedProto(nullptr), numFixed,
+ map, mapLength, objectFlags);
+}
+
template <class DataT>
inline size_t SizeOfAllocatedData(DataT* data) {
return SizeOfScopeData<DataT>(data->length);