Fix image size regression with struct array tree shaking
parent
ab45402d04
commit
23f34febbb
|
@ -27,9 +27,7 @@ M: struct-array nth-unsafe
|
||||||
M: struct-array set-nth-unsafe
|
M: struct-array set-nth-unsafe
|
||||||
[ (nth-ptr) swap ] [ element-size>> ] bi memcpy ; inline
|
[ (nth-ptr) swap ] [ element-size>> ] bi memcpy ; inline
|
||||||
|
|
||||||
! Foldable memo word. This is an optimization; by precompiling a
|
: (struct-element-constructor) ( c-type -- word )
|
||||||
! constructor for array elements, we avoid memory>struct's slow path.
|
|
||||||
MEMO: struct-element-constructor ( c-type -- word )
|
|
||||||
[
|
[
|
||||||
"struct-array-ctor" f <word>
|
"struct-array-ctor" f <word>
|
||||||
[
|
[
|
||||||
|
@ -37,7 +35,12 @@ MEMO: struct-element-constructor ( c-type -- word )
|
||||||
[ '[ _ memory>struct ] [ ] like ] [ drop [ ] ] if
|
[ '[ _ memory>struct ] [ ] like ] [ drop [ ] ] if
|
||||||
(( alien -- object )) define-inline
|
(( alien -- object )) define-inline
|
||||||
] keep
|
] 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 )
|
: <direct-struct-array> ( alien length c-type -- struct-array )
|
||||||
[ heap-size ] [ c-type-struct-class ] [ struct-element-constructor ]
|
[ heap-size ] [ c-type-struct-class ] [ struct-element-constructor ]
|
||||||
|
|
|
@ -68,9 +68,14 @@ IN: tools.deploy.shaker
|
||||||
] when ;
|
] when ;
|
||||||
|
|
||||||
: strip-destructors ( -- )
|
: strip-destructors ( -- )
|
||||||
"libc" vocab [
|
"Stripping destructor debug code" show
|
||||||
"Stripping destructor debug code" show
|
"vocab:tools/deploy/shaker/strip-destructors.factor"
|
||||||
"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
|
run-file
|
||||||
] when ;
|
] when ;
|
||||||
|
|
||||||
|
@ -493,6 +498,7 @@ SYMBOL: deploy-vocab
|
||||||
: strip ( -- )
|
: strip ( -- )
|
||||||
init-stripper
|
init-stripper
|
||||||
strip-libc
|
strip-libc
|
||||||
|
strip-struct-arrays
|
||||||
strip-destructors
|
strip-destructors
|
||||||
strip-call
|
strip-call
|
||||||
strip-cocoa
|
strip-cocoa
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
>>
|
Loading…
Reference in New Issue