Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 157438 Details for
Bug 287907
Indexer holds exclusive index lock for too long
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Clear result cache only once per IASTTranslationUnit
287907.txt (text/plain), 19.88 KB, created by
Markus Schorn
on 2010-01-27 13:17:58 EST
(
hide
)
Description:
Clear result cache only once per IASTTranslationUnit
Filename:
MIME Type:
Creator:
Markus Schorn
Created:
2010-01-27 13:17:58 EST
Size:
19.88 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.cdt.core >Index: parser/org/eclipse/cdt/internal/core/index/CIndex.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java,v >retrieving revision 1.41 >diff -u -r1.41 CIndex.java >--- parser/org/eclipse/cdt/internal/core/index/CIndex.java 23 Jan 2010 22:42:23 -0000 1.41 >+++ parser/org/eclipse/cdt/internal/core/index/CIndex.java 27 Jan 2010 18:14:34 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2006, 2009 Wind River Systems, Inc. and others. >+ * Copyright (c) 2006, 2010 Wind River Systems, Inc. and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -99,12 +99,12 @@ > } else { > List<IIndexBinding[]> result = new ArrayList<IIndexBinding[]>(); > ILinkage[] linkages = Linkage.getIndexerLinkages(); >- for (int j = 0; j < linkages.length; j++) { >- if (filter.acceptLinkage(linkages[j])) { >+ for (ILinkage linkage : linkages) { >+ if (filter.acceptLinkage(linkage)) { > IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][]; > for (int i = 0; i < fPrimaryFragmentCount; i++) { > try { >- IBinding[] part = fFragments[i].findBindings(patterns, isFullyQualified, retargetFilter(linkages[j], filter), monitor); >+ IBinding[] part = fFragments[i].findBindings(patterns, isFullyQualified, retargetFilter(linkage, filter), monitor); > fragmentBindings[i] = new IIndexFragmentBinding[part.length]; > System.arraycopy(part, 0, fragmentBindings[i], 0, part.length); > } catch (CoreException e) { >@@ -112,7 +112,7 @@ > fragmentBindings[i] = IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY; > } > } >- ICompositesFactory factory = getCompositesFactory(linkages[j].getLinkageID()); >+ ICompositesFactory factory = getCompositesFactory(linkage.getLinkageID()); > result.add(factory.getCompositeBindings(fragmentBindings)); > } > } >@@ -126,12 +126,12 @@ > } else { > List<IIndexBinding[]> result = new ArrayList<IIndexBinding[]>(); > ILinkage[] linkages = Linkage.getIndexerLinkages(); >- for (int j = 0; j < linkages.length; j++) { >- if (filter.acceptLinkage(linkages[j])) { >+ for (ILinkage linkage : linkages) { >+ if (filter.acceptLinkage(linkage)) { > IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][]; > for (int i = 0; i < fPrimaryFragmentCount; i++) { > try { >- IBinding[] part = fFragments[i].findMacroContainers(pattern, retargetFilter(linkages[j], filter), monitor); >+ IBinding[] part = fFragments[i].findMacroContainers(pattern, retargetFilter(linkage, filter), monitor); > fragmentBindings[i] = new IIndexFragmentBinding[part.length]; > System.arraycopy(part, 0, fragmentBindings[i], 0, part.length); > } catch (CoreException e) { >@@ -139,7 +139,7 @@ > fragmentBindings[i] = IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY; > } > } >- ICompositesFactory factory = getCompositesFactory(linkages[j].getLinkageID()); >+ ICompositesFactory factory = getCompositesFactory(linkage.getLinkageID()); > result.add(factory.getCompositeBindings(fragmentBindings)); > } > } >@@ -156,8 +156,7 @@ > } > if (bindings.length > 1) { > ArrayList<IIndexName> multi= new ArrayList<IIndexName>(); >- for (int i = 0; i < bindings.length; i++) { >- IBinding b = bindings[i]; >+ for (IBinding b : bindings) { > multi.addAll(Arrays.asList(findNames(b, flags))); > } > return multi.toArray(new IIndexName[multi.size()]); >@@ -221,8 +220,7 @@ > BitSet linkages= new BitSet(); > for (int i = 0; i < fPrimaryFragmentCount; i++) { > IIndexFragmentFile[] candidates= fFragments[i].getFiles(location); >- for (int j = 0; j < candidates.length; j++) { >- IIndexFragmentFile candidate= candidates[j]; >+ for (IIndexFragmentFile candidate : candidates) { > int linkage= candidate.getLinkageID(); > if (!linkages.get(linkage) && candidate.hasContent()) { > result.add(candidate); >@@ -261,12 +259,11 @@ > > public void findIncludedBy(List<IIndexFile> in, List<IIndexInclude> out, int depth, HashSet<IIndexFileLocation> handled) throws CoreException { > List<IIndexFile> nextLevel= depth != 0 ? new LinkedList<IIndexFile>() : null; >- for (Iterator<IIndexFile> it= in.iterator(); it.hasNext(); ) { >- IIndexFragmentFile file = (IIndexFragmentFile) it.next(); >+ for (IIndexFile iIndexFile : in) { >+ IIndexFragmentFile file = (IIndexFragmentFile) iIndexFile; > for (int j = 0; j < fPrimaryFragmentCount; j++) { > IIndexInclude[] includedBy= fFragments[j].findIncludedBy(file); >- for (int k = 0; k < includedBy.length; k++) { >- IIndexInclude include = includedBy[k]; >+ for (IIndexInclude include : includedBy) { > if (handled.add(include.getIncludedByLocation())) { > out.add(include); > if (depth != 0) { >@@ -298,11 +295,10 @@ > > private void findIncludes(List<IIndexFile> in, List<IIndexInclude> out, int depth, HashSet<Object> handled) throws CoreException { > List<IIndexFile> nextLevel= depth != 0 ? new LinkedList<IIndexFile>() : null; >- for (Iterator<IIndexFile> it= in.iterator(); it.hasNext(); ) { >- IIndexFragmentFile file = (IIndexFragmentFile) it.next(); >+ for (IIndexFile iIndexFile : in) { >+ IIndexFragmentFile file = (IIndexFragmentFile) iIndexFile; > IIndexInclude[] includes= file.getIncludes(); >- for (int k = 0; k < includes.length; k++) { >- IIndexInclude include = includes[k]; >+ for (IIndexInclude include : includes) { > IIndexFileLocation target= include.getIncludesLocation(); > Object key= target != null ? (Object) target : include.getFullName(); > if (handled.add(key)) { >@@ -346,8 +342,8 @@ > > public synchronized void releaseReadLock() { > if (--fReadLock == 0) { >- for (int i = 0; i < fFragments.length; i++) { >- fFragments[i].releaseReadLock(); >+ for (IIndexFragment fFragment : fFragments) { >+ fFragment.releaseReadLock(); > } > } > } >@@ -357,8 +353,8 @@ > } > > public boolean hasWaitingReaders() { >- for (int i= 0; i < fFragments.length; i++) { >- if (fFragments[i].hasWaitingReaders()) { >+ for (IIndexFragment fFragment : fFragments) { >+ if (fFragment.hasWaitingReaders()) { > return true; > } > } >@@ -367,8 +363,8 @@ > > public long getLastWriteAccess() { > long result= 0; >- for (int i = 0; i < fFragments.length; i++) { >- result= Math.max(result, fFragments[i].getLastWriteAccess()); >+ for (IIndexFragment fFragment : fFragments) { >+ result= Math.max(result, fFragment.getLastWriteAccess()); > } > return result; > } >@@ -388,12 +384,12 @@ > List<IIndexBinding[]> result = new ArrayList<IIndexBinding[]>(); > ILinkage[] linkages = Linkage.getIndexerLinkages(); > monitor.beginTask(Messages.CIndex_FindBindingsTask_label, fFragments.length * linkages.length); >- for (int j = 0; j < linkages.length; j++) { >- if (filter.acceptLinkage(linkages[j])) { >+ for (ILinkage linkage : linkages) { >+ if (filter.acceptLinkage(linkage)) { > IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][]; > for (int i = 0; i < fPrimaryFragmentCount; i++) { > try { >- IBinding[] part = fFragments[i].findBindings(names, retargetFilter(linkages[j], filter), new SubProgressMonitor(monitor, 1)); >+ IBinding[] part = fFragments[i].findBindings(names, retargetFilter(linkage, filter), new SubProgressMonitor(monitor, 1)); > fragmentBindings[i] = new IIndexFragmentBinding[part.length]; > System.arraycopy(part, 0, fragmentBindings[i], 0, part.length); > } catch (CoreException e) { >@@ -401,7 +397,7 @@ > fragmentBindings[i] = IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY; > } > } >- ICompositesFactory factory = getCompositesFactory(linkages[j].getLinkageID()); >+ ICompositesFactory factory = getCompositesFactory(linkage.getLinkageID()); > result.add(factory.getCompositeBindings(fragmentBindings)); > } > } >@@ -460,8 +456,8 @@ > > public IIndexFragmentBinding[] findEquivalentBindings(IBinding binding) throws CoreException { > List<IIndexFragmentBinding> result = new ArrayList<IIndexFragmentBinding>(); >- for (int i = 0; i < fFragments.length; i++) { >- IIndexFragmentBinding adapted = fFragments[i].adaptBinding(binding); >+ for (IIndexFragment fFragment : fFragments) { >+ IIndexFragmentBinding adapted = fFragment.adaptBinding(binding); > if (adapted != null) { > result.add(adapted); > } >@@ -513,12 +509,12 @@ > } else { > List<IIndexBinding[]> result = new ArrayList<IIndexBinding[]>(); > ILinkage[] linkages = Linkage.getIndexerLinkages(); >- for (int j = 0; j < linkages.length; j++) { >- if (filter.acceptLinkage(linkages[j])) { >+ for (ILinkage linkage : linkages) { >+ if (filter.acceptLinkage(linkage)) { > IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][]; > for (int i = 0; i < fPrimaryFragmentCount; i++) { > try { >- IBinding[] part = fFragments[i].findBindingsForPrefix(prefix, filescope, retargetFilter(linkages[j], filter), monitor); >+ IBinding[] part = fFragments[i].findBindingsForPrefix(prefix, filescope, retargetFilter(linkage, filter), monitor); > fragmentBindings[i] = new IIndexFragmentBinding[part.length]; > System.arraycopy(part, 0, fragmentBindings[i], 0, part.length); > } catch (CoreException e) { >@@ -526,7 +522,7 @@ > fragmentBindings[i] = IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY; > } > } >- ICompositesFactory factory = getCompositesFactory(linkages[j].getLinkageID()); >+ ICompositesFactory factory = getCompositesFactory(linkage.getLinkageID()); > result.add(factory.getCompositeBindings(fragmentBindings)); > } > } >@@ -540,12 +536,12 @@ > } else { > List<IIndexBinding[]> result = new ArrayList<IIndexBinding[]>(); > ILinkage[] linkages = Linkage.getIndexerLinkages(); >- for (int j = 0; j < linkages.length; j++) { >- if (filter.acceptLinkage(linkages[j])) { >+ for (ILinkage linkage : linkages) { >+ if (filter.acceptLinkage(linkage)) { > IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][]; > for (int i = 0; i < fPrimaryFragmentCount; i++) { > try { >- IBinding[] part = fFragments[i].findBindings(name, filescope, retargetFilter(linkages[j], filter), monitor); >+ IBinding[] part = fFragments[i].findBindings(name, filescope, retargetFilter(linkage, filter), monitor); > fragmentBindings[i] = new IIndexFragmentBinding[part.length]; > System.arraycopy(part, 0, fragmentBindings[i], 0, part.length); > } catch (CoreException e) { >@@ -553,7 +549,7 @@ > fragmentBindings[i] = IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY; > } > } >- ICompositesFactory factory = getCompositesFactory(linkages[j].getLinkageID()); >+ ICompositesFactory factory = getCompositesFactory(linkage.getLinkageID()); > result.add(factory.getCompositeBindings(fragmentBindings)); > } > } >@@ -582,8 +578,7 @@ > HashSet<IIndexFile> allowedFiles= new HashSet<IIndexFile>(); > try { > IIndexMacro[] macros= fFragments[i].findMacros(name, isPrefix, caseSensitive, filter, new SubProgressMonitor(monitor, 1)); >- for (int k = 0; k < macros.length; k++) { >- IIndexMacro indexMacro = macros[k]; >+ for (IIndexMacro indexMacro : macros) { > IIndexFile file= indexMacro.getFile(); > if (!allowedFiles.contains(file)) { > if (handledIFLs.add(file.getLocation())) { >@@ -604,27 +599,27 @@ > > public long getCacheHits() { > long result= 0; >- for (int i = 0; i < fFragments.length; i++) { >- result+= fFragments[i].getCacheHits(); >+ for (IIndexFragment fFragment : fFragments) { >+ result+= fFragment.getCacheHits(); > } > return result; > } > > public long getCacheMisses() { > long result= 0; >- for (int i = 0; i < fFragments.length; i++) { >- result+= fFragments[i].getCacheMisses(); >+ for (IIndexFragment fFragment : fFragments) { >+ result+= fFragment.getCacheMisses(); > } > return result; > } > > public void resetCacheCounters() { >- for (int i = 0; i < fFragments.length; i++) { >- fFragments[i].resetCacheCounters(); >+ for (IIndexFragment fFragment : fFragments) { >+ fFragment.resetCacheCounters(); > } > } > >- void clearResultCaches() { >+ protected void clearResultCache() { > for (IIndexFragment frag : fFragments) { > frag.clearResultCache(); > } >Index: parser/org/eclipse/cdt/internal/core/index/IWritableIndex.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IWritableIndex.java,v >retrieving revision 1.18 >diff -u -r1.18 IWritableIndex.java >--- parser/org/eclipse/cdt/internal/core/index/IWritableIndex.java 23 Jan 2010 22:42:23 -0000 1.18 >+++ parser/org/eclipse/cdt/internal/core/index/IWritableIndex.java 27 Jan 2010 18:14:34 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others. >+ * Copyright (c) 2006, 2010 Wind River Systems, Inc. and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -10,7 +10,6 @@ > * Andrew Ferguson (Symbian) > * Sergey Prigogin (Google) > *******************************************************************************/ >- > package org.eclipse.cdt.internal.core.index; > > import java.util.Collection; >@@ -151,4 +150,9 @@ > * Returns the size of the database in bytes. > */ > long getDatabaseSizeBytes(); >+ >+ /** >+ * Clears the result cache, caller needs to hold a write-lock. >+ */ >+ void clearResultCache(); > } >Index: parser/org/eclipse/cdt/internal/core/index/WritableCIndex.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/WritableCIndex.java,v >retrieving revision 1.21 >diff -u -r1.21 WritableCIndex.java >--- parser/org/eclipse/cdt/internal/core/index/WritableCIndex.java 23 Jan 2010 22:42:23 -0000 1.21 >+++ parser/org/eclipse/cdt/internal/core/index/WritableCIndex.java 27 Jan 2010 18:14:34 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others. >+ * Copyright (c) 2006, 2010 Wind River Systems, Inc. and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -10,7 +10,6 @@ > * Andrew Ferguson (Symbian) > * Sergey Prigogin (Google) > *******************************************************************************/ >- > package org.eclipse.cdt.internal.core.index; > > import java.util.Collection; >@@ -134,11 +133,19 @@ > assert fIsWriteLocked: "No write lock to be released"; //$NON-NLS-1$ > assert establishReadlockCount == getReadLockCount(): "Unexpected read lock is not allowed"; //$NON-NLS-1$ > >+ // Bug 297641: Result cache of read only providers needs to be cleared. >+ if (establishReadlockCount == 0) { >+ clearResultCache(); >+ } >+ > fIsWriteLocked= false; > fWritableFragment.releaseWriteLock(establishReadlockCount, flush); >- >- // Bug 297641: Result cache of read only providers needs to be cleared. >- clearResultCaches(); >+ } >+ >+ @Override >+ public void clearResultCache() { >+ assert fIsWriteLocked: "Need to hold a write lock to clear result caches"; //$NON-NLS-1$ >+ super.clearResultCache(); > } > > public void flush() throws CoreException { >Index: parser/org/eclipse/cdt/internal/core/pdom/PDOM.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java,v >retrieving revision 1.147 >diff -u -r1.147 PDOM.java >--- parser/org/eclipse/cdt/internal/core/pdom/PDOM.java 23 Jan 2010 22:42:24 -0000 1.147 >+++ parser/org/eclipse/cdt/internal/core/pdom/PDOM.java 27 Jan 2010 18:14:34 -0000 >@@ -863,7 +863,10 @@ > > @SuppressWarnings("nls") > public void releaseWriteLock(int establishReadLocks, boolean flush) { >- clearResultCache(); >+ // When all locks are released we can clear the result cache. >+ if (establishReadLocks == 0) { >+ clearResultCache(); >+ } > try { > db.giveUpExclusiveLock(flush); > } catch (CoreException e) { >Index: parser/org/eclipse/cdt/internal/core/pdom/PDOMWriter.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMWriter.java,v >retrieving revision 1.50 >diff -u -r1.50 PDOMWriter.java >--- parser/org/eclipse/cdt/internal/core/pdom/PDOMWriter.java 23 Jan 2010 22:42:23 -0000 1.50 >+++ parser/org/eclipse/cdt/internal/core/pdom/PDOMWriter.java 27 Jan 2010 18:14:34 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others. >+ * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -219,6 +219,11 @@ > } catch (AssertionError e) { > th= e; > } finally { >+ // When the caller holds a read-lock, the result cache of the index is never cleared. >+ // ==> Before releasing the lock for the last time in this ast, we clear the result cache. >+ if (readlockCount > 0 && i == ifls.length-1) { >+ index.clearResultCache(); >+ } > lock.release(); > } > if (th != null) { >Index: parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassSpecialization.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassSpecialization.java,v >retrieving revision 1.29 >diff -u -r1.29 PDOMCPPClassSpecialization.java >--- parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassSpecialization.java 11 Dec 2009 11:11:17 -0000 1.29 >+++ parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassSpecialization.java 27 Jan 2010 18:14:34 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2007, 2009 QNX Software Systems and others. >+ * Copyright (c) 2007, 2010 QNX Software Systems and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -151,12 +151,14 @@ > } > > public void addBase(PDOMCPPBase base) throws CoreException { >+ getPDOM().removeCachedResult(record+PDOMCPPLinkage.CACHE_BASES); > PDOMCPPBase firstBase = getFirstBase(); > base.setNextBase(firstBase); > setFirstBase(base); > } > > public void removeBase(PDOMName pdomName) throws CoreException { >+ getPDOM().removeCachedResult(record+PDOMCPPLinkage.CACHE_BASES); > PDOMCPPBase base= getFirstBase(); > PDOMCPPBase predecessor= null; > long nameRec= pdomName.getRecord();
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
mschorn.eclipse
:
iplog-
Actions:
View
|
Diff
Attachments on
bug 287907
:
149821
|
150451
|
150633
|
155176
|
155189
|
155709
|
156475
|
157044
|
157435
| 157438