Skip to content

Commit 76bd8b5

Browse files
authored
Building runtime with debugging symbols (#96)
* building runtime with debugging symbols * fix a bug in inlining monotonic operations * adding profiled runtime
1 parent 90da1d4 commit 76bd8b5

File tree

4 files changed

+47
-11
lines changed

4 files changed

+47
-11
lines changed

main.rkt

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,21 @@
22
#lang racket/base
33

44
(require "src/compile.rkt"
5+
"src/backend-c/runtime-location.rkt"
56
racket/cmdline
67
racket/match
78
racket/runtime-path
89
racket/system)
910

1011
(provide (all-from-out "src/compile.rkt"))
1112

13+
(define (make-runtime-with-param param param_runtime.o-path)
14+
(when (not (directory-exists? param_runtime.o-path))
15+
(define-values (pwd _1 _2) (split-path runtime.o-path))
16+
(parameterize ([current-directory pwd])
17+
(unless (system (string-append "make " param) #:set-pwd? #t)
18+
(printf (format "\nError: Running make failed in ~a" pwd))))))
19+
1220
(define-runtime-path this-dir ".")
1321
(define (print-version-info)
1422
(unless (system "git rev-parse --verify HEAD" #:set-pwd? this-dir)
@@ -169,12 +177,6 @@
169177
#:mode 'text
170178
#:exists 'replace))
171179
(grift-log-port of-port)]))]
172-
[("-g" "--with-debug-symbols")
173-
"Invoke c compiler so that debugging symbols are retained."
174-
(c-flags (cons "-g" (c-flags)))]
175-
[("--profile")
176-
"Invoke c compiler with profiling flags"
177-
(c-flags (cons "-pg" (c-flags)))]
178180
[("--no-inline-proxied-branch")
179181
"Do not inline proxied operations"
180182
(inline-proxied-branch? #f)]
@@ -187,6 +189,17 @@
187189
#:once-any
188190
["--Boehm" "Use Boehm Conservative Collector" (garbage-collector 'Boehm)]
189191
["--No-GC" "Do not Collect Garbage" (garbage-collector 'None)]
192+
#:once-any
193+
[("-g" "--with-debug-symbols")
194+
"Invoke c compiler so that debugging symbols are retained."
195+
(c-flags (cons "-g" (c-flags)))
196+
(make-runtime-with-param "debug" debug_runtime.o-path)
197+
(runtime-path debug_runtime.o-path)]
198+
[("-p" "--profile")
199+
"Invoke c compiler with profiling flags"
200+
(c-flags (cons "-pg" (c-flags)))
201+
(make-runtime-with-param "profile" profile_runtime.o-path)
202+
(runtime-path profile_runtime.o-path)]
190203
#:args args
191204
(match args
192205
[(list)

src/backend-c/runtime-location.rkt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@
88

99
;; primitive functions implemented in c
1010
(: runtime.o-path Path)
11-
(: runtime.c-path Path)
1211
(: runtime.h-path Path)
1312
(define-runtime-path runtime.o-path "runtime/runtime.o")
14-
(define-runtime-path runtime.c-path "runtime/runtime.c")
1513
(define-runtime-path runtime.h-path "runtime/runtime.h")
1614

15+
(: debug_runtime.o-path Path)
16+
(: profile_runtime.o-path Path)
17+
(define-runtime-path debug_runtime.o-path "runtime/debug_object/runtime.o")
18+
(define-runtime-path profile_runtime.o-path "runtime/profile_object/runtime.o")
19+
1720
;; hashcons implementation in c
1821
(: hashcons.o-path Path)
1922
(: hashcons.c-path Path)

src/backend-c/runtime/Makefile

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ NDEBUG ?= -D NDEBUG
22

33
all : libgc nonegc.o runtime.o castprofiler.o
44

5-
debug: tidy ndebug all
5+
debug: tidy ndebug libgc nonegc.o debug_object/runtime.o castprofiler.o
6+
7+
profile: tidy ndebug libgc nonegc.o profile_object/runtime.o castprofiler.o
68

79
libgc : boehm-gc-install/lib/libgc.a
810

@@ -22,6 +24,24 @@ boehm-gc-install/lib/libgc.a :
2224
runtime.o : boehm-gc-install/lib/libgc.a io.o assoc_stack.o hashcons.o suspended_cast.o cast_queue.o
2325
ld -r $^ -o $@
2426

27+
debug_object/%.o : %.c debug_object
28+
cc -Iboehm-gc-install/include -std=c99 -g $< -c -o $@
29+
30+
debug_object:
31+
mkdir $@
32+
33+
debug_object/runtime.o : boehm-gc-install/lib/libgc.a debug_object/io.o debug_object/assoc_stack.o debug_object/hashcons.o debug_object/suspended_cast.o debug_object/cast_queue.o
34+
ld -r $^ -o $@
35+
36+
profile_object/%.o : %.c profile_object
37+
cc -Iboehm-gc-install/include -std=c99 -pg $< -c -o $@
38+
39+
profile_object:
40+
mkdir $@
41+
42+
profile_object/runtime.o : boehm-gc-install/lib/libgc.a profile_object/io.o profile_object/assoc_stack.o profile_object/hashcons.o profile_object/suspended_cast.o profile_object/cast_queue.o
43+
ld -r $^ -o $@
44+
2545
test : runtime.o
2646
cd tests && make all && ./tests
2747

src/casts/interpret-casts-common.rkt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ TODO write unit tests
598598
(mref-state-reduction-uid? mref-state-reduction-uid))
599599
(define (mref-state-reduction)
600600
(if (monotonic-cast-inline-without-types?)
601-
(code-gen-mref-state-reduction)
601+
(begin$ (code-gen-mref-state-reduction) ZERO-EXPR)
602602
(let ([uid? (mref-state-reduction-uid?)])
603603
(or uid? (make-code!))
604604
(interp-mref-state-reduction))))
@@ -636,7 +636,7 @@ TODO write unit tests
636636
(mvect-state-reduction-uid? mvect-state-reduction-uid))
637637
(define (mvect-state-reduction)
638638
(if (monotonic-cast-inline-without-types?)
639-
(code-gen-mvect-state-reduction)
639+
(begin$ (code-gen-mvect-state-reduction) ZERO-EXPR)
640640
(let ([uid? (mvect-state-reduction-uid?)])
641641
(or uid? (make-code!))
642642
(interp-mvect-state-reduction))))

0 commit comments

Comments
 (0)