Files
UnrealEngineUWP/Engine/Source/Developer/HotReload/Private/HotReloadClassReinstancer.cpp

565 lines
18 KiB
C++
Raw Normal View History

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
#include "HotReloadPrivatePCH.h"
#include "HotReloadClassReinstancer.h"
#if WITH_ENGINE
#include "Engine/BlueprintGeneratedClass.h"
#include "Layers/ILayers.h"
#include "BlueprintEditor.h"
#include "Kismet2/CompilerResultsLog.h"
void FHotReloadClassReinstancer::SetupNewClassReinstancing(UClass* InNewClass, UClass* InOldClass)
{
// Set base class members to valid values
ClassToReinstance = InNewClass;
DuplicatedClass = InOldClass;
OriginalCDO = InOldClass->GetDefaultObject();
bHasReinstanced = false;
bSkipGarbageCollection = false;
bNeedsReinstancing = true;
NewClass = InNewClass;
// Collect the original CDO property values
SerializeCDOProperties(InOldClass->GetDefaultObject(), OriginalCDOProperties);
// Collect the property values of the new CDO
SerializeCDOProperties(InNewClass->GetDefaultObject(), ReconstructedCDOProperties);
SaveClassFieldMapping(InOldClass);
ObjectsThatShouldUseOldStuff.Add(InOldClass); //CDO of REINST_ class can be used as archetype
TArray<UClass*> ChildrenOfClass;
GetDerivedClasses(InOldClass, ChildrenOfClass);
for (auto ClassIt = ChildrenOfClass.CreateConstIterator(); ClassIt; ++ClassIt)
{
UClass* ChildClass = *ClassIt;
UBlueprint* ChildBP = Cast<UBlueprint>(ChildClass->ClassGeneratedBy);
if (ChildBP && !ChildBP->HasAnyFlags(RF_BeingRegenerated))
{
// If this is a direct child, change the parent and relink so the property chain is valid for reinstancing
if (!ChildBP->HasAnyFlags(RF_NeedLoad))
{
if (ChildClass->GetSuperClass() == InOldClass)
{
ReparentChild(ChildBP);
}
Children.AddUnique(ChildBP);
if (ChildBP->ParentClass == InOldClass)
{
ChildBP->ParentClass = NewClass;
}
}
else
{
// If this is a child that caused the load of their parent, relink to the REINST class so that we can still serialize in the CDO, but do not add to later processing
ReparentChild(ChildClass);
}
}
}
// Finally, remove the old class from Root so that it can get GC'd and mark it as CLASS_NewerVersionExists
InOldClass->RemoveFromRoot();
InOldClass->ClassFlags |= CLASS_NewerVersionExists;
}
void FHotReloadClassReinstancer::SerializeCDOProperties(UObject* InObject, FHotReloadClassReinstancer::FCDOPropertyData& OutData)
{
// Creates a mem-comparable CDO data
class FCDOWriter : public FMemoryWriter
{
/** Objects already visited by this archive */
TSet<UObject*>& VisitedObjects;
/** Output property data */
FCDOPropertyData& PropertyData;
/** Current subobject being serialized */
FName SubobjectName;
public:
/** Serializes all script properties of the provided DefaultObject */
FCDOWriter(FCDOPropertyData& InOutData, UObject* DefaultObject, TSet<UObject*>& InVisitedObjects, FName InSubobjectName = NAME_None)
: FMemoryWriter(InOutData.Bytes, /* bIsPersistent = */ false, /* bSetOffset = */ true)
, VisitedObjects(InVisitedObjects)
, PropertyData(InOutData)
, SubobjectName(InSubobjectName)
{
// Disable delta serialization, we want to serialize everything
ArNoDelta = true;
DefaultObject->SerializeScriptProperties(*this);
}
virtual void Serialize(void* Data, int64 Num) override
{
// Collect serialized properties so we can later update their values on instances if they change
auto SerializedProperty = GetSerializedProperty();
if (SerializedProperty != nullptr)
{
FCDOProperty& PropertyInfo = PropertyData.Properties.FindOrAdd(SerializedProperty->GetFName());
if (PropertyInfo.Property == nullptr)
{
PropertyInfo.Property = SerializedProperty;
PropertyInfo.SubobjectName = SubobjectName;
PropertyInfo.SerializedValueOffset = Tell();
PropertyInfo.SerializedValueSize = Num;
PropertyData.Properties.Add(SerializedProperty->GetFName(), PropertyInfo);
}
else
{
PropertyInfo.SerializedValueSize += Num;
}
}
FMemoryWriter::Serialize(Data, Num);
}
/** Serializes an object. Only name and class for normal references, deep serialization for DSOs */
virtual FArchive& operator<<(class UObject*& InObj) override
{
FArchive& Ar = *this;
if (InObj)
{
FName ClassName = InObj->GetClass()->GetFName();
FName ObjectName = InObj->GetFName();
Ar << ClassName;
Ar << ObjectName;
if (!VisitedObjects.Contains(InObj))
{
VisitedObjects.Add(InObj);
if (Ar.GetSerializedProperty() && Ar.GetSerializedProperty()->ContainsInstancedObjectProperty())
{
// Serialize all DSO properties too
FCDOWriter DefaultSubobjectWriter(PropertyData, InObj, VisitedObjects, InObj->GetFName());
Seek(PropertyData.Bytes.Num());
}
}
}
else
{
FName UnusedName = NAME_None;
Ar << UnusedName;
Ar << UnusedName;
}
return *this;
}
/** Serializes an FName as its index and number */
virtual FArchive& operator<<(FName& InName) override
{
FArchive& Ar = *this;
NAME_INDEX ComparisonIndex = InName.GetComparisonIndex();
NAME_INDEX DisplayIndex = InName.GetDisplayIndex();
int32 Number = InName.GetNumber();
Ar << ComparisonIndex;
Ar << DisplayIndex;
Ar << Number;
return Ar;
}
virtual FArchive& operator<<(FLazyObjectPtr& LazyObjectPtr) override
{
FArchive& Ar = *this;
auto UniqueID = LazyObjectPtr.GetUniqueID();
Ar << UniqueID;
return *this;
}
virtual FArchive& operator<<(FAssetPtr& AssetPtr) override
{
FArchive& Ar = *this;
auto UniqueID = AssetPtr.GetUniqueID();
Ar << UniqueID;
return Ar;
}
virtual FArchive& operator<<(FStringAssetReference& Value) override
{
FArchive& Ar = *this;
FString Path = Value.ToString();
Ar << Path;
if (IsLoading())
{
Value.SetPath(MoveTemp(Path));
}
return Ar;
}
/** Archive name, for debugging */
virtual FString GetArchiveName() const override { return TEXT("FCDOWriter"); }
};
TSet<UObject*> VisitedObjects;
VisitedObjects.Add(InObject);
FCDOWriter Ar(OutData, InObject, VisitedObjects);
}
void FHotReloadClassReinstancer::ReconstructClassDefaultObject(UClass* InClass, UObject* InOuter, FName InName, EObjectFlags InFlags)
{
// Get the parent CDO
UClass* ParentClass = InClass->GetSuperClass();
UObject* ParentDefaultObject = NULL;
if (ParentClass != NULL)
{
ParentDefaultObject = ParentClass->GetDefaultObject(); // Force the default object to be constructed if it isn't already
}
// Re-create
Copying //UE4/Dev-Core to //UE4/Main ========================== MAJOR FEATURES + CHANGES ========================== Change 2717513 on 2015/10/06 by Robert.Manuszewski@Robert_Manuszewski_EGUK_M1 GC and WeakObjectPtr performance optimizations. - Moved some of the EObjectFlags to EInternalObjectFlags and merged them with FUObjectArray - Moved WeakObjectPtr serial numbersto FUObjectArray - Added pre-allocated UObject array Change 2716517 on 2015/10/05 by Robert.Manuszewski@Robert_Manuszewski_EGUK_M1 Make SavePackage thread safe UObject-wise so that StaticFindObject etc can't run in parallel when packages are being saved. Change 2721142 on 2015/10/08 by Mikolaj.Sieluzycki@Dev-Core_D0920 UHT will now use makefiles to speed up iterative runs. Change 2726320 on 2015/10/13 by Jaroslaw.Palczynski@jaroslaw.palczynski_D1732_2963 Hot-reload performance optimizations: 1. Got rid of redundant touched BPs optimization (which was necessary before major HR fixes submitted earlier). 2. Parallelized search for old CDOs referencers. Change 2759032 on 2015/11/09 by Graeme.Thornton@GThornton_DesktopMaster Dependency preloading improvements - Asset registry dependencies now resolve asset redirectors - Rearrange runtime loading to put dependency preloads within BeginLoad/EndLoad for the source package Change 2754342 on 2015/11/04 by Robert.Manuszewski@Robert_Manuszewski_Stream1 Allow UnfocusedVolumeMultiplier to be set programmatically Change 2764008 on 2015/11/12 by Robert.Manuszewski@Robert_Manuszewski_Stream1 When cooking, don't add imports that are outers of objects excluded from the current cook target. Change 2755562 on 2015/11/05 by Steve.Robb@Dev-Core Inline storage for TFunction. Fix for delegate inline storage on Win64. Some build fixes. Visualizer fixes for new TFunction format. Change 2735084 on 2015/10/20 by Jaroslaw.Surowiec@Stream.1.JarekSurowiec CrashReporter Web - Search by Platform Added initial support for streams (GetBranchesAsListItems, CopyToJira) Change 2762387 on 2015/11/11 by Steve.Robb@Dev-Core Unnecessary allocation removed when loading empty files in FFileHelper::LoadFileToString. Change 2762632 on 2015/11/11 by Steve.Robb@Dev-Core Some TSet function optimisations: Avoiding unnecessary hashing of function arguments if the container is empty (rather than the hash being empty, which is not necessarily equivalent). Taking local copies of HashSize during iterations. Change 2762936 on 2015/11/11 by Steve.Robb@Dev-Core BulkData zero byte allocations are now handled by an RAII object which owns the memory. Change 2765758 on 2015/11/13 by Steve.Robb@Dev-Core FName::operator== and != optimised to be a single comparison. Change 2757195 on 2015/11/06 by Jaroslaw.Surowiec@Stream.1.JarekSurowiec PR #1305: Improvements in CrashReporter for Symbol Server usage (Contributed by bozaro) Change 2760778 on 2015/11/10 by Jaroslaw.Surowiec@Stream.1.JarekSurowiec PR #1725: Fixed typos in ProfilerCommon.h; Added comments (Contributed by BGR360) Also fixed starting condition. Change 2739804 on 2015/10/23 by Robert.Manuszewski@Robert_Manuszewski_Stream1 PR #1470: [UObjectGlobals] Do not overwrite instanced subobjects with ones from CDO (Contributed by slonopotamus) Change 2744733 on 2015/10/28 by Steve.Robb@Dev-Core PR #1540 - Specifying a different Saved folder at launch through a command line parameter Integrated and optimized. #lockdown Nick.Penwarden [CL 2772222 by Robert Manuszewski in Main branch]
2015-11-18 16:20:49 -05:00
InClass->ClassDefaultObject = StaticAllocateObject(InClass, InOuter, InName, InFlags, EInternalObjectFlags::None, false);
check(InClass->ClassDefaultObject);
const bool bShouldInitilizeProperties = false;
const bool bCopyTransientsFromClassDefaults = false;
(*InClass->ClassConstructor)(FObjectInitializer(InClass->ClassDefaultObject, ParentDefaultObject, bCopyTransientsFromClassDefaults, bShouldInitilizeProperties));
}
void FHotReloadClassReinstancer::RecreateCDOAndSetupOldClassReinstancing(UClass* InOldClass)
{
// Set base class members to valid values
ClassToReinstance = InOldClass;
DuplicatedClass = InOldClass;
OriginalCDO = InOldClass->GetDefaultObject();
bHasReinstanced = false;
bSkipGarbageCollection = false;
bNeedsReinstancing = false;
NewClass = InOldClass; // The class doesn't change in this case
// Collect the original property values
SerializeCDOProperties(InOldClass->GetDefaultObject(), OriginalCDOProperties);
// Remember all the basic info about the object before we rename it
EObjectFlags CDOFlags = OriginalCDO->GetFlags();
UObject* CDOOuter = OriginalCDO->GetOuter();
FName CDOName = OriginalCDO->GetFName();
// Rename original CDO, so we can store this one as OverridenArchetypeForCDO
// and create new one with the same name and outer.
OriginalCDO->Rename(
*MakeUniqueObjectName(
GetTransientPackage(),
OriginalCDO->GetClass(),
*FString::Printf(TEXT("BPGC_ARCH_FOR_CDO_%s"), *InOldClass->GetName())
).ToString(),
GetTransientPackage(),
REN_DoNotDirty | REN_DontCreateRedirectors | REN_NonTransactional | REN_SkipGeneratedClasses | REN_ForceNoResetLoaders);
// Re-create the CDO, re-running its constructor
ReconstructClassDefaultObject(InOldClass, CDOOuter, CDOName, CDOFlags);
ReconstructedCDOsMap.Add(OriginalCDO, InOldClass->GetDefaultObject());
// Collect the property values after re-constructing the CDO
SerializeCDOProperties(InOldClass->GetDefaultObject(), ReconstructedCDOProperties);
// We only want to re-instance the old class if its CDO's values have changed or any of its DSOs' property values have changed
if (DefaultPropertiesHaveChanged())
{
bNeedsReinstancing = true;
SaveClassFieldMapping(InOldClass);
TArray<UClass*> ChildrenOfClass;
GetDerivedClasses(InOldClass, ChildrenOfClass);
for (auto ClassIt = ChildrenOfClass.CreateConstIterator(); ClassIt; ++ClassIt)
{
UClass* ChildClass = *ClassIt;
UBlueprint* ChildBP = Cast<UBlueprint>(ChildClass->ClassGeneratedBy);
if (ChildBP && !ChildBP->HasAnyFlags(RF_BeingRegenerated))
{
if (!ChildBP->HasAnyFlags(RF_NeedLoad))
{
Children.AddUnique(ChildBP);
auto BPGC = Cast<UBlueprintGeneratedClass>(ChildBP->GeneratedClass);
auto CurrentCDO = BPGC ? BPGC->GetDefaultObject(false) : nullptr;
if (CurrentCDO && (OriginalCDO == CurrentCDO->GetArchetype()))
{
BPGC->OverridenArchetypeForCDO = OriginalCDO;
}
}
}
}
}
}
FHotReloadClassReinstancer::FHotReloadClassReinstancer(UClass* InNewClass, UClass* InOldClass, const TMap<UClass*, UClass*>& InOldToNewClassesMap, TMap<UObject*, UObject*>& OutReconstructedCDOsMap, TSet<UBlueprint*>& InBPSetToRecompile, TSet<UBlueprint*>& InBPSetToRecompileBytecodeOnly)
: NewClass(nullptr)
, bNeedsReinstancing(false)
, CopyOfPreviousCDO(nullptr)
, ReconstructedCDOsMap(OutReconstructedCDOsMap)
, BPSetToRecompile(InBPSetToRecompile)
, BPSetToRecompileBytecodeOnly(InBPSetToRecompileBytecodeOnly)
, OldToNewClassesMap(InOldToNewClassesMap)
{
ensure(InOldClass);
ensure(!HotReloadedOldClass && !HotReloadedNewClass);
HotReloadedOldClass = InOldClass;
HotReloadedNewClass = InNewClass ? InNewClass : InOldClass;
for (const TPair<UClass*, UClass*>& OldToNewClass : OldToNewClassesMap)
{
ObjectsThatShouldUseOldStuff.Add(OldToNewClass.Key);
}
// If InNewClass is NULL, then the old class has not changed after hot-reload.
// However, we still need to check for changes to its constructor code (CDO values).
if (InNewClass)
{
SetupNewClassReinstancing(InNewClass, InOldClass);
TMap<UObject*, UObject*> ClassRedirects;
ClassRedirects.Add(InOldClass, InNewClass);
for (TObjectIterator<UBlueprint> BlueprintIt; BlueprintIt; ++BlueprintIt)
{
FArchiveReplaceObjectRef<UObject> ReplaceObjectArch(*BlueprintIt, ClassRedirects, false, true, true);
if (ReplaceObjectArch.GetCount())
{
EnlistDependentBlueprintToRecompile(*BlueprintIt, false);
}
}
}
else
{
RecreateCDOAndSetupOldClassReinstancing(InOldClass);
}
}
FHotReloadClassReinstancer::~FHotReloadClassReinstancer()
{
// Make sure the base class does not remove the DuplicatedClass from root, we not always want it.
// For example when we're just reconstructing CDOs. Other cases are handled by HotReloadClassReinstancer.
DuplicatedClass = nullptr;
ensure(HotReloadedOldClass);
HotReloadedOldClass = nullptr;
HotReloadedNewClass = nullptr;
}
/** Helper for finding subobject in an array. Usually there's not that many subobjects on a class to justify a TMap */
FORCEINLINE static UObject* FindDefaultSubobject(TArray<UObject*>& InDefaultSubobjects, FName SubobjectName)
{
for (auto Subobject : InDefaultSubobjects)
{
if (Subobject->GetFName() == SubobjectName)
{
return Subobject;
}
}
return nullptr;
}
void FHotReloadClassReinstancer::UpdateDefaultProperties()
{
struct FPropertyToUpdate
{
UProperty* Property;
FName SubobjectName;
uint8* OldSerializedValuePtr;
uint8* NewValuePtr;
int64 OldSerializedSize;
};
/** Memory writer archive that supports UObject values the same way as FCDOWriter. */
class FPropertyValueMemoryWriter : public FMemoryWriter
{
public:
FPropertyValueMemoryWriter(TArray<uint8>& OutData)
: FMemoryWriter(OutData)
{}
virtual FArchive& operator<<(class UObject*& InObj) override
{
FArchive& Ar = *this;
if (InObj)
{
FName ClassName = InObj->GetClass()->GetFName();
FName ObjectName = InObj->GetFName();
Ar << ClassName;
Ar << ObjectName;
}
else
{
FName UnusedName = NAME_None;
Ar << UnusedName;
Ar << UnusedName;
}
return *this;
}
virtual FArchive& operator<<(FName& InName) override
{
FArchive& Ar = *this;
NAME_INDEX ComparisonIndex = InName.GetComparisonIndex();
NAME_INDEX DisplayIndex = InName.GetDisplayIndex();
int32 Number = InName.GetNumber();
Ar << ComparisonIndex;
Ar << DisplayIndex;
Ar << Number;
return Ar;
}
virtual FArchive& operator<<(FLazyObjectPtr& LazyObjectPtr) override
{
FArchive& Ar = *this;
auto UniqueID = LazyObjectPtr.GetUniqueID();
Ar << UniqueID;
return *this;
}
virtual FArchive& operator<<(FAssetPtr& AssetPtr) override
{
FArchive& Ar = *this;
auto UniqueID = AssetPtr.GetUniqueID();
Ar << UniqueID;
return Ar;
}
virtual FArchive& operator<<(FStringAssetReference& Value) override
{
FArchive& Ar = *this;
FString Path = Value.ToString();
Ar << Path;
if (IsLoading())
{
Value.SetPath(MoveTemp(Path));
}
return Ar;
}
};
// Collect default subobjects to update their properties too
const int32 DefaultSubobjectArrayCapacity = 16;
TArray<UObject*> DefaultSubobjectArray;
DefaultSubobjectArray.Empty(DefaultSubobjectArrayCapacity);
NewClass->GetDefaultObject()->CollectDefaultSubobjects(DefaultSubobjectArray);
TArray<FPropertyToUpdate> PropertiesToUpdate;
// Collect all properties that have actually changed
for (auto& Pair : ReconstructedCDOProperties.Properties)
{
auto OldPropertyInfo = OriginalCDOProperties.Properties.Find(Pair.Key);
if (OldPropertyInfo)
{
auto& NewPropertyInfo = Pair.Value;
uint8* OldSerializedValuePtr = OriginalCDOProperties.Bytes.GetData() + OldPropertyInfo->SerializedValueOffset;
uint8* NewSerializedValuePtr = ReconstructedCDOProperties.Bytes.GetData() + NewPropertyInfo.SerializedValueOffset;
if (OldPropertyInfo->SerializedValueSize != NewPropertyInfo.SerializedValueSize ||
FMemory::Memcmp(OldSerializedValuePtr, NewSerializedValuePtr, OldPropertyInfo->SerializedValueSize) != 0)
{
// Property value has changed so add it to the list of properties that need updating on instances
FPropertyToUpdate PropertyToUpdate;
PropertyToUpdate.Property = NewPropertyInfo.Property;
PropertyToUpdate.NewValuePtr = nullptr;
PropertyToUpdate.SubobjectName = NewPropertyInfo.SubobjectName;
if (NewPropertyInfo.Property->GetOuter() == NewClass)
{
PropertyToUpdate.NewValuePtr = PropertyToUpdate.Property->ContainerPtrToValuePtr<uint8>(NewClass->GetDefaultObject());
}
else if (NewPropertyInfo.SubobjectName != NAME_None)
{
UObject* DefaultSubobjectPtr = FindDefaultSubobject(DefaultSubobjectArray, NewPropertyInfo.SubobjectName);
if (DefaultSubobjectPtr && NewPropertyInfo.Property->GetOuter() == DefaultSubobjectPtr->GetClass())
{
PropertyToUpdate.NewValuePtr = PropertyToUpdate.Property->ContainerPtrToValuePtr<uint8>(DefaultSubobjectPtr);
}
}
if (PropertyToUpdate.NewValuePtr)
{
PropertyToUpdate.OldSerializedValuePtr = OldSerializedValuePtr;
PropertyToUpdate.OldSerializedSize = OldPropertyInfo->SerializedValueSize;
PropertiesToUpdate.Add(PropertyToUpdate);
}
}
}
}
if (PropertiesToUpdate.Num())
{
TArray<uint8> CurrentValueSerializedData;
// Update properties on all existing instances of the class
for (FObjectIterator It(NewClass); It; ++It)
{
UObject* ObjectPtr = *It;
DefaultSubobjectArray.Empty(DefaultSubobjectArrayCapacity);
ObjectPtr->CollectDefaultSubobjects(DefaultSubobjectArray);
for (auto& PropertyToUpdate : PropertiesToUpdate)
{
uint8* InstanceValuePtr = nullptr;
if (PropertyToUpdate.SubobjectName == NAME_None)
{
InstanceValuePtr = PropertyToUpdate.Property->ContainerPtrToValuePtr<uint8>(ObjectPtr);
}
else
{
UObject* DefaultSubobjectPtr = FindDefaultSubobject(DefaultSubobjectArray, PropertyToUpdate.SubobjectName);
if (DefaultSubobjectPtr && PropertyToUpdate.Property->GetOuter() == DefaultSubobjectPtr->GetClass())
{
InstanceValuePtr = PropertyToUpdate.Property->ContainerPtrToValuePtr<uint8>(DefaultSubobjectPtr);
}
}
if (InstanceValuePtr)
{
// Serialize current value to a byte array as we don't have the previous CDO to compare against, we only have its serialized property data
CurrentValueSerializedData.Empty(CurrentValueSerializedData.Num() + CurrentValueSerializedData.GetSlack());
FPropertyValueMemoryWriter CurrentValueWriter(CurrentValueSerializedData);
PropertyToUpdate.Property->SerializeItem(CurrentValueWriter, InstanceValuePtr);
// Update only when the current value on the instance is identical to the original CDO
if (CurrentValueSerializedData.Num() == PropertyToUpdate.OldSerializedSize &&
FMemory::Memcmp(CurrentValueSerializedData.GetData(), PropertyToUpdate.OldSerializedValuePtr, CurrentValueSerializedData.Num()) == 0)
{
// Update with the new value
PropertyToUpdate.Property->CopyCompleteValue(InstanceValuePtr, PropertyToUpdate.NewValuePtr);
}
}
}
}
}
}
void FHotReloadClassReinstancer::ReinstanceObjectsAndUpdateDefaults()
{
ReinstanceObjects(true);
UpdateDefaultProperties();
}
void FHotReloadClassReinstancer::AddReferencedObjects(FReferenceCollector& Collector)
{
FBlueprintCompileReinstancer::AddReferencedObjects(Collector);
Copying //UE4/Dev-Core to //UE4/Main ========================== MAJOR FEATURES + CHANGES ========================== Change 2783106 on 2015/11/30 by Robert.Manuszewski@Robert.Manuszewski_NCL_Stream2 Introduced GC UObject clusters. GC clusters provide means to create disregard for GC subsets at load time (e.g. Materials with material expressions and their textures). - Saves about 25ms in reachability analysis (58ms -> 33ms) - UObject classes/instances can now be marked as cluster root objects with CanBeClusterRoot() function override. - Cluster creation is automatic. Clusters don't require any manual handling for GC to collect them when nothing is referencing them. - Moved token stream processing to a new class FFastReferenceFinder to make it more generic and re-usable by other code - Removed REFERENCE_INFO macro from GC code and replaced it with a local variable (saves about ~1.9ms: 33.2ms -> 31.3ms) Change 2773094 on 2015/11/19 by Steve.Robb@Dev-Core Multicast script delegate check for existing bindings replaced with ensure. Multicast native delegate no longer checks for existing bindings. Removal of old delegate code. Some FORCEINLINEing to improve debugging experience of stepping into delegate code. Change 2782180 on 2015/11/27 by Graeme.Thornton@GThornton_DesktopMaster Make scoped seconds timer class available outside of stats build. Normal usage macros still remain guarded Added SCOPE_SECONDS_COUNTER_RECURSION_SAFE which only times during the outmost instance of a recursive function Added SCOPE_SECONDS_COUNTER_RECURSION_SAFE_BASE and SCOPE_SECONDS_COUNTER_BASE which are defined in all build types, for easy temporary timing in Test/Shipping builds. Added a boolean parameter to the timer class which can be used to disable it without having to mess around with scoping the calling code Change 2782635 on 2015/11/30 by Graeme.Thornton@GThornton_DesktopMaster Added GetTimeStampPair() to the filemanager and platformfile interfaces. Requests timestamps for a pair of files where we assume that both files would always exist at the same wrapper level. Allows us to skip file system queries for localization package lookups where the native file is in a pak but the localized file doesn't exist. Change 2775153 on 2015/11/20 by Jaroslaw.Surowiec@Stream.1.JarekSurowiec CrashReportServer moved out of the not for licencees, a few fixes, removed RegisterPII Change 2775560 on 2015/11/20 by Steve.Robb@Dev-Core FDelegateBase::GetDelegateInstance deprecated and replaced with FDelegateBase::GetDelegateInstanceProtected. Change 2781138 on 2015/11/25 by Jaroslaw.Surowiec@Stream.1.JarekSurowiec Stats - Converted is using a new stats reader, a few more optimizations, should be 10x times faster Change 2772990 on 2015/11/19 by Robert.Manuszewski@Robert.Manuszewski_NCL_Stream2 Fixing potential dead lock when suspending and resuming async loading multiple times Change 2773023 on 2015/11/19 by Robert.Manuszewski@Robert.Manuszewski_NCL_Stream2 Support for references added through AddReferencedObjects in FArchiveReplaceObjectRef Change 2781055 on 2015/11/25 by Steve.Robb@Dev-Core Changes to IDelegateInstance reverted to allow licensees an easier time when upgrading their use of the now-deprecated GetDelegateInstance() code path. New TryGetBoundFunctionName() to aid the debugging of delegate bindings in non-shipping configs. Change 2773114 on 2015/11/19 by Steve.Robb@Dev-Core FMath::IsPowerOfTwo is now templated to take any type. Change 2773643 on 2015/11/19 by Steve.Robb@Dev-Core GetDelegateInstance() calls replaced - delegate instances never compare equal unless you are comparing two unbound delegates (both null) or comparing a delegate with itself. Change 2777686 on 2015/11/23 by Steve.Robb@Dev-Core GitHub #1793 - File write flags argument Change 2780590 on 2015/11/25 by Steve.Robb@Dev-Core Fix for FArchiveProxy::operator<< overloads. Change 2780845 on 2015/11/25 by Jaroslaw.Surowiec@Stream.1.JarekSurowiec #jira UE-23358 - MDD relies on hard-coded P4 depot paths (fixed source context for streams) Change 2780962 on 2015/11/25 by Jaroslaw.Surowiec@Stream.1.JarekSurowiec Stats - Added FStatsWriteStream for basic saving stat messages into a stream, initial support for reading a regular stats file, minor performance optimization, coding standard fixes #jira UECORE-170 - Improve profiler loading performance (wip) Change 2781887 on 2015/11/26 by Jaroslaw.Surowiec@Stream.1.JarekSurowiec Profiler/ProfilerClient - Removed unneeded synchronization points, replaces with task graph SendTo jobs, removed PROFILER_THREADED_LOAD, replaced with new stats loading mechanism, should be around 2x times faster (4x since the optimization pass) #jira UECORE-170 - Improve profiler loading performance (wip) Change 2781893 on 2015/11/26 by Steve.Robb@Dev-Core TCachedOSPageAllocator abstracted from MallocBinned2. Misc tidy-ups. Change 2782198 on 2015/11/27 by Jaroslaw.Surowiec@Stream.1.JarekSurowiec Profiler - Better indication of the loading progress, should no longer freeze without a progress bar #jira UECORE-170 - Improve profiler loading performance (wip) Change 2782446 on 2015/11/29 by Steve.Robb@Dev-Core Warn when calling delegates' Create* functions when they're not assigned to anything. #codereview robert.manuszewski Change 2782538 on 2015/11/30 by Robert.Manuszewski@Robert.Manuszewski_NCL_Stream1 #UE4 Removed DiskCachedAssetDataBuffer as it was not strictly necessary and was triggering a crash when loading the cached registry from disk. This data is now stored directly in DiskCachedAssetDataMap. It was already true that this map does not change outside of SerializeCache but now it is critical since NewCachedAssetDataMap keeps pointers directly to its values. Asset registry fixes by Bob Tellez. Possible fix for UE-23783. Change 2782564 on 2015/11/30 by Robert.Manuszewski@Robert.Manuszewski_NCL_Stream1 FReferenceCollector::AddReferenceObjects performance improvements for TArrays. ARO will no longer call HandleObjectReference multiple times but instead will call HandleObjectReferences just once (currently only implemented for FGCCollector). Reduces the number of virtual function calls while GC'ing. Change 2782716 on 2015/11/30 by Steve.Robb@Dev-Core UObject serial number array initialized for debug visualization. Change 2782933 on 2015/11/30 by Steve.Robb@Dev-Core Critical sections are no longer copyable. Change 2783061 on 2015/11/30 by Steve.Robb@Dev-Core
2015-12-03 14:21:29 -05:00
Collector.AllowEliminatingReferences(false);
Collector.AddReferencedObject(CopyOfPreviousCDO);
Copying //UE4/Dev-Core to //UE4/Main ========================== MAJOR FEATURES + CHANGES ========================== Change 2783106 on 2015/11/30 by Robert.Manuszewski@Robert.Manuszewski_NCL_Stream2 Introduced GC UObject clusters. GC clusters provide means to create disregard for GC subsets at load time (e.g. Materials with material expressions and their textures). - Saves about 25ms in reachability analysis (58ms -> 33ms) - UObject classes/instances can now be marked as cluster root objects with CanBeClusterRoot() function override. - Cluster creation is automatic. Clusters don't require any manual handling for GC to collect them when nothing is referencing them. - Moved token stream processing to a new class FFastReferenceFinder to make it more generic and re-usable by other code - Removed REFERENCE_INFO macro from GC code and replaced it with a local variable (saves about ~1.9ms: 33.2ms -> 31.3ms) Change 2773094 on 2015/11/19 by Steve.Robb@Dev-Core Multicast script delegate check for existing bindings replaced with ensure. Multicast native delegate no longer checks for existing bindings. Removal of old delegate code. Some FORCEINLINEing to improve debugging experience of stepping into delegate code. Change 2782180 on 2015/11/27 by Graeme.Thornton@GThornton_DesktopMaster Make scoped seconds timer class available outside of stats build. Normal usage macros still remain guarded Added SCOPE_SECONDS_COUNTER_RECURSION_SAFE which only times during the outmost instance of a recursive function Added SCOPE_SECONDS_COUNTER_RECURSION_SAFE_BASE and SCOPE_SECONDS_COUNTER_BASE which are defined in all build types, for easy temporary timing in Test/Shipping builds. Added a boolean parameter to the timer class which can be used to disable it without having to mess around with scoping the calling code Change 2782635 on 2015/11/30 by Graeme.Thornton@GThornton_DesktopMaster Added GetTimeStampPair() to the filemanager and platformfile interfaces. Requests timestamps for a pair of files where we assume that both files would always exist at the same wrapper level. Allows us to skip file system queries for localization package lookups where the native file is in a pak but the localized file doesn't exist. Change 2775153 on 2015/11/20 by Jaroslaw.Surowiec@Stream.1.JarekSurowiec CrashReportServer moved out of the not for licencees, a few fixes, removed RegisterPII Change 2775560 on 2015/11/20 by Steve.Robb@Dev-Core FDelegateBase::GetDelegateInstance deprecated and replaced with FDelegateBase::GetDelegateInstanceProtected. Change 2781138 on 2015/11/25 by Jaroslaw.Surowiec@Stream.1.JarekSurowiec Stats - Converted is using a new stats reader, a few more optimizations, should be 10x times faster Change 2772990 on 2015/11/19 by Robert.Manuszewski@Robert.Manuszewski_NCL_Stream2 Fixing potential dead lock when suspending and resuming async loading multiple times Change 2773023 on 2015/11/19 by Robert.Manuszewski@Robert.Manuszewski_NCL_Stream2 Support for references added through AddReferencedObjects in FArchiveReplaceObjectRef Change 2781055 on 2015/11/25 by Steve.Robb@Dev-Core Changes to IDelegateInstance reverted to allow licensees an easier time when upgrading their use of the now-deprecated GetDelegateInstance() code path. New TryGetBoundFunctionName() to aid the debugging of delegate bindings in non-shipping configs. Change 2773114 on 2015/11/19 by Steve.Robb@Dev-Core FMath::IsPowerOfTwo is now templated to take any type. Change 2773643 on 2015/11/19 by Steve.Robb@Dev-Core GetDelegateInstance() calls replaced - delegate instances never compare equal unless you are comparing two unbound delegates (both null) or comparing a delegate with itself. Change 2777686 on 2015/11/23 by Steve.Robb@Dev-Core GitHub #1793 - File write flags argument Change 2780590 on 2015/11/25 by Steve.Robb@Dev-Core Fix for FArchiveProxy::operator<< overloads. Change 2780845 on 2015/11/25 by Jaroslaw.Surowiec@Stream.1.JarekSurowiec #jira UE-23358 - MDD relies on hard-coded P4 depot paths (fixed source context for streams) Change 2780962 on 2015/11/25 by Jaroslaw.Surowiec@Stream.1.JarekSurowiec Stats - Added FStatsWriteStream for basic saving stat messages into a stream, initial support for reading a regular stats file, minor performance optimization, coding standard fixes #jira UECORE-170 - Improve profiler loading performance (wip) Change 2781887 on 2015/11/26 by Jaroslaw.Surowiec@Stream.1.JarekSurowiec Profiler/ProfilerClient - Removed unneeded synchronization points, replaces with task graph SendTo jobs, removed PROFILER_THREADED_LOAD, replaced with new stats loading mechanism, should be around 2x times faster (4x since the optimization pass) #jira UECORE-170 - Improve profiler loading performance (wip) Change 2781893 on 2015/11/26 by Steve.Robb@Dev-Core TCachedOSPageAllocator abstracted from MallocBinned2. Misc tidy-ups. Change 2782198 on 2015/11/27 by Jaroslaw.Surowiec@Stream.1.JarekSurowiec Profiler - Better indication of the loading progress, should no longer freeze without a progress bar #jira UECORE-170 - Improve profiler loading performance (wip) Change 2782446 on 2015/11/29 by Steve.Robb@Dev-Core Warn when calling delegates' Create* functions when they're not assigned to anything. #codereview robert.manuszewski Change 2782538 on 2015/11/30 by Robert.Manuszewski@Robert.Manuszewski_NCL_Stream1 #UE4 Removed DiskCachedAssetDataBuffer as it was not strictly necessary and was triggering a crash when loading the cached registry from disk. This data is now stored directly in DiskCachedAssetDataMap. It was already true that this map does not change outside of SerializeCache but now it is critical since NewCachedAssetDataMap keeps pointers directly to its values. Asset registry fixes by Bob Tellez. Possible fix for UE-23783. Change 2782564 on 2015/11/30 by Robert.Manuszewski@Robert.Manuszewski_NCL_Stream1 FReferenceCollector::AddReferenceObjects performance improvements for TArrays. ARO will no longer call HandleObjectReference multiple times but instead will call HandleObjectReferences just once (currently only implemented for FGCCollector). Reduces the number of virtual function calls while GC'ing. Change 2782716 on 2015/11/30 by Steve.Robb@Dev-Core UObject serial number array initialized for debug visualization. Change 2782933 on 2015/11/30 by Steve.Robb@Dev-Core Critical sections are no longer copyable. Change 2783061 on 2015/11/30 by Steve.Robb@Dev-Core
2015-12-03 14:21:29 -05:00
Collector.AllowEliminatingReferences(true);
}
void FHotReloadClassReinstancer::EnlistDependentBlueprintToRecompile(UBlueprint* BP, bool bBytecodeOnly)
{
if (IsValid(BP))
{
if (bBytecodeOnly)
{
if (!BPSetToRecompile.Contains(BP) && !BPSetToRecompileBytecodeOnly.Contains(BP))
{
BPSetToRecompileBytecodeOnly.Add(BP);
}
}
else
{
if (!BPSetToRecompile.Contains(BP))
{
if (BPSetToRecompileBytecodeOnly.Contains(BP))
{
BPSetToRecompileBytecodeOnly.Remove(BP);
}
BPSetToRecompile.Add(BP);
}
}
}
}
void FHotReloadClassReinstancer::BlueprintWasRecompiled(UBlueprint* BP, bool bBytecodeOnly)
{
BPSetToRecompile.Remove(BP);
BPSetToRecompileBytecodeOnly.Remove(BP);
FBlueprintCompileReinstancer::BlueprintWasRecompiled(BP, bBytecodeOnly);
}
#endif