mirror of
https://github.com/open-goal/jak-project
synced 2026-07-11 07:25:37 -04:00
d1ece445d4
Relates to #1353 This adds no new functionality or overhead to the compiler, yet. This is the preliminary work that has: - added code to the compiler in several spots to flag when something is used without being properly required/imported/whatever (disabled by default) - that was used to generate project wide file dependencies (some circulars were manually fixed) - then that graph underwent a transitive reduction and the result was written to all `jak1` source files. The next step will be making this actually produce and use a dependency graph. Some of the reasons why I'm working on this: - eliminates more `game.gp` boilerplate. This includes the `.gd` files to some extent (`*-ag` files and `tpage` files will still need to be handled) this is the point of the new `bundles` form. This should make it even easier to add a new file into the source tree. - a build order that is actually informed from something real and compiler warnings that tell you when you are using something that won't be available at build time. - narrows the search space for doing LSP actions -- like searching for references. Since it would be way too much work to store in the compiler every location where every symbol/function/etc is used, I have to do ad-hoc searches. By having a dependency graph i can significantly reduce that search space. - opens the doors for common shared code with a legitimate pattern. Right now jak 2 shares code from the jak 1 folder. This is basically a hack -- but by having an explicit require syntax, it would be possible to reference arbitrary file paths, such as a `common` folder. Some stats: - Jak 1 has about 2500 edges between files, including transitives - With transitives reduced at the source code level, each file seems to have a modest amount of explicit requirements. Known issues: - Tracking the location for where `defmacro`s and virtual state definitions were defined (and therefore the file) is still problematic. Because those forms are in a macro environment, the reader does not track them. I'm wondering if a workaround could be to search the reader's text_db by not just the `goos::Object` but by the text position. But for the purposes of finishing this work, I just statically analyzed and searched the code with throwaway python code.
131 lines
2.7 KiB
Common Lisp
131 lines
2.7 KiB
Common Lisp
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
(bundles "ENGINE.CGO" "GAME.CGO")
|
|
|
|
(require "kernel/gcommon.gc")
|
|
|
|
;; name: stats-h.gc
|
|
;; name in dgo: stats-h
|
|
;; dgos: GAME, ENGINE
|
|
|
|
;; DECOMP BEGINS
|
|
|
|
(deftype tr-stat (structure)
|
|
((groups uint16)
|
|
(fragments uint16)
|
|
(tris uint32)
|
|
(dverts uint32)
|
|
(instances uint16)
|
|
(pad uint16)
|
|
)
|
|
)
|
|
|
|
|
|
(deftype merc-global-stats (structure)
|
|
((merc tr-stat :inline)
|
|
(mercneric tr-stat :inline)
|
|
)
|
|
)
|
|
|
|
|
|
(deftype perf-stat (structure)
|
|
((frame-number uint32)
|
|
(count uint32)
|
|
(cycles uint32)
|
|
(instructions uint32)
|
|
(icache uint32)
|
|
(dcache uint32)
|
|
(select uint32)
|
|
(ctrl uint32)
|
|
(accum0 uint32)
|
|
(accum1 uint32)
|
|
(to-vu0-waits uint32)
|
|
(to-spr-waits uint32)
|
|
(from-spr-waits uint32)
|
|
)
|
|
:pack-me
|
|
(:methods
|
|
(perf-stat-method-9 (_type_) none)
|
|
(print-to-stream (_type_ string basic) none)
|
|
(reset! (_type_) none)
|
|
(read! (_type_) none)
|
|
(update-wait-stats (_type_ uint uint uint) none)
|
|
)
|
|
)
|
|
|
|
|
|
(deftype perf-stat-array (inline-array-class)
|
|
((data perf-stat :inline :dynamic)
|
|
)
|
|
)
|
|
|
|
(set! (-> perf-stat-array heap-base) (the-as uint 52))
|
|
|
|
(define *pc-perf-stat-counter* (the-as uint 0))
|
|
|
|
(defmethod reset! ((this perf-stat))
|
|
"Perfomance counters are partially implemented, they just count cycles."
|
|
(+! (-> this count) 1)
|
|
(when (nonzero? (-> this ctrl))
|
|
(set! *pc-perf-stat-counter* (get-cpu-clock))
|
|
)
|
|
#|
|
|
(let ((v1-0 (-> this ctrl)))
|
|
(+! (-> this count) 1)
|
|
(b! (zero? v1-0) cfg-2 :delay (nop!))
|
|
(.mtc0 Perf 0)
|
|
(.sync.l)
|
|
(.sync.p)
|
|
(.mtpc pcr0 0)
|
|
(.mtpc pcr1 0)
|
|
(.sync.l)
|
|
(.sync.p)
|
|
(.mtc0 Perf v1-0)
|
|
)
|
|
(.sync.l)
|
|
(.sync.p)
|
|
(label cfg-2)
|
|
|#
|
|
0
|
|
(none)
|
|
)
|
|
|
|
(defmethod read! ((this perf-stat))
|
|
"Perfomance counters are partially implemented, they just count cycles."
|
|
(when (nonzero? (-> this ctrl))
|
|
(+! (-> this accum0) (- (get-cpu-clock) *pc-perf-stat-counter*))
|
|
(set! (-> this accum1) 0)
|
|
)
|
|
|
|
#|
|
|
(local-vars (v1-1 int) (v1-3 int))
|
|
(b! (zero? (-> this ctrl)) cfg-2 :delay (nop!))
|
|
(.mtc0 Perf 0)
|
|
(.sync.l)
|
|
(.sync.p)
|
|
(.mfpc v1-1 pcr0)
|
|
(+! (-> this accum0) v1-1)
|
|
(.mfpc v1-3 pcr1)
|
|
(+! (-> this accum1) v1-3)
|
|
(label cfg-2)
|
|
|#
|
|
0
|
|
(none)
|
|
)
|
|
|
|
(defmethod update-wait-stats ((this perf-stat) (arg0 uint) (arg1 uint) (arg2 uint))
|
|
(when (nonzero? (-> this ctrl))
|
|
(+! (-> this to-vu0-waits) arg0)
|
|
(+! (-> this to-spr-waits) arg1)
|
|
(+! (-> this from-spr-waits) arg2)
|
|
)
|
|
0
|
|
(none)
|
|
)
|
|
|
|
(when (not *debug-segment*)
|
|
(set! (-> perf-stat method-table 11) nothing)
|
|
(set! (-> perf-stat method-table 12) nothing)
|
|
(set! (-> perf-stat method-table 13) nothing)
|
|
)
|