Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic Structure for the Abstract Interpretation #397

Merged
merged 51 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
8759589
feat: added an abstract interpretation (ai) step
LukasPietzschmann Oct 12, 2023
7c25938
feat-fix: forgot to add processor.ts
LukasPietzschmann Oct 12, 2023
a96f623
feat-fix: pass the correct arguments to the ai and slicing step
LukasPietzschmann Oct 12, 2023
954b547
feat: added the normalized ast as a parameter to the ai step
LukasPietzschmann Oct 12, 2023
87e328d
feat-fix: remove the explicitly included normalzsation step
LukasPietzschmann Oct 13, 2023
c3f0a99
refactor: remove normalized ast parameter from abstract interpretatio…
EagleoutIce Oct 13, 2023
2b1020c
git: Merge tag 'v1.2.0' into 378-basic-structure-for-the-abstract-int…
LukasPietzschmann Oct 16, 2023
91c029f
feat: added back the ast as an input for the ai processor
LukasPietzschmann Oct 16, 2023
2c6a555
Merge branch 'main' into 378-basic-structure-for-the-abstract-interpr…
LukasPietzschmann Oct 16, 2023
38077e8
feat, wip: borderline execution trace visitor for the cfg
EagleoutIce Nov 3, 2023
c75224d
feat, wip: only visit exit nodes after we have visited all of its suc…
EagleoutIce Nov 3, 2023
6739f2e
feat, wip: attributing vertex type in cfg
EagleoutIce Nov 3, 2023
71c4e2d
test-fix: adapting tests to new cfg vertex types
EagleoutIce Nov 3, 2023
5023dba
lint-fix: remove unused reference
EagleoutIce Nov 3, 2023
35b9620
Merge branch 'main' into 378-basic-structure-for-the-abstract-interpr…
EagleoutIce Nov 22, 2023
59561af
feat: Added basic structure for traversing the cfg
LukasPietzschmann Dec 6, 2023
1982f2e
feat: Added an interface specifying an interval
LukasPietzschmann Dec 7, 2023
934499a
feat: Narrowed down the node type of assignments
LukasPietzschmann Dec 7, 2023
14401a9
refactor: Intervals -> Domain
LukasPietzschmann Dec 7, 2023
302d19a
feat: If a dfg node reads from multiple sources, unify their domains
LukasPietzschmann Dec 7, 2023
2aab44a
refactor: fixed function names
LukasPietzschmann Dec 7, 2023
20fe13b
refactor: Refactored the unification of domains
LukasPietzschmann Dec 8, 2023
e397ecf
refactor: Domain is now a real class
LukasPietzschmann Dec 8, 2023
2929cae
refactor: Consistent naming scheme and no more .forEach
LukasPietzschmann Dec 8, 2023
7db9f76
feat-fix: don't use members before setting them lol
LukasPietzschmann Dec 9, 2023
7735735
feat: Exported functions, classes and interfaces
LukasPietzschmann Dec 9, 2023
aec40b9
test: Added AI test
LukasPietzschmann Dec 9, 2023
bfa5dca
feat-fix: Added additional flag for comparing intervals
LukasPietzschmann Dec 10, 2023
cc3bb71
refactor: replaced new Array() by the literal syntax []
LukasPietzschmann Dec 10, 2023
76a8242
test: Added tests for the unification of domains
LukasPietzschmann Dec 10, 2023
c3b19e4
refactor: Don't inherit Domain from a Set, make the intervals a member
LukasPietzschmann Dec 10, 2023
b316241
feat: Added interface AINode and a place to store them
LukasPietzschmann Jan 6, 2024
5002fdd
refactor: More sensible types and names
LukasPietzschmann Jan 6, 2024
6c8dd13
refactor: Merged BinOp and Assignment
LukasPietzschmann Jan 6, 2024
621ffef
feat: Added function for adding two domains
LukasPietzschmann Jan 6, 2024
1f439b0
refactor: Fixed formatting
LukasPietzschmann Jan 6, 2024
25ea6ec
feat: Implemented more handling code for bin ops
LukasPietzschmann Jan 6, 2024
b0db502
fix: Don't create Intervals using the literal syntax
LukasPietzschmann Jan 7, 2024
f187d45
fix: Typo
LukasPietzschmann Jan 8, 2024
3a73901
feat: We can now subtract one domain from another
LukasPietzschmann Jan 8, 2024
9b5e98e
refactor: Split into multiple files
LukasPietzschmann Jan 8, 2024
5ce85d9
feat: Added unifyIntervals as a helper
LukasPietzschmann Jan 8, 2024
5d57eef
feat: Check for interval overlaps, if an interval is added to a domain
LukasPietzschmann Jan 8, 2024
775863f
refactor: Code cleanup
LukasPietzschmann Jan 11, 2024
2d31117
refactor: Use the flowR logger
LukasPietzschmann Jan 11, 2024
e7a4e35
refactor: Add static factory methods to the Domain
LukasPietzschmann Jan 11, 2024
c57732e
refactor: Removed TODOs referencing more tests
LukasPietzschmann Jan 15, 2024
d9462d7
refactor: De-globalized the nodeMap
LukasPietzschmann Jan 15, 2024
af963b7
refactor: Replaced a guard with a warning
LukasPietzschmann Jan 22, 2024
7c68256
fix: Temporarily remove the call to `runAbstractInterpretation`
LukasPietzschmann Jan 23, 2024
dcf9eae
Merge branch 'main' into 378-basic-structure-for-the-abstract-interpr…
EagleoutIce Jan 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/abstract-interpretation/processor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { DataflowInformation } from '../dataflow/internal/info'
import { NormalizedAst } from '../r-bridge'

export function runAbstractInterpretation(ast: NormalizedAst, dfg: DataflowInformation): DataflowInformation {
console.log('hi from abstract interpretation')
return dfg
}
2 changes: 2 additions & 0 deletions src/benchmark/slicer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export class BenchmarkSlicer {
private loadedXml: string | undefined
private tokenMap: Record<string, string> | undefined
private dataflow: DataflowInformation | undefined
private ai: DataflowInformation | undefined
private normalizedAst: NormalizedAst | undefined
private totalStopwatch: IStoppableStopwatch
private finished = false
Expand Down Expand Up @@ -133,6 +134,7 @@ export class BenchmarkSlicer {
this.loadedXml = await this.measureCommonStep('parse', 'retrieve AST from R code')
this.normalizedAst = await this.measureCommonStep('normalize', 'normalize R AST')
this.dataflow = await this.measureCommonStep('dataflow', 'produce dataflow information')
this.ai = await this.measureCommonStep('ai', 'run abstract interpretation')

this.stepper.switchToSliceStage()

Expand Down
2 changes: 1 addition & 1 deletion src/benchmark/stats/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { SingleSlicingCriterion, SlicingCriteria } from '../../slicing'
import { NodeId, RParseRequestFromFile, RParseRequestFromText } from '../../r-bridge'
import { ReconstructionResult } from '../../slicing'

export const CommonSlicerMeasurements = ['initialize R session', 'inject home path', 'ensure installation of xmlparsedata', 'retrieve token map', 'retrieve AST from R code', 'normalize R AST', 'produce dataflow information', 'close R session', 'total'] as const
export const CommonSlicerMeasurements = ['initialize R session', 'inject home path', 'ensure installation of xmlparsedata', 'retrieve token map', 'retrieve AST from R code', 'normalize R AST', 'produce dataflow information', 'run abstract interpretation', 'close R session', 'total'] as const
export type CommonSlicerMeasurements = typeof CommonSlicerMeasurements[number]

export const PerSliceMeasurements = ['static slicing', 'reconstruct code', 'total'] as const
Expand Down
1 change: 1 addition & 0 deletions src/cli/repl/server/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export class FlowRServerConnection {
parse: serialize2quads(await xlm2jsonObject(parseConfig, results.parse as string), config()),
normalize: serialize2quads(results.normalize?.ast as RNodeWithParent, config()),
dataflow: df2quads(results.dataflow?.graph as DataflowGraph, config()),
ai: ''
}
})
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/core/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ interface BaseSteppingSlicerInput<InterestedIn extends StepName | undefined> ext
autoSelectIf?: AutoSelectPredicate
}

interface NormalizeSteppingSlicerInput<InterestedIn extends 'dataflow' | 'normalize'> extends BaseSteppingSlicerInput<InterestedIn> {
interface NormalizeSteppingSlicerInput<InterestedIn extends 'ai' | 'dataflow' | 'normalize'> extends BaseSteppingSlicerInput<InterestedIn> {
stepOfInterest: InterestedIn
tokenMap: TokenMap
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type StepResultsHelper<InterestedIn extends StepName> = {
'parse': Out<'parse'>
'normalize': StepResultsHelper<'parse'> & Out<'normalize'>
'dataflow': StepResultsHelper<'normalize'> & Out<'dataflow'>
'slice': StepResultsHelper<'dataflow'> & Out<'slice'>
'ai': StepResultsHelper<'normalize'> & StepResultsHelper<'dataflow'> & Out<'ai'>
LukasPietzschmann marked this conversation as resolved.
Show resolved Hide resolved
'slice': StepResultsHelper<'ai'> & Out<'slice'>
'reconstruct': StepResultsHelper<'slice'> & Out<'reconstruct'>
}[InterestedIn]

8 changes: 6 additions & 2 deletions src/core/slicer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,15 @@ export class SteppingSlicer<InterestedIn extends StepName | undefined = typeof L
result = executeSingleSubStep(step, this.results.normalize as NormalizedAst)
break
case 3:
step = guardStep('ai')
result = executeSingleSubStep(step, this.results.normalize as NormalizedAst, this.results.dataflow as DataflowInformation)
break
case 4:
guard(this.criterion !== undefined, 'Cannot decode criteria without a criterion')
step = guardStep('slice')
result = executeSingleSubStep(step, (this.results.dataflow as DataflowInformation).graph, this.results.normalize as NormalizedAst, this.criterion)
result = executeSingleSubStep(step, (this.results.ai as DataflowInformation).graph, this.results.normalize as NormalizedAst, this.criterion)
break
case 4:
case 5:
step = guardStep('reconstruct')
result = executeSingleSubStep(step, this.results.normalize as NormalizedAst<NoInfo>, (this.results.slice as SliceResult).result)
break
Expand Down
13 changes: 11 additions & 2 deletions src/core/steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { internalPrinter, IStepPrinter, StepOutputFormat } from './print/print'
import { normalizedAstToJson } from './print/normalize-printer'
import { guard } from '../util/assert'
import { dataflowGraphToJson } from './print/dataflow-printer'
import { runAbstractInterpretation } from '../abstract-interpretation/processor'

/**
* This represents close a function that we know completely nothing about.
Expand Down Expand Up @@ -80,7 +81,15 @@ export const STEPS_PER_FILE = {
[StepOutputFormat.Internal]: internalPrinter,
[StepOutputFormat.Json]: dataflowGraphToJson
}
} satisfies IStep<typeof produceDataFlowGraph>
} satisfies IStep<typeof produceDataFlowGraph>,
'ai': {
description: 'Run abstract interpretation',
processor: runAbstractInterpretation,
required: 'once-per-file',
printer: {
[StepOutputFormat.Internal]: internalPrinter
}
} satisfies IStep<typeof runAbstractInterpretation>
} as const

export const STEPS_PER_SLICE = {
Expand All @@ -103,7 +112,7 @@ export const STEPS_PER_SLICE = {
} as const

export const STEPS = { ...STEPS_PER_FILE, ...STEPS_PER_SLICE } as const
export const LAST_PER_FILE_STEP = 'dataflow' as const
export const LAST_PER_FILE_STEP = 'ai' as const
export const LAST_STEP = 'reconstruct' as const

export type StepName = keyof typeof STEPS
Expand Down