-
Notifications
You must be signed in to change notification settings - Fork 79
Feat/improving ffi #924
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
Open
tesonep
wants to merge
24
commits into
pharo-project:pharo-12
Choose a base branch
from
evref-inria:feat/improving-FFI
base: pharo-12
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feat/improving ffi #924
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
9f90f8d
- Adding primitive that extracts the pointer to the content of the ob…
tesonep bd814d4
Co-authored-by: doste <[email protected]>
tesonep 81fcdbf
- Adding tests for the FFI calls
tesonep f374b68
Adding pragma to mark functions that need all localized variables to …
tesonep dbfb5fa
Adding externenalization for supporting functions that require all lo…
tesonep 4a7246f
- Fixing problems with localized variables
tesonep 3d1fb90
- Adding tests
tesonep ee88308
Adding required extensions to the InstructionClient so the StackDepth…
tesonep a81e552
Improving tests to handle correctly the arguments in a FFI test
tesonep 9212a66
Handling arguments for X64 SystemV
tesonep e405146
Implementing the fetch of arguments in the superclass
tesonep 42edeee
Fixing accessing to floating point registers
tesonep d397a36
Extending the unicorn simulator to handle the different ABIs of X64
tesonep c12852d
- Making it work in Windows ABI
tesonep b2ead2b
Adding accessors for registers in calling convention
tesonep 27c4244
Merge branch 'new-lib-versions-p12' into feat/improving-FFI
tesonep 236cfc9
Merge branch 'new-lib-versions-p12' into feat/improving-FFI
tesonep 0ca8da3
Merge branch 'pharo-12' into feat/improving-FFI
tesonep 60dd074
Fixing merge
tesonep 0247d01
Fixing merge
tesonep 838c323
Merge branch 'pharo-12' into feat/improving-FFI
tesonep d110d3f
Fixing the pointers marshalling for X64
tesonep a64d876
Merge 838c323b563140c4963756cada484b9aac18a6ca
tesonep c610f3e
Adding a trampoline in the middle of the FFI calls so we can handle t…
tesonep File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -158,7 +158,7 @@ MLLocalizationTestCase >> testAutoLocalizeVariableDoesNotLineariseUnnecessarySta | |
|
||
printedString := String streamContents: [ :str | (block asCASTIn: ccg) prettyPrintOn: str ]. | ||
|
||
self assert: printedString equals: '{ | ||
self assert: printedString trimBoth equals: '{ | ||
nonInlinedMethodNotUsingAutolocalizedVariables(nonInlinedMethodNotUsingAutolocalizedVariables()); | ||
}' | ||
] | ||
|
@@ -184,7 +184,7 @@ MLLocalizationTestCase >> testAutoLocalizeVariableExternalizesBeforeReturnRefere | |
printedString := String streamContents: [ :str | | ||
((TStatementListNode statements: (interpretMethod statements last: 2)) asCASTIn: ccg) | ||
prettyPrintOn: str ]. | ||
self assert: printedString equals: '{ | ||
self assert: printedString trimBoth equals: '{ | ||
local_autoLocalizedVariable += 1; | ||
{ | ||
autoLocalizedVariable = local_autoLocalizedVariable; | ||
|
@@ -240,14 +240,50 @@ MLLocalizationTestCase >> testAutoLocalizeVariableReplacesByLocalOnInline [ | |
self assert: (variableNode isVariable and: [ variableNode name = #local_autoLocalizedVariable ]). | ||
] | ||
|
||
{ #category : 'tests - localisation' } | ||
MLLocalizationTestCase >> testBytecodeUsingExternalizeAllVariables [ | ||
|
||
| interpretMethod cast printedString linearizedBlock | | ||
|
||
MockLocalizationInterpreterMock initializeWithBytecodeUsingExternalizeAllVariables. | ||
|
||
interpretMethod := self applyLocalizationTo: #interpretWithSeveralVariablesToLocalize. | ||
|
||
"Assert that the send node is preceded by variable externalization" | ||
linearizedBlock := self linearizedBlockOfCaseMethod: interpretMethod. | ||
cast := linearizedBlock asCASTIn: ccg. | ||
|
||
printedString := String streamContents: [ :str | cast prettyPrintOn: str ]. | ||
|
||
"The if statement should not be wrapped. Only the inner statements" | ||
self assert: printedString trimBoth equals: | ||
'{ | ||
{ | ||
autoLocalizedVariable = local_autoLocalizedVariable; | ||
autoLocalizedVariable1 = local_autoLocalizedVariable1; | ||
autoLocalizedVariable2 = local_autoLocalizedVariable2; | ||
autoLocalizedVariable3 = local_autoLocalizedVariable3; | ||
autoLocalizedVariable4 = local_autoLocalizedVariable4; | ||
aMethodHavingExternalizeAllVariables(); | ||
local_autoLocalizedVariable = autoLocalizedVariable; | ||
local_autoLocalizedVariable1 = autoLocalizedVariable1; | ||
local_autoLocalizedVariable2 = autoLocalizedVariable2; | ||
local_autoLocalizedVariable3 = autoLocalizedVariable3; | ||
local_autoLocalizedVariable4 = autoLocalizedVariable4; | ||
} | ||
} | ||
' trimBoth | ||
] | ||
|
||
{ #category : 'tests - free variables' } | ||
MLLocalizationTestCase >> testCollectFreeVariablesOfMethodWithManyCallers [ | ||
|
||
| collector | | ||
collector := SLCallGraphFreeVariableCollector codeGenerator: ccg. | ||
|
||
ccg addClass: MockLocalizationInterpreterMock. | ||
ccg prepareMethods. | ||
|
||
" | ||
variableToLocalize should be considered free in the entire transitive call graph. | ||
|
||
|
@@ -259,10 +295,17 @@ MLLocalizationTestCase >> testCollectFreeVariablesOfMethodWithManyCallers [ | |
" | ||
collector startFromSelector: #methodWithDiamond. | ||
|
||
self assert: ((collector freeVariablesUsedByMethodNamed: #bytecodeUsingLocalizedVariable) includes: #variableToLocalize). | ||
self assert: ((collector freeVariablesUsedByMethodNamed: #methodCallingBytecodeUsingLocalizedVariable) includes: #variableToLocalize). | ||
self assert: ((collector freeVariablesUsedByMethodNamed: #methodCallingBytecodeUsingLocalizedVariable2) includes: #variableToLocalize). | ||
self assert: ((collector freeVariablesUsedByMethodNamed: #methodWithDiamond) includes: #variableToLocalize). | ||
self assert: ((collector freeVariablesUsedByMethodNamed: | ||
#bytecodeUsingLocalizedVariable) includes: #variableToLocalize). | ||
self assert: ((collector freeVariablesUsedByMethodNamed: | ||
#methodCallingBytecodeUsingLocalizedVariable) includes: | ||
#variableToLocalize). | ||
self assert: ((collector freeVariablesUsedByMethodNamed: | ||
#methodCallingBytecodeUsingLocalizedVariable2) includes: | ||
#variableToLocalize). | ||
self assert: | ||
((collector freeVariablesUsedByMethodNamed: #methodWithDiamond) | ||
includes: #variableToLocalize) | ||
] | ||
|
||
{ #category : 'tests - localisation' } | ||
|
@@ -277,7 +320,7 @@ MLLocalizationTestCase >> testExternalEscapingAsArgument [ | |
|
||
printedString := String streamContents: [ :str | cast prettyPrintOn: str ]. | ||
|
||
self assert: printedString equals: | ||
self assert: printedString trimBoth equals: | ||
'{ | ||
sqInt t0; | ||
|
||
|
@@ -303,7 +346,7 @@ MLLocalizationTestCase >> testExternalEscapingAsArgumentOfExternalCall [ | |
|
||
printedString := String streamContents: [ :str | cast prettyPrintOn: str ]. | ||
|
||
self assert: printedString equals: '{ | ||
self assert: printedString trimBoth equals: '{ | ||
sqInt t0; | ||
|
||
{ | ||
|
@@ -335,7 +378,7 @@ MLLocalizationTestCase >> testExternalEscapingSendNodeInInlinedMethod [ | |
|
||
printedString := String streamContents: [ :str | cast prettyPrintOn: str ]. | ||
|
||
self assert: printedString equals: '{ | ||
self assert: printedString trimBoth equals: '{ | ||
autoLocalizedVariable = local_autoLocalizedVariable; | ||
autoLocalizedVariable1 = local_autoLocalizedVariable1; | ||
foo2(); | ||
|
@@ -357,7 +400,7 @@ MLLocalizationTestCase >> testExternalEscapingSendNodeShouldBeTranslatedWithExte | |
|
||
printedString := String streamContents: [ :str | cast prettyPrintOn: str ]. | ||
|
||
self assert: printedString equals: '{ | ||
self assert: printedString trimBoth equals: '{ | ||
local_autoLocalizedVariable += 1; | ||
{ | ||
autoLocalizedVariable = local_autoLocalizedVariable; | ||
|
@@ -380,7 +423,7 @@ MLLocalizationTestCase >> testExternalEscapingStatementInConditionalBody [ | |
printedString := String streamContents: [ :str | cast prettyPrintOn: str ]. | ||
|
||
"The if statement should not be wrapped. Only the inner statements" | ||
self assert: printedString equals: | ||
self assert: printedString trimBoth equals: | ||
'{ | ||
if (1) { | ||
sqInt t0; | ||
|
@@ -411,7 +454,7 @@ MLLocalizationTestCase >> testExternalPerform [ | |
|
||
printedString := String streamContents: [ :str | cast prettyPrintOn: str ]. | ||
|
||
self assert: printedString equals: | ||
self assert: printedString trimBoth trimBoth equals: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More more |
||
'{ | ||
{ | ||
autoLocalizedVariable = local_autoLocalizedVariable; | ||
|
@@ -433,7 +476,7 @@ MLLocalizationTestCase >> testExternalSendNodeExternalizeAndInternalizeOnlyNeede | |
cast := linearizedBlock asCASTIn: ccg. | ||
|
||
printedString := String streamContents: [ :str | cast prettyPrintOn: str ]. | ||
self assert: printedString equals: '{ | ||
self assert: printedString trimBoth equals: '{ | ||
local_autoLocalizedVariable += 1; | ||
{ | ||
autoLocalizedVariable = local_autoLocalizedVariable; | ||
|
@@ -460,7 +503,7 @@ MLLocalizationTestCase >> testExternalSendNodeShouldBeTranslatedWithExternalizat | |
cast := linearizedBlock asCASTIn: ccg. | ||
printedString := String streamContents: [ :str | cast prettyPrintOn: str ]. | ||
|
||
self assert: printedString equals: '{ | ||
self assert: printedString trimBoth equals: '{ | ||
sqInt t0; | ||
|
||
{ | ||
|
@@ -499,8 +542,8 @@ MLLocalizationTestCase >> testLinearizeAndInsideValueIf [ | |
t0 | ||
ifTrue: [ t0 := self condition ] | ||
ifFalse: [ t0 := t0 ] ]. | ||
overflow := t0. | ||
^ overflow'. | ||
_overflow := t0. | ||
^ _overflow'. | ||
] | ||
|
||
{ #category : 'tests - linearization' } | ||
|
@@ -532,8 +575,8 @@ MLLocalizationTestCase >> testLinearizeAndInsideValueIfNestedTwice [ | |
t0 | ||
ifTrue: [ t0 := self condition ] | ||
ifFalse: [ t0 := t0 ] ] ]. | ||
overflow := t0. | ||
^ overflow'. | ||
_overflow := t0. | ||
^ _overflow'. | ||
] | ||
|
||
{ #category : 'tests - linearization' } | ||
|
@@ -640,7 +683,7 @@ MLLocalizationTestCase >> testLinearizeNestedCallsWithAssignment [ | |
arguments: { TVariableNode named: 't0' }))). | ||
self assert: (replacementBlock statements third | ||
isSameAs: (TAssignmentNode | ||
variableNamed: 'foo' | ||
variableNamed: '_foo' | ||
expression: (TVariableNode named: 't1'))) | ||
] | ||
|
||
|
@@ -728,8 +771,8 @@ MLLocalizationTestCase >> testLinearizeReceiverOfConditionalAndAssigned [ | |
self assert: replacementBlock isRewrittenAs: ' | ||
t0 := self nonInlinedMethodUsingAutolocalizedVariable. | ||
t0 ifTrue: [ t1 := self nonInlinedMethodUsingAutolocalizedVariable ] ifFalse: [ t1 := t0 ]. | ||
var := t1. | ||
var ifTrue: [nil]'. | ||
_var := t1. | ||
_var ifTrue: [nil]'. | ||
] | ||
|
||
{ #category : 'tests - linearization' } | ||
|
@@ -883,7 +926,7 @@ MLLocalizationTestCase >> testNoExternalSendNodeOnSafeExternalCall [ | |
|
||
printedString := String streamContents: [ :str | cast prettyPrintOn: str ]. | ||
|
||
self assert: printedString equals: '{ | ||
self assert: printedString trimBoth equals: '{ | ||
nonInlinedMethodNotUsingAutolocalizedVariables((local_autoLocalizedVariable += 1)); | ||
}' | ||
] |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -35,9 +35,9 @@ Class { | |
|
||
{ #category : 'instance creation' } | ||
SLCallGraphVisitor class >> codeGenerator: aCodeGenerator [ | ||
|
||
^ self new | ||
codeGenerator: aCodeGenerator; | ||
codeGenerator: aCodeGenerator | ||
yourself | ||
Comment on lines
39
to
41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this ok? |
||
] | ||
|
||
|
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class should be in
Slang-Tests
package (now it is not running on the CI). I though that I already moved it 🤔