Skip to content

Commit eea1705

Browse files
committed
Disable fixed field and equivalent type spec code from DISABLE_JIT builds
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.
1 parent 3b5a4a4 commit eea1705

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
{

0 commit comments

Comments
 (0)