Skip to content

Commit ec22731

Browse files
Merge branch 'develop' into migration/reflective-calls-to-string-analysis
2 parents f22d87a + 1cdb64f commit ec22731

File tree

5 files changed

+35
-40
lines changed

5 files changed

+35
-40
lines changed

OPAL/br/src/main/scala/org/opalj/br/reader/BytecodeOptimizer.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,10 @@ trait BytecodeOptimizer extends MethodsBinding {
292292
if (newBranchoffset >= Short.MinValue &&
293293
newBranchoffset <= Short.MaxValue
294294
) {
295-
// Replace it by a short goto
296-
instructions(pc + 0) = NOP
297-
instructions(pc + 1) = NOP
298-
instructions(pc + 2) = GOTO(newBranchoffset)
295+
// Replace it by a short goto, which has length 3 instead of length 5
296+
instructions(pc + 0) = GOTO(newBranchoffset)
297+
instructions(pc + 3) = NOP
298+
instructions(pc + 4) = NOP
299299
simplified = true
300300
} else {
301301
// let's replace the original jump

OPAL/tac/src/main/scala/org/opalj/tac/fpcf/analyses/alias/pointsto/AbstractPointsToBasedAliasAnalysis.scala

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ import org.opalj.fpcf.UBP
3434
import org.opalj.tac.cg.TypeIteratorKey
3535
import org.opalj.tac.common.DefinitionSitesKey
3636
import org.opalj.tac.fpcf.analyses.alias.TacBasedAliasAnalysis
37+
import org.opalj.tac.fpcf.analyses.pointsto
3738
import org.opalj.tac.fpcf.analyses.pointsto.AbstractPointsToBasedAnalysis
38-
import org.opalj.tac.fpcf.analyses.pointsto.toEntity
3939
import org.opalj.tac.fpcf.properties.TACAI
4040

4141
/**
@@ -77,11 +77,11 @@ trait AbstractPointsToBasedAliasAnalysis extends TacBasedAliasAnalysis with Abst
7777
ase match {
7878
case AliasUVar(uVar, _, _) =>
7979
uVar.defPCs.foreach(ds => {
80-
handlePointsToEntity(ase, getPointsToOfDefSite(ds, context.contextOf(ase), tac.get))
80+
handlePointsToEntity(ase, getPointsToOfDefSite(ds, context.contextOf(ase)))
8181
})
8282

8383
case AliasFormalParameter(fp) =>
84-
handlePointsToEntity(ase, getPointsToOfDefSite(fp.origin, context.contextOf(ase), tac.get))
84+
handlePointsToEntity(ase, getPointsToOfDefSite(fp.origin, context.contextOf(ase)))
8585

8686
case AliasStaticField(field) => handlePointsToEntity(ase, getPointsToOfStaticField(field))
8787

@@ -96,10 +96,13 @@ trait AbstractPointsToBasedAliasAnalysis extends TacBasedAliasAnalysis with Abst
9696

9797
/**
9898
* Retrieves the points-to set of the given definition site.
99+
*
100+
* @param defSitePC The program counter (not TAC index!) of the definition site, in value origin form
101+
* @param context The context in which the defSitePC is valid
99102
*/
100-
private[this] def getPointsToOfDefSite(defSite: Int, context: Context, tac: Tac): EOptionP[Entity, PointsToSet] = {
103+
private[this] def getPointsToOfDefSite(defSitePC: Int, context: Context): EOptionP[Entity, PointsToSet] = {
101104
propertyStore(
102-
toEntity(if (defSite < 0) defSite else tac.properStmtIndexForPC(defSite), context, tac.stmts),
105+
pointsto.toEntity(defSitePC, context),
103106
pointsToPropertyKey
104107
)
105108
}
@@ -126,7 +129,9 @@ trait AbstractPointsToBasedAliasAnalysis extends TacBasedAliasAnalysis with Abst
126129

127130
val allocationSites = ArrayBuffer.empty[ElementType]
128131

129-
field.fieldReference.defSites.map(getPointsToOfDefSite(_, fieldContext, tac))
132+
field.fieldReference.defSites.map { defSite =>
133+
getPointsToOfDefSite(if (defSite < 0) defSite else tac.stmts(defSite).pc, fieldContext)
134+
}
130135
.foreach(pts => {
131136

132137
if (pts.isEPK) {

OPAL/tac/src/main/scala/org/opalj/tac/fpcf/analyses/cg/TypeIterator.scala

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ abstract class TypeIterator(val project: SomeProject) extends ContextProvider {
115115
field: DeclaredField,
116116
fieldAllocation: DefinitionSite,
117117
depender: Entity,
118-
context: Context,
119-
stmts: Array[Stmt[V]]
118+
context: Context
120119
)(
121120
implicit
122121
propertyStore: PropertyStore,
@@ -704,7 +703,7 @@ trait PointsToTypeIterator[ElementType, PointsToSet >: Null <: PointsToSetLike[E
704703
} else {
705704
combine(
706705
result,
707-
currentPointsTo(depender, pointsto.toEntity(defSite, context, stmts))
706+
currentPointsTo(depender, pointsto.toEntity(pc, context))
708707
)
709708
}
710709
}
@@ -714,16 +713,15 @@ trait PointsToTypeIterator[ElementType, PointsToSet >: Null <: PointsToSetLike[E
714713
field: DeclaredField,
715714
fieldAllocation: DefinitionSite,
716715
depender: Entity,
717-
context: Context,
718-
stmts: Array[Stmt[V]]
716+
context: Context
719717
)(
720718
implicit
721719
propertyStore: PropertyStore,
722720
state: TypeIteratorState
723721
): PointsToSet = {
724722
val objects = currentPointsTo(
725723
depender,
726-
pointsto.toEntity(fieldAllocation.pc, context, stmts)
724+
pointsto.toEntity(fieldAllocation.pc, context)
727725
)
728726
var pointsTo = emptyPointsToSet
729727
objects.forNewestNElements(objects.numElements) { as =>
@@ -999,13 +997,7 @@ class AllocationSitesPointsToTypeIterator(project: SomeProject)
999997

1000998
result = combine(
1001999
result,
1002-
typesProperty(
1003-
field,
1004-
DefinitionSite(method, defPC),
1005-
depender,
1006-
newContext(definedMethod),
1007-
theTAC.stmts
1008-
)
1000+
typesProperty(field, DefinitionSite(method, defPC), depender, newContext(definedMethod))
10091001
)
10101002
}
10111003

@@ -1039,7 +1031,7 @@ class AllocationSitesPointsToTypeIterator(project: SomeProject)
10391031
val defPC = if (defSite < 0) defSite else theTAC.stmts(defSite).pc
10401032
val objects = currentPointsTo(
10411033
depender,
1042-
pointsto.toEntity(defPC, newContext(definedMethod), theTAC.stmts)(
1034+
pointsto.toEntity(defPC, newContext(definedMethod))(
10431035
formalParameters,
10441036
definitionSites,
10451037
this
@@ -1245,7 +1237,7 @@ class CFA_k_l_TypeIterator(project: SomeProject, val k: Int, val l: Int)
12451237

12461238
result = combine(
12471239
result,
1248-
typesProperty(field, DefinitionSite(method, defPC), depender, calleeContext, theTAC.stmts)
1240+
typesProperty(field, DefinitionSite(method, defPC), depender, calleeContext)
12491241
)
12501242
}
12511243

OPAL/tac/src/main/scala/org/opalj/tac/fpcf/analyses/pointsto/PointsToAnalysisBase.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ trait PointsToAnalysisBase extends AbstractPointsToBasedAnalysis with TypeConsum
7272
}
7373

7474
@inline protected[this] def toEntity(defSite: Int)(implicit state: State): Entity = {
75-
pointsto.toEntity(defSite, state.callContext, state.tac.stmts)
75+
pointsto.toEntity(if (defSite < 0) defSite else state.tac.stmts(defSite).pc, state.callContext)
7676
}
7777

7878
@inline protected[this] def getDefSite(pc: Int)(implicit state: State): Entity = {

OPAL/tac/src/main/scala/org/opalj/tac/fpcf/analyses/pointsto/package.scala

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,32 @@ import org.opalj.br.fpcf.analyses.SimpleContextProvider
1010
import org.opalj.br.fpcf.properties.Context
1111
import org.opalj.fpcf.Entity
1212
import org.opalj.tac.common.DefinitionSites
13-
import org.opalj.value.ValueInformation
1413

1514
package object pointsto {
1615

1716
/**
18-
* Given a definition site (value origin) in a certain method, this returns the
17+
* Given a definition site PC (value origin) in a certain method, this returns the
1918
* entity to be used to attach/retrieve points-to information from.
2019
*/
2120
def toEntity(
22-
defSite: Int,
23-
context: Context,
24-
stmts: Array[Stmt[DUVar[ValueInformation]]]
21+
defSitePC: Int,
22+
context: Context
2523
)(
2624
implicit
2725
formalParameters: VirtualFormalParameters,
2826
definitionSites: DefinitionSites,
2927
contextProvider: ContextProvider
3028
): Entity = {
31-
val entity = if (ai.isMethodExternalExceptionOrigin(defSite)) {
32-
val pc = ai.pcOfMethodExternalException(defSite)
33-
CallExceptions(definitionSites(context.method.definedMethod, stmts(pc).pc))
34-
} else if (ai.isImmediateVMException(defSite)) {
35-
val pc = ai.pcOfImmediateVMException(defSite)
36-
definitionSites(context.method.definedMethod, stmts(pc).pc)
37-
} else if (defSite < 0) {
38-
formalParameters.apply(context.method)(-1 - defSite)
29+
val entity = if (ai.isMethodExternalExceptionOrigin(defSitePC)) {
30+
val pc = ai.pcOfMethodExternalException(defSitePC)
31+
CallExceptions(definitionSites(context.method.definedMethod, pc))
32+
} else if (ai.isImmediateVMException(defSitePC)) {
33+
val pc = ai.pcOfImmediateVMException(defSitePC)
34+
definitionSites(context.method.definedMethod, pc)
35+
} else if (defSitePC < 0) {
36+
formalParameters.apply(context.method)(-1 - defSitePC)
3937
} else {
40-
definitionSites(context.method.definedMethod, stmts(defSite).pc)
38+
definitionSites(context.method.definedMethod, defSitePC)
4139
}
4240
contextProvider match {
4341
case _: SimpleContextProvider => entity

0 commit comments

Comments
 (0)