Skip to content
/ VarTra Public

Squeak instrumentation mechanism to synchronously react to variable assignments.

License

Notifications You must be signed in to change notification settings

stlutz/VarTra

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VarTra - Squeak Variable Tracking Build Status Coverage Status

VarTra (from Variable Tracking) is a low-performance-impact mechanism to synchronousuly react to variable assignments in Squeak/Smalltalk. It uses an altered compilation process to inline notification code around all variable assignments. To ensure that the transformed code is minimally expensive, VarTra emits optimized bytecode for its instrumented assignments.

Supported variable types:

  • Instance variables
  • Temporary variables
  • Literal variables (class, global, shared pools).

Installation

WARNING! This project overrides system methods to change the default compilation process.

A successful installation involves recompilation of all methods within your image.

Check Travis to see whether your version of Squeak is supported.

Option 1: Metacello

  1. Make sure to have Metacello installed.
  2. Then you can use the following code to load VarTra and all its prerequisites:
    Metacello new
      baseline: 'VarTra';
      repository: 'github://stlutz/VarTra/src';
      load.

Option 2: Git Browser

Only for Squeak 5.2 and newer

  1. Make sure to have Squot installed
    Installer installGitInfrastructure.
  2. Clone this repository

Option 3: Monticello

  1. Make sure to have FileTree installed
  2. Clone this repository somewhere on your file system
  3. Add the src/ folder of this repository as a filetree:// repository
  4. Load the individual packages via Monticello in the following order:
    1. (If you use a Squeak older than 5.2:) VarTra-Compat51-Compiling
    2. VarTra-Compiling
    3. VarTra-Core
    4. VarTra-Tests

Usage

"Activate variable tracking and recompile all methods with it."
VarTra install.

"Deactivate variable tracking and recompile all methods to remove it."
VarTra uninstall.

"Subscribe to changes of a variable"
VarTra subscribe: self toInstVarNamed: 'instVar' ofObject: VtMockInstVarPublisher new.
VarTra subscribe: self toLitVar: (self environment bindingOf: #VtMockGlobal).
VarTra subscribe: self toTempVarNamed: 'tempVar' ofContext: thisContext.

"Unsubscribe from variable changes"
VarTra unsubscribe: self fromInstVarNamed: 'instVar' ofObject: anObject.
VarTra unsubscribe: self fromLitVar: (self environment bindingOf: #VtMockGlobal).
VarTra unsubscribe: self fromTempVarNamed: 'tempVar' ofContext: thisContext.

"When a variable changes, its subscribers are notified via a message send.
To react, subclasses of Object need to override the respective methods."
Object >> #'instVarNamed:ofObject:changedFrom:to:inContext:'.
Object >> #'litVar:changedFrom:to:inContext:'.
Object >> #'tempVarNamed:changedFrom:to:inContext:'.

Tracking Mechanism

To be notified of variable assignments, VarTra emits modified bytecodes for variable assignments. It does so by parsing assignments as VtTrackedAssignmentNodes, a subclass of the normal AssignmentNode. The actual injection of instrumentation code then happens during bytecode generation.

More details can be found here.

Example

About

Squeak instrumentation mechanism to synchronously react to variable assignments.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published