Bistro Compiler Optimizations

The page reports on the status of optimizations supported by the Bistro compiler.

Completed optimizations include:

Optimizations still in need of implementation.

Because Bistro supports imports from other packages, Bistro does not provide any analog of Smalltalk pool dictionaries. Hence, all constants in Smalltalk bound to pools must be recoded to use accessors.

Message Optimization Details

The Bistro compiler attempts to resolve the type of each message receiver. For message primaries such as constants, variables and arguments, the compiler resolves an inferred type (for constants) or a declared type (for variables and arguments). For nested message expressions, the compiler attempts to resolve the type of each nested message result. Where such type resolution is possible, the compiler determines whether the receiver implements the message selector using the Java reflection facility. If the compiler can locate an appropriate method at compile-time, the compiler generates a direct method invocation against the receiver rather than a dynamic method resolution using one of the perform: selectors. Whenever the compiler can generate a direct method invocation, it also remembers the result type of the invoked method. This gives it the opportunity to resolve a further method invoked on the message result in the case of nested message expressions.

Performance Benchmarks

The smalltalk.example package includes two benchmarks for measuring the performance of Bistro. The SticBenchmark class is a transcription of the original STIC benchmarks. The SimpleHanoi class compares the performance of Java™ and Bistro, with and without dynamic method resolution.

The Tower of Hanoi test moves 22 disks between 3 towers. The Java™ version of the test is coded as a hand-optimized primitive Java™ method. The Fast version of the test is coded as a natural Bistro method with type annotations that instruct the Bistro compiler to generate direct method invocations. The Slow version of the test is coded as a natural Bistro method without type annotations. So, the Bistro compiler generates dynamic method resolutions with the appropriate perform: idioms.

The following performance measurements were collected using a 400 MHz Pentium II-MMX with 128 MB RAM, running the Java™ 2 HotSpot™ VM v1.3 (build 1.3.0-C). The times reflect the best performance of each test from 3 separate test runs.

Test Time (secs)   Test Time (secs)


100000 Array allocations 1.782   Java Tower of Hanoi 0.240
100000 Array writes 1.503   Fast Tower of Hanoi 3.885
100000 Dictionary writes 1.081   Slow Tower of Hanoi 67.808
100000 Float operations 10.816  
100000 Integer operations 5.398  
100000 OrderedCollection iterations 6.759  
100000 OrderedCollection writes 0.922  
100000 String comparisons 0.681  

Permission is granted to copy this document provided this copyright statement is retained in all copies.
Copyright 1999-2001 Nikolas S. Boyd.