Ejemplo n.º 1
0
        public RapidTypeAnalysis(WholeProgram wholeProgram, TargetProfile profile)
        {
            Contract.Ensures(!this.FinishedAnalysis);

            this.types   = new HashSet <ITypeDefinition>(new TypeDefinitionEqualityComparer());
            this.methods = new HashSet <IMethodDefinition>(new MethodDefinitionEqualityComparer());
            this.virtualCallsInDemand = new VirtualDispatchDemand();

            this.nonvirtualDispatches = new HashSet <IMethodDefinition>(new MethodDefinitionEqualityComparer());

            this.fields      = new HashSet <IFieldDefinition>(new FieldDefinitionEqualityComparer());
            this.constructed = new HashSet <ITypeDefinition>(new TypeDefinitionEqualityComparer());

            this.constructedGenericParameters = new HashSet <IGenericParameter>(new TypeDefinitionEqualityComparer());

            // Note: we use the interned key as the hashcode, so this set should be deterministic
            this.worklist = new HashSet <IMethodDefinition>(new MethodDefinitionEqualityComparer());

            this.wholeProgram = wholeProgram;

            this.reflectionSummarizers = new HashSet <IMethodSummarizer>();

            this.simpleBytecodeSummarizer           = new SimpleBytecodeMethodSummarizer();
            this.reachabilityFlowBytecodeSummarizer = new ReachabilityBasedLocalFlowMethodSummarizer();

            //systemObjectType = wholeProgram.Host().PlatformType.SystemObject.ResolvedType;

            // Weak heuristic -- should provide custom host?

            IAssembly coreAssembly = wholeProgram.HeuristicFindCoreAssemblyForProfile(profile);

            Contract.Assert(coreAssembly != null);

            systemObjectType = GarbageCollectHelper.CreateTypeReference(wholeProgram.Host(), coreAssembly, "System.Object").ResolvedType;
            Contract.Assert(!(systemObjectType is Dummy));

            systemObjectFinalizeMethod = TypeHelper.GetMethod(systemObjectType, wholeProgram.Host().NameTable.GetNameFor("Finalize"));
            Contract.Assert(!(systemObjectFinalizeMethod is Dummy));

            methodsRequiringReflectionSummary = new HashSet <IMethodDefinition>(new MethodDefinitionEqualityComparer());

            unresolvedReferences = new HashSet <IReference>(new ReferenceEqualityComparer());

            unspecializedTypesPassedAsTypeVariables = new HashSet <ITypeDefinition>(new TypeDefinitionEqualityComparer());
        }
Ejemplo n.º 2
0
    public RapidTypeAnalysis(WholeProgram wholeProgram, TargetProfile profile) {
      Contract.Ensures(!this.FinishedAnalysis);

      this.types = new HashSet<ITypeDefinition>(new TypeDefinitionEqualityComparer());
      this.methods = new HashSet<IMethodDefinition>(new MethodDefinitionEqualityComparer());
      this.virtualCallsInDemand = new VirtualDispatchDemand();

      this.nonvirtualDispatches = new HashSet<IMethodDefinition>(new MethodDefinitionEqualityComparer());

      this.fields = new HashSet<IFieldDefinition>(new FieldDefinitionEqualityComparer());
      this.constructed = new HashSet<ITypeDefinition>(new TypeDefinitionEqualityComparer());

      this.constructedGenericParameters = new HashSet<IGenericParameter>(new TypeDefinitionEqualityComparer());

      // Note: we use the interned key as the hashcode, so this set should be deterministic
      this.worklist = new HashSet<IMethodDefinition>(new MethodDefinitionEqualityComparer());

      this.wholeProgram = wholeProgram;

      this.reflectionSummarizers = new HashSet<IMethodSummarizer>();
     
      this.simpleBytecodeSummarizer = new SimpleBytecodeMethodSummarizer();
      this.reachabilityFlowBytecodeSummarizer = new ReachabilityBasedLocalFlowMethodSummarizer();

      //systemObjectType = wholeProgram.Host().PlatformType.SystemObject.ResolvedType;

      // Weak heuristic -- should provide custom host?

      IAssembly coreAssembly = wholeProgram.HeuristicFindCoreAssemblyForProfile(profile);
      Contract.Assert(coreAssembly != null);

      systemObjectType = GarbageCollectHelper.CreateTypeReference(wholeProgram.Host(), coreAssembly, "System.Object").ResolvedType;
      Contract.Assert(!(systemObjectType is Dummy));

      systemObjectFinalizeMethod = TypeHelper.GetMethod(systemObjectType, wholeProgram.Host().NameTable.GetNameFor("Finalize"));
      Contract.Assert(!(systemObjectFinalizeMethod is Dummy));

      methodsRequiringReflectionSummary = new HashSet<IMethodDefinition>(new MethodDefinitionEqualityComparer());

      unresolvedReferences = new HashSet<IReference>(new ReferenceEqualityComparer());

      unspecializedTypesPassedAsTypeVariables = new HashSet<ITypeDefinition>(new TypeDefinitionEqualityComparer());

    }