1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-22 17:48:01 +02:00

Arithmetic overflow checks

This commit is contained in:
Brian Fiete 2022-01-11 08:17:09 -05:00
parent 1f0d2dcc82
commit eb375362a1
29 changed files with 503 additions and 87 deletions

View file

@ -102,6 +102,8 @@ namespace IDE
[Reflect]
public bool? mEmitObjectAccessCheck; // Only valid with mObjectHasDebugFlags
[Reflect]
public bool? mArithmeticCheck;
[Reflect]
public int32? mAllocStackTraceDepth;
[Reflect]
public BuildOptions.AlwaysIncludeKind mReflectAlwaysInclude;
@ -135,6 +137,7 @@ namespace IDE
newVal.mInitLocalVariables = mInitLocalVariables;
newVal.mEmitDynamicCastCheck = mEmitDynamicCastCheck;
newVal.mEmitObjectAccessCheck = mEmitObjectAccessCheck;
newVal.mArithmeticCheck = mArithmeticCheck;
newVal.mAllocStackTraceDepth = mAllocStackTraceDepth;
newVal.mReflectAlwaysInclude = mReflectAlwaysInclude;
newVal.mReflectBoxing = mReflectBoxing;
@ -164,6 +167,8 @@ namespace IDE
mEmitDynamicCastCheck = data.GetBool("EmitDynamicCastCheck");
if (data.Contains("EmitObjectAccessCheck"))
mEmitObjectAccessCheck = data.GetBool("EmitObjectAccessCheck");
if (data.Contains("ArithmeticCheck"))
mArithmeticCheck = data.GetBool("ArithmeticCheck");
if (data.Contains("AllocStackTraceDepth"))
mAllocStackTraceDepth = data.GetInt("AllocStackTraceDepth");
@ -194,6 +199,7 @@ namespace IDE
data.ConditionalAdd("InitLocalVariables", mInitLocalVariables);
data.ConditionalAdd("EmitDynamicCastCheck", mEmitDynamicCastCheck);
data.ConditionalAdd("EmitObjectAccessCheck", mEmitObjectAccessCheck);
data.ConditionalAdd("ArithmeticCheck", mArithmeticCheck);
data.ConditionalAdd("AllocStackTraceDepth", mAllocStackTraceDepth);
data.ConditionalAdd("ReflectAlwaysInclude", mReflectAlwaysInclude);
data.ConditionalAdd("ReflectBoxing", mReflectBoxing);

View file

@ -38,6 +38,7 @@ namespace IDE.Compiler
DebugAlloc = 0x8000,
OmitDebugHelpers = 0x10000,
NoFramePointerElim = 0x20000,
ArithmeticChecks = 0x40000
}
[CallingConvention(.Stdcall), CLink]
@ -663,6 +664,7 @@ namespace IDE.Compiler
SetOpt(options.mEmitDynamicCastCheck, .EmitDynamicCastCheck);
SetOpt(enableObjectDebugFlags, .EnableObjectDebugFlags);
SetOpt(emitObjectAccessCheck, .EmitObjectAccessCheck);
SetOpt(options.mArithmeticCheck, .ArithmeticChecks);
if (options.LeakCheckingEnabled)
SetOpt(options.mEnableRealtimeLeakCheck, .EnableRealtimeLeakCheck);

View file

@ -15,18 +15,19 @@ namespace IDE.Compiler
InitLocalVariables = 2,
EmitDynamicCastCheck = 4,
EmitObjectAccessCheck = 8,
ArithmeticCheck = 0x10,
ReflectAlwaysIncludeType = 0x10,
ReflectAlwaysIncludeAll = 0x20,
ReflectAssumeInstantiated = 0x40,
ReflectBoxing = 0x80,
ReflectStaticFields = 0x100,
ReflectNonStaticFields = 0x200,
ReflectStaticMethods = 0x400,
ReflectNonStaticMethods = 0x800,
ReflectConstructors = 0x1000,
ReflectAlwaysIncludeType = 0x20,
ReflectAlwaysIncludeAll = 0x40,
ReflectAssumeInstantiated = 0x80,
ReflectBoxing = 0x100,
ReflectStaticFields = 0x200,
ReflectNonStaticFields = 0x400,
ReflectStaticMethods = 0x800,
ReflectNonStaticMethods = 0x1000,
ReflectConstructors = 0x2000,
All = 0x1FFF
All = 0x3FFF
};
[CallingConvention(.Stdcall), CLink]
@ -408,6 +409,8 @@ namespace IDE.Compiler
SetFlag(typeOption.mReflectStaticMethods, .ReflectStaticMethods);
SetFlag(typeOption.mReflectNonStaticMethods, .ReflectNonStaticMethods);
SetFlag(typeOption.mReflectConstructors, .ReflectConstructors);
SetFlag(typeOption.mEmitObjectAccessCheck, .EmitObjectAccessCheck);
SetFlag(typeOption.mArithmeticCheck, .ArithmeticCheck);
AddTypeOptions(typeOption.mFilter, typeOption.mBfSIMDSetting, typeOption.mBfOptimizationLevel, typeOption.mEmitDebugInfo, andFlags, orFlags, typeOption.mAllocStackTraceDepth, typeOption.mReflectMethodFilter);
}

View file

@ -240,6 +240,8 @@ namespace IDE
[Reflect]
public bool mEmitObjectAccessCheck; // Only valid with mObjectHasDebugFlags
[Reflect]
public bool mArithmeticCheck;
[Reflect]
public bool mEnableRealtimeLeakCheck;
[Reflect]
public bool mEnableSideStack;
@ -297,6 +299,7 @@ namespace IDE
mEmitDynamicCastCheck = prev.mEmitDynamicCastCheck;
mEnableObjectDebugFlags = prev.mEnableObjectDebugFlags;
mEmitObjectAccessCheck = prev.mEmitObjectAccessCheck;
mArithmeticCheck = prev.mArithmeticCheck;
mEnableRealtimeLeakCheck = prev.mEnableRealtimeLeakCheck;
mEnableSideStack = prev.mEnableSideStack;
mAllowHotSwapping = prev.mAllowHotSwapping;
@ -694,6 +697,7 @@ namespace IDE
data.ConditionalAdd("EmitDynamicCastCheck", options.mEmitDynamicCastCheck, !isRelease);
data.ConditionalAdd("EnableObjectDebugFlags", options.mEnableObjectDebugFlags, !isRelease);
data.ConditionalAdd("EmitObjectAccessCheck", options.mEmitObjectAccessCheck, !isRelease);
data.ConditionalAdd("ArithmeticCheck", options.mArithmeticCheck, false);
data.ConditionalAdd("EnableRealtimeLeakCheck", options.mEnableRealtimeLeakCheck, (platformType == .Windows) && !isRelease);
data.ConditionalAdd("EnableSideStack", options.mEnableSideStack, (platformType == .Windows) && isParanoid);
data.ConditionalAdd("AllowHotSwapping", options.mAllowHotSwapping, (platformType == .Windows) && !isRelease);
@ -888,6 +892,7 @@ namespace IDE
options.mEmitDynamicCastCheck = !isRelease;
options.mEnableObjectDebugFlags = !isRelease;
options.mEmitObjectAccessCheck = !isRelease;
options.mArithmeticCheck = false;
if (platformType == .Windows)
{
@ -994,6 +999,7 @@ namespace IDE
options.mEmitDynamicCastCheck = data.GetBool("EmitDynamicCastCheck", !isRelease);
options.mEnableObjectDebugFlags = data.GetBool("EnableObjectDebugFlags", !isRelease);
options.mEmitObjectAccessCheck = data.GetBool("EmitObjectAccessCheck", !isRelease);
options.mArithmeticCheck = data.GetBool("ArithmeticCheck", false);
options.mEnableRealtimeLeakCheck = data.GetBool("EnableRealtimeLeakCheck", (platformType == .Windows) && !isRelease);
options.mEnableSideStack = data.GetBool("EnableSideStack", (platformType == .Windows) && isParanoid);
options.mAllowHotSwapping = data.GetBool("AllowHotSwapping", (platformType == .Windows) && !isRelease);

View file

@ -143,6 +143,10 @@ namespace IDE.ui
AddPropertiesItem(category, "Object Access Check", typeName,
scope String[] ( "No", "Yes" ));
typeName.Clear(); typeName.Append(optionsName, "mArithmeticCheck");
AddPropertiesItem(category, "Arithmetic Check", typeName,
scope String[] ( "No", "Yes" ));
typeName.Clear(); typeName.Append(optionsName, "mAllocStackTraceDepth");
AddPropertiesItem(category, "Alloc Stack Trace Depth", typeName);

View file

@ -796,6 +796,8 @@ namespace IDE.ui
scope String[] ( "No", "Yes" ));
AddPropertiesItem(category, "Object Access Check", "mEmitObjectAccessCheck",
scope String[] ( "No", "Yes" ));
AddPropertiesItem(category, "Arithmetic Check", "mArithmeticCheck",
scope String[] ( "No", "Yes" ));
AddPropertiesItem(category, "Realtime Leak Check", "mEnableRealtimeLeakCheck",
scope String[] ( "No", "Yes" ));
AddPropertiesItem(category, "Enable Hot Compilation", "mAllowHotSwapping",