diff options
author | Manoj Palat | 2015-07-28 06:05:53 +0000 |
---|---|---|
committer | Manoj Palat | 2015-07-31 06:45:37 +0000 |
commit | fc5c5e8f9b2ae428895ab620b46421efd9c38e0f (patch) | |
tree | 398ca3b2ff80a33848440cf58222ed6b426ad528 | |
parent | 1c0c68e97904e9e4293798bd287ad84668ef5a3f (diff) | |
download | eclipse.jdt.core-fc5c5e8f9b2ae428895ab620b46421efd9c38e0f.tar.gz eclipse.jdt.core-fc5c5e8f9b2ae428895ab620b46421efd9c38e0f.tar.xz eclipse.jdt.core-fc5c5e8f9b2ae428895ab620b46421efd9c38e0f.zip |
Fix for Bug 457871 [Performance] Java compiler CPU time regression
compared to 4.2.2 (plus bug 419971)
5 files changed, 43 insertions, 19 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15JLS4Test.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15JLS4Test.java index 62bf3f256c..c27f32c6d4 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15JLS4Test.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15JLS4Test.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2014 IBM Corporation and others. + * Copyright (c) 2011, 2015 IBM Corporation 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 @@ -9389,7 +9389,7 @@ public class ASTConverter15JLS4Test extends ConverterTestSetup { //https://bugs.eclipse.org/bugs/show_bug.cgi?id=192774 //Test ability to distinguish AST nodes of multiple similar annotations. - public void _test0276() throws JavaModelException { + public void test0276() throws JavaModelException { this.workingCopy = getWorkingCopy("/Converter15/src/X.java", true/*resolve*/); String contents = "@interface Annot {\n" + diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15JLS8Test.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15JLS8Test.java index e5c3e9b24b..a59232cadd 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15JLS8Test.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15JLS8Test.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2013 IBM Corporation and others. + * Copyright (c) 2011, 2015 IBM Corporation 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 @@ -9376,7 +9376,7 @@ public class ASTConverter15JLS8Test extends ConverterTestSetup { //https://bugs.eclipse.org/bugs/show_bug.cgi?id=192774 //Test ability to distinguish AST nodes of multiple similar annotations. - public void _test0276() throws JavaModelException { + public void test0276() throws JavaModelException { this.workingCopy = getWorkingCopy("/Converter15/src/X.java", true/*resolve*/); String contents = "@interface Annot {\n" + diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java index 9a815298e2..7ffcd7cc62 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 IBM Corporation and others. + * Copyright (c) 2000, 2015 IBM Corporation 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 @@ -9400,7 +9400,7 @@ public class ASTConverter15Test extends ConverterTestSetup { //https://bugs.eclipse.org/bugs/show_bug.cgi?id=192774 //Test ability to distinguish AST nodes of multiple similar annotations. - public void _test0276() throws JavaModelException { + public void test0276() throws JavaModelException { this.workingCopy = getWorkingCopy("/Converter15/src/X.java", true/*resolve*/); String contents = "@interface Annot {\n" + diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/AnnotationBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/AnnotationBinding.java index 02070bddf4..cfd1fa7814 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/AnnotationBinding.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/AnnotationBinding.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2014 IBM Corporation and others. + * Copyright (c) 2000, 2015 IBM Corporation 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 @@ -245,7 +245,12 @@ public String toString() { } public int hashCode() { - return this.type.hashCode(); + int result = 17; + int c = this.type.hashCode(); + result = 31 * result + c; + c = Arrays.hashCode(this.pairs); + result = 31 * result + c; + return result; } public boolean equals(Object object) { if (this == object) diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java index 8dbc02bcfd..94b2bedad2 100644 --- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java +++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2014 IBM Corporation and others. + * Copyright (c) 2000, 2015 IBM Corporation 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 @@ -92,14 +92,21 @@ class DefaultBindingResolver extends BindingResolver { */ Map bindingKeysToBindings; /** - * This map is used to keep the correspondance between new bindings and the - * compiler bindings as well as new annotation instances to their internal counterpart. - * This is an identity map. We should only create one object for one binding or annotation. + * This map is used to keep the correspondence between new bindings and the + * compiler bindings to their internal counterpart. + * This is an identity map. We should only create one object for one binding. */ Map compilerBindingsToASTBindings; + /** + * This map is used to keep the correspondence between new annotation instances to their internal counterpart. + * This is an identity map. We should only create one object for one annotation. + */ + Map compilerAnnotationBindingsToASTBindings; + BindingTables() { this.compilerBindingsToASTBindings = new ConcurrentHashMap(); + this.compilerAnnotationBindingsToASTBindings = new ConcurrentHashMap(); this.bindingKeysToBindings = new ConcurrentHashMap(); } @@ -506,6 +513,21 @@ class DefaultBindingResolver extends BindingResolver { return null; } + static class AnnotationIdentityBinding { + org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding internalInstance; + AnnotationIdentityBinding(org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding internalInstance) { + this.internalInstance = internalInstance; + } + @Override + public boolean equals(Object o) { + return o instanceof AnnotationIdentityBinding && this.internalInstance == ((AnnotationIdentityBinding)o).internalInstance; + } + @Override + public int hashCode() { + return this.internalInstance.hashCode(); + } + } + synchronized IAnnotationBinding getAnnotationInstance(org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding internalInstance) { if (internalInstance == null) return null; ReferenceBinding annotationType = internalInstance.getAnnotationType(); @@ -514,13 +536,10 @@ class DefaultBindingResolver extends BindingResolver { return null; } } - IAnnotationBinding domInstance = - (IAnnotationBinding) this.bindingTables.compilerBindingsToASTBindings.get(internalInstance); - if (domInstance != null) - return domInstance; - domInstance = new AnnotationBinding(internalInstance, this); - this.bindingTables.compilerBindingsToASTBindings.put(internalInstance, domInstance); - return domInstance; + Object key = new AnnotationIdentityBinding(internalInstance); + IAnnotationBinding newDomInstance = new AnnotationBinding(internalInstance, this); + IAnnotationBinding domInstance = (IAnnotationBinding) ((ConcurrentHashMap)this.bindingTables.compilerAnnotationBindingsToASTBindings).putIfAbsent(key, newDomInstance); + return domInstance != null ? domInstance : newDomInstance; } boolean isResolvedTypeInferredFromExpectedType(MethodInvocation methodInvocation) { |