The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Adapting Smalltalk bytecodes at runtime

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
Adapting Smalltalk bytecodes at runtime Posted: Aug 16, 2005 9:09 AM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: Adapting Smalltalk bytecodes at runtime
Feed Title: Cincom Smalltalk Blog - Smalltalk with Rants
Feed URL: http://www.cincomsmalltalk.com/rssBlog/rssBlogView.xml
Feed Description: James Robertson comments on Cincom Smalltalk, the Smalltalk development community, and IT trends and issues in general.
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Cincom Smalltalk Blog - Smalltalk with Rants

Advertisement

Well - I'm finally here (that's another post). Now, I'm trying to pay attention to Markus' talk on bytecode x-forms. What he's done is implement a library (Squeak) called ByteSurgeon. It provides a high level API, and should be portable. So... why muck at the bytecode level?

  • No need to change the VM
  • No source needed
  • Other languages are possible
  • Performance - no need to change any sources or worry about decompilation

The idea - simple API:

Instrument: [:instruction | InstrCounter increase].
InstrCounter reset

InstrumentSend: [instruction | InstrCounter increase].

What about transforming bytecode? There's #insertBefore:, #insertAfter, #replace: It's easy to see how those are useful for debugging and method wrappering - in fact, the VW debugger uses bytecode insertion in order to add breakpoints. It's also a simple way to add in no cost (at runtime, not at dev time) logging.

What about accessing various pieces of useful state? meta variables to access receiver, arguments, result, etc.

InstrumentSend: [:s | m insertAfter: 'Logger logSendTo: <meta: #receiver>].

That opens up a number of possibilities. The nifty thing (at least for Squeak and VW) is that the Smalltalk level compiler is accessible, and you can jump in and insert additional steps at the AST level (which is what Markus is talking about). Using ByteSurgeon to create Method Wrappers - 40 lines of code, not much slower on execution (5x). Simple MOP achieved.

At least in Squeak, using ByteSurgeon is faster than whole method compilation (2x faster than the optimized Squeak compiler).

Futures?

  • AST vs Bytecode
  • Gepetto MOP
  • Omniscient Debugger

Read: Adapting Smalltalk bytecodes at runtime

Topic: Death by Starcraft Previous Topic   Next Topic Topic: What's in your wallet? Sounds like no...

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use