public override void Visit(GuardedCast node)
 {
   base.Visit(node);
   if (_result.ValueType == mdr.ValueTypes.DValueRef && ((JSRuntime.Instance.Configuration.EnableGuardElimination && node.IsRequired) ||
                                                          !JSRuntime.Instance.Configuration.EnableGuardElimination))
   {
     int profIndex = _currFuncMetadata.GetProfileIndex(node);
     _ilGen.Dup();
     _ilGen.Call(Types.DValue.GetValueType);
     _ilGen.Ldloc(_profiler);
     _ilGen.Ldc_I4(profIndex);
     _ilGen.Call(Types.Operations.Internals.UpdateGuardProfile);
   }
 }
Exemple #2
0
 public override void Visit(GuardedCast node)
 {
   Visit((ParenExpression)node);
 }
Exemple #3
0
 public override void Visit(GuardedCast node)
 {
   base.Visit(node);
   node.ValueType = GetType(node, _currProfile);
   GuardedCastProfile[node] = _currProfile; 
 }
Exemple #4
0
 internal static mdr.ValueTypes GetType(GuardedCast node, Profiler profiler)
 {
   var expType = node.Expression.ValueType;
   if (expType != mdr.ValueTypes.DValueRef && JSRuntime.Instance.Configuration.EnableGuardElimination)
       node.IsRequired = false;
   if (expType == mdr.ValueTypes.DValueRef && JSRuntime.Instance.Configuration.EnableSpeculativeJIT && profiler != null)
   {
     var nodeProfile = profiler.GetNodeProfile(node) as GuardNodeProfile;
     var speculativeType = nodeProfile != null ? nodeProfile.GetHotPrimitiveType() : mdr.ValueTypes.DValueRef;
     if (speculativeType != mdr.ValueTypes.DValueRef)
     {
       expType = speculativeType;
     }
     if (JSRuntime.Instance.Configuration.EnableGuardElimination) node.IsRequired = true;
   }
   return expType;
 }
      public override void Visit(GuardedCast node)
      {
        base.Visit(node);

        if (_result.ValueType != mdr.ValueTypes.DValueRef)
          return;

        var nodeProfile = _currProfiler.GetNodeProfile(node);

        if (nodeProfile != null)
        {
          var hotType = nodeProfile.GetHotType();
          if (hotType != mdr.ValueTypes.DValueRef)
          {
            var valueType = _localVars.Declare(typeof(int));
            _ilGen.Dup();
            _ilGen.Call(Types.DValue.GetValueType);
            _ilGen.Conv_I4();
            _ilGen.Dup();
            _ilGen.Stloc(valueType);
            _ilGen.Ldc_I4((int)hotType);
            var success = _ilGen.DefineLabel();
            _ilGen.Beq(success);

            if (JSRuntime.Instance.Configuration.EnableDeoptimization)
            {
                /*
                Get the types of the values in the stack right now from the ValidatingILGenerator
                Encode it in a string and push it onto the stack
                Push the icIndex of the GuardedCast node
                Add the jump to the deoptimizer here
                */
                var vILGen = _ilGen as mjr.ILGen.ValidatingILGenerator;
                if (vILGen != null) vILGen.DeactivateValidation();

                _ilGen.Ldarg_CallFrame();
                _ilGen.Ldc_I4(_currFuncMetadata.ValuesLength);
                _ilGen.NewArr(Types.DValue.TypeOf);
                _ilGen.Stfld(Types.CallFrame.Values);

                var types = _ilGen.GetValueTypes();
                var length = types.Length;
                var stackStartIndex = 2 + _currFuncMetadata.Scope.Symbols.Count;
                var index = 1;

                /// CallFrame.Values is usually assinged like this:
                /// +-------+---------+-------------+-----------+-----------------+
                /// |context|arguments|...symbols...|...stack...|...temporaries...|
                /// +-------+---------+-------------+-----------+-----------------+
                foreach (var t in types)
                {
                    var vType = Types.ValueTypeOf(t);
                    //Console.WriteLine("Storing Symbols is called as well!\n");
                    //_ilGen.Call(Types.Operations.Internals.PrintString);
                    _ilGen.StoreValue(stackStartIndex + length - index++, vType);
                }

                //_ilGen.Ldstr(valueTypesString);
                _ilGen.Ldc_I4(node.ICIndex);
                _ilGen.Ldloc(valueType);
                //_ilGen.Ldstr("JSSpeculationFailed is called as well!");
                //_ilGen.Call(Types.Operations.Internals.PrintString);
                _ilGen.Call(Types.JSSpeculationFailedException.Throw.Get(mdr.ValueTypes.Int32));

                if (vILGen != null) vILGen.ReactivateValidation();
            }
            else
            {
                _ilGen.Ldc_I4(node.ICIndex);
                _ilGen.Ldloc(valueType);
                _ilGen.Call(Types.JSSpeculationFailedException.Throw.Get(mdr.ValueTypes.Int32));
            }
            _ilGen.MarkLabel(success);
            AsX(hotType);
          }
        }
      }
 public override void Visit(GuardedCast node)
 {
   //Update the index where the values need to be stored.
   node.ICIndex = GetCurrentICIndex() + 1;
   base.Visit(node);
 }
Exemple #7
0
 public override void Visit(GuardedCast node)
 {
     Visit((ParenExpression)node);
 }
Exemple #8
0
 public abstract void Visit(GuardedCast node);
Exemple #9
0
 internal void PopLocation(GuardedCast node, ref mdr.DValue result)
 {
   if (_currProfiler != null)
   {
     _currProfiler.GetOrAddNodeProfile(node).UpdateNodeProfile(result.ValueType);
   }
 }
Exemple #10
0
 public override void Visit(GuardedCast node)
 {
   PushLocation(node);
   VisitNode(node.Expression);
   PopLocation();
 }
 public override void Visit(GuardedCast node) { AssignToImplicitReturn(node); }
Exemple #12
0
 public int GetProfileIndex(GuardedCast node) { return (node.ProfileIndex == -1) ? (node.ProfileIndex = GuardedCastNodeCount++) : node.ProfileIndex; }