Skip to content

Commit

Permalink
default mode is the fastest
Browse files Browse the repository at this point in the history
  • Loading branch information
AqlaSolutions committed Feb 15, 2016
1 parent 7788e3d commit f93e8f9
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 7 deletions.
4 changes: 3 additions & 1 deletion RunSharpShared/Aqla/RunSharpDebug.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ public static class RunSharpDebug
/// <summary>
/// Set to minimal to improve generation performance
/// </summary>
public static LeakingDetectionMode LeakingDetection { get; set; } = LeakingDetectionMode.DetectAndCaptureStackWithFiles;
public static LeakingDetectionMode LeakingDetection { get; set; } = LeakingDetectionMode.Minimal;

public static bool CaptureStackOnUnreachable { get; set; }
}

public enum LeakingDetectionMode
Expand Down
2 changes: 1 addition & 1 deletion RunSharpShared/AttributeGen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ internal AttributeGen(AttributeTargets target, AttributeType attributeType, obje

static bool IsValidAttributeParamType(Type t)
{
return t != null && (t.IsPrimitive || t.IsEnum || Helpers.IsAssignableFrom(typeof(Type), t) || t.FullName == typeof(string).FullName);
return t != null && (t.IsPrimitive || t.IsEnum || Helpers.IsAssignableFrom(typeof(System.Type), t) || t.FullName == typeof(string).FullName);
}

static bool IsSingleDimensionalZeroBasedArray(Array a)
Expand Down
5 changes: 4 additions & 1 deletion RunSharpShared/CodeGen.Statements.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,10 @@ void BeforeStatement()
{
if (!IsReachable)
{
throw new InvalidOperationException(Properties.Messages.ErrCodeNotReachable + ", \r\n set unreachable at \r\n" + _unreachableFrom);
var msg = ", \r\n set unreachable at \r\n" + _unreachableFrom;
if (_unreachableFrom == null)
msg = ", enable " + nameof(RunSharpDebug) + "." + nameof(RunSharpDebug.CaptureStackOnUnreachable) + " for capturing stack on unreachable";
throw new InvalidOperationException(Properties.Messages.ErrCodeNotReachable + msg);
}
#if !PHONE8
if (_cg != null && !_chainCalled && !_cg.Type.TypeBuilder.IsValueType)
Expand Down
3 changes: 2 additions & 1 deletion RunSharpShared/CodeGen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ public bool IsReachable
private set
{
_isReachable = value;
_unreachableFrom = value ? null :
_unreachableFrom = (value || !RunSharpDebug.CaptureStackOnUnreachable)
? null :
#if !SILVERLIGHT
new StackTrace(1, true);
#else
Expand Down
2 changes: 1 addition & 1 deletion RunSharpShared/Operand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ protected internal override void EmitAddressOf(CodeGen g)
string message = "RunSharp: a possible leak of operand " + ((this as ContextualOperand)?.GetInternalOperandType() ?? this.GetType()).Name
+ " detected, see Operand.SetNotLeaked() if it's not the case. " +
"Operand creation stack trace "
+ (_leakedStateStack != null ? "\r\n" + _leakedStateStack : " may be enabled with RunSharpDebug.StoreLeakingStackTrace = LeakingDetectionMode.Minimal");
+ (_leakedStateStack != null ? "\r\n" + _leakedStateStack : " may be enabled with RunSharpDebug.StoreLeakingStackTrace = LeakingDetectionMode.DetectAndCaptureStack");
throw new InvalidOperationException(message);
}
}
Expand Down
4 changes: 2 additions & 2 deletions RunSharpShared/Operands/TypeLiteral.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ protected internal override void EmitGet(CodeGen g)
{
OperandExtensions.SetLeakedState(this, false);
g.IL.Emit(OpCodes.Ldtoken, _t);
g.IL.Emit(OpCodes.Call, g.TypeMapper.MapType(typeof(Type)).GetMethod("GetTypeFromHandle"));
g.IL.Emit(OpCodes.Call, g.TypeMapper.MapType(typeof(System.Type)).GetMethod("GetTypeFromHandle"));
}

public override Type GetReturnType(ITypeMapper typeMapper) => typeMapper.MapType(typeof(Type));
public override Type GetReturnType(ITypeMapper typeMapper) => typeMapper.MapType(typeof(System.Type));

protected internal override object ConstantValue => _t;
}
Expand Down

0 comments on commit f93e8f9

Please sign in to comment.