mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 03:28:20 +02:00
Fixes from valgrind
This commit is contained in:
parent
0feaaded22
commit
676e7988fb
31 changed files with 243 additions and 147 deletions
|
@ -38,3 +38,6 @@ BfOptimizationLevel = "O2"
|
||||||
RuntimeChecks = false
|
RuntimeChecks = false
|
||||||
EmitDynamicCastCheck = false
|
EmitDynamicCastCheck = false
|
||||||
EmitObjectAccessCheck = false
|
EmitObjectAccessCheck = false
|
||||||
|
|
||||||
|
[Configs.Debug.Linux64]
|
||||||
|
PreprocessorMacros = ["DEBUG", "VALGRIND"]
|
||||||
|
|
|
@ -54,7 +54,7 @@ namespace System.IO
|
||||||
case .Copy:
|
case .Copy:
|
||||||
mString.Set(str);
|
mString.Set(str);
|
||||||
case .Reference:
|
case .Reference:
|
||||||
mString = new String();
|
mStringKind = .Reference;
|
||||||
mString.Reference(str.Ptr, str.Length);
|
mString.Reference(str.Ptr, str.Length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,8 @@ namespace System
|
||||||
{
|
{
|
||||||
int bufferSize = (count == 0) ? 0 : (count - 1) & ~(sizeof(char8*) - 1);
|
int bufferSize = (count == 0) ? 0 : (count - 1) & ~(sizeof(char8*) - 1);
|
||||||
#unwarn
|
#unwarn
|
||||||
char8* addlPtr = append char8[bufferSize]*(?);
|
char8* addlPtr = append char8[bufferSize]*(?);
|
||||||
|
Init(bufferSize);
|
||||||
mAllocSizeAndFlags = (uint_strsize)bufferSize + (int_strsize)sizeof(char8*);
|
mAllocSizeAndFlags = (uint_strsize)bufferSize + (int_strsize)sizeof(char8*);
|
||||||
mLength = 0;
|
mLength = 0;
|
||||||
}
|
}
|
||||||
|
@ -83,7 +84,8 @@ namespace System
|
||||||
{
|
{
|
||||||
let bufferSize = 16 - sizeof(char8*);
|
let bufferSize = 16 - sizeof(char8*);
|
||||||
#unwarn
|
#unwarn
|
||||||
char8* addlPtr = append char8[bufferSize]*(?);
|
char8* addlPtr = append char8[bufferSize]*(?);
|
||||||
|
Init(bufferSize);
|
||||||
mAllocSizeAndFlags = (uint_strsize)bufferSize + (int_strsize)sizeof(char8*);
|
mAllocSizeAndFlags = (uint_strsize)bufferSize + (int_strsize)sizeof(char8*);
|
||||||
mLength = 0;
|
mLength = 0;
|
||||||
}
|
}
|
||||||
|
@ -94,7 +96,8 @@ namespace System
|
||||||
let count = str.mLength;
|
let count = str.mLength;
|
||||||
int bufferSize = (count == 0) ? 0 : (count - 1) & ~(sizeof(char8*) - 1);
|
int bufferSize = (count == 0) ? 0 : (count - 1) & ~(sizeof(char8*) - 1);
|
||||||
#unwarn
|
#unwarn
|
||||||
char8* addlPtr = append char8[bufferSize]*(?);
|
char8* addlPtr = append char8[bufferSize]*(?);
|
||||||
|
Init(bufferSize);
|
||||||
Internal.MemCpy(Ptr, str.Ptr, count);
|
Internal.MemCpy(Ptr, str.Ptr, count);
|
||||||
mLength = count;
|
mLength = count;
|
||||||
mAllocSizeAndFlags = (uint_strsize)bufferSize + (int_strsize)sizeof(char8*);
|
mAllocSizeAndFlags = (uint_strsize)bufferSize + (int_strsize)sizeof(char8*);
|
||||||
|
@ -108,6 +111,7 @@ namespace System
|
||||||
int bufferSize = (count == 0) ? 0 : (count - 1) & ~(sizeof(char8*) - 1);
|
int bufferSize = (count == 0) ? 0 : (count - 1) & ~(sizeof(char8*) - 1);
|
||||||
#unwarn
|
#unwarn
|
||||||
char8* addlPtr = append char8[bufferSize]*(?);
|
char8* addlPtr = append char8[bufferSize]*(?);
|
||||||
|
Init(bufferSize);
|
||||||
let ptr = Ptr;
|
let ptr = Ptr;
|
||||||
let srcPtr = str.Ptr;
|
let srcPtr = str.Ptr;
|
||||||
for (int_strsize i = 0; i < count; i++)
|
for (int_strsize i = 0; i < count; i++)
|
||||||
|
@ -125,6 +129,7 @@ namespace System
|
||||||
int bufferSize = (count == 0) ? 0 : (count - 1) & ~(sizeof(char8*) - 1);
|
int bufferSize = (count == 0) ? 0 : (count - 1) & ~(sizeof(char8*) - 1);
|
||||||
#unwarn
|
#unwarn
|
||||||
char8* addlPtr = append char8[bufferSize]*(?);
|
char8* addlPtr = append char8[bufferSize]*(?);
|
||||||
|
Init(bufferSize);
|
||||||
let ptr = Ptr;
|
let ptr = Ptr;
|
||||||
let srcPtr = str.Ptr;
|
let srcPtr = str.Ptr;
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
|
@ -139,6 +144,7 @@ namespace System
|
||||||
int bufferSize = (count == 0) ? 0 : (count - 1) & ~(sizeof(char8*) - 1);
|
int bufferSize = (count == 0) ? 0 : (count - 1) & ~(sizeof(char8*) - 1);
|
||||||
#unwarn
|
#unwarn
|
||||||
char8* addlPtr = append char8[bufferSize]*(?);
|
char8* addlPtr = append char8[bufferSize]*(?);
|
||||||
|
Init(bufferSize);
|
||||||
let ptr = Ptr;
|
let ptr = Ptr;
|
||||||
for (int_strsize i = 0; i < count; i++)
|
for (int_strsize i = 0; i < count; i++)
|
||||||
ptr[i] = c;
|
ptr[i] = c;
|
||||||
|
@ -152,7 +158,8 @@ namespace System
|
||||||
let count = Internal.CStrLen(char8Ptr);
|
let count = Internal.CStrLen(char8Ptr);
|
||||||
int bufferSize = (count == 0) ? 0 : (count - 1) & ~(sizeof(char8*) - 1);
|
int bufferSize = (count == 0) ? 0 : (count - 1) & ~(sizeof(char8*) - 1);
|
||||||
#unwarn
|
#unwarn
|
||||||
char8* addlPtr = append char8[bufferSize]*(?);
|
char8* addlPtr = append char8[bufferSize]*(?);
|
||||||
|
Init(bufferSize);
|
||||||
let ptr = Ptr;
|
let ptr = Ptr;
|
||||||
for (int_strsize i = 0; i < count; i++)
|
for (int_strsize i = 0; i < count; i++)
|
||||||
ptr[i] = char8Ptr[i];
|
ptr[i] = char8Ptr[i];
|
||||||
|
@ -166,6 +173,7 @@ namespace System
|
||||||
int bufferSize = (count == 0) ? 0 : (count - 1) & ~(sizeof(char8*) - 1);
|
int bufferSize = (count == 0) ? 0 : (count - 1) & ~(sizeof(char8*) - 1);
|
||||||
#unwarn
|
#unwarn
|
||||||
char8* addlPtr = append char8[bufferSize]*(?);
|
char8* addlPtr = append char8[bufferSize]*(?);
|
||||||
|
Init(bufferSize);
|
||||||
let ptr = Ptr;
|
let ptr = Ptr;
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
ptr[i] = char8Ptr[i];
|
ptr[i] = char8Ptr[i];
|
||||||
|
@ -180,6 +188,7 @@ namespace System
|
||||||
int bufferSize = (count == 0) ? 0 : (count - 1) & ~(sizeof(char8*) - 1);
|
int bufferSize = (count == 0) ? 0 : (count - 1) & ~(sizeof(char8*) - 1);
|
||||||
#unwarn
|
#unwarn
|
||||||
char8* addlPtr = append char8[bufferSize]*(?);
|
char8* addlPtr = append char8[bufferSize]*(?);
|
||||||
|
Init(bufferSize);
|
||||||
mAllocSizeAndFlags = (uint_strsize)bufferSize + (int_strsize)sizeof(char8*);
|
mAllocSizeAndFlags = (uint_strsize)bufferSize + (int_strsize)sizeof(char8*);
|
||||||
mLength = 0;
|
mLength = 0;
|
||||||
UTF16.Decode(char16Ptr, this);
|
UTF16.Decode(char16Ptr, this);
|
||||||
|
@ -192,6 +201,7 @@ namespace System
|
||||||
int bufferSize = (count == 0) ? 0 : (count - 1) & ~(sizeof(char8*) - 1);
|
int bufferSize = (count == 0) ? 0 : (count - 1) & ~(sizeof(char8*) - 1);
|
||||||
#unwarn
|
#unwarn
|
||||||
char8* addlPtr = append char8[bufferSize]*(?);
|
char8* addlPtr = append char8[bufferSize]*(?);
|
||||||
|
Init(bufferSize);
|
||||||
mAllocSizeAndFlags = (uint_strsize)bufferSize + (int_strsize)sizeof(char8*);
|
mAllocSizeAndFlags = (uint_strsize)bufferSize + (int_strsize)sizeof(char8*);
|
||||||
mLength = 0;
|
mLength = 0;
|
||||||
UTF16.Decode(chars, this);
|
UTF16.Decode(chars, this);
|
||||||
|
@ -204,6 +214,7 @@ namespace System
|
||||||
let bufferSize = (tryBufferSize >= 0) ? tryBufferSize : 0;
|
let bufferSize = (tryBufferSize >= 0) ? tryBufferSize : 0;
|
||||||
#unwarn
|
#unwarn
|
||||||
char8* addlPtr = append char8[bufferSize]*(?);
|
char8* addlPtr = append char8[bufferSize]*(?);
|
||||||
|
Init(bufferSize);
|
||||||
let ptr = Ptr;
|
let ptr = Ptr;
|
||||||
Internal.MemCpy(ptr, strView.Ptr, strView.Length);
|
Internal.MemCpy(ptr, strView.Ptr, strView.Length);
|
||||||
mAllocSizeAndFlags = (uint_strsize)bufferSize + (int_strsize)sizeof(char8*);
|
mAllocSizeAndFlags = (uint_strsize)bufferSize + (int_strsize)sizeof(char8*);
|
||||||
|
@ -216,7 +227,8 @@ namespace System
|
||||||
let count = strView.Length + (flags.HasFlag(.NullTerminate) ? 1 : 0);
|
let count = strView.Length + (flags.HasFlag(.NullTerminate) ? 1 : 0);
|
||||||
int bufferSize = (count == 0) ? 0 : (count - 1) & ~(sizeof(char8*) - 1);
|
int bufferSize = (count == 0) ? 0 : (count - 1) & ~(sizeof(char8*) - 1);
|
||||||
#unwarn
|
#unwarn
|
||||||
char8* addlPtr = append char8[bufferSize]*(?);
|
char8* addlPtr = append char8[bufferSize]*(?);
|
||||||
|
Init(bufferSize);
|
||||||
let ptr = Ptr;
|
let ptr = Ptr;
|
||||||
Internal.MemCpy(ptr, strView.Ptr, strView.Length);
|
Internal.MemCpy(ptr, strView.Ptr, strView.Length);
|
||||||
if (flags.HasFlag(.NullTerminate))
|
if (flags.HasFlag(.NullTerminate))
|
||||||
|
@ -233,7 +245,8 @@ namespace System
|
||||||
let count = strView.Length - offset;
|
let count = strView.Length - offset;
|
||||||
int bufferSize = (count == 0) ? 0 : (count - 1) & ~(sizeof(char8*) - 1);
|
int bufferSize = (count == 0) ? 0 : (count - 1) & ~(sizeof(char8*) - 1);
|
||||||
#unwarn
|
#unwarn
|
||||||
char8* addlPtr = append char8[bufferSize]*(?);
|
char8* addlPtr = append char8[bufferSize]*(?);
|
||||||
|
Init(bufferSize);
|
||||||
let ptr = Ptr;
|
let ptr = Ptr;
|
||||||
let srcPtr = strView.Ptr;
|
let srcPtr = strView.Ptr;
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
|
@ -250,7 +263,8 @@ namespace System
|
||||||
|
|
||||||
int bufferSize = (count == 0) ? 0 : (count - 1) & ~(sizeof(char8*) - 1);
|
int bufferSize = (count == 0) ? 0 : (count - 1) & ~(sizeof(char8*) - 1);
|
||||||
#unwarn
|
#unwarn
|
||||||
char8* addlPtr = append char8[bufferSize]*(?);
|
char8* addlPtr = append char8[bufferSize]*(?);
|
||||||
|
Init(bufferSize);
|
||||||
let ptr = Ptr;
|
let ptr = Ptr;
|
||||||
let srcPtr = strView.Ptr;
|
let srcPtr = strView.Ptr;
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
|
@ -264,7 +278,8 @@ namespace System
|
||||||
{
|
{
|
||||||
int bufferSize = (count == 0) ? 0 : (count - 1) & ~(sizeof(char8*) - 1);
|
int bufferSize = (count == 0) ? 0 : (count - 1) & ~(sizeof(char8*) - 1);
|
||||||
#unwarn
|
#unwarn
|
||||||
char8* addlPtr = append char8[bufferSize]*(?);
|
char8* addlPtr = append char8[bufferSize]*(?);
|
||||||
|
Init(bufferSize);
|
||||||
let ptr = Ptr;
|
let ptr = Ptr;
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
ptr[i] = chars[i + offset];
|
ptr[i] = chars[i + offset];
|
||||||
|
@ -287,6 +302,7 @@ namespace System
|
||||||
int bufferSize = (count == 0) ? 0 : (count - 1) & ~(sizeof(char8*) - 1);
|
int bufferSize = (count == 0) ? 0 : (count - 1) & ~(sizeof(char8*) - 1);
|
||||||
#unwarn
|
#unwarn
|
||||||
char8* addlPtr = append char8[bufferSize]*(?);
|
char8* addlPtr = append char8[bufferSize]*(?);
|
||||||
|
Init(bufferSize);
|
||||||
let ptr = Ptr;
|
let ptr = Ptr;
|
||||||
int curIdx = 0;
|
int curIdx = 0;
|
||||||
for (var str in strs)
|
for (var str in strs)
|
||||||
|
@ -299,6 +315,14 @@ namespace System
|
||||||
mAllocSizeAndFlags = (uint_strsize)bufferSize + (int_strsize)sizeof(char8*);
|
mAllocSizeAndFlags = (uint_strsize)bufferSize + (int_strsize)sizeof(char8*);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !VALGRIND
|
||||||
|
[SkipCall]
|
||||||
|
#endif
|
||||||
|
void Init(int appendSize)
|
||||||
|
{
|
||||||
|
Internal.MemSet(Ptr, 0, appendSize + (int_strsize)sizeof(char8*));
|
||||||
|
}
|
||||||
|
|
||||||
public ~this()
|
public ~this()
|
||||||
{
|
{
|
||||||
if (IsDynAlloc)
|
if (IsDynAlloc)
|
||||||
|
@ -692,8 +716,11 @@ namespace System
|
||||||
{
|
{
|
||||||
Debug.Assert(AllocSize > 0, "String has been frozen");
|
Debug.Assert(AllocSize > 0, "String has been frozen");
|
||||||
Debug.Assert((uint)newSize <= cSizeFlags);
|
Debug.Assert((uint)newSize <= cSizeFlags);
|
||||||
char8* newPtr = new:this char8[newSize]*;
|
char8* newPtr = new:this char8[newSize]* (?);
|
||||||
Internal.MemCpy(newPtr, Ptr, mLength);
|
Internal.MemCpy(newPtr, Ptr, mLength);
|
||||||
|
#if VALGRIND
|
||||||
|
Internal.MemSet(newPtr + mLength, 0, newSize - mLength);
|
||||||
|
#endif
|
||||||
if (IsDynAlloc)
|
if (IsDynAlloc)
|
||||||
delete:this mPtr;
|
delete:this mPtr;
|
||||||
mPtr = newPtr;
|
mPtr = newPtr;
|
||||||
|
@ -772,7 +799,10 @@ namespace System
|
||||||
{
|
{
|
||||||
// This handles appending to ourselves, we invalidate 'ptr' after calling Realloc
|
// This handles appending to ourselves, we invalidate 'ptr' after calling Realloc
|
||||||
int newSize = CalcNewSize(newCurrentIndex);
|
int newSize = CalcNewSize(newCurrentIndex);
|
||||||
char8* newPtr = new:this char8[newSize]*;
|
char8* newPtr = new:this char8[newSize]* (?);
|
||||||
|
#if VALGRIND
|
||||||
|
Internal.MemSet(newPtr, 0, newSize);
|
||||||
|
#endif
|
||||||
Internal.MemCpy(newPtr + mLength, appendPtr, length);
|
Internal.MemCpy(newPtr + mLength, appendPtr, length);
|
||||||
Realloc(newPtr, newSize);
|
Realloc(newPtr, newSize);
|
||||||
ptr = newPtr;
|
ptr = newPtr;
|
||||||
|
@ -793,7 +823,10 @@ namespace System
|
||||||
{
|
{
|
||||||
// This handles appending to ourselves, we invalidate 'ptr' after calling Realloc
|
// This handles appending to ourselves, we invalidate 'ptr' after calling Realloc
|
||||||
int newSize = CalcNewSize(newCurrentIndex);
|
int newSize = CalcNewSize(newCurrentIndex);
|
||||||
char8* newPtr = new:this char8[newSize]*;
|
char8* newPtr = new:this char8[newSize]* (?);
|
||||||
|
#if VALGRIND
|
||||||
|
Internal.MemSet(newPtr, 0, newSize);
|
||||||
|
#endif
|
||||||
Internal.MemCpy(newPtr + mLength, appendPtr, length);
|
Internal.MemCpy(newPtr + mLength, appendPtr, length);
|
||||||
Realloc(newPtr, newSize);
|
Realloc(newPtr, newSize);
|
||||||
ptr = newPtr;
|
ptr = newPtr;
|
||||||
|
@ -814,7 +847,10 @@ namespace System
|
||||||
{
|
{
|
||||||
// This handles appending to ourselves, we invalidate 'ptr' after calling Realloc
|
// This handles appending to ourselves, we invalidate 'ptr' after calling Realloc
|
||||||
int newSize = CalcNewSize(newCurrentIndex);
|
int newSize = CalcNewSize(newCurrentIndex);
|
||||||
char8* newPtr = new:this char8[newSize]*;
|
char8* newPtr = new:this char8[newSize]* (?);
|
||||||
|
#if VALGRIND
|
||||||
|
Internal.MemSet(newPtr, 0, newSize);
|
||||||
|
#endif
|
||||||
Internal.MemCpy(newPtr + mLength, arr.CArray() + idx, length);
|
Internal.MemCpy(newPtr + mLength, arr.CArray() + idx, length);
|
||||||
Realloc(newPtr, newSize);
|
Realloc(newPtr, newSize);
|
||||||
ptr = newPtr;
|
ptr = newPtr;
|
||||||
|
|
|
@ -73,14 +73,22 @@ namespace System.Threading
|
||||||
|
|
||||||
int32 stackStart = 0;
|
int32 stackStart = 0;
|
||||||
thread.SetStackStart((void*)&stackStart);
|
thread.SetStackStart((void*)&stackStart);
|
||||||
if (thread.mDelegate is ThreadStart)
|
|
||||||
|
var dlg = thread.mDelegate;
|
||||||
|
var threadStartArg = thread.mThreadStartArg;
|
||||||
|
thread.mDelegate = null;
|
||||||
|
|
||||||
|
thread.ThreadStarted();
|
||||||
|
|
||||||
|
if (dlg is ThreadStart)
|
||||||
{
|
{
|
||||||
((ThreadStart)thread.mDelegate)();
|
((ThreadStart)dlg)();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
((ParameterizedThreadStart)thread.mDelegate)(thread.mThreadStartArg);
|
((ParameterizedThreadStart)dlg)(threadStartArg);
|
||||||
}
|
}
|
||||||
|
delete dlg;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static this()
|
public static this()
|
||||||
|
@ -173,6 +181,7 @@ namespace System.Threading
|
||||||
extern void ManualThreadInit();
|
extern void ManualThreadInit();
|
||||||
extern void StartInternal();
|
extern void StartInternal();
|
||||||
extern void SetStackStart(void* ptr);
|
extern void SetStackStart(void* ptr);
|
||||||
|
extern void ThreadStarted();
|
||||||
|
|
||||||
public void Start(bool autoDelete = true)
|
public void Start(bool autoDelete = true)
|
||||||
{
|
{
|
||||||
|
@ -335,10 +344,9 @@ namespace System.Threading
|
||||||
mMaxStackSize = maxStackSize;
|
mMaxStackSize = maxStackSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ~this()
|
public ~this()
|
||||||
{
|
{
|
||||||
// Make sure we're not deleting manually it mAutoDelete is set
|
// Make sure we're not deleting manually if mAutoDelete is set
|
||||||
Debug.Assert((!mAutoDelete) || (CurrentThread == this));
|
Debug.Assert((!mAutoDelete) || (CurrentThread == this));
|
||||||
// Delegate to the unmanaged portion.
|
// Delegate to the unmanaged portion.
|
||||||
InternalFinalize();
|
InternalFinalize();
|
||||||
|
|
|
@ -547,8 +547,11 @@ void Internal::Dbg_ObjectPreCustomDelete(bf::System::Object* object)
|
||||||
{
|
{
|
||||||
BF_ASSERT((BFRTFLAGS & BfRtFlags_ObjectHasDebugFlags) != 0);
|
BF_ASSERT((BFRTFLAGS & BfRtFlags_ObjectHasDebugFlags) != 0);
|
||||||
|
|
||||||
const char* errorPtr = NULL;
|
if ((object->mObjectFlags & BfObjectFlag_AppendAlloc) != 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const char* errorPtr = NULL;
|
||||||
|
|
||||||
if ((object->mObjectFlags & BfObjectFlag_StackAlloc) != 0)
|
if ((object->mObjectFlags & BfObjectFlag_StackAlloc) != 0)
|
||||||
errorPtr = "Attempting to delete stack-allocated object";
|
errorPtr = "Attempting to delete stack-allocated object";
|
||||||
if ((object->mObjectFlags & BfObjectFlag_Deleted) != 0)
|
if ((object->mObjectFlags & BfObjectFlag_Deleted) != 0)
|
||||||
|
@ -564,8 +567,7 @@ void Internal::Dbg_ObjectPreCustomDelete(bf::System::Object* object)
|
||||||
errorStr += StrFormat(" (%s)0x%@\n", typeName.c_str(), object);
|
errorStr += StrFormat(" (%s)0x%@\n", typeName.c_str(), object);
|
||||||
SETUP_ERROR(errorStr.c_str(), 2);
|
SETUP_ERROR(errorStr.c_str(), 2);
|
||||||
BF_DEBUG_BREAK();
|
BF_DEBUG_BREAK();
|
||||||
BFRTCALLBACKS.DebugMessageData_Fatal();
|
BFRTCALLBACKS.DebugMessageData_Fatal();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -120,16 +120,21 @@ static void BF_CALLTYPE CStartProc(void* threadParam)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto internalThread = thread->GetInternalThread();
|
auto internalThread = thread->GetInternalThread();
|
||||||
|
|
||||||
|
// Hold lock until we get ThreadStarted callback
|
||||||
|
internalThread->mCritSect.Lock();
|
||||||
|
|
||||||
|
internalThread->mStartedEvent.Set(true);
|
||||||
internalThread->mThreadHandle = BfpThread_GetCurrent();
|
internalThread->mThreadHandle = BfpThread_GetCurrent();
|
||||||
internalThread->mStackStart = (intptr)&thread;
|
internalThread->mStackStart = (intptr)&thread;
|
||||||
internalThread->ThreadStarted();
|
internalThread->ThreadStarted();
|
||||||
|
|
||||||
bool isAutoDelete = gBfRtCallbacks.Thread_IsAutoDelete(thread);
|
bool isAutoDelete = gBfRtCallbacks.Thread_IsAutoDelete(thread);
|
||||||
gBfRtCallbacks.Thread_ThreadProc(thread);
|
gBfRtCallbacks.Thread_ThreadProc(thread);
|
||||||
bool isLastThread = BfpSystem_InterlockedExchangeAdd32((uint32*)&gLiveThreadCount, -1) == 1;
|
bool isLastThread = BfpSystem_InterlockedExchangeAdd32((uint32*)&gLiveThreadCount, -1) == 1;
|
||||||
|
|
||||||
//printf("Stopping thread\n");
|
//printf("Stopping thread\n");
|
||||||
|
|
||||||
bool wantsDelete = false;
|
bool wantsDelete = false;
|
||||||
//
|
//
|
||||||
{
|
{
|
||||||
|
@ -143,8 +148,7 @@ static void BF_CALLTYPE CStartProc(void* threadParam)
|
||||||
if (internalThread->mThread == NULL)
|
if (internalThread->mThread == NULL)
|
||||||
{
|
{
|
||||||
// If the thread was already deleted then we need to delete ourselves now
|
// If the thread was already deleted then we need to delete ourselves now
|
||||||
wantsDelete = true;
|
wantsDelete = true;
|
||||||
internalThread = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,6 +198,9 @@ void Thread::StartInternal()
|
||||||
BfpSystem_InterlockedExchangeAdd32((uint32*)&gLiveThreadCount, 1);
|
BfpSystem_InterlockedExchangeAdd32((uint32*)&gLiveThreadCount, 1);
|
||||||
|
|
||||||
BfInternalThread* internalThread = SetupInternalThread();
|
BfInternalThread* internalThread = SetupInternalThread();
|
||||||
|
|
||||||
|
Beefy::AutoCrit autoCrit(internalThread->mCritSect);
|
||||||
|
internalThread->mStarted = true;
|
||||||
internalThread->mThread = this;
|
internalThread->mThread = this;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
internalThread->mThreadHandle = BfpThread_Create(CStartProc, (void*)this, GetMaxStackSize(), (BfpThreadCreateFlags)(BfpThreadCreateFlag_StackSizeReserve | BfpThreadCreateFlag_Suspended), &internalThread->mThreadId);
|
internalThread->mThreadHandle = BfpThread_Create(CStartProc, (void*)this, GetMaxStackSize(), (BfpThreadCreateFlags)(BfpThreadCreateFlag_StackSizeReserve | BfpThreadCreateFlag_Suspended), &internalThread->mThreadId);
|
||||||
|
@ -205,6 +212,12 @@ void Thread::StartInternal()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Thread::ThreadStarted()
|
||||||
|
{
|
||||||
|
auto internalThread = GetInternalThread();
|
||||||
|
internalThread->mCritSect.Unlock();
|
||||||
|
}
|
||||||
|
|
||||||
int Thread::GetThreadId()
|
int Thread::GetThreadId()
|
||||||
{
|
{
|
||||||
return (int)GetInternalThread()->mThreadId;
|
return (int)GetInternalThread()->mThreadId;
|
||||||
|
@ -221,11 +234,22 @@ void Thread::InternalFinalize()
|
||||||
auto internalThread = GetInternalThread();
|
auto internalThread = GetInternalThread();
|
||||||
if (internalThread == NULL)
|
if (internalThread == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool wantsJoin = false;
|
bool wantsJoin = false;
|
||||||
|
|
||||||
|
bool started = false;
|
||||||
//
|
//
|
||||||
{
|
{
|
||||||
Beefy::AutoCrit autoCrit(internalThread->mCritSect);
|
Beefy::AutoCrit autoCrit(internalThread->mCritSect);
|
||||||
|
started = internalThread->mStarted;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (started)
|
||||||
|
internalThread->mStartedEvent.WaitFor();
|
||||||
|
|
||||||
|
//
|
||||||
|
{
|
||||||
|
Beefy::AutoCrit autoCrit(internalThread->mCritSect);
|
||||||
if ((!internalThread->mDone) && (internalThread->mJoinOnDelete))
|
if ((!internalThread->mDone) && (internalThread->mJoinOnDelete))
|
||||||
{
|
{
|
||||||
if (this != BfGetCurrentThread())
|
if (this != BfGetCurrentThread())
|
||||||
|
@ -255,6 +279,9 @@ void Thread::InternalFinalize()
|
||||||
SetInternalThread(NULL);
|
SetInternalThread(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (internalThread->mIsManualInit)
|
||||||
|
wantsDelete = true;
|
||||||
|
|
||||||
if (wantsDelete)
|
if (wantsDelete)
|
||||||
delete internalThread;
|
delete internalThread;
|
||||||
}
|
}
|
||||||
|
@ -283,53 +310,3 @@ void Thread::MemoryBarrier()
|
||||||
{
|
{
|
||||||
BF_FULL_MEMORY_FENCE();
|
BF_FULL_MEMORY_FENCE();
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// BfInternalThread::BfInternalThread()
|
|
||||||
// {
|
|
||||||
// #ifdef BF_GC_SUPPORTED
|
|
||||||
// mBFIThreadData = NULL;
|
|
||||||
// #endif
|
|
||||||
//
|
|
||||||
// mThread = NULL;
|
|
||||||
// mThreadHandle = 0;
|
|
||||||
// mStarted = false;
|
|
||||||
// mRunning = false;
|
|
||||||
// mDone = false;
|
|
||||||
// mIsSuspended = false;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// BfInternalThread::~BfInternalThread()
|
|
||||||
// {
|
|
||||||
// if (mThreadHandle != 0)
|
|
||||||
// {
|
|
||||||
// BfpThread_Release(mThreadHandle);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// void BfInternalThread::ManualThreadInit(bf::System::Threading::Thread* thread)
|
|
||||||
// {
|
|
||||||
// bf::System::Threading::Thread* newThread = thread;
|
|
||||||
//
|
|
||||||
// mStarted = true;
|
|
||||||
// mThread = newThread;
|
|
||||||
// newThread->SetInternalThread(this);
|
|
||||||
// mThreadId = BfpThread_GetCurrentId();
|
|
||||||
// mThreadHandle = BfpThread_GetCurrent();
|
|
||||||
// mStackStart = ((intptr)&newThread + 0xFFF) & ~(intptr)0xFFF;
|
|
||||||
// ThreadStarted();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// void BfInternalThread::ThreadStarted()
|
|
||||||
// {
|
|
||||||
// BF_ASSERT((gBfRtFlags & BfRtFlags_ObjectHasDebugFlags) == 0);
|
|
||||||
// int threadPriority = BfpThread_GetPriority(mThreadHandle, NULL);
|
|
||||||
// mRunning = true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// void BfInternalThread::ThreadStopped()
|
|
||||||
// {
|
|
||||||
// BF_ASSERT((gBfRtFlags & BfRtFlags_ObjectHasDebugFlags) == 0);
|
|
||||||
// mRunning = false;
|
|
||||||
// }
|
|
||||||
|
|
|
@ -55,6 +55,7 @@ namespace bf
|
||||||
BFRT_EXPORT static Thread* GetCurrentThreadNative();
|
BFRT_EXPORT static Thread* GetCurrentThreadNative();
|
||||||
BFRT_EXPORT unsigned long GetProcessDefaultStackSize();
|
BFRT_EXPORT unsigned long GetProcessDefaultStackSize();
|
||||||
BFRT_EXPORT void StartInternal();
|
BFRT_EXPORT void StartInternal();
|
||||||
|
BFRT_EXPORT void ThreadStarted();
|
||||||
BFRT_EXPORT void SetStackStart(void* ptr);
|
BFRT_EXPORT void SetStackStart(void* ptr);
|
||||||
BFRT_EXPORT void InternalFinalize();
|
BFRT_EXPORT void InternalFinalize();
|
||||||
BFRT_EXPORT bool IsBackgroundNative();
|
BFRT_EXPORT bool IsBackgroundNative();
|
||||||
|
@ -107,9 +108,11 @@ public:
|
||||||
bool mDone;
|
bool mDone;
|
||||||
bool mStarted;
|
bool mStarted;
|
||||||
bool mJoinOnDelete;
|
bool mJoinOnDelete;
|
||||||
|
bool mIsManualInit;
|
||||||
BfpThread* mThreadHandle;
|
BfpThread* mThreadHandle;
|
||||||
intptr mThreadId;
|
intptr mThreadId;
|
||||||
Beefy::CritSect mCritSect;
|
Beefy::CritSect mCritSect;
|
||||||
|
Beefy::SyncEvent mStartedEvent;
|
||||||
|
|
||||||
BfInternalThread()
|
BfInternalThread()
|
||||||
{
|
{
|
||||||
|
@ -120,6 +123,7 @@ public:
|
||||||
mDone = false;
|
mDone = false;
|
||||||
mIsSuspended = false;
|
mIsSuspended = false;
|
||||||
mJoinOnDelete = true;
|
mJoinOnDelete = true;
|
||||||
|
mIsManualInit = false;
|
||||||
mStackStart = 0;
|
mStackStart = 0;
|
||||||
mThreadId = 0;
|
mThreadId = 0;
|
||||||
}
|
}
|
||||||
|
@ -136,7 +140,9 @@ public:
|
||||||
{
|
{
|
||||||
bf::System::Threading::Thread* newThread = thread;
|
bf::System::Threading::Thread* newThread = thread;
|
||||||
|
|
||||||
|
mIsManualInit = true;
|
||||||
mStarted = true;
|
mStarted = true;
|
||||||
|
mStartedEvent.Set(true);
|
||||||
mThread = newThread;
|
mThread = newThread;
|
||||||
newThread->SetInternalThread(this);
|
newThread->SetInternalThread(this);
|
||||||
mThreadId = BfpThread_GetCurrentId();
|
mThreadId = BfpThread_GetCurrentId();
|
||||||
|
|
|
@ -1219,6 +1219,10 @@ struct BfpThread
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~BfpThread()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void Release()
|
void Release()
|
||||||
{
|
{
|
||||||
int refCount = __sync_fetch_and_sub(&mRefCount, 1) - 1;
|
int refCount = __sync_fetch_and_sub(&mRefCount, 1) - 1;
|
||||||
|
@ -1240,11 +1244,13 @@ static __thread BfpThreadInfo gCurrentThreadInfo;
|
||||||
void* ThreadFunc(void* threadParam)
|
void* ThreadFunc(void* threadParam)
|
||||||
{
|
{
|
||||||
BfpThread* thread = (BfpThread*)threadParam;
|
BfpThread* thread = (BfpThread*)threadParam;
|
||||||
|
|
||||||
gCurrentThread = thread;
|
gCurrentThread = thread;
|
||||||
thread->mStartProc(thread->mThreadParam);
|
thread->mStartProc(thread->mThreadParam);
|
||||||
#ifndef BFP_HAS_PTHREAD_TIMEDJOIN_NP
|
#ifndef BFP_HAS_PTHREAD_TIMEDJOIN_NP
|
||||||
BfpEvent_Set(thread->mDoneEvent, true);
|
BfpEvent_Set(thread->mDoneEvent, true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
thread->Release();
|
thread->Release();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1300,6 +1306,7 @@ BFP_EXPORT void BFP_CALLTYPE BfpThread_Release(BfpThread* thread)
|
||||||
pthread_detach(thread->mPThread);
|
pthread_detach(thread->mPThread);
|
||||||
thread->mPThreadReleased = true;
|
thread->mPThreadReleased = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
thread->Release();
|
thread->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1485,6 +1492,7 @@ BFP_EXPORT BfpCritSect* BFP_CALLTYPE BfpCritSect_Create()
|
||||||
BFP_EXPORT void BFP_CALLTYPE BfpCritSect_Release(BfpCritSect* critSect)
|
BFP_EXPORT void BFP_CALLTYPE BfpCritSect_Release(BfpCritSect* critSect)
|
||||||
{
|
{
|
||||||
pthread_mutex_destroy(&critSect->mPMutex);
|
pthread_mutex_destroy(&critSect->mPMutex);
|
||||||
|
delete critSect;
|
||||||
}
|
}
|
||||||
|
|
||||||
BFP_EXPORT void BFP_CALLTYPE BfpCritSect_Enter(BfpCritSect* critSect)
|
BFP_EXPORT void BFP_CALLTYPE BfpCritSect_Enter(BfpCritSect* critSect)
|
||||||
|
@ -1564,6 +1572,7 @@ BFP_EXPORT void BFP_CALLTYPE BfpEvent_Release(BfpEvent* event)
|
||||||
{
|
{
|
||||||
pthread_cond_destroy(&event->mCondVariable);
|
pthread_cond_destroy(&event->mCondVariable);
|
||||||
pthread_mutex_destroy(&event->mMutex);
|
pthread_mutex_destroy(&event->mMutex);
|
||||||
|
delete event;
|
||||||
}
|
}
|
||||||
|
|
||||||
BFP_EXPORT void BFP_CALLTYPE BfpEvent_Set(BfpEvent* event, bool requireManualReset)
|
BFP_EXPORT void BFP_CALLTYPE BfpEvent_Set(BfpEvent* event, bool requireManualReset)
|
||||||
|
@ -2266,7 +2275,7 @@ BFP_EXPORT void BFP_CALLTYPE BfpFile_GetFullPath(const char* inPath, char* outPa
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char* cwdPtr = getcwd(NULL, 0);
|
char* cwdPtr = getcwd(NULL, 0);
|
||||||
Beefy::String cwdPath = cwdPtr;
|
Beefy::String cwdPath = cwdPtr;
|
||||||
free(cwdPtr);
|
free(cwdPtr);
|
||||||
str = GetAbsPath(inPath, cwdPath);
|
str = GetAbsPath(inPath, cwdPath);
|
||||||
}
|
}
|
||||||
|
@ -2324,6 +2333,7 @@ BFP_EXPORT BfpFindFileData* BFP_CALLTYPE BfpFindFileData_FindFirstFile(const cha
|
||||||
if (!BfpFindFileData_FindNextFile(findData))
|
if (!BfpFindFileData_FindNextFile(findData))
|
||||||
{
|
{
|
||||||
OUTRESULT(BfpFileResult_NoResults);
|
OUTRESULT(BfpFileResult_NoResults);
|
||||||
|
closedir(findData->mDirStruct);
|
||||||
delete findData;
|
delete findData;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -2448,6 +2458,7 @@ BFP_EXPORT int64 BFP_CALLTYPE BfpFindFileData_GetFileSize(BfpFindFileData* findD
|
||||||
|
|
||||||
BFP_EXPORT void BFP_CALLTYPE BfpFindFileData_Release(BfpFindFileData* findData)
|
BFP_EXPORT void BFP_CALLTYPE BfpFindFileData_Release(BfpFindFileData* findData)
|
||||||
{
|
{
|
||||||
|
closedir(findData->mDirStruct);
|
||||||
delete findData;
|
delete findData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -870,7 +870,7 @@ void* BpManager::AllocBytes(int size)
|
||||||
|
|
||||||
void BpManager::FreeBytes(void* ptr)
|
void BpManager::FreeBytes(void* ptr)
|
||||||
{
|
{
|
||||||
delete (uint8*)ptr;
|
delete [] (uint8*)ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BpManager::FinishWorkThread()
|
void BpManager::FinishWorkThread()
|
||||||
|
|
|
@ -43,7 +43,7 @@ public:
|
||||||
|
|
||||||
~BitSet()
|
~BitSet()
|
||||||
{
|
{
|
||||||
delete this->mBits;
|
delete [] this->mBits;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Resize(int numBits)
|
void Resize(int numBits)
|
||||||
|
|
|
@ -429,7 +429,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delete mEntries;
|
delete [] mEntries;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary& operator=(const Dictionary& rhs)
|
Dictionary& operator=(const Dictionary& rhs)
|
||||||
|
|
|
@ -25,6 +25,7 @@ namespace IDE
|
||||||
public List<RegistryEntry> mEntries = new List<RegistryEntry>() ~ DeleteContainerAndItems!(_);
|
public List<RegistryEntry> mEntries = new List<RegistryEntry>() ~ DeleteContainerAndItems!(_);
|
||||||
public Monitor mMonitor = new .() ~ delete _;
|
public Monitor mMonitor = new .() ~ delete _;
|
||||||
public WaitEvent mEvent = new .() ~ delete _;
|
public WaitEvent mEvent = new .() ~ delete _;
|
||||||
|
public Thread mThread ~ delete _;
|
||||||
|
|
||||||
public ~this()
|
public ~this()
|
||||||
{
|
{
|
||||||
|
@ -75,8 +76,9 @@ namespace IDE
|
||||||
|
|
||||||
public void StartResolve()
|
public void StartResolve()
|
||||||
{
|
{
|
||||||
var thread = new Thread(new => Resolve);
|
delete mThread;
|
||||||
thread.Start(true);
|
mThread = new Thread(new => Resolve);
|
||||||
|
mThread.Start(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11554,11 +11554,13 @@ namespace IDE
|
||||||
|
|
||||||
public void CreateSpellChecker()
|
public void CreateSpellChecker()
|
||||||
{
|
{
|
||||||
|
#if !CLI
|
||||||
mSpellChecker = new SpellChecker();
|
mSpellChecker = new SpellChecker();
|
||||||
if (mSpellChecker.Init(scope String(mInstallDir, "en_US")) case .Err)
|
if (mSpellChecker.Init(scope String(mInstallDir, "en_US")) case .Err)
|
||||||
{
|
{
|
||||||
DeleteAndNullify!(mSpellChecker);
|
DeleteAndNullify!(mSpellChecker);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileVersionInfo GetVersionInfo(out DateTime exeTime)
|
public FileVersionInfo GetVersionInfo(out DateTime exeTime)
|
||||||
|
|
|
@ -2854,16 +2854,16 @@ void BeIRCodeGen::HandleNextCmd()
|
||||||
CMD_PARAM(int, typeId);
|
CMD_PARAM(int, typeId);
|
||||||
CMD_PARAM(BeMDNode*, type);
|
CMD_PARAM(BeMDNode*, type);
|
||||||
auto& typeEntry = GetTypeEntry(typeId);
|
auto& typeEntry = GetTypeEntry(typeId);
|
||||||
typeEntry.mDIType = (BeDbgType*)type;
|
typeEntry.mDIType = BeValueDynCast<BeDbgType>(type);
|
||||||
if (typeEntry.mInstDIType == NULL)
|
if (typeEntry.mInstDIType == NULL)
|
||||||
typeEntry.mInstDIType = (BeDbgType*)type;
|
typeEntry.mInstDIType = BeValueDynCast<BeDbgType>(type);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BfIRCmd_DbgSetInstType:
|
case BfIRCmd_DbgSetInstType:
|
||||||
{
|
{
|
||||||
CMD_PARAM(int, typeId);
|
CMD_PARAM(int, typeId);
|
||||||
CMD_PARAM(BeMDNode*, type);
|
CMD_PARAM(BeMDNode*, type);
|
||||||
GetTypeEntry(typeId).mInstDIType = (BeDbgType*)type;
|
GetTypeEntry(typeId).mInstDIType = BeValueDynCast<BeDbgType>(type);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BfIRCmd_DbgGetType:
|
case BfIRCmd_DbgGetType:
|
||||||
|
@ -2955,7 +2955,7 @@ void BeIRCodeGen::HandleNextCmd()
|
||||||
dbgType->mName = name;
|
dbgType->mName = name;
|
||||||
dbgType->mSize = (int)(sizeInBits / 8);
|
dbgType->mSize = (int)(sizeInBits / 8);
|
||||||
dbgType->mAlign = (int)(alignInBits / 8);
|
dbgType->mAlign = (int)(alignInBits / 8);
|
||||||
dbgType->mDerivedFrom = (BeDbgType*)derivedFrom;
|
dbgType->mDerivedFrom = BeValueDynCast<BeDbgType>(derivedFrom);
|
||||||
dbgType->mDefFile = (BeDbgFile*)file;
|
dbgType->mDefFile = (BeDbgFile*)file;
|
||||||
dbgType->mDefLine = lineNum - 1;
|
dbgType->mDefLine = lineNum - 1;
|
||||||
dbgType->mIsFullyDefined = true;
|
dbgType->mIsFullyDefined = true;
|
||||||
|
@ -2981,7 +2981,7 @@ void BeIRCodeGen::HandleNextCmd()
|
||||||
dbgType->mSize = (int)(sizeInBits / 8);
|
dbgType->mSize = (int)(sizeInBits / 8);
|
||||||
dbgType->mAlign = (int)(alignInBits / 8);
|
dbgType->mAlign = (int)(alignInBits / 8);
|
||||||
dbgType->mIsFullyDefined = true;
|
dbgType->mIsFullyDefined = true;
|
||||||
dbgType->mElementType = (BeDbgType*)underlyingType;
|
dbgType->mElementType = BeValueDynCast<BeDbgType>(underlyingType);
|
||||||
for (auto member : members)
|
for (auto member : members)
|
||||||
{
|
{
|
||||||
if (auto enumMember = BeValueDynCast<BeDbgEnumMember>(member))
|
if (auto enumMember = BeValueDynCast<BeDbgEnumMember>(member))
|
||||||
|
@ -3101,7 +3101,7 @@ void BeIRCodeGen::HandleNextCmd()
|
||||||
auto dbgArray = mBeModule->mDbgModule->mTypes.Alloc<BeDbgArrayType>();
|
auto dbgArray = mBeModule->mDbgModule->mTypes.Alloc<BeDbgArrayType>();
|
||||||
dbgArray->mSize = (int)(sizeInBits / 8);
|
dbgArray->mSize = (int)(sizeInBits / 8);
|
||||||
dbgArray->mAlign = (int)(alignInBits / 8);
|
dbgArray->mAlign = (int)(alignInBits / 8);
|
||||||
dbgArray->mElement = (BeDbgType*)elementType;
|
dbgArray->mElement = BeValueDynCast<BeDbgType>(elementType);
|
||||||
dbgArray->mNumElements = numElements;
|
dbgArray->mNumElements = numElements;
|
||||||
|
|
||||||
SetResult(curId, dbgArray);
|
SetResult(curId, dbgArray);
|
||||||
|
@ -3212,9 +3212,11 @@ void BeIRCodeGen::HandleNextCmd()
|
||||||
CMD_PARAM(int64, sizeInBits);
|
CMD_PARAM(int64, sizeInBits);
|
||||||
CMD_PARAM(int64, alignInBits);
|
CMD_PARAM(int64, alignInBits);
|
||||||
|
|
||||||
auto dbgType = (BeDbgType*)mdType;
|
if (auto dbgType = BeValueDynCast<BeDbgType>(mdType))
|
||||||
dbgType->mSize = (int)(sizeInBits / 8);
|
{
|
||||||
dbgType->mAlign = (int)(alignInBits / 8);
|
dbgType->mSize = (int)(sizeInBits / 8);
|
||||||
|
dbgType->mAlign = (int)(alignInBits / 8);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BfIRCmd_DbgReplaceAllUses:
|
case BfIRCmd_DbgReplaceAllUses:
|
||||||
|
@ -3244,7 +3246,7 @@ void BeIRCodeGen::HandleNextCmd()
|
||||||
}
|
}
|
||||||
else if (auto dbgType = BeValueDynCast<BeDbgEnumType>(diNode))
|
else if (auto dbgType = BeValueDynCast<BeDbgEnumType>(diNode))
|
||||||
{
|
{
|
||||||
dbgType->mElementType = (BeDbgType*)diBaseType;
|
dbgType->mElementType = BeValueDynCast<BeDbgType>(diBaseType);
|
||||||
dbgType->SetMembers(members);
|
dbgType->SetMembers(members);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -3279,7 +3281,7 @@ void BeIRCodeGen::HandleNextCmd()
|
||||||
|
|
||||||
auto dbgMember = mBeModule->mOwnedValues.Alloc<BeDbgStructMember>();
|
auto dbgMember = mBeModule->mOwnedValues.Alloc<BeDbgStructMember>();
|
||||||
dbgMember->mName = name;
|
dbgMember->mName = name;
|
||||||
dbgMember->mType = (BeDbgType*)type;
|
dbgMember->mType = BeValueDynCast<BeDbgType>(type);
|
||||||
dbgMember->mOffset = (int)(offsetInBits / 8);
|
dbgMember->mOffset = (int)(offsetInBits / 8);
|
||||||
dbgMember->mFlags = flags;
|
dbgMember->mFlags = flags;
|
||||||
|
|
||||||
|
@ -3300,7 +3302,7 @@ void BeIRCodeGen::HandleNextCmd()
|
||||||
|
|
||||||
auto dbgMember = mBeModule->mOwnedValues.Alloc<BeDbgStructMember>();
|
auto dbgMember = mBeModule->mOwnedValues.Alloc<BeDbgStructMember>();
|
||||||
dbgMember->mName = name;
|
dbgMember->mName = name;
|
||||||
dbgMember->mType = (BeDbgType*)type;
|
dbgMember->mType = BeValueDynCast<BeDbgType>(type);
|
||||||
dbgMember->mOffset = -1;
|
dbgMember->mOffset = -1;
|
||||||
dbgMember->mStaticValue = val;
|
dbgMember->mStaticValue = val;
|
||||||
dbgMember->mFlags = flags;
|
dbgMember->mFlags = flags;
|
||||||
|
@ -3317,7 +3319,7 @@ void BeIRCodeGen::HandleNextCmd()
|
||||||
CMD_PARAM(int, flags);
|
CMD_PARAM(int, flags);
|
||||||
|
|
||||||
auto dbgInheritance = mBeModule->mAlloc.Alloc<BeDbgInheritance>();
|
auto dbgInheritance = mBeModule->mAlloc.Alloc<BeDbgInheritance>();
|
||||||
dbgInheritance->mBaseType = (BeDbgType*)baseType;
|
dbgInheritance->mBaseType = BeValueDynCast<BeDbgType>(baseType);
|
||||||
|
|
||||||
SetResult(curId, dbgInheritance);
|
SetResult(curId, dbgInheritance);
|
||||||
}
|
}
|
||||||
|
@ -3358,7 +3360,7 @@ void BeIRCodeGen::HandleNextCmd()
|
||||||
for (auto arg : genericArgs)
|
for (auto arg : genericArgs)
|
||||||
{
|
{
|
||||||
BF_ASSERT(arg != NULL);
|
BF_ASSERT(arg != NULL);
|
||||||
dbgFunc->mGenericArgs.Add((BeDbgType*)arg);
|
dbgFunc->mGenericArgs.Add(BeValueDynCast<BeDbgType>(arg));
|
||||||
}
|
}
|
||||||
for (auto genericConstValue : genericConstValueArgs)
|
for (auto genericConstValue : genericConstValueArgs)
|
||||||
dbgFunc->mGenericConstValueArgs.Add(genericConstValue);
|
dbgFunc->mGenericConstValueArgs.Add(genericConstValue);
|
||||||
|
@ -3457,9 +3459,9 @@ void BeIRCodeGen::HandleNextCmd()
|
||||||
auto dbgFuncType = mBeModule->mOwnedValues.Alloc<BeDbgFunctionType>();
|
auto dbgFuncType = mBeModule->mOwnedValues.Alloc<BeDbgFunctionType>();
|
||||||
if (!elements.empty())
|
if (!elements.empty())
|
||||||
{
|
{
|
||||||
dbgFuncType->mReturnType = (BeDbgType*)elements[0];
|
dbgFuncType->mReturnType = BeValueDynCast<BeDbgType>(elements[0]);
|
||||||
for (int i = 1; i < (int)elements.size(); i++)
|
for (int i = 1; i < (int)elements.size(); i++)
|
||||||
dbgFuncType->mParams.push_back((BeDbgType*)elements[i]);
|
dbgFuncType->mParams.push_back(BeValueDynCast<BeDbgType>(elements[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
SetResult(curId, dbgFuncType);
|
SetResult(curId, dbgFuncType);
|
||||||
|
|
|
@ -68,8 +68,9 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
BfSizedArray()
|
BfSizedArray()
|
||||||
{
|
{
|
||||||
mSize = 0;
|
mSize = 0;
|
||||||
|
mVals = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
BfSizedArray(const llvm::SmallVectorImpl<T>& refVec)
|
BfSizedArray(const llvm::SmallVectorImpl<T>& refVec)
|
||||||
|
|
|
@ -104,6 +104,13 @@ struct BfVariant
|
||||||
return mSingle;
|
return mSingle;
|
||||||
return (double)mInt64;
|
return (double)mInt64;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BfVariant()
|
||||||
|
{
|
||||||
|
mTypeCode = BfTypeCode_None;
|
||||||
|
mWarnType = 0;
|
||||||
|
mUInt64 = 0;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
enum BfToken : uint8
|
enum BfToken : uint8
|
||||||
|
|
|
@ -370,8 +370,7 @@ BfCompiler::BfCompiler(BfSystem* bfSystem, bool isResolveOnly)
|
||||||
mHadCancel = false;
|
mHadCancel = false;
|
||||||
mCompileState = CompileState_None;
|
mCompileState = CompileState_None;
|
||||||
|
|
||||||
//mMaxInterfaceSlots = 4;
|
//mMaxInterfaceSlots = 4;
|
||||||
mContext = new BfContext(this);
|
|
||||||
mHotData = NULL;
|
mHotData = NULL;
|
||||||
mHotState = NULL;
|
mHotState = NULL;
|
||||||
mHotResolveData = NULL;
|
mHotResolveData = NULL;
|
||||||
|
@ -479,8 +478,7 @@ BfCompiler::BfCompiler(BfSystem* bfSystem, bool isResolveOnly)
|
||||||
|
|
||||||
mLastAutocompleteModule = NULL;
|
mLastAutocompleteModule = NULL;
|
||||||
|
|
||||||
//if (isResolveOnly)
|
mContext = new BfContext(this);
|
||||||
//mCeMachine = NULL;
|
|
||||||
mCeMachine = new CeMachine(this);
|
mCeMachine = new CeMachine(this);
|
||||||
mCurCEExecuteId = -1;
|
mCurCEExecuteId = -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,8 +34,7 @@ USING_NS_BF;
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
BfContext::BfContext(BfCompiler* compiler) :
|
BfContext::BfContext(BfCompiler* compiler) :
|
||||||
mTypeDefTypeRefPool(true),
|
mTypeDefTypeRefPool(true, true)
|
||||||
mNamedTypeRefPool(true)
|
|
||||||
{
|
{
|
||||||
mCompiler = compiler;
|
mCompiler = compiler;
|
||||||
mSystem = compiler->mSystem;
|
mSystem = compiler->mSystem;
|
||||||
|
|
|
@ -424,8 +424,6 @@ public:
|
||||||
BfAllocPool<BfArrayType> mArrayTypeInstancePool;
|
BfAllocPool<BfArrayType> mArrayTypeInstancePool;
|
||||||
BfAllocPool<BfGenericParamType> mGenericParamTypePool;
|
BfAllocPool<BfGenericParamType> mGenericParamTypePool;
|
||||||
BfAllocPool<BfDirectTypeDefReference> mTypeDefTypeRefPool;
|
BfAllocPool<BfDirectTypeDefReference> mTypeDefTypeRefPool;
|
||||||
BfAllocPool<BfDirectStrTypeReference> mNamedTypeRefPool;
|
|
||||||
BfAllocPool<BfGenericInstanceTypeRef> mGenericTypeRefPool;
|
|
||||||
BfAllocPool<BfConcreteInterfaceType> mConcreteInterfaceTypePool;
|
BfAllocPool<BfConcreteInterfaceType> mConcreteInterfaceTypePool;
|
||||||
BfAllocPool<BfConstExprValueType> mConstExprValueTypePool;
|
BfAllocPool<BfConstExprValueType> mConstExprValueTypePool;
|
||||||
BfAllocPool<BfDelegateType> mDelegateTypePool;
|
BfAllocPool<BfDelegateType> mDelegateTypePool;
|
||||||
|
|
|
@ -2864,7 +2864,7 @@ void BfIRCodeGen::HandleNextCmd()
|
||||||
bool isFakeIntrinsic = (int)intrinsics[intrinId].mID == -2;
|
bool isFakeIntrinsic = (int)intrinsics[intrinId].mID == -2;
|
||||||
if (isFakeIntrinsic)
|
if (isFakeIntrinsic)
|
||||||
{
|
{
|
||||||
auto intrinsicData = mAlloc.Alloc<BfIRIntrinsicData>();
|
auto intrinsicData = mIntrinsicData.Alloc();
|
||||||
intrinsicData->mName = intrinName;
|
intrinsicData->mName = intrinName;
|
||||||
intrinsicData->mIntrinsic = (BfIRIntrinsic)intrinId;
|
intrinsicData->mIntrinsic = (BfIRIntrinsic)intrinId;
|
||||||
intrinsicData->mReturnType = returnType;
|
intrinsicData->mReturnType = returnType;
|
||||||
|
@ -2884,7 +2884,7 @@ void BfIRCodeGen::HandleNextCmd()
|
||||||
|
|
||||||
if (platName.IsEmpty())
|
if (platName.IsEmpty())
|
||||||
{
|
{
|
||||||
auto intrinsicData = mAlloc.Alloc<BfIRIntrinsicData>();
|
auto intrinsicData = mIntrinsicData.Alloc();
|
||||||
intrinsicData->mName = platIntrinName;
|
intrinsicData->mName = platIntrinName;
|
||||||
intrinsicData->mIntrinsic = BfIRIntrinsic__PLATFORM;
|
intrinsicData->mIntrinsic = BfIRIntrinsic__PLATFORM;
|
||||||
intrinsicData->mReturnType = returnType;
|
intrinsicData->mReturnType = returnType;
|
||||||
|
|
|
@ -121,6 +121,7 @@ public:
|
||||||
Dictionary<llvm::Type*, llvm::Type*> mAlignedTypeToNormalType;
|
Dictionary<llvm::Type*, llvm::Type*> mAlignedTypeToNormalType;
|
||||||
Dictionary<llvm::Type*, int> mTypeToTypeIdMap;
|
Dictionary<llvm::Type*, int> mTypeToTypeIdMap;
|
||||||
HashSet<llvm::BasicBlock*> mLockedBlocks;
|
HashSet<llvm::BasicBlock*> mLockedBlocks;
|
||||||
|
OwnedArray<BfIRIntrinsicData> mIntrinsicData;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void InitTarget();
|
void InitTarget();
|
||||||
|
|
|
@ -966,14 +966,14 @@ void BfModule::RemoveModuleData()
|
||||||
}
|
}
|
||||||
|
|
||||||
void BfModule::Init(bool isFullRebuild)
|
void BfModule::Init(bool isFullRebuild)
|
||||||
{
|
{
|
||||||
mContext->mFinishedModuleWorkList.Remove(this);
|
mContext->mFinishedModuleWorkList.Remove(this);
|
||||||
|
|
||||||
if ((mCompiler->mIsResolveOnly) && (this != mContext->mUnreifiedModule))
|
if ((mCompiler->mIsResolveOnly) && (this != mContext->mUnreifiedModule))
|
||||||
BF_ASSERT(mIsReified);
|
BF_ASSERT(mIsReified);
|
||||||
|
|
||||||
if (!mIsScratchModule)
|
if (!mIsScratchModule)
|
||||||
{
|
{
|
||||||
mCompiler->mStats.mModulesStarted++;
|
mCompiler->mStats.mModulesStarted++;
|
||||||
if (mIsReified)
|
if (mIsReified)
|
||||||
mCompiler->mStats.mReifiedModuleCount++;
|
mCompiler->mStats.mReifiedModuleCount++;
|
||||||
|
@ -981,7 +981,7 @@ void BfModule::Init(bool isFullRebuild)
|
||||||
}
|
}
|
||||||
|
|
||||||
mIsHotModule = (mProject != NULL) && (mCompiler->mOptions.mHotProject != NULL) && (mCompiler->mOptions.mHotProject->ContainsReference(mProject));
|
mIsHotModule = (mProject != NULL) && (mCompiler->mOptions.mHotProject != NULL) && (mCompiler->mOptions.mHotProject->ContainsReference(mProject));
|
||||||
|
|
||||||
mFuncReferences.Clear();
|
mFuncReferences.Clear();
|
||||||
mClassVDataRefs.Clear();
|
mClassVDataRefs.Clear();
|
||||||
mClassVDataExtRefs.Clear();
|
mClassVDataExtRefs.Clear();
|
||||||
|
@ -990,22 +990,25 @@ void BfModule::Init(bool isFullRebuild)
|
||||||
CleanupFileInstances();
|
CleanupFileInstances();
|
||||||
mStaticFieldRefs.Clear();
|
mStaticFieldRefs.Clear();
|
||||||
//mInterfaceSlotRefs.Clear();
|
//mInterfaceSlotRefs.Clear();
|
||||||
|
|
||||||
// If we are just doing an extension then the ownede types aren't rebuilt.
|
// If we are just doing an extension then the ownede types aren't rebuilt.
|
||||||
// If we set mRevision then QueueMethodSpecializations wouldn't actually queue up required specializations
|
// If we set mRevision then QueueMethodSpecializations wouldn't actually queue up required specializations
|
||||||
// and we'd end up with link errors if the original module uniquely referred to any generic methods
|
// and we'd end up with link errors if the original module uniquely referred to any generic methods
|
||||||
if (isFullRebuild)
|
if (isFullRebuild)
|
||||||
mRevision = mCompiler->mRevision;
|
mRevision = mCompiler->mRevision;
|
||||||
|
|
||||||
BF_ASSERT(mCurTypeInstance == NULL);
|
BF_ASSERT(mCurTypeInstance == NULL);
|
||||||
|
|
||||||
mIsModuleMutable = true;
|
mIsModuleMutable = true;
|
||||||
BF_ASSERT((mBfIRBuilder == NULL) || (mCompiler->mIsResolveOnly));
|
BF_ASSERT((mBfIRBuilder == NULL) || (mCompiler->mIsResolveOnly));
|
||||||
|
if (!mIsComptimeModule)
|
||||||
|
{
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
EnsureIRBuilder(mCompiler->mLastAutocompleteModule == this);
|
EnsureIRBuilder(mCompiler->mLastAutocompleteModule == this);
|
||||||
#else
|
#else
|
||||||
EnsureIRBuilder(false);
|
EnsureIRBuilder(false);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
mCurMethodState = NULL;
|
mCurMethodState = NULL;
|
||||||
mAwaitingInitFinish = true;
|
mAwaitingInitFinish = true;
|
||||||
|
@ -1151,7 +1154,7 @@ void BfModule::SetupIRBuilder(bool dbgVerifyCodeGen)
|
||||||
if (mIsScratchModule)
|
if (mIsScratchModule)
|
||||||
{
|
{
|
||||||
mBfIRBuilder->mIgnoreWrites = true;
|
mBfIRBuilder->mIgnoreWrites = true;
|
||||||
BF_ASSERT(!dbgVerifyCodeGen);
|
BF_ASSERT(!dbgVerifyCodeGen);
|
||||||
}
|
}
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
if (mCompiler->mIsResolveOnly)
|
if (mCompiler->mIsResolveOnly)
|
||||||
|
@ -6561,6 +6564,7 @@ BfIRValue BfModule::CreateTypeData(BfType* type, Dictionary<int, int>& usedStrin
|
||||||
{
|
{
|
||||||
reflectKind = (BfReflectKind)(reflectKind | GetUserReflectKind(attr.mType));
|
reflectKind = (BfReflectKind)(reflectKind | GetUserReflectKind(attr.mType));
|
||||||
}
|
}
|
||||||
|
delete customAttrs;
|
||||||
}
|
}
|
||||||
return reflectKind;
|
return reflectKind;
|
||||||
};
|
};
|
||||||
|
@ -12225,6 +12229,9 @@ void BfModule::ProcessTypeInstCustomAttributes(int& packing, bool& isUnion, bool
|
||||||
// Checking to see if we're an attribute or not
|
// Checking to see if we're an attribute or not
|
||||||
void BfModule::ProcessCustomAttributeData()
|
void BfModule::ProcessCustomAttributeData()
|
||||||
{
|
{
|
||||||
|
if (mCurTypeInstance->mAttributeData != NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
bool isAttribute = false;
|
bool isAttribute = false;
|
||||||
auto checkTypeInst = mCurTypeInstance->mBaseType;
|
auto checkTypeInst = mCurTypeInstance->mBaseType;
|
||||||
while (checkTypeInst != NULL)
|
while (checkTypeInst != NULL)
|
||||||
|
|
|
@ -4110,7 +4110,9 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
typeInstance->mCustomAttributes = GetCustomAttributes(typeDef->mTypeDeclaration->mAttributes, attrTarget);
|
|
||||||
|
typeInstance->mCustomAttributes = new BfCustomAttributes();
|
||||||
|
GetCustomAttributes(typeInstance->mCustomAttributes, typeDef->mTypeDeclaration->mAttributes, attrTarget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4127,7 +4129,7 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
||||||
prevSkipTypeProtectionChecks.Restore();
|
prevSkipTypeProtectionChecks.Restore();
|
||||||
typeInstance->mInstSize = std::max(0, typeInstance->mInstSize);
|
typeInstance->mInstSize = std::max(0, typeInstance->mInstSize);
|
||||||
typeInstance->mInstAlign = std::max(0, typeInstance->mInstAlign);
|
typeInstance->mInstAlign = std::max(0, typeInstance->mInstAlign);
|
||||||
|
|
||||||
ProcessCustomAttributeData();
|
ProcessCustomAttributeData();
|
||||||
int packing = 0;
|
int packing = 0;
|
||||||
bool isUnion = false;
|
bool isUnion = false;
|
||||||
|
@ -8355,7 +8357,6 @@ BfType* BfModule::ResolveGenericType(BfType* unspecializedType, BfTypeVector* ty
|
||||||
BfDelegateInfo* delegateInfo = delegateType->GetDelegateInfo();
|
BfDelegateInfo* delegateInfo = delegateType->GetDelegateInfo();
|
||||||
delegateInfo->mParams.Clear();
|
delegateInfo->mParams.Clear();
|
||||||
|
|
||||||
|
|
||||||
BfTypeDef* typeDef = new BfTypeDef();
|
BfTypeDef* typeDef = new BfTypeDef();
|
||||||
|
|
||||||
typeDef->mProject = baseDelegateType->mTypeDef->mProject;
|
typeDef->mProject = baseDelegateType->mTypeDef->mProject;
|
||||||
|
@ -9852,6 +9853,7 @@ void BfModule::GetDelegateTypeRefAttributes(BfDelegateTypeRef* delegateTypeRef,
|
||||||
callingConvention = (BfCallingConvention)constant->mInt32;
|
callingConvention = (BfCallingConvention)constant->mInt32;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
delete customAttributes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3642,7 +3642,7 @@ void BfParser::HadSrcRealloc()
|
||||||
memset(jumpTable, 0, jumpTableSize * sizeof(BfLineStartEntry));
|
memset(jumpTable, 0, jumpTableSize * sizeof(BfLineStartEntry));
|
||||||
memcpy(jumpTable, mJumpTable, mJumpTableSize * sizeof(BfLineStartEntry));
|
memcpy(jumpTable, mJumpTable, mJumpTableSize * sizeof(BfLineStartEntry));
|
||||||
|
|
||||||
delete mJumpTable;
|
delete [] mJumpTable;
|
||||||
|
|
||||||
mJumpTable = jumpTable;
|
mJumpTable = jumpTable;
|
||||||
mJumpTableSize = jumpTableSize;
|
mJumpTableSize = jumpTableSize;
|
||||||
|
|
|
@ -1574,9 +1574,13 @@ BfMethodInstanceGroup::BfMethodInstanceGroup(BfMethodInstanceGroup&& prev) noexc
|
||||||
mOwner = prev.mOwner;
|
mOwner = prev.mOwner;
|
||||||
mDefault = prev.mDefault;
|
mDefault = prev.mDefault;
|
||||||
mMethodSpecializationMap = prev.mMethodSpecializationMap;
|
mMethodSpecializationMap = prev.mMethodSpecializationMap;
|
||||||
|
mDefaultCustomAttributes = prev.mDefaultCustomAttributes;
|
||||||
mMethodIdx = prev.mMethodIdx;
|
mMethodIdx = prev.mMethodIdx;
|
||||||
mRefCount = prev.mRefCount;
|
mRefCount = prev.mRefCount;
|
||||||
mOnDemandKind = prev.mOnDemandKind;
|
mOnDemandKind = prev.mOnDemandKind;
|
||||||
|
mExplicitlyReflected = prev.mExplicitlyReflected;
|
||||||
|
mHasEmittedReference = prev.mHasEmittedReference;
|
||||||
|
|
||||||
if (mDefault != NULL)
|
if (mDefault != NULL)
|
||||||
mDefault->mMethodInstanceGroup = this;
|
mDefault->mMethodInstanceGroup = this;
|
||||||
if (mMethodSpecializationMap != NULL)
|
if (mMethodSpecializationMap != NULL)
|
||||||
|
@ -1584,9 +1588,8 @@ BfMethodInstanceGroup::BfMethodInstanceGroup(BfMethodInstanceGroup&& prev) noexc
|
||||||
for (auto& pair : *mMethodSpecializationMap)
|
for (auto& pair : *mMethodSpecializationMap)
|
||||||
pair.mValue->mMethodInstanceGroup = this;
|
pair.mValue->mMethodInstanceGroup = this;
|
||||||
}
|
}
|
||||||
mDefaultCustomAttributes = prev.mDefaultCustomAttributes;
|
|
||||||
prev.mDefaultCustomAttributes = NULL;
|
prev.mDefaultCustomAttributes = NULL;
|
||||||
|
|
||||||
prev.mRefCount = 0;
|
prev.mRefCount = 0;
|
||||||
prev.mDefault = NULL;
|
prev.mDefault = NULL;
|
||||||
prev.mMethodSpecializationMap = NULL;
|
prev.mMethodSpecializationMap = NULL;
|
||||||
|
@ -2716,10 +2719,17 @@ void BfClosureType::Finish()
|
||||||
BfDelegateType::~BfDelegateType()
|
BfDelegateType::~BfDelegateType()
|
||||||
{
|
{
|
||||||
mMethodInstanceGroups.Clear();
|
mMethodInstanceGroups.Clear();
|
||||||
delete mTypeDef;
|
delete mTypeDef;
|
||||||
mTypeDef = NULL;
|
mTypeDef = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BfDelegateType::Dispose()
|
||||||
|
{
|
||||||
|
delete mTypeDef;
|
||||||
|
mTypeDef = NULL;
|
||||||
|
BfTypeInstance::Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
BfTupleType::BfTupleType()
|
BfTupleType::BfTupleType()
|
||||||
|
@ -2766,6 +2776,17 @@ void BfTupleType::Init(BfProject* bfProject, BfTypeInstance* valueTypeInstance)
|
||||||
mCreatedTypeDef = true;
|
mCreatedTypeDef = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BfTupleType::Dispose()
|
||||||
|
{
|
||||||
|
if (mCreatedTypeDef)
|
||||||
|
{
|
||||||
|
delete mTypeDef;
|
||||||
|
mTypeDef = NULL;
|
||||||
|
mCreatedTypeDef = false;
|
||||||
|
}
|
||||||
|
BfTypeInstance::Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
BfFieldDef* BfTupleType::AddField(const StringImpl& name)
|
BfFieldDef* BfTupleType::AddField(const StringImpl& name)
|
||||||
{
|
{
|
||||||
return BfDefBuilder::AddField(mTypeDef, NULL, name);
|
return BfDefBuilder::AddField(mTypeDef, NULL, name);
|
||||||
|
@ -2790,8 +2811,8 @@ void BfTupleType::Finish()
|
||||||
|
|
||||||
BfBoxedType::~BfBoxedType()
|
BfBoxedType::~BfBoxedType()
|
||||||
{
|
{
|
||||||
if ((mTypeDef != NULL) && (mTypeDef->mEmitParent != NULL))
|
//if ((mTypeDef != NULL) && (mTypeDef->mEmitParent != NULL))
|
||||||
mTypeDef = NULL;
|
mTypeDef = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
BfType* BfBoxedType::GetModifiedElementType()
|
BfType* BfBoxedType::GetModifiedElementType()
|
||||||
|
@ -2940,7 +2961,7 @@ BfVariant BfResolvedTypeSet::EvaluateToVariant(LookupContext* ctx, BfExpression*
|
||||||
outType = NULL;
|
outType = NULL;
|
||||||
|
|
||||||
BfConstResolver constResolver(ctx->mModule);
|
BfConstResolver constResolver(ctx->mModule);
|
||||||
BfVariant variant = { BfTypeCode_None };
|
BfVariant variant;
|
||||||
constResolver.mAllowGenericConstValue = true;
|
constResolver.mAllowGenericConstValue = true;
|
||||||
constResolver.mBfEvalExprFlags = BfEvalExprFlags_NoCast;
|
constResolver.mBfEvalExprFlags = BfEvalExprFlags_NoCast;
|
||||||
constResolver.mExpectingType = ctx->mModule->GetPrimitiveType(BfTypeCode_Int64);
|
constResolver.mExpectingType = ctx->mModule->GetPrimitiveType(BfTypeCode_Int64);
|
||||||
|
|
|
@ -2007,7 +2007,7 @@ public:
|
||||||
|
|
||||||
~BfTypeInstance();
|
~BfTypeInstance();
|
||||||
|
|
||||||
void Dispose();
|
virtual void Dispose();
|
||||||
void ReleaseData();
|
void ReleaseData();
|
||||||
|
|
||||||
virtual bool IsInstanceOf(BfTypeDef* typeDef) override { if (typeDef == NULL) return false; return typeDef->GetDefinition() == mTypeDef->GetDefinition(); }
|
virtual bool IsInstanceOf(BfTypeDef* typeDef) override { if (typeDef == NULL) return false; return typeDef->GetDefinition() == mTypeDef->GetDefinition(); }
|
||||||
|
@ -2245,6 +2245,7 @@ public:
|
||||||
}
|
}
|
||||||
~BfDelegateType();
|
~BfDelegateType();
|
||||||
|
|
||||||
|
virtual void Dispose() override;
|
||||||
virtual bool IsOnDemand() override { return true; }
|
virtual bool IsOnDemand() override { return true; }
|
||||||
|
|
||||||
virtual bool IsDelegate() override { return mTypeDef->mIsDelegate; }
|
virtual bool IsDelegate() override { return mTypeDef->mIsDelegate; }
|
||||||
|
@ -2277,6 +2278,7 @@ public:
|
||||||
~BfTupleType();
|
~BfTupleType();
|
||||||
|
|
||||||
void Init(BfProject* bfProject, BfTypeInstance* valueTypeInstance);
|
void Init(BfProject* bfProject, BfTypeInstance* valueTypeInstance);
|
||||||
|
virtual void Dispose() override;
|
||||||
BfFieldDef* AddField(const StringImpl& name);
|
BfFieldDef* AddField(const StringImpl& name);
|
||||||
void Finish();
|
void Finish();
|
||||||
|
|
||||||
|
|
|
@ -41,12 +41,7 @@ BfSource::~BfSource()
|
||||||
delete mSourceData;
|
delete mSourceData;
|
||||||
|
|
||||||
if (mSrcAllocSize >= 0)
|
if (mSrcAllocSize >= 0)
|
||||||
delete mSrc;
|
delete [] mSrc;
|
||||||
|
|
||||||
for (auto typeDef : mTypeDefs)
|
|
||||||
{
|
|
||||||
NOP;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BfSource::WantsStats()
|
bool BfSource::WantsStats()
|
||||||
|
@ -84,7 +79,7 @@ int BfSource::AllocChars(int charCount)
|
||||||
if (mSrc != NULL)
|
if (mSrc != NULL)
|
||||||
{
|
{
|
||||||
memcpy(newSrc, mSrc, mSrcLength);
|
memcpy(newSrc, mSrc, mSrcLength);
|
||||||
delete mSrc;
|
delete [] mSrc;
|
||||||
}
|
}
|
||||||
mSrc = newSrc;
|
mSrc = newSrc;
|
||||||
mSrcAllocSize = newAllocSize;
|
mSrcAllocSize = newAllocSize;
|
||||||
|
|
|
@ -49,7 +49,7 @@ public:
|
||||||
{
|
{
|
||||||
BF_ASSERT(mExteriorNodes.mSize >= 0);
|
BF_ASSERT(mExteriorNodes.mSize >= 0);
|
||||||
BF_ASSERT(mExteriorNodes.mSize < 0x00FFFFFF);
|
BF_ASSERT(mExteriorNodes.mSize < 0x00FFFFFF);
|
||||||
delete mSrc;
|
delete [] mSrc;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual BfParserData* ToParserData()
|
virtual BfParserData* ToParserData()
|
||||||
|
|
|
@ -2108,7 +2108,7 @@ void BfSystem::ProcessAtomGraveyard()
|
||||||
{
|
{
|
||||||
deletedAtoms.Add(atom);
|
deletedAtoms.Add(atom);
|
||||||
auto itr = mAtomMap.Remove(atom->mString);
|
auto itr = mAtomMap.Remove(atom->mString);
|
||||||
delete atom->mString.mPtr;
|
free((void*)atom->mString.mPtr);
|
||||||
delete atom;
|
delete atom;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,11 +146,13 @@ public:
|
||||||
Array<T*> mVals;
|
Array<T*> mVals;
|
||||||
T* mNext;
|
T* mNext;
|
||||||
bool mOwnsAll;
|
bool mOwnsAll;
|
||||||
|
bool mZeroAlloc;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BfAllocPool(bool ownsAll = false)
|
BfAllocPool(bool ownsAll = false, bool zeroAlloc = false)
|
||||||
{
|
{
|
||||||
mOwnsAll = ownsAll;
|
mOwnsAll = ownsAll;
|
||||||
|
mZeroAlloc = zeroAlloc;
|
||||||
mNext = NULL;
|
mNext = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,8 +162,13 @@ public:
|
||||||
delete mNext;
|
delete mNext;
|
||||||
for (auto val : mVals)
|
for (auto val : mVals)
|
||||||
{
|
{
|
||||||
val->~T();
|
if (mZeroAlloc)
|
||||||
free(val);
|
{
|
||||||
|
val->~T();
|
||||||
|
free(val);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
delete val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,10 +183,15 @@ public:
|
||||||
mVals.pop_back();
|
mVals.pop_back();
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
//val = new T();
|
|
||||||
void* addr = malloc(sizeof(T));
|
if (mZeroAlloc)
|
||||||
memset(addr, 0, sizeof(T));
|
{
|
||||||
val = new(addr) T();
|
void* addr = malloc(sizeof(T));
|
||||||
|
memset(addr, 0, sizeof(T));
|
||||||
|
val = new(addr) T();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
val = new T();
|
||||||
if (mOwnsAll)
|
if (mOwnsAll)
|
||||||
mVals.push_back(val);
|
mVals.push_back(val);
|
||||||
return val;
|
return val;
|
||||||
|
|
|
@ -5087,6 +5087,7 @@ BfTypedValue CeContext::Call(CeCallSource callSource, BfModule* module, BfMethod
|
||||||
retAddr = stackPtr - memStart;
|
retAddr = stackPtr - memStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete mCeMachine->mAppendAllocInfo;
|
||||||
mCeMachine->mAppendAllocInfo = NULL;
|
mCeMachine->mAppendAllocInfo = NULL;
|
||||||
|
|
||||||
BfType* returnType = NULL;
|
BfType* returnType = NULL;
|
||||||
|
@ -6705,7 +6706,7 @@ bool CeContext::Execute(CeFunction* startFunction, uint8* startStackPtr, uint8*
|
||||||
CE_CHECKADDR(outStdInAddr, ptrSize);
|
CE_CHECKADDR(outStdInAddr, ptrSize);
|
||||||
if (outStdOutAddr != 0)
|
if (outStdOutAddr != 0)
|
||||||
CE_CHECKADDR(outStdOutAddr, ptrSize);
|
CE_CHECKADDR(outStdOutAddr, ptrSize);
|
||||||
if (outStdErrAddr != NULL)
|
if (outStdErrAddr != 0)
|
||||||
CE_CHECKADDR(outStdErrAddr, ptrSize);
|
CE_CHECKADDR(outStdErrAddr, ptrSize);
|
||||||
|
|
||||||
BfpFile* outStdIn = NULL;
|
BfpFile* outStdIn = NULL;
|
||||||
|
@ -8526,6 +8527,8 @@ CeMachine::~CeMachine()
|
||||||
|
|
||||||
void CeMachine::Init()
|
void CeMachine::Init()
|
||||||
{
|
{
|
||||||
|
BF_ASSERT(mCeModule == NULL);
|
||||||
|
|
||||||
mCeModule = new BfModule(mCompiler->mContext, "__constEval");
|
mCeModule = new BfModule(mCompiler->mContext, "__constEval");
|
||||||
mCeModule->mIsSpecialModule = true;
|
mCeModule->mIsSpecialModule = true;
|
||||||
//mCeModule->mIsScratchModule = true;
|
//mCeModule->mIsScratchModule = true;
|
||||||
|
@ -8537,6 +8540,7 @@ void CeMachine::Init()
|
||||||
mCeModule->mIsReified = false;
|
mCeModule->mIsReified = false;
|
||||||
mCeModule->Init();
|
mCeModule->Init();
|
||||||
|
|
||||||
|
BF_ASSERT(mCeModule->mBfIRBuilder == NULL);
|
||||||
mCeModule->mBfIRBuilder = new BfIRBuilder(mCeModule);
|
mCeModule->mBfIRBuilder = new BfIRBuilder(mCeModule);
|
||||||
mCeModule->mBfIRBuilder->mDbgVerifyCodeGen = true;
|
mCeModule->mBfIRBuilder->mDbgVerifyCodeGen = true;
|
||||||
mCeModule->FinishInit();
|
mCeModule->FinishInit();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue