Re: [Pharo-project] Issue 2559 in pharo: Senders of #ifNotNil: do not show
Comment #2 on issue 2559 by marcus.d...@gmail.com: Senders of #ifNotNil: do not show http://code.google.com/p/pharo/issues/detail?id=2559 Issue 2911 has been merged into this issue.
Comment #3 on issue 2559 by nicolas....@gmail.com: Senders of #ifNotNil: do not show http://code.google.com/p/pharo/issues/detail?id=2559 Fully agree. Unfortunately, current implementation seriously limits the number of literals, so care must be taken... numLiterals "Answer the number of literals used by the receiver." ^ (self header bitShift: -9) bitAnd: 16rFF Two literals are consumed by selector or methodProperties see #penultimateLiteral And the target class methodClass "answer the class that I am installed in" ^self numLiterals > 0 ifTrue: [ (self literalAt: self numLiterals) value ] ifFalse: [ nil ] It is possible that some method would compile before the change, and wouldn't after the change... This kind of change would be so easier with a different CompiledMethod format.
Comment #4 on issue 2559 by nicolas....@gmail.com: Senders of #ifNotNil: do not show http://code.google.com/p/pharo/issues/detail?id=2559 One idea would be to put these selectors in a literalArray in order to consume only one slot. Another idea would be to use a MethodProperties and extend it with ugly stuff (a very bad idea in the long term, but safer in the short term).
Updates: Status: FixedWaitingToBePharoed Labels: Milestone-1.3 Type-Squeak Comment #5 on issue 2559 by nicolas....@gmail.com: Senders of #ifNotNil: do not show http://code.google.com/p/pharo/issues/detail?id=2559 Nicolas Cellier uploaded a new version of Compiler to project The Trunk: http://source.squeak.org/trunk/Compiler-nice.201.mcz ==================== Summary ==================== Name: Compiler-nice.201 Author: nice Time: 31 March 2011, 12:45:32.697 am UUID: d694a5f8-4d75-2f4d-a06d-4c5de7fe1656 Ancestors: Compiler-nice.200 Put optimized selectors in CompiledMethod literals so that senders can be browsed normally. Take care to not overflow the scarse literal ressource. It is necessary to evaluate (Compiler recompileAll) before succesfully browsing senders of #ifNil: Thanks to Marcus at http://code.google.com/p/pharo/issues/detail?id=2559 for the idea. =============== Diff against Compiler-nice.200 =============== Item was changed: ParseNode subclass: #Encoder + instanceVariableNames: 'scopeTable nTemps supered requestor class selector literalStream selectorSet litIndSet litSet sourceRanges globalSourceRanges addedSelectorAndMethodClassLiterals optimizedSelectors' - instanceVariableNames: 'scopeTable nTemps supered requestor class selector literalStream selectorSet litIndSet litSet sourceRanges globalSourceRanges addedSelectorAndMethodClassLiterals' classVariableNames: '' poolDictionaries: '' category: 'Compiler-Kernel'! !Encoder commentStamp: '<historical>' prior: 0! I encode names and literals into tree nodes with byte codes for the compiler. Byte codes for literals are not assigned until the tree-sizing pass of the compiler, because only then is it known which literals are actually needed. I also keep track of sourceCode ranges during parsing and code generation so I can provide an inverse map for the debugger.! Item was changed: ----- Method: Encoder>>allLiterals (in category 'results') ----- allLiterals + addedSelectorAndMethodClassLiterals ifFalse: - ((literalStream isKindOf: WriteStream) - and: [ (addedSelectorAndMethodClassLiterals ifNil: [ false ]) not]) ifTrue: [addedSelectorAndMethodClassLiterals := true. + "Put the optimized selectors in literals so as to browse senders more easily" + optimizedSelectors := optimizedSelectors reject: [:e| literalStream originalContents hasLiteral: e]. + optimizedSelectors isEmpty ifFalse: [ + "Use one entry per literal if enough room, else make anArray" + literalStream position + optimizedSelectors size + 2 > 255 + ifTrue: [self litIndex: optimizedSelectors asArray] + ifFalse: [optimizedSelectors do: [:e | self litIndex: e]]]. + "Add a slot for selector or MethodProperties" + self litIndex: nil. + self litIndex: self associationForClass]. + ^literalStream contents! - self litIndex: nil. - self litIndex: self associationForClass]. - ^literalStream contents - - "The funky ifNil: [false], even though the init method initializes addedSAMCL, - is simply so that Monticello can load and compile this update without - killing the encoder that is compiling that update itself..."! Item was changed: ----- Method: Encoder>>initScopeAndLiteralTables (in category 'initialize-release') ----- initScopeAndLiteralTables scopeTable := StdVariables copy. litSet := StdLiterals copy. "comments can be left hanging on nodes from previous compilations. probably better than this hack fix is to create the nodes afresh on each compilation." scopeTable do: [:varNode| varNode comment: nil]. litSet do: [:varNode| varNode comment: nil]. selectorSet := StdSelectors copy. litIndSet := Dictionary new: 16. literalStream := WriteStream on: (Array new: 32). + addedSelectorAndMethodClassLiterals := false. + optimizedSelectors := Set new! - addedSelectorAndMethodClassLiterals := false! Item was removed: - ----- Method: Encoder>>nTemps:literals:class: (in category 'initialize-release') ----- - nTemps: n literals: lits class: cl - "Decompile." - - supered := false. - class := cl. - nTemps := n. - literalStream := ReadStream on: lits. - literalStream position: lits size. - sourceRanges := Dictionary new: 32. - globalSourceRanges := OrderedCollection new: 32. - ! Item was added: + ----- Method: Encoder>>noteOptimizedSelector: (in category 'encoding') ----- + noteOptimizedSelector: aSymbol + "Register a selector as being optimized. + These optimized selectors will later be registered into the literals so that tools can easily browse senders." + optimizedSelectors add: aSymbol! Item was changed: ----- Method: MessageNode>>sizeCodeForEffect: (in category 'code generation') ----- sizeCodeForEffect: encoder special > 0 + ifTrue: + [encoder noteOptimizedSelector: originalSelector. + ^self perform: (MacroSizers at: special) with: encoder with: false]. - ifTrue: [^self perform: (MacroSizers at: special) with: encoder with: false]. ^super sizeCodeForEffect: encoder! Item was changed: ----- Method: MessageNode>>sizeCodeForValue: (in category 'code generation') ----- sizeCodeForValue: encoder | total | special > 0 + ifTrue: + [encoder noteOptimizedSelector: originalSelector. + ^self perform: (MacroSizers at: special) with: encoder with: true]. - ifTrue: [^self perform: (MacroSizers at: special) with: encoder with: true]. receiver == NodeSuper ifTrue: [selector := selector copy "only necess for splOops"]. total := selector sizeCode: encoder args: arguments size super: receiver == NodeSuper. receiver == nil ifFalse: [total := total + (receiver sizeCodeForValue: encoder)]. sizes := arguments collect: [:arg | | argSize | argSize := arg sizeCodeForValue: encoder. total := total + argSize. argSize]. ^total!
Comment #6 on issue 2559 by nicolas....@gmail.com: Senders of #ifNotNil: do not show http://code.google.com/p/pharo/issues/detail?id=2559 There are too many changes pending in old Compiler from Squeak. If you integrate issue2360 first, I'll see if i can merge. Anyway, you might be more interested in an Opal solution...
Comment #7 on issue 2559 by ryd...@gmail.com: Senders of #ifNotNil: do not show http://code.google.com/p/pharo/issues/detail?id=2559 FWIW, this looks like a good solution for the standard Compiler though :)
Comment #8 on issue 2559 by nicolas....@gmail.com: Senders of #ifNotNil: do not show http://code.google.com/p/pharo/issues/detail?id=2559 Name: SLICE-Issue-2559-SpecialMessages-browseThem-cascadeThem-overrideThem-nice.1 Dependencies: Compiler-nice.279 Let special selectors be a bit less special. Special selectors are inlined by the compiler if receiver and arguments follow certain rules (like being a block with prescribed number of arguments).. Inlining is very important for speeding up execution but there was a price to pay: 1) Until now, in case the rules are not followed, Compiler would sometimes send the message as an ordinary one, and would sometimes refuse to compile (though I already relaxed the rules a lot in the past few years). 2) Also you could not browse reference to them because they were inlined and had no marker in CompiledMethod. 3) And Compiler would refuse to cascade them because inlining was harder to implement in such case. Now, you can. 1) not respect the rules (in this case the message will always be sent) 2) browse references (there is literal added to the compiled code) 3) cascade (in a cascade, no message is inlined) While at it I removed the odd rules for compiling caseOf: and that simplifies Compiler. There is no support yet to prevent inlining, and thus to enable true overriding (if receiver/arguments respect the rules, message won't be sent but still inlined with a hardcoded implementation). However, you can hack by using any other argument but a Block: (2>1) ifTrue: ['print me'] yourself. This way you could activate your own override of ifTrue: Also you can write this if you feel like: (2>1) ifTrue: [2 inspect]; and: [2 odd]. Of course, from pragmatic point of view, you won't probably need this stuff. But if we can avoid useless sacrifices, let's avoid.
Updates: Status: FixProposed Comment #9 on issue 2559 by nicolas....@gmail.com: Senders of #ifNotNil: do not show http://code.google.com/p/pharo/issues/detail?id=2559 I forgot to say, recompileAll is required so as to be able to browse special senders
Comment #10 on issue 2559 by nicolas....@gmail.com: Senders of #ifNotNil: do not show http://code.google.com/p/pharo/issues/detail?id=2559 Name: SLICE-Issue-2559-SpecialMessages-browseThem-cascadeThem-overrideThem-nice.2 Dependencies: Compiler-nice.280 Don't forget to deoptimize the receiver in case of cascade. Add a missing ivar to BlockNode.
Comment #11 on issue 2559 by marcus.d...@gmail.com: Senders of #ifNotNil: do not show http://code.google.com/p/pharo/issues/detail?id=2559 The interesting thing is that it it just takes 200Kb more space. I can live with that! (I took a version with, one without. Recompiled, did a #releaseclean in both and the difference is 14802344 vs. 15007540 for saved images of the same window size. One problem that I see is that we need to change the metric of Cog when not to JIT. Right now it does not JIT when the method is too large, and that "too large" is defined as having more than X literals (60, I think).
Comment #12 on issue 2559 by marcus.d...@gmail.com: Senders of #ifNotNil: do not show http://code.google.com/p/pharo/issues/detail?id=2559 Issue 3940 has been merged into this issue.
Updates: Status: Closed Comment #13 on issue 2559 by marcus.d...@gmail.com: Senders of #ifNotNil: do not show http://code.google.com/p/pharo/issues/detail?id=2559 in 13138
participants (1)
-
pharo@googlecode.com