|
2 | 2 |
|
3 | 3 | (require racket/match |
4 | 4 | racket/function |
5 | | - racket/flonum) |
| 5 | + racket/flonum |
| 6 | + racket/performance-hint) |
6 | 7 |
|
7 | 8 | (require "machine.rkt" |
8 | 9 | "adjust.rkt" |
|
13 | 14 | rival-machine-run |
14 | 15 | rival-machine-return |
15 | 16 | rival-machine-adjust |
| 17 | + rival-machine-record |
16 | 18 | apply-instruction) ; for compile.rkt |
17 | 19 |
|
18 | 20 | (define (rival-machine-load machine args) |
19 | 21 | (vector-copy! (rival-machine-registers machine) 0 args) |
20 | 22 | (set-rival-machine-bumps! machine 0) |
21 | 23 | (*bumps-activated* #f)) |
22 | 24 |
|
23 | | -(define (rival-machine-record machine name number precision time memory iter) |
24 | | - (define profile-ptr (rival-machine-profile-ptr machine)) |
25 | | - (define profile-instruction (rival-machine-profile-instruction machine)) |
26 | | - (when (< profile-ptr (vector-length profile-instruction)) |
27 | | - (define profile-number (rival-machine-profile-number machine)) |
28 | | - (define profile-time (rival-machine-profile-time machine)) |
29 | | - (define profile-memory (rival-machine-profile-memory machine)) |
30 | | - (define profile-precision (rival-machine-profile-precision machine)) |
31 | | - (define profile-iteration (rival-machine-profile-iteration machine)) |
32 | | - (vector-set! profile-instruction profile-ptr name) |
33 | | - (vector-set! profile-number profile-ptr number) |
34 | | - (vector-set! profile-memory profile-ptr memory) |
35 | | - (vector-set! profile-precision profile-ptr precision) |
36 | | - (vector-set! profile-iteration profile-ptr iter) |
37 | | - (flvector-set! profile-time profile-ptr time) |
38 | | - (set-rival-machine-profile-ptr! machine (add1 profile-ptr)))) |
| 25 | +;; Inlining critical, otherwise `time` is heap-allocated (Chez boxes floats) |
| 26 | +(define-inline (rival-machine-record machine name number precision time memory iter) |
| 27 | + (define profile-ptr (rival-machine-profile-ptr machine)) |
| 28 | + (define profile-instruction (rival-machine-profile-instruction machine)) |
| 29 | + (when (< profile-ptr (vector-length profile-instruction)) |
| 30 | + (define profile-number (rival-machine-profile-number machine)) |
| 31 | + (define profile-time (rival-machine-profile-time machine)) |
| 32 | + (define profile-memory (rival-machine-profile-memory machine)) |
| 33 | + (define profile-precision (rival-machine-profile-precision machine)) |
| 34 | + (define profile-iteration (rival-machine-profile-iteration machine)) |
| 35 | + (vector-set! profile-instruction profile-ptr name) |
| 36 | + (vector-set! profile-number profile-ptr number) |
| 37 | + (vector-set! profile-memory profile-ptr memory) |
| 38 | + (vector-set! profile-precision profile-ptr precision) |
| 39 | + (vector-set! profile-iteration profile-ptr iter) |
| 40 | + (flvector-set! profile-time profile-ptr time) |
| 41 | + (set-rival-machine-profile-ptr! machine (add1 profile-ptr)))) |
39 | 42 |
|
40 | 43 | (define (rival-machine-run machine vhint) |
41 | 44 | (define ivec (rival-machine-instructions machine)) |
|
0 commit comments