Skip to content

Commit 08d7955

Browse files
committed
[MERGE #3566 @curtisman] Disable fixed field and equivalent type spec code from DISABLE_JIT builds
Merge pull request #3566 from curtisman:lite2 Put equivalent type spec and property guard code under ENABLE_NATIVE_CODEGEN Also fixed ability to disable SUPPORT_FIXED_FIELDS_ON_PATH_TYPES Disable fixed field for when JIT is disabled. Reduced binary size of the lite build by ~41K on x86 and ~65K on x64.
2 parents ffdeb1d + eea1705 commit 08d7955

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+716
-383
lines changed

lib/Backend/InterpreterThunkEmitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//-------------------------------------------------------------------------------------------------------
55
#include "Backend.h"
66

7-
#ifdef ENABLE_NATIVE_CODEGEN
7+
#if ENABLE_NATIVE_CODEGEN
88
#ifdef _M_X64
99
#ifdef _WIN32
1010
const BYTE InterpreterThunkEmitter::FunctionInfoOffset = 23;

lib/Backend/InterpreterThunkEmitter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//-------------------------------------------------------------------------------------------------------
55
#pragma once
66

7-
#ifdef ENABLE_NATIVE_CODEGEN
7+
#if ENABLE_NATIVE_CODEGEN
88
class ThunkBlock
99
{
1010
private:

lib/Backend/NativeCodeGenerator.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2733,6 +2733,7 @@ NativeCodeGenerator::GatherCodeGenData(
27332733
}
27342734

27352735
Js::JavascriptFunction* fixedFunctionObject = nullptr;
2736+
#if ENABLE_FIXED_FIELDS
27362737
if (inlineCache && (inlineCache->IsLocal() || inlineCache->IsProto()))
27372738
{
27382739
inlineCache->TryGetFixedMethodFromCache(functionBody, ldFldInlineCacheIndex, &fixedFunctionObject);
@@ -2742,6 +2743,7 @@ NativeCodeGenerator::GatherCodeGenData(
27422743
{
27432744
fixedFunctionObject = nullptr;
27442745
}
2746+
#endif
27452747

27462748
if (!PHASE_OFF(Js::InlineRecursivePhase, functionBody))
27472749
{

lib/Backend/ObjTypeSpecFldInfo.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,9 @@ ObjTypeSpecFldInfo* ObjTypeSpecFldInfo::CreateFrom(uint id, Js::InlineCache* cac
275275
bool isLocal = localCache.IsLocal();
276276
bool isProto = localCache.IsProto();
277277
bool isAccessor = localCache.IsAccessor();
278+
#if ENABLE_FIXED_FIELDS
278279
bool isGetter = localCache.IsGetterAccessor();
280+
#endif
279281
if (isLocal)
280282
{
281283
type = TypeWithoutAuxSlotTag(localCache.u.local.type);
@@ -372,6 +374,7 @@ ObjTypeSpecFldInfo* ObjTypeSpecFldInfo::CreateFrom(uint id, Js::InlineCache* cac
372374
Assert(entryPoint->GetJitTransferData() != nullptr);
373375
entryPoint->GetJitTransferData()->AddJitTimeTypeRef(type, recycler);
374376

377+
#if ENABLE_FIXED_FIELDS
375378
bool allFixedPhaseOFF = PHASE_OFF(Js::FixedMethodsPhase, topFunctionBody) & PHASE_OFF(Js::UseFixedDataPropsPhase, topFunctionBody);
376379

377380
if (!allFixedPhaseOFF)
@@ -534,6 +537,7 @@ ObjTypeSpecFldInfo* ObjTypeSpecFldInfo::CreateFrom(uint id, Js::InlineCache* cac
534537
}
535538
}
536539
}
540+
#endif
537541

538542
FixedFieldInfo * fixedFieldInfoArray = RecyclerNewArrayZ(recycler, FixedFieldInfo, 1);
539543

@@ -756,7 +760,12 @@ ObjTypeSpecFldInfo* ObjTypeSpecFldInfo::CreateFrom(uint id, Js::PolymorphicInlin
756760
areEquivalent = areStressEquivalent = false;
757761
}
758762

763+
#if ENABLE_FIXED_FIELDS
759764
gatherDataForInlining = gatherDataForInlining && (typeCount <= 4); // Only support 4-way (max) polymorphic inlining
765+
#else
766+
gatherDataForInlining = false;
767+
#endif
768+
760769
if (!areEquivalent && !areStressEquivalent)
761770
{
762771
IncInlineCacheCount(nonEquivPolyInlineCacheCount);
@@ -786,6 +795,7 @@ ObjTypeSpecFldInfo* ObjTypeSpecFldInfo::CreateFrom(uint id, Js::PolymorphicInlin
786795
// as the allocation may trigger a GC which can clear the inline caches.
787796
FixedFieldInfo localFixedFieldInfoArray[Js::DynamicProfileInfo::maxPolymorphicInliningSize] = {};
788797

798+
#if ENABLE_FIXED_FIELDS
789799
// For polymorphic field loads we only support fixed functions on prototypes. This helps keep the equivalence check helper simple.
790800
// Since all types in the polymorphic cache share the same prototype, it's enough to grab the fixed function from the prototype object.
791801
Js::Var fixedProperty = nullptr;
@@ -805,12 +815,11 @@ ObjTypeSpecFldInfo* ObjTypeSpecFldInfo::CreateFrom(uint id, Js::PolymorphicInlin
805815

806816
// TODO (ObjTypeSpec): Enable constructor caches on equivalent polymorphic field loads with fixed functions.
807817
}
808-
818+
#endif
809819
// Let's get the types.
810820
Js::Type* localTypes[MaxPolymorphicInlineCacheSize];
811821

812822
uint16 typeNumber = 0;
813-
Js::JavascriptFunction* fixedFunctionObject = nullptr;
814823
for (uint16 i = firstNonEmptyCacheIndex; i < polyCacheSize; i++)
815824
{
816825
Js::InlineCache& inlineCache = inlineCaches[i];
@@ -820,8 +829,10 @@ ObjTypeSpecFldInfo* ObjTypeSpecFldInfo::CreateFrom(uint id, Js::PolymorphicInlin
820829
inlineCache.IsProto() ? TypeWithoutAuxSlotTag(inlineCache.u.proto.type) :
821830
TypeWithoutAuxSlotTag(inlineCache.u.accessor.type);
822831

832+
#if ENABLE_FIXED_FIELDS
823833
if (gatherDataForInlining)
824834
{
835+
Js::JavascriptFunction* fixedFunctionObject = nullptr;
825836
inlineCache.TryGetFixedMethodFromCache(functionBody, cacheId, &fixedFunctionObject);
826837
if (!fixedFunctionObject || !fixedFunctionObject->GetFunctionInfo()->HasBody())
827838
{
@@ -845,7 +856,7 @@ ObjTypeSpecFldInfo* ObjTypeSpecFldInfo::CreateFrom(uint id, Js::PolymorphicInlin
845856

846857
fixedFunctionCount++;
847858
}
848-
859+
#endif
849860
typeNumber++;
850861
}
851862

lib/Common/CommonDefines.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "Warnings.h"
1313
#include "ChakraCoreVersion.h"
1414

15+
1516
//----------------------------------------------------------------------------------------------------
1617
// Default debug/fretest/release flags values
1718
// - Set the default values of debug/fretest/release flags if it is not set by the command line
@@ -122,7 +123,15 @@
122123

123124
// Type system features
124125
#define PERSISTENT_INLINE_CACHES // *** TODO: Won't build if disabled currently
125-
#define SUPPORT_FIXED_FIELDS_ON_PATH_TYPES // *** TODO: Won't build if disabled currently
126+
127+
#if !DISABLE_JIT
128+
#define ENABLE_FIXED_FIELDS 1 // Turn on fixed fields if JIT is enabled
129+
#endif
130+
131+
#if ENABLE_FIXED_FIELDS
132+
#define SUPPORT_FIXED_FIELDS_ON_PATH_TYPES
133+
#endif
134+
126135

127136
// xplat-todo: revisit these features
128137
#ifdef _WIN32

lib/Runtime/Base/FunctionBody.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ namespace Js
7979
Type * type;
8080
void * data;
8181
};
82+
83+
#if ENABLE_NATIVE_CODEGEN
8284
class PropertyGuard
8385
{
8486
friend class PropertyGuardValidator;
@@ -271,6 +273,7 @@ namespace Js
271273
this->cache = cache;
272274
}
273275
};
276+
#endif // ENABLE_NATIVE_CODEGEN
274277

275278
#pragma region Inline Cache Info class declarations
276279
class PolymorphicCacheUtilizationArray

lib/Runtime/Base/ThreadContext.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ ThreadContext::RecyclableData::RecyclableData(Recycler *const recycler) :
8888
oomErrorObject(nullptr, nullptr, nullptr, true),
8989
terminatedErrorObject(nullptr, nullptr, nullptr),
9090
typesWithProtoPropertyCache(recycler),
91+
#if ENABLE_NATIVE_CODEGEN
9192
propertyGuards(recycler, 128),
93+
#endif
9294
oldEntryPointInfo(nullptr),
9395
#ifdef ENABLE_SCRIPT_DEBUGGING
9496
returnedValueList(nullptr),
@@ -3099,6 +3101,7 @@ ThreadContext::ClearInlineCachesWithDeadWeakRefs()
30993101
}
31003102
}
31013103

3104+
#if ENABLE_NATIVE_CODEGEN
31023105
void
31033106
ThreadContext::ClearInvalidatedUniqueGuards()
31043107
{
@@ -3131,6 +3134,7 @@ ThreadContext::ClearInvalidatedUniqueGuards()
31313134
});
31323135
});
31333136
}
3137+
#endif
31343138

31353139
void
31363140
ThreadContext::ClearInlineCaches()

lib/Runtime/Base/ThreadContext.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,14 +572,15 @@ class ThreadContext sealed :
572572
// that would not get removed, but it would also not get any bigger.
573573
Field(PropertyIdToTypeHashSetDictionary) typesWithProtoPropertyCache;
574574

575+
#if ENABLE_NATIVE_CODEGEN
575576
// The property guard dictionary contains property guards which need to be invalidated in response to properties changing
576577
// from writable to read-only and vice versa, properties being shadowed or unshadowed on prototypes, etc. The dictionary
577578
// holds only weak references to property guards and their lifetimes are controlled by their creators (typically entry points).
578579
// When a guard is no longer needed it is garbage collected, but the weak references and dictionary entries remain, until
579580
// the guards for a given property get invalidated.
580581
// TODO: Create and use a self-cleaning weak reference dictionary, which would periodically remove any unused weak references.
581582
Field(PropertyGuardDictionary) propertyGuards;
582-
583+
#endif
583584

584585
Field(PropertyNoCaseSetType *) caseInvariantPropertySet;
585586

lib/Runtime/Language/CacheOperators.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ namespace Js
3838
(RootObjectBase::Is(objectWithProperty) && propertyIndex == RootObjectBase::FromVar(objectWithProperty)->GetRootPropertyIndex(propertyId)));
3939
Assert(DynamicType::Is(objectWithProperty->GetTypeId()));
4040

41+
#if ENABLE_FIXED_FIELDS
4142
// We are populating a cache guarded by the instance's type (not the type of the object with property somewhere in the prototype chain),
4243
// so we only care if the instance's property (if any) is fixed.
4344
Assert(info->IsNoCache() || !info->IsStoreFieldCacheEnabled() || info->GetInstance() != objectWithProperty || !objectWithProperty->IsFixedProperty(propertyId));
45+
#endif
4446

4547
PropertyIndex slotIndex;
4648
bool isInlineSlot;
@@ -210,7 +212,9 @@ namespace Js
210212
{
211213
AssertMsg(instance == object, "invalid instance for non setter");
212214
Assert(DynamicType::Is(typeWithoutProperty->GetTypeId()));
215+
#if ENABLE_FIXED_FIELDS
213216
Assert(info->IsNoCache() || !info->IsStoreFieldCacheEnabled() || object->CanStorePropertyValueDirectly(propertyId, isRoot));
217+
#endif
214218
Assert(info->IsWritable());
215219

216220
DynamicType* newType = (DynamicType*)object->GetType();

lib/Runtime/Language/InlineCache.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ namespace Js
413413
return clone;
414414
}
415415

416+
#if ENABLE_FIXED_FIELDS
416417
bool InlineCache::TryGetFixedMethodFromCache(Js::FunctionBody* functionBody, uint cacheId, Js::JavascriptFunction** pFixedMethod)
417418
{
418419
Assert(pFixedMethod);
@@ -464,6 +465,7 @@ namespace Js
464465

465466
return false;
466467
}
468+
#endif
467469

468470
void InlineCache::CopyTo(PropertyId propertyId, ScriptContext * scriptContext, InlineCache * const clone)
469471
{

lib/Runtime/Language/InlineCache.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,9 @@ namespace Js
322322
InlineCache *Clone(TAllocator *const allocator);
323323
InlineCache *Clone(Js::PropertyId propertyId, ScriptContext* scriptContext);
324324
void CopyTo(PropertyId propertyId, ScriptContext * scriptContext, InlineCache * const clone);
325+
#if ENABLE_FIXED_FIELDS
325326
bool TryGetFixedMethodFromCache(Js::FunctionBody* functionBody, uint cacheId, Js::JavascriptFunction** pFixedMethod);
327+
#endif
326328

327329
bool GetGetterSetter(Type *const type, RecyclableObject **callee);
328330
bool GetCallApplyTarget(RecyclableObject* obj, RecyclableObject **callee);

lib/Runtime/Language/JavascriptOperators.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,7 +1722,7 @@ namespace Js
17221722

17231723
if (foundProperty)
17241724
{
1725-
#if DBG
1725+
#if ENABLE_FIXED_FIELDS && DBG
17261726
if (DynamicObject::Is(object))
17271727
{
17281728
DynamicObject* dynamicObject = (DynamicObject*)object;
@@ -2067,7 +2067,8 @@ namespace Js
20672067
{
20682068
JavascriptError::ThrowReferenceError(requestContext, JSERR_UseBeforeDeclaration);
20692069
}
2070-
#if DBG
2070+
2071+
#if ENABLE_FIXED_FIELDS && DBG
20712072
if (DynamicObject::Is(object))
20722073
{
20732074
DynamicObject* dynamicObject = (DynamicObject*)object;
@@ -5435,7 +5436,9 @@ namespace Js
54355436

54365437
if (!newType->GetIsShared())
54375438
{
5439+
#if ENABLE_FIXED_FIELDS
54385440
newType->GetTypeHandler()->SetSingletonInstanceIfNeeded(instance);
5441+
#endif
54395442
}
54405443
#ifdef PROFILE_OBJECT_LITERALS
54415444
else
@@ -8135,6 +8138,7 @@ namespace Js
81358138
}
81368139
}
81378140

8141+
#if ENABLE_NATIVE_CODEGEN
81388142
#if ENABLE_DEBUG_CONFIG_OPTIONS
81398143
void JavascriptOperators::TracePropertyEquivalenceCheck(const JitEquivalentTypeGuard* guard, const Type* type, const Type* refType, bool isEquivalent, uint failedPropertyIndex)
81408144
{
@@ -8440,6 +8444,7 @@ namespace Js
84408444
guard->SetTypeAddr((intptr_t)type);
84418445
return true;
84428446
}
8447+
#endif
84438448

84448449
void JavascriptOperators::GetPropertyIdForInt(uint64 value, ScriptContext* scriptContext, PropertyRecord const ** propertyRecord)
84458450
{

lib/Runtime/Language/JavascriptOperators.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,13 +517,15 @@ namespace Js
517517

518518
static Var PatchGetMethodFromObject(Var instance, RecyclableObject * propertyObject, PropertyId propertyId, PropertyValueInfo * info, ScriptContext * scriptContext, bool isRootLd);
519519

520+
#if ENABLE_NATIVE_CODEGEN
520521
#if ENABLE_DEBUG_CONFIG_OPTIONS
521522
static void TracePropertyEquivalenceCheck(const JitEquivalentTypeGuard* guard, const Type* type, const Type* refType, bool isEquivalent, uint failedPropertyIndex);
522523
#endif
523524
static bool IsStaticTypeObjTypeSpecEquivalent(const TypeEquivalenceRecord& equivalenceRecord, uint& failedIndex);
524525
static bool IsStaticTypeObjTypeSpecEquivalent(const EquivalentPropertyEntry *entry);
525526
static bool CheckIfTypeIsEquivalent(Type* type, JitEquivalentTypeGuard* guard);
526527
static bool CheckIfTypeIsEquivalentForFixedField(Type* type, JitEquivalentTypeGuard* guard);
528+
#endif
527529

528530
static void GetPropertyIdForInt(uint64 value, ScriptContext* scriptContext, PropertyRecord const ** propertyRecord);
529531
static void GetPropertyIdForInt(uint32 value, ScriptContext* scriptContext, PropertyRecord const ** propertyRecord);

lib/Runtime/Language/ModuleNamespace.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ namespace Js
4949
virtual BOOL SetPropertyWithAttributes(PropertyId propertyId, Var value, PropertyAttributes attributes, PropertyValueInfo* info, PropertyOperationFlags flags = PropertyOperation_None, SideEffects possibleSideEffects = SideEffects_Any) override { return false; }
5050
virtual BOOL DeleteProperty(PropertyId propertyId, PropertyOperationFlags flags) override;
5151
virtual BOOL DeleteProperty(JavascriptString *propertyNameString, PropertyOperationFlags flags) override;
52+
#if ENABLE_FIXED_FIELDS
5253
virtual BOOL IsFixedProperty(PropertyId propertyId) override { return false; }
54+
#endif
5355
virtual PropertyQueryFlags HasItemQuery(uint32 index) override { return PropertyQueryFlags::Property_NotFound; }
5456
virtual BOOL HasOwnItem(uint32 index) override { return false; }
5557
virtual PropertyQueryFlags GetItemQuery(Var originalInstance, uint32 index, Var* value, ScriptContext * requestContext) override { return PropertyQueryFlags::Property_NotFound; }

lib/Runtime/Library/GlobalObject.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ namespace Js
2626
GlobalObject* globalObject = RecyclerNewPlus(scriptContext->GetRecycler(),
2727
sizeof(Var) * InlineSlotCapacity, GlobalObject, globalType, scriptContext);
2828

29+
#if ENABLE_FIXED_FIELDS
2930
globalTypeHandler->SetSingletonInstanceIfNeeded(scriptContext->GetRecycler()->CreateWeakReferenceHandle<DynamicObject>(globalObject));
31+
#endif
3032

3133
return globalObject;
3234
}

lib/Runtime/Library/JavascriptProxy.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,11 +850,13 @@ namespace Js
850850
return TRUE;
851851
}
852852

853+
#if ENABLE_FIXED_FIELDS
853854
BOOL JavascriptProxy::IsFixedProperty(PropertyId propertyId)
854855
{
855856
// TODO: can we add support for fixed property? don't see a clear way to invalidate...
856857
return false;
857858
}
859+
#endif
858860

859861
PropertyQueryFlags JavascriptProxy::HasItemQuery(uint32 index)
860862
{

lib/Runtime/Library/JavascriptProxy.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ namespace Js
9494
virtual BOOL InitFuncScoped(PropertyId propertyId, Var value) override;
9595
virtual BOOL DeleteProperty(PropertyId propertyId, PropertyOperationFlags flags) override;
9696
virtual BOOL DeleteProperty(JavascriptString *propertyNameString, PropertyOperationFlags flags) override;
97+
#if ENABLE_FIXED_FIELDS
9798
virtual BOOL IsFixedProperty(PropertyId propertyId) override;
99+
#endif
98100
virtual PropertyQueryFlags HasItemQuery(uint32 index) override;
99101
virtual BOOL HasOwnItem(uint32 index) override;
100102
virtual PropertyQueryFlags GetItemQuery(Var originalInstance, uint32 index, Var* value, ScriptContext * requestContext) override;

0 commit comments

Comments
 (0)