Beispiel #1
0
        public FunctionAnalysis2ndPass GetSecondPass(JSMethod method, QualifiedMemberIdentifier forCaller)
        {
            if (method == null)
            {
                return(null);
            }

            var   id    = method.QualifiedIdentifier;
            Entry entry = Cache.GetOrCreate(
                id, method, MakeCacheEntry
                );

            if (entry == null)
            {
                return(null);
            }

            GetFirstPass(id, forCaller);

            if (!TryAcquireStaticAnalysisDataLock(entry, method.QualifiedIdentifier))
            {
                return(null);
            }

            try {
                return(_GetOrCreateSecondPass(entry));
            } finally {
                entry.StaticAnalysisDataLock.Exit();
            }
        }
Beispiel #2
0
        public FunctionAnalysis2ndPass GetSecondPass(JSMethod method)
        {
            var id = method.QualifiedIdentifier;

            Entry entry = Cache.GetOrCreate(
                id, method, MakeCacheEntry
                );

            if (entry.SecondPass == null)
            {
                if (entry.InProgress)
                {
                    return(null);
                }

                if (entry.Expression == null)
                {
                    return(null);
                }
                else
                {
                    var firstPass = GetFirstPass(id);
                    try {
                        entry.InProgress = true;
                        entry.SecondPass = new FunctionAnalysis2ndPass(this, firstPass);
                    } finally {
                        entry.InProgress = false;
                    }
                }
            }

            return(entry.SecondPass);
        }
Beispiel #3
0
            public NodeVisitor Get(JSNode node)
            {
                if (node == null)
                {
                    return(null);
                }

                var nodeType    = node.GetType();
                var currentType = nodeType;

                return(Cache.GetOrCreate(
                           nodeType, () => {
                    while (currentType != null)
                    {
                        NodeVisitor result;
                        if (Methods.TryGetValue(currentType, out result))
                        {
                            return result;
                        }

                        currentType = currentType.BaseType;
                    }

                    return null;
                }
                           ));
            }
Beispiel #4
0
            public static VisitorCache Get(JSAstVisitor visitor)
            {
                var visitorType = visitor.GetType();

                return(VisitorCaches.GetOrCreate(
                           visitorType, () => new VisitorCache(visitorType)
                           ));
            }
Beispiel #5
0
        public Token GetPrivateToken(string assemblyFullName)
        {
            Token result = Tokens.GetOrCreate(
                assemblyFullName, MakeToken
                );

            return(result);
        }
Beispiel #6
0
        public Token GetPrivateToken(string assemblyFullName)
        {
            Token result = Tokens.GetOrCreate(
                assemblyFullName, () => {
                AssignedIdentifiers = false;
                return(new Token(assemblyFullName));
            }
                );

            return(result);
        }
Beispiel #7
0
        public ModuleInfo GetModuleInformation(ModuleDefinition module)
        {
            if (module == null)
            {
                throw new ArgumentNullException("module");
            }

            var fullName = module.FullyQualifiedName;

            return(ModuleInformation.GetOrCreate(
                       fullName, module, MakeModuleInfo
                       ));
        }
Beispiel #8
0
            public NodeVisitor Get(JSNode node)
            {
                if (node == null)
                {
                    return(null);
                }

                var nodeType = node.GetType();

                return(Cache.GetOrCreate(
                           nodeType, FindNodeVisitor
                           ));
            }
Beispiel #9
0
        public FunctionAnalysis2ndPass GetSecondPass(JSMethod method)
        {
            var id = method.QualifiedIdentifier;

            Entry entry = Cache.GetOrCreate(
                id, () => {
                OptimizationQueue.TryEnqueue(id);

                return(new Entry {
                    Info = method.Method,
                    Reference = method.Reference,
                    Identifier = id,
                    ParameterNames = new HashSet <string>(from p in method.Method.Parameters select p.Name),
                    SecondPass = new FunctionAnalysis2ndPass(this, method.Method)
                });
            }
                );

            if (entry.SecondPass == null)
            {
                if (entry.InProgress)
                {
                    return(null);
                }

                if (entry.Expression == null)
                {
                    return(null);
                }
                else
                {
                    entry.SecondPass = new FunctionAnalysis2ndPass(this, GetFirstPass(id));
                }
            }

            return(entry.SecondPass);
        }
Beispiel #10
0
        internal bool TryCreateWait(WeakTrackedLockReference weakLock, out DeadlockInfo deadlock, out Wait wait)
        {
            var lck = (TrackedLock)weakLock.Target;

            if (lck == null)
            {
                wait     = default(Wait);
                deadlock = default(DeadlockInfo);
                return(false);
            }

            var currentThread = Thread.CurrentThread;
            var waits         = Waits.GetOrCreate(lck, MakeWaitList);

            wait = new Wait(this, lck, currentThread);

            lock (waits)
                waits.Enqueue(wait, false);

            deadlock = DetectDeadlock(wait);
            if (deadlock != null)
            {
                lock (waits)
                    waits.Remove(wait);

                var wasSignaled = wait.IsSignaled;

                wait.Dispose();
                wait = null;

                // It's possible, albeit incredibly unlikely, for someone to call Wake on our wait
                //  before we do the deadlock check.
                // If this happens, try to dequeue another wait from the queue and wake it up in our stead.
                // This can probably still break, though...
                if (wasSignaled)
                {
                    if (TryDequeueOneWait(lck, out wait))
                    {
                        wait.Wake();
                    }
                }

                return(false);
            }

            return(true);
        }
Beispiel #11
0
        void ITypeInfoSource.CacheProxyNames(MemberReference mr)
        {
            var name = new HashedString(mr.DeclaringType.Name);
            var proxiesByFullName = ProxiesByName.GetOrCreate(
                name, mr, MakeProxiesByName
                );

            var fullName = new HashedString(mr.DeclaringType.FullName);

            if (proxiesByFullName.Cache.TryCreate(
                    fullName, mr,
                    MakeProxiesByFullName, ShouldAddProxies
                    ))
            {
                Interlocked.Increment(ref proxiesByFullName.Count);
            }
        }
Beispiel #12
0
            public static VisitorCache Get(JSAstVisitor visitor)
            {
                var visitorType = visitor.GetType();

                return(VisitorCaches.GetOrCreate(visitorType, CreateCacheEntry));
            }