Ejemplo n.º 1
0
        /// <summary>
        /// Generates a mask to best represent parts of the signature to be compared
        /// </summary>
        public static ulong GetMask(ref DFunctionSignature signature)
        {
            var   value = signature.Value;
            ulong mask  = 0;
            //ulong argTypeMask = TypeMask; //(int)ValueTypes.Any;
            //while ((value & mask) != value)
            //{
            //  if ((value & argTypeMask) != 0)
            //    mask |= argTypeMask;
            //  argTypeMask <<= BitsPerType;
            //}

            var argOffset = 0;

            while (value != 0)
            {
                var argType = value & TypeMask;
                if (argType != 0)
                {
                    ///TODO: we used to have the following code so that higher types can capture lowe types. (e.g. Object captures also Array). However
                    ///this causes problem in the code cache and we should make sure we don't add repetitive code to it.

                    //if (argType == (ulong)ValueTypes.Object)
                    //  mask |= ((ulong)ValueTypes.Object << argOffset);
                    //else
                    mask |= ((ulong)TypeMask << argOffset);
                }
                argOffset += BitsPerType;
                value    >>= BitsPerType;
            }

            return(mask);
        }
Ejemplo n.º 2
0
    /// <summary>
    /// Generates a mask to best represent parts of the signature to be compared
    /// </summary>
    public static ulong GetMask(ref DFunctionSignature signature)
    {
      var value = signature.Value;
      ulong mask = 0;
      //ulong argTypeMask = TypeMask; //(int)ValueTypes.Any;
      //while ((value & mask) != value)
      //{
      //  if ((value & argTypeMask) != 0)
      //    mask |= argTypeMask;
      //  argTypeMask <<= BitsPerType;
      //}

      var argOffset = 0;
      while (value != 0)
      {
        var argType = value & TypeMask;
        if (argType != 0)
          ///TODO: we used to have the following code so that higher types can capture lowe types. (e.g. Object captures also Array). However
          ///this causes problem in the code cache and we should make sure we don't add repetitive code to it. 

          //if (argType == (ulong)ValueTypes.Object) 
          //  mask |= ((ulong)ValueTypes.Object << argOffset);
          //else
            mask |= ((ulong)TypeMask << argOffset);
        argOffset += BitsPerType;
        value >>= BitsPerType;
      }
      
      return mask;
    }
Ejemplo n.º 3
0
        static DFunctionSignature()
        {
            EmptySignature       = new DFunctionSignature();
            EmptySignature.Value = 0; //Set all unused bits to ValueTypes.Undefined
            Debug.Assert((int)ValueTypes.Undefined == 0x0, "Invalid value assigned to Undefined value type");

            //EmptySignature.Value = ulong.MaxValue; //Set all unused bits to ValueTypes.Unknown
            //Debug.Assert((int)ValueTypes.Unknown == 0xF, "Invalid value assigned to Unknown value type");
        }
Ejemplo n.º 4
0
    static DFunctionSignature()
    {
      EmptySignature = new DFunctionSignature();
      EmptySignature.Value = 0; //Set all unused bits to ValueTypes.Undefined
      Debug.Assert((int)ValueTypes.Undefined == 0x0, "Invalid value assigned to Undefined value type");

      //EmptySignature.Value = ulong.MaxValue; //Set all unused bits to ValueTypes.Unknown
      //Debug.Assert((int)ValueTypes.Unknown == 0xF, "Invalid value assigned to Unknown value type");
    }
Ejemplo n.º 5
0
 public T Get(ref DFunctionSignature signature)
 {
     for (int i = _items.Count - 1; i >= 0; --i)
     {
         var funcCode = _items[i].Code;
         if (funcCode.MatchSignature(ref signature))
         {
             //TODO: optimizations such as: update count, bring to front, etc.
             return(funcCode);
         }
     }
     return(null);
 }
Ejemplo n.º 6
0
 public DFunctionCode(ref DFunctionSignature signature)
 {
     SignatureMask.Value = DFunctionSignature.GetMask(ref signature);
     Signature.Value     = SignatureMask.Value & signature.Value;
 }
Ejemplo n.º 7
0
 public bool MatchSignature(ref DFunctionSignature signature)
 {
     return((signature.Value & SignatureMask.Value) == Signature.Value);
 }
Ejemplo n.º 8
0
 public DFunctionCode(ref DFunctionSignature signature)
 {
   SignatureMask.Value = DFunctionSignature.GetMask(ref signature);
   Signature.Value = SignatureMask.Value & signature.Value;
 }
Ejemplo n.º 9
0
 public bool MatchSignature(ref DFunctionSignature signature)
 {
   return (signature.Value & SignatureMask.Value) == Signature.Value;
 }