コード例 #1
0
        static RuleBasedPrototypeMemorySpecs()
        {
            Default = new RuleBasedPrototypeMemorySpecs();

            Default.Register <AllocaArrayPrototype>(MemorySpecification.Nothing);
            Default.Register <AllocaPrototype>(MemorySpecification.Nothing);
            Default.Register <BoxPrototype>(MemorySpecification.Nothing);
            Default.Register <ConstantPrototype>(MemorySpecification.Nothing);
            Default.Register <CopyPrototype>(MemorySpecification.Nothing);
            Default.Register <DynamicCastPrototype>(MemorySpecification.Nothing);
            Default.Register <GetStaticFieldPointerPrototype>(MemorySpecification.Nothing);
            Default.Register <ReinterpretCastPrototype>(MemorySpecification.Nothing);
            Default.Register <GetFieldPointerPrototype>(MemorySpecification.Nothing);
            Default.Register <NewDelegatePrototype>(MemorySpecification.Nothing);
            Default.Register <UnboxPrototype>(MemorySpecification.Nothing);

            // Mark volatile loads and stores as unknown to ensure that they are never reordered
            // with regard to other memory operations.
            // TODO: is this really how we should represent volatility?
            Default.Register <LoadPrototype>(proto =>
                                             proto.IsVolatile ? MemorySpecification.Unknown : MemorySpecification.ArgumentRead.Create(0));
            Default.Register <StorePrototype>(proto =>
                                              proto.IsVolatile ? MemorySpecification.Unknown : MemorySpecification.ArgumentWrite.Create(0));

            // Call-like instruction prototypes.
            Default.Register <CallPrototype>(
                proto => proto.Lookup == MethodLookup.Static
                    ? proto.Callee.GetMemorySpecification()
                    : MemorySpecification.Unknown);
            Default.Register <NewObjectPrototype>(
                proto => proto.Constructor.GetMemorySpecification());
            Default.Register <IndirectCallPrototype>(MemorySpecification.Unknown);

            // Arithmetic intrinsics never read or write.
            foreach (var name in ArithmeticIntrinsics.Operators.All)
            {
                Default.Register(
                    ArithmeticIntrinsics.GetArithmeticIntrinsicName(name, false),
                    MemorySpecification.Nothing);
                Default.Register(
                    ArithmeticIntrinsics.GetArithmeticIntrinsicName(name, true),
                    MemorySpecification.Nothing);
            }

            // Array intrinsics.
            Default.Register(
                ArrayIntrinsics.Namespace.GetIntrinsicName(ArrayIntrinsics.Operators.GetElementPointer),
                MemorySpecification.Nothing);
            Default.Register(
                ArrayIntrinsics.Namespace.GetIntrinsicName(ArrayIntrinsics.Operators.LoadElement),
                MemorySpecification.UnknownRead);
            Default.Register(
                ArrayIntrinsics.Namespace.GetIntrinsicName(ArrayIntrinsics.Operators.StoreElement),
                MemorySpecification.UnknownWrite);
            Default.Register(
                ArrayIntrinsics.Namespace.GetIntrinsicName(ArrayIntrinsics.Operators.GetLength),
                MemorySpecification.Nothing);
            Default.Register(
                ArrayIntrinsics.Namespace.GetIntrinsicName(ArrayIntrinsics.Operators.NewArray),
                MemorySpecification.Nothing);

            // Exception intrinsics.
            Default.Register(
                ExceptionIntrinsics.Namespace.GetIntrinsicName(ExceptionIntrinsics.Operators.GetCapturedException),
                MemorySpecification.UnknownRead);

            // Object intrinsics.
            Default.Register(
                ObjectIntrinsics.Namespace.GetIntrinsicName(ObjectIntrinsics.Operators.UnboxAny),
                MemorySpecification.UnknownRead);

            // Memory intrinsics.
            Default.Register(
                MemoryIntrinsics.Namespace.GetIntrinsicName(MemoryIntrinsics.Operators.AllocaPinned),
                MemorySpecification.Nothing);
        }
コード例 #2
0
 /// <summary>
 /// Creates a copy of another set of prototype exception spec rules.
 /// </summary>
 public RuleBasedPrototypeMemorySpecs(RuleBasedPrototypeMemorySpecs other)
 {
     this.store = new RuleBasedSpecStore <MemorySpecification>(other.store);
 }