LazyMethod.st
changeset 4403 4649f9dd9614
parent 4208 083861c0557e
child 4587 07094cd02017
equal deleted inserted replaced
4402:365edc34920c 4403:4649f9dd9614
   116      Hard-compile the method, install its bytecode in the receiver,
   116      Hard-compile the method, install its bytecode in the receiver,
   117      and recall it."
   117      and recall it."
   118 
   118 
   119     |sender spec class selector|
   119     |sender spec class selector|
   120 
   120 
       
   121     sender := thisContext sender.
       
   122     selector := sender selector.
       
   123 
   121     "compile the method"
   124     "compile the method"
   122 
   125 
   123     self makeRealMethod isNil ifTrue:[
   126     self makeRealMethod isNil ifTrue:[
   124         "
   127         "/ compilation failed
   125          compilation failed
       
   126         "
       
   127         selector := thisContext sender selector.
       
   128 
       
   129         class := self containingClass.
   128         class := self containingClass.
   130         class notNil ifTrue:[
   129         class notNil ifTrue:[
   131             spec := class name , '>>' , selector
   130             spec := class name , '>>' , selector
   132         ] ifFalse:[
   131         ] ifFalse:[
   133             spec := 'unknown>>' , selector
   132             spec := 'unknown>>' , selector
   144          the selector is found in the local 'selector'.
   143          the selector is found in the local 'selector'.
   145 
   144 
   146          As a general rule: never edit autoloaded classes from anything
   145          As a general rule: never edit autoloaded classes from anything
   147          except the browser - to check that they work and are compilable.
   146          except the browser - to check that they work and are compilable.
   148         "
   147         "
   149         ^ CompilationFailedSignal raiseRequestWith:self
   148         ^ CompilationFailedSignal 
   150                                   errorString:('compilation of lazy method ' , spec , ' failed')
   149                 raiseRequestWith:self
       
   150                 errorString:('compilation of lazy method ' , spec , ' failed')
   151     ].
   151     ].
   152 
   152 
   153     "
   153     "
   154      Now, the receiver method has mutated into a real (non-lazy) one.
   154      Now, the receiver method has mutated into a real (non-lazy) one.
   155      Get the original message receiver and args, and execute the method.
   155      Get the original message receiver and args, and execute the method.
   156 
   156 
   157      ThisContext sender is the context of the original send (the failed one)
   157      ThisContext sender is the context of the original send (the failed one)
   158     "
   158     "
   159     sender := thisContext sender.
       
   160     ObjectMemory flushCaches.
   159     ObjectMemory flushCaches.
   161 
   160 
   162     ^ self valueWithReceiver:(sender receiver)
   161     ^ self 
   163                    arguments:(sender args)
   162         valueWithReceiver:(sender receiver)
   164                     selector:(sender selector)
   163         arguments:(sender args)
   165                       search:(sender searchClass)
   164         selector:selector
   166                       sender:nil
   165         search:(sender searchClass)
       
   166         sender:nil
   167 
   167 
   168     "Modified (comment): / 21-11-2017 / 13:02:50 / cg"
   168     "Modified (comment): / 21-11-2017 / 13:02:50 / cg"
       
   169     "Modified (format): / 03-04-2019 / 22:39:44 / Claus Gittinger"
   169 ! !
   170 ! !
   170 
   171 
   171 !LazyMethod methodsFor:'queries'!
   172 !LazyMethod methodsFor:'queries'!
   172 
   173 
   173 isLazyMethod
   174 isLazyMethod