From 40a355a42d4a9444dc753c04c6608dade2f06a23 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:13:27 +0200 Subject: Adding upstream version 125.0.1. Signed-off-by: Daniel Baumann --- js/src/vm/Scope.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'js/src/vm/Scope.cpp') 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 module) { + Rooted 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 inline size_t SizeOfAllocatedData(DataT* data) { return SizeOfScopeData(data->length); -- cgit v1.2.3