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

7871-Proposal-Simplify-How-Pragmas-are-stored #7930

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 5 additions & 13 deletions src/Kernel/AdditionalMethodState.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -240,21 +240,13 @@ AdditionalMethodState >> postCopy [
{ #category : #accessing }
AdditionalMethodState >> pragmas [
"Return the Pragma objects. Properties are stored as Associations"
^ Array new: self basicSize streamContents: [ :pragmaStream |
1 to: self basicSize do: [ :i |
| propertyOrPragma "<Association|Pragma>" |
(propertyOrPragma := self basicAt: i) isAssociation ifFalse: [
pragmaStream nextPut: propertyOrPragma ] ] ]
self at: #pragmas ifPresent: [ :p | ^p ].
^#().
]

{ #category : #enumerating }
AdditionalMethodState >> pragmasDo: aBlock [

1 to: self basicSize do: [ :i |
| propertyOrPragma "<Association|Pragma>" |
propertyOrPragma := self basicAt: i.
propertyOrPragma isAssociation
ifFalse: [ aBlock value: propertyOrPragma ] ]
{ #category : #accessing }
AdditionalMethodState >> pragmasDo: a [
self pragmas do: a
]

{ #category : #printing }
Expand Down
28 changes: 14 additions & 14 deletions src/Kernel/CompiledMethod.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -754,14 +754,18 @@ CompiledMethod >> penultimateLiteral: anObject [

{ #category : #copying }
CompiledMethod >> postCopy [
| penultimateLiteral |
(penultimateLiteral := self penultimateLiteral) isMethodProperties ifTrue:
[self penultimateLiteral: (penultimateLiteral copy
method: self;
yourself).
self penultimateLiteral pragmas do:
[:p| p method: self]]

| penultimateLiteral pragmas |
(penultimateLiteral := self penultimateLiteral) isMethodProperties
ifFalse: [ ^ self ].

pragmas := self pragmas collect: [ :each | each copy ] as: Array.
pragmas do: [ :p | p method: self ].
penultimateLiteral := pragmas
ifEmpty: [ penultimateLiteral copy ]
ifNotEmpty: [ penultimateLiteral copyWith: (#pragmas -> pragmas) ].
self penultimateLiteral: (penultimateLiteral method: self)

]

{ #category : #'accessing-pragmas & properties' }
Expand All @@ -779,17 +783,13 @@ CompiledMethod >> pragmaRefersToLiteral: literal [

{ #category : #'accessing-pragmas & properties' }
CompiledMethod >> pragmas [
| selectorOrProperties |
^(selectorOrProperties := self penultimateLiteral) isMethodProperties
ifTrue: [selectorOrProperties pragmas]
ifFalse: [#()]
^ self propertyAt: #pragmas ifAbsent: [#() ]

]

{ #category : #'accessing-pragmas & properties' }
CompiledMethod >> pragmasDo: aBlock [
| selectorOrProperties |
(selectorOrProperties := self penultimateLiteral) isMethodProperties
ifTrue: [selectorOrProperties pragmasDo: aBlock]
self pragmas do: aBlock
]

{ #category : #'debugger support' }
Expand Down
13 changes: 8 additions & 5 deletions src/OpalCompiler-Core/IRBytecodeGenerator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,14 @@ IRBytecodeGenerator >> addLiteral: object [

{ #category : #private }
IRBytecodeGenerator >> addPragma: aPragma [
properties ifNil: [ properties := AdditionalMethodState new ].
properties := properties copyWith: aPragma.



properties ifNil: [ properties := AdditionalMethodState new ].
properties
at: #pragmas
ifAbsent: [ properties := properties copyWith: #pragmas -> #( ) ].
properties
at: #pragmas
put: ((properties at: #pragmas) copyWith: aPragma)
]

{ #category : #results }
Expand All @@ -121,7 +124,7 @@ IRBytecodeGenerator >> addProperties: cm [
properties
ifNotNil: [ cm penultimateLiteral: properties.
properties method: cm.
properties pragmas do: [ :each | each method: cm ] ]
properties at: #pragmas ifPresent: [ :props | props do: [:each | each method: cm ] ]]
]

{ #category : #accessing }
Expand Down