Ver Fonte

Minor optimizations

Brian Fiete há 3 anos atrás
pai
commit
3736281ff7

+ 13 - 8
IDEHelper/Backend/BeModule.cpp

@@ -1886,7 +1886,7 @@ String BeModule::ToString(BeFunction* wantFunc)
 {
 	Dictionary<int, BeDbgLoc*> dbgLocs;
 
-	String str;
+	StringT<128*1024> str;
 	
 	SetAndRestoreValue<BeFunction*> prevActiveFunc(mActiveFunction, NULL);
 
@@ -1943,12 +1943,12 @@ String BeModule::ToString(BeFunction* wantFunc)
 			if (gv->mInitializer != NULL)
 			{
 				str += " ";
-				str += dc.ToString(gv->mInitializer);
+				dc.ToString(str, gv->mInitializer);
 			}
 			else
 			{
 				str += " ";
-				str += dc.ToString(gv->mType);
+				dc.ToString(str, gv->mType);
 			}
 			if (gv->mAlign != -1)
 			{
@@ -2005,8 +2005,10 @@ String BeModule::ToString(BeFunction* wantFunc)
 					str += " = {";
 					if (dbgStructType->mSize != -1)
 					{
-						str += StrFormat("\n  Size: %d", dbgStructType->mSize);
-						str += StrFormat("\n  Align: %d", dbgStructType->mAlign);
+						str += "\n  Size: ";
+						str += StrFormat("%d", dbgStructType->mSize);
+						str += "\n  Align : ";
+						str += StrFormat("%d", dbgStructType->mAlign);
 					}
 					if (dbgStructType->mDerivedFrom != NULL)
 					{
@@ -2045,12 +2047,15 @@ String BeModule::ToString(BeFunction* wantFunc)
 					str += " = enum {";
 					if (dbgEnumType->mSize != -1)
 					{
-						str += StrFormat("\n  Size: %d", dbgEnumType->mSize);
-						str += StrFormat("\n  Align: %d", dbgEnumType->mAlign);
+						str += "\n  Size: ";
+						str += StrFormat("%d", dbgEnumType->mSize);
+						str += "\n  Align : ";
+						str += StrFormat("%d", dbgEnumType->mAlign);						
 					}
 					if (dbgEnumType->mElementType != NULL)
 					{
-						str += "\n  Underlying: "; str += dc.ToString(dbgEnumType->mElementType);
+						str += "\n  Underlying: "; 
+						dc.ToString(str, dbgEnumType->mElementType);
 					}
 					if (!dbgEnumType->mMembers.IsEmpty())
 					{

+ 4 - 4
IDEHelper/Compiler/BfCodeGen.cpp

@@ -125,7 +125,7 @@ void BfCodeGenDirectoryData::Write()
 		if (!DirectoryExists(directory))
 		{
 			// Someone else (or the user) cleared this directory
-			DoBfLog(2, "BfCodeGen cleared cache because '%s' was removed\n", directory.c_str());
+			BfLogX(2, "BfCodeGen cleared cache because '%s' was removed\n", directory.c_str());
 			mFileMap.Clear();
 			return;
 		}
@@ -312,7 +312,7 @@ void BfCodeGenThread::RunLoop()
 		Val128 hash;
 		Val128 orderedHash;
 
-		DoBfLog(2, "BfCodeGen handle %s\n", request->mOutFileName.c_str());
+		BfLogX(2, "BfCodeGen handle %s\n", request->mOutFileName.c_str());
 
 		bool isLibWrite = (request->mOptions.mOptLevel == BfOptLevel_OgPlus) && (request->mOptions.mWriteToLib) && (!request->mOptions.mIsHotCompile);
 
@@ -391,7 +391,7 @@ void BfCodeGenThread::RunLoop()
 				hashCtx.Mixin(request->mOptions.mHash);
 				beIRCodeGen->Hash(hashCtx);				
 				auto newOrderedHash = hashCtx.Finish128();
-				DoBfLog(2, "Ordered hash for %s New:%s Old:%s\n", cacheFileName.c_str(), newOrderedHash.ToString().c_str(), orderedHash.ToString().c_str());
+				BfLogX(2, "Ordered hash for %s New:%s Old:%s\n", cacheFileName.c_str(), newOrderedHash.ToString().c_str(), orderedHash.ToString().c_str());
 				hasCacheMatch = newOrderedHash == orderedHash;
 				
 				errorMsg = beIRCodeGen->mErrorMsg;
@@ -442,7 +442,7 @@ void BfCodeGenThread::RunLoop()
 					beIRCodeGen->Process();
 				errorMsg = beIRCodeGen->mErrorMsg;
 
-				DoBfLog(2, "Generating obj %s\n", request->mOutFileName.c_str());
+				BfLogX(2, "Generating obj %s\n", request->mOutFileName.c_str());
 
 				BeCOFFObject coffObject;
 				coffObject.mWriteToLib = request->mOptions.mWriteToLib;				

+ 7 - 0
IDEHelper/Compiler/BfSystem.h

@@ -1861,6 +1861,13 @@ public:
 #define BfLog(fmt, ...) {} // Nothing
 #endif
 
+#ifdef BF_WANTS_LOG
+#define BfLogX(logIdx, fmt, ...) DoBfLog(logIdx, fmt, ##__VA_ARGS__)
+#else
+#define BfLogX(logIdx, fmt, ...) {} // Nothing
+#endif
+
+
 #ifdef BF_WANTS_LOG_SYS
 #define BfLogSys(sys, fmt, ...) DoBfLog((sys)->mIsResolveOnly ? 1 : 2, fmt, ##__VA_ARGS__)
 #define BfLogSysM(fmt, ...) DoBfLog(mSystem->mIsResolveOnly ? 1 : 2, fmt, ##__VA_ARGS__)

+ 1 - 1
IDEHelper/Compiler/CeMachine.cpp

@@ -9574,7 +9574,7 @@ CeContext* CeMachine::AllocContext()
 	mCurEmitContext = NULL;	
 	mExecuteId++;	
 	ceContext->mStackSize = BF_CE_DEFAULT_STACK_SIZE;
-	ceContext->mMemory.Resize(ceContext->mStackSize);
+	ceContext->mMemory.ResizeRaw(ceContext->mStackSize);
 	ceContext->mExecuteId = mExecuteId;
 	ceContext->mCurHandleId = 0;
 	return ceContext;