Skip to content

Commit 9260358

Browse files
Atul Kattipleath
authored andcommitted
1 parent 6a1c942 commit 9260358

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lib/Runtime/Types/SimpleTypeHandler.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,17 @@ namespace Js
190190
false);
191191
newTypeHandler->SetMayBecomeShared();
192192

193+
#if ENABLE_FIXED_FIELDS
194+
#ifdef SUPPORT_FIXED_FIELDS_ON_PATH_TYPES
195+
Assert(HasSingletonInstanceOnlyIfNeeded());
196+
197+
// If instance has a shared type, the type handler change below will induce a type transition, which
198+
// guarantees that any existing fast path field stores (which could quietly overwrite a fixed field
199+
// on this instance) will be invalidated. It is safe to mark all fields as fixed.
200+
bool const allowFixedFields = DynamicTypeHandler::AreSingletonInstancesNeeded() && instance->HasLockedType();
201+
#endif
202+
#endif
203+
193204
DynamicType *existingType = instance->GetDynamicType();
194205
DynamicType *currentType = DynamicType::New(scriptContext, existingType->GetTypeId(), existingType->GetPrototype(), nullptr, newTypeHandler, false, false);
195206
PropertyId propertyId = Constants::NoProperty;
@@ -205,7 +216,7 @@ namespace Js
205216
newTypeHandler = PathTypeHandlerBase::FromTypeHandler(currentType->GetTypeHandler());
206217
#if ENABLE_FIXED_FIELDS
207218
#ifdef SUPPORT_FIXED_FIELDS_ON_PATH_TYPES
208-
bool markAsFixed = !IsInternalPropertyId(propertyId) &&
219+
bool markAsFixed = allowFixedFields && !IsInternalPropertyId(propertyId) &&
209220
(JavascriptFunction::Is(value) ? ShouldFixMethodProperties() : false);
210221
newTypeHandler->InitializePath(instance, i, newTypeHandler->GetPathLength(), scriptContext, [=]() { return markAsFixed; });
211222
#endif

0 commit comments

Comments
 (0)