-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add experimental option '-XX-world-cache-mode'
- Loading branch information
1 parent
6e39bfc
commit aa2562f
Showing
43 changed files
with
734 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
# macOS hidden file | ||
.DS_Store | ||
.gradle/ | ||
.idea/ | ||
bin/ | ||
build/ | ||
cache/ | ||
out/ | ||
output/ | ||
|
||
# MacOS hidden file | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
src/main/java/pascal/taie/frontend/cache/CachedIRBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Tai-e: A Static Analysis Framework for Java | ||
* | ||
* Copyright (C) 2022 Tian Tan <[email protected]> | ||
* Copyright (C) 2022 Yue Li <[email protected]> | ||
* | ||
* This file is part of Tai-e. | ||
* | ||
* Tai-e is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License | ||
* as published by the Free Software Foundation, either version 3 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* Tai-e is distributed in the hope that it will be useful,but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General | ||
* Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with Tai-e. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package pascal.taie.frontend.cache; | ||
|
||
|
||
import pascal.taie.ir.IR; | ||
import pascal.taie.ir.IRBuilder; | ||
import pascal.taie.language.classes.ClassHierarchy; | ||
import pascal.taie.language.classes.JClass; | ||
import pascal.taie.language.classes.JMethod; | ||
|
||
import java.util.Collection; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* The {@link pascal.taie.ir.IRBuilder} is for keeping the {@link IR}s of all methods to | ||
* prevent cyclic references with too long a path which may make | ||
* the serialization fail or {@link java.lang.StackOverflowError}. | ||
*/ | ||
public class CachedIRBuilder implements IRBuilder { | ||
|
||
private final Map<String, IR> methodSig2IR; | ||
|
||
public CachedIRBuilder(IRBuilder irBuilder, ClassHierarchy hierarchy) { | ||
irBuilder.buildAll(hierarchy); | ||
methodSig2IR = hierarchy.allClasses() | ||
.map(JClass::getDeclaredMethods) | ||
.flatMap(Collection::stream) | ||
.filter(m -> !m.isAbstract() || m.isNative()) | ||
.collect(Collectors.toMap(JMethod::getSignature, JMethod::getIR)); | ||
} | ||
|
||
/** | ||
* This method will be called by {@link JMethod#getIR()} only once, | ||
* so remove the IR from the map after returning it. | ||
*/ | ||
@Override | ||
public IR buildIR(JMethod method) { | ||
return methodSig2IR.remove(method.getSignature()); | ||
} | ||
|
||
@Override | ||
public void buildAll(ClassHierarchy hierarchy) { | ||
hierarchy.allClasses() | ||
.map(JClass::getDeclaredMethods) | ||
.flatMap(Collection::stream) | ||
.filter(m -> !m.isAbstract() || m.isNative()) | ||
.forEach(JMethod::getIR); | ||
} | ||
} |
Oops, something went wrong.