Squeak Class Documentation category index | class index  
 
CompiledMethod
  category: Kernel-Methods
  superclass: ByteArray
  subclasses:

I represent a method suitable for interpretation by the virtual machine. My instances have pointer fields, including a header and some literals, followed by non-pointer fields comprising the byte encoded instructions for the method. The header encodes the number of arguments, the number of literals, and the amount of temporary space needed (for context allocation).

An extra three bytes are added after the executable code. These contain an external file address to the source code for the method.

instance methods
  accessing
  endPC
flushCache
frameSize
initialPC
numArgs
numLiterals
numTemps
primitive
returnField
selector

  comparing
  =

  evaluating
  valueWithReceiver:arguments:

  file in/out
  readDataFrom:size:
storeDataOn:
veryDeepCopyWith:
zapSourcePointer

  initialize-release
  copyWithTrailerBytes:
needsFrameSize:

  literals
  hasLiteral:
hasLiteralSuchThat:
hasLiteralThorough:
header
literalAt:
literalAt:put:
literalStrings
literals
objectAt:
objectAt:put:

  printing
  decompileString
printOn:
printOnStream:
printPrimitiveOn:
storeLiteralsOn:forClass:
storeOn:
symbolic
who

  scanning
  messages
readsField:
readsRef:
scanFor:
scanLongLoad:
scanLongStore:
scanVeryLongLoad:offset:
scanVeryLongStore:offset:
sendsToSuper
writesField:
writesRef:

  source code management
  cacheTempNames:
checkOKToAdd:at:
copyWithTempNames:
fileIndex
filePosition
getSourceFor:in:
getSourceFromFile
putSource:fromParseNode:class:category:inFile:priorMethod:
putSource:fromParseNode:class:category:withStamp:inFile:priorMethod:
putSource:fromParseNode:inFile:withPreamble:
qCompress:
qDecompress:
setSourcePointer:
setSourcePosition:inFile:
setTempNamesIfCached:
sourcePointer
tempNames

  testing
  hasReportableSlip
isQuick
isReturnField
isReturnSelf
isReturnSpecial

class methods
  class initialization
  fullFrameSize
initialize

  instance creation
  basicNew:
new
new:
newBytes:trailerBytes:nArgs:nTemps:nStack:nLits:primitive:
newMethod:header:
toReturnConstant:trailerBytes:
toReturnField:trailerBytes:
toReturnSelf
toReturnSelfTrailerBytes:

instance methods
  accessing top  
 

endPC

Answer the index of the last bytecode.


 

flushCache

Tell the interpreter to remove all references to this method from its method lookup cache, if it has one. This primitive must be called whenever a method is defined or removed.
NOTE: Only one of two selective flush methods needs to be used.
Squeak 2.2 and earlier uses 119 (See Symbol flushCache).
Squeak 2.3 and later uses 116 (See CompiledMethod flushCache).


 

frameSize

Answer the size of temporary frame needed to run the receiver.


 

initialPC

Answer the program counter for the receiver's first bytecode.


 

numArgs

Answer the number of arguments the receiver takes.


 

numLiterals

Answer the number of literals used by the receiver.


 

numTemps

Answer the number of temporary variables used by the receiver.


 

primitive

Answer the primitive index associated with the receiver.
Zero indicates that this is not a primitive method.
We currently allow 11 bits of primitive index, but they are in two places
for backward compatibility. The time to unpack is negligible,
since the reconstituted full index is stored in the method cache.


 

returnField

Answer the index of the instance variable returned by a quick return
method.


 

selector

This is slow, so don't call it frivolously


  comparing top  
 

=

Answer whether the receiver implements the same code as the
argument, method.


  evaluating top  
 

valueWithReceiver:arguments:


  file in/out top  
 

readDataFrom:size:

Fill in my fields. My header and number of literals are already installed. Must read both objects for the literals and bytes for the bytecodes.


 

storeDataOn:

Store myself on a DataStream. I am a mixture of objects and raw data bytes. Only use this for blocks. Normal methodDictionaries should not be put out using ReferenceStreams. Their fileOut should be attached to the beginning of the file.


 

veryDeepCopyWith:

Return self. I am always shared. Do not record me. Only use this for blocks. Normally methodDictionaries should not be copied this way.


 

zapSourcePointer

clobber the source pointer since it will be wrong


  initialize-release top  
 

copyWithTrailerBytes:

Testing:
(CompiledMethod compiledMethodAt: #copyWithTrailerBytes:)
tempNamesPut: 'copy end '


 

needsFrameSize:

Set the largeFrameBit to accomodate the newFrameSize


  literals top  
 

hasLiteral:

Answer whether the receiver references the argument, literal.


 

hasLiteralSuchThat:

Answer true if litBlock returns true for any literal in this method, even if imbedded in array structure.


 

hasLiteralThorough:

Answer true if any literal in this method is literal,
even if embedded in array structure.


 

header

Answer the word containing the information about the form of the
receiver and the form of the context needed to run the receiver.


 

literalAt:

Answer the literal indexed by the argument.


 

literalAt:put:

Replace the literal indexed by the first argument with the second
argument. Answer the second argument.


 

literalStrings


 

literals

Answer an Array of the literals referenced by the receiver.


 

objectAt:

Primitive. Answer the method header (if index=1) or a literal (if index
>1) from the receiver. Essential. See Object documentation
whatIsAPrimitive.


 

objectAt:put:

Primitive. Store the value argument into a literal in the receiver. An
index of 2 corresponds to the first literal. Fails if the index is less than 2
or greater than the number of literals. Answer the value as the result.
Normally only the compiler sends this message, because only the
compiler stores values in CompiledMethods. Essential. See Object
documentation whatIsAPrimitive.


  printing top  
 

decompileString


 

printOn:

Overrides method inherited from the byte arrayed collection.


 

printOnStream:

Overrides method inherited from the byte arrayed collection.


 

printPrimitiveOn:

Print the primitive on aStream


 

storeLiteralsOn:forClass:

Store the literals referenced by the receiver on aStream, each terminated by a space.


 

storeOn:

Refer to the comment in Object|storeOn:.


 

symbolic

Answer a String that contains a list of all the byte codes in a method
with a short description of each.


 

who

Answer an Array of the class in which the receiver is defined and the
selector to which it corresponds.


  scanning top  
 

messages

Answer a Set of all the message selectors sent by this method.


 

readsField:

Answer whether the receiver loads the instance variable indexed by the
argument.


 

readsRef:

Answer whether the receiver loads the argument.


 

scanFor:

Answer whether the receiver contains the argument as a bytecode.


 

scanLongLoad:

Answer whether the receiver contains a long load whose extension is the
argument.


 

scanLongStore:

Answer whether the receiver contains a long store whose extension is
the argument.


 

scanVeryLongLoad:offset:

Answer whether the receiver contains a long load whose extension is the
argument.


 

scanVeryLongStore:offset:

Answer whether the receiver contains a long load with the given offset.
Note that the constant +32 is the known difference between a
store and a storePop for instVars, and it will always fail on literal variables,
but these only use store (followed by pop) anyway.


 

sendsToSuper

Answer whether the receiver sends any message to super.


 

writesField:

Answer whether the receiver stores into the instance variable indexed
by the argument.


 

writesRef:

Answer whether the receiver stores the argument.


  source code management top  
 

cacheTempNames:


 

checkOKToAdd:at:

Issue several warnings as the end of the changes file approaches its limit,
and finally halt with an error when the end is reached.


 

copyWithTempNames:


 

fileIndex


 

filePosition


 

getSourceFor:in:

Retrieve or reconstruct the source code for this method.


 

getSourceFromFile

Read the source code from file, determining source file index and
file position from the last 3 bytes of this method.


 

putSource:fromParseNode:class:category:inFile:priorMethod:


 

putSource:fromParseNode:class:category:withStamp:inFile:priorMethod:


 

putSource:fromParseNode:inFile:withPreamble:

Store the source code for the receiver on an external file.
If no sources are available, i.e., SourceFile is nil, then store
temp names for decompilation at the end of the method.
If the fileIndex is 1, print on *.sources; if it is 2, print on *.changes,
in each case, storing a 4-byte source code pointer at the method end.


 

qCompress:

A very simple text compression routine designed for method temp names.
Most common 12 chars get values 0-11 packed in one 4-bit nibble;
others get values 12-15 (2 bits) * 16 plus next nibble.
Last char of str must be a space so it may be dropped without
consequence if output ends on odd nibble.


 

qDecompress:

Decompress strings compressed by qCompress:.
Most common 12 chars get values 0-11 packed in one 4-bit nibble;
others get values 12-15 (2 bits) * 16 plus next nibble


 

setSourcePointer:


 

setSourcePosition:inFile:


 

setTempNamesIfCached:

This is a cache used by the debugger, independent of the storage of
temp names when the system is converted to decompilation with temps.


 

sourcePointer

Answer the integer which can be used to find the source file and position for this method.
The returned value is either 0 (if no source is stored) or a number between 16r1000000 and 16r4FFFFFF.
The actual interpretation of this number is up to the SourceFileArray stored in the global variable SourceFiles.


 

tempNames


  testing top  
 

hasReportableSlip

Answer whether the receiver contains anything that should be brought to the attention of the author when filing out. Customize the lists here to suit your preferences. If slips do not get reported in spite of your best efforts here, make certain that the Preference 'checkForSlips' is set to true.


 

isQuick

Answer whether the receiver is a quick return (of self or of an instance
variable).


 

isReturnField

Answer whether the receiver is a quick return of an instance variable.


 

isReturnSelf

Answer whether the receiver is a quick return of self.


 

isReturnSpecial

Answer whether the receiver is a quick return of self or constant.


class methods
  class initialization top  
 

fullFrameSize

CompiledMethod fullFrameSize


 

initialize

CompiledMethod initialize


  instance creation top  
 

basicNew:

Primitive. Answer an instance of this class with the number
of indexable variables specified by the argument, sizeRequested.
Fail if this class is not indexable or if the argument is not a
positive Integer, or if there is not enough memory available.
Essential. See Object documentation whatIsAPrimitive.


 

new

This will not make a meaningful method, but it could be used
to invoke some otherwise useful method in this class.


 

new:

Answer an instance of this class with the number of indexable
variables specified by the argument, sizeRequested.


 

newBytes:trailerBytes:nArgs:nTemps:nStack:nLits:primitive:

Answer an instance of me. The header is specified by the message
arguments. The remaining parts are not as yet determined.


 

newMethod:header:

Primitive. Answer an instance of me. The number of literals (and other
information) is specified the headerWord. The first argument specifies
the number of fields for bytecodes in the method. Fail if either
argument is not a SmallInteger, or if numberOfBytes is negative. Once
the header of a method is set by this primitive, it cannot be changed in
any way. Essential. See Object documentation whatIsAPrimitive.


 

toReturnConstant:trailerBytes:

Answer an instance of me that is a quick return of the constant
indexed in (true false nil -1 0 1 2).


 

toReturnField:trailerBytes:

Answer an instance of me that is a quick return of the instance variable
indexed by the argument, field.


 

toReturnSelf

Answer an instance of me that is a quick return of the instance (^self).


 

toReturnSelfTrailerBytes:

Answer an instance of me that is a quick return of the instance (^self).