Fix image size regression with struct array tree shaking

db4
Slava Pestov 2009-08-31 16:34:58 -05:00
parent ab45402d04
commit 23f34febbb
3 changed files with 29 additions and 7 deletions

View File

@ -27,9 +27,7 @@ M: struct-array nth-unsafe
M: struct-array set-nth-unsafe
[ (nth-ptr) swap ] [ element-size>> ] bi memcpy ; inline
! Foldable memo word. This is an optimization; by precompiling a
! constructor for array elements, we avoid memory>struct's slow path.
MEMO: struct-element-constructor ( c-type -- word )
: (struct-element-constructor) ( c-type -- word )
[
"struct-array-ctor" f <word>
[
@ -37,7 +35,12 @@ MEMO: struct-element-constructor ( c-type -- word )
[ '[ _ memory>struct ] [ ] like ] [ drop [ ] ] if
(( alien -- object )) define-inline
] keep
] with-compilation-unit ; foldable
] with-compilation-unit ;
! Foldable memo word. This is an optimization; by precompiling a
! constructor for array elements, we avoid memory>struct's slow path.
MEMO: struct-element-constructor ( c-type -- word )
(struct-element-constructor) ; foldable
: <direct-struct-array> ( alien length c-type -- struct-array )
[ heap-size ] [ c-type-struct-class ] [ struct-element-constructor ]

View File

@ -68,9 +68,14 @@ IN: tools.deploy.shaker
] when ;
: strip-destructors ( -- )
"libc" vocab [
"Stripping destructor debug code" show
"vocab:tools/deploy/shaker/strip-destructors.factor"
"Stripping destructor debug code" show
"vocab:tools/deploy/shaker/strip-destructors.factor"
run-file ;
: strip-struct-arrays ( -- )
"struct-arrays" vocab [
"Stripping dynamic struct array code" show
"vocab:tools/deploy/shaker/strip-struct-arrays.factor"
run-file
] when ;
@ -493,6 +498,7 @@ SYMBOL: deploy-vocab
: strip ( -- )
init-stripper
strip-libc
strip-struct-arrays
strip-destructors
strip-call
strip-cocoa

View File

@ -0,0 +1,13 @@
USING: kernel stack-checker.transforms ;
IN: struct-arrays
: struct-element-constructor ( c-type -- word )
"Struct array usages must be compiled" throw ;
<<
\ struct-element-constructor [
(struct-element-constructor) [ ] curry
] 1 define-transform
>>