The Trunk: Kernel-eem.1349.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Kernel-eem.1349.mcz

commits-2
Eliot Miranda uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-eem.1349.mcz

==================== Summary ====================

Name: Kernel-eem.1349
Author: eem
Time: 9 October 2020, 7:49:50.4607 pm
UUID: 6db35c96-122e-414f-bf75-c74d07149f49
Ancestors: Kernel-eem.1348

Neaten CompiledMethod>>#setSourcePointer:, avoiding unnecessary copies and becomes, bu=y refactoring CompiledMethodTrailer>>#createMethod:class:header: into copyToMethod:.  Nuke the unsent method dropSourcePointer which is a duplicate of the much older (but also un sent) method zapSourcePointer.

=============== Diff against Kernel-eem.1348 ===============

Item was removed:
- ----- Method: CompiledMethod>>dropSourcePointer (in category 'source code management') -----
- dropSourcePointer
- self trailer hasSourcePointer ifTrue: [
- self becomeForward:
- (self copyWithTrailerBytes:
- (CompiledMethodTrailer new sourceCode: self getSource))]
- !

Item was changed:
  ----- Method: CompiledMethod>>setSourcePointer: (in category 'source code management') -----
  setSourcePointer: srcPointer
+ "We can't necessarily change the trailer of existing method, since
+ it could have a completely different format. If so, generate a copy
+ with a new trailer, containing a srcPointer, and then become it."
+ | newTrailer myTrailer |
+ myTrailer := self trailer.
+ srcPointer = 0
+ ifTrue: "catch the common case of setting the source pointer to 0 when already 0"
+ [myTrailer sourcePointer = 0 ifTrue:
+ [^self].
+ newTrailer := CompiledMethodTrailer empty]
- "We can't change the trailer of existing method, since it could have a
- completely different format. Therefore we need to generate a copy
- with new trailer, containing a srcPointer, and then #become it."
- | trailer copy start |
- trailer := srcPointer = 0
- ifTrue: "catch the common case of setting the source pointer to 0 when already 0"
- [self sourcePointer = 0 ifTrue:
- [^self].
- CompiledMethodTrailer empty]
- ifFalse:
- [CompiledMethodTrailer new sourcePointer: srcPointer].
- copy := self copyWithTrailerBytes: trailer.
-
- "ar 3/31/2010: Be a bit more clever since #become: is slow.
- If the old and the new trailer have the same size, just replace it."
- (self trailer class == trailer class and:[self size = copy size])
- ifTrue:
- [start := self endPC + 1.
- self replaceFrom: start to: self size with: copy startingAt: start]
  ifFalse:
+ [newTrailer := CompiledMethodTrailer new sourcePointer: srcPointer].
+ (myTrailer size = newTrailer size
+ and: [myTrailer kind = newTrailer kind]) ifTrue:
+ [^newTrailer copyToMethod: self].
- [self becomeForward: copy].
 
+ ^self becomeForward: (self copyWithTrailerBytes: newTrailer)!
- ^self "will be copy if #become was needed"
- !

Item was added:
+ ----- Method: CompiledMethodTrailer>>copyToMethod: (in category 'creating a method') -----
+ copyToMethod: aCompiledMethod
+ "Copy the encoded trailer data to aCompiledMethod. Answer aCompiledMethod."
+ | delta |
+ delta := aCompiledMethod size - self size.
+ 1 to: size do:
+ [:i | aCompiledMethod at: delta + i put: (encodedData at: i)].
+ ^aCompiledMethod!

Item was changed:
  ----- Method: CompiledMethodTrailer>>createMethod:class:header: (in category 'creating a method') -----
+ createMethod: numberOfBytesForAllButTrailer class: aCompiledMethodClass header: headerWord
+ "Answer a new compiled method of the given class, headerWord (which defines the number of literals)
+ and with the receiver asd its encoded trailer."
+ ^self copyToMethod: (aCompiledMethodClass newMethod: numberOfBytesForAllButTrailer + self size header: headerWord)!
- createMethod: numberOfBytesForAllButTrailer class: aCompiledMethodClass header: headerWord
- | meth delta |
- encodedData ifNil: [self encode].
-
- meth := aCompiledMethodClass newMethod: numberOfBytesForAllButTrailer + size header: headerWord.
- "copy the encoded trailer data"
- delta := meth size - size.
- 1 to: size do:
- [:i | meth at: delta + i put: (encodedData at: i)].
-
- ^meth!

Item was changed:
  ----- Method: CompiledMethodTrailer>>size (in category 'accessing') -----
  size
  "Answer the size of method's trailer , in bytes"
+ encodedData ifNil: [self encode].
+ ^size!
- ^ size!