| 
									
										
										
										
											2010-01-13 05:18:43 -05:00
										 |  |  | ! Copyright (C) 2007, 2010 Slava Pestov. | 
					
						
							| 
									
										
										
										
											2008-09-10 23:11:03 -04:00
										 |  |  | ! See http://factorcode.org/license.txt for BSD license. | 
					
						
							| 
									
										
										
										
											2010-06-11 20:06:00 -04:00
										 |  |  | USING: arrays bit-arrays byte-arrays byte-vectors generic assocs | 
					
						
							|  |  |  | hashtables io.binary kernel kernel.private math namespaces make | 
					
						
							| 
									
										
										
										
											2010-09-27 01:20:50 -04:00
										 |  |  | sequences words quotations strings sorting alien.accessors | 
					
						
							|  |  |  | alien.strings layouts system combinators math.bitwise math.order | 
					
						
							| 
									
										
										
										
											2010-06-13 17:36:08 -04:00
										 |  |  | combinators.short-circuit combinators.smart accessors growable | 
					
						
							|  |  |  | fry memoize compiler.constants compiler.cfg.instructions | 
					
						
							|  |  |  | cpu.architecture ;
 | 
					
						
							| 
									
										
										
										
											2008-09-17 01:46:38 -04:00
										 |  |  | IN: compiler.codegen.fixup | 
					
						
							| 
									
										
										
										
											2008-09-10 23:11:03 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-05-03 17:23:03 -04:00
										 |  |  | ! Utilities | 
					
						
							|  |  |  | : push-uint ( value vector -- )
 | 
					
						
							|  |  |  |     [ length ] [ B{ 0 0 0 0 } swap push-all ] [ underlying>> ] tri
 | 
					
						
							|  |  |  |     swap set-alien-unsigned-4 ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-02 05:28:15 -05:00
										 |  |  | ! Parameter table | 
					
						
							|  |  |  | SYMBOL: parameter-table | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : add-parameter ( obj -- ) parameter-table get push ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-01 03:32:36 -04:00
										 |  |  | ! Literal table | 
					
						
							|  |  |  | SYMBOL: literal-table | 
					
						
							| 
									
										
										
										
											2008-09-10 23:11:03 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-01 03:32:36 -04:00
										 |  |  | : add-literal ( obj -- ) literal-table get push ;
 | 
					
						
							| 
									
										
										
										
											2008-09-10 23:11:03 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-01 03:32:36 -04:00
										 |  |  | ! Labels | 
					
						
							| 
									
										
										
										
											2008-09-10 23:11:03 -04:00
										 |  |  | SYMBOL: label-table | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-01 03:32:36 -04:00
										 |  |  | TUPLE: label offset ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : <label> ( -- label ) label new ;
 | 
					
						
							|  |  |  | : define-label ( name -- ) <label> swap set ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : compiled-offset ( -- n ) building get length ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : resolve-label ( label/name -- )
 | 
					
						
							|  |  |  |     dup label? [ get ] unless
 | 
					
						
							|  |  |  |     compiled-offset >>offset drop ;
 | 
					
						
							| 
									
										
										
										
											2008-09-10 23:11:03 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-01 03:32:36 -04:00
										 |  |  | TUPLE: label-fixup { label label } { class integer } { offset integer } ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : label-fixup ( label class -- )
 | 
					
						
							| 
									
										
										
										
											2010-01-02 07:03:30 -05:00
										 |  |  |     compiled-offset \ label-fixup boa label-table get push ;
 | 
					
						
							| 
									
										
										
										
											2008-09-10 23:11:03 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-01 03:32:36 -04:00
										 |  |  | ! Relocation table | 
					
						
							|  |  |  | SYMBOL: relocation-table | 
					
						
							| 
									
										
										
										
											2008-09-10 23:11:03 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-01 00:28:08 -04:00
										 |  |  | : add-relocation-entry ( type class offset -- )
 | 
					
						
							| 
									
										
										
										
											2010-05-03 17:23:03 -04:00
										 |  |  |     { 0 24 28 } bitfield relocation-table get push-uint ;
 | 
					
						
							| 
									
										
										
										
											2008-09-10 23:11:03 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-01 03:32:36 -04:00
										 |  |  | : rel-fixup ( class type -- )
 | 
					
						
							| 
									
										
										
										
											2010-01-02 07:03:30 -05:00
										 |  |  |     swap compiled-offset add-relocation-entry ;
 | 
					
						
							| 
									
										
										
										
											2008-09-10 23:11:03 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-05-03 17:23:03 -04:00
										 |  |  | ! Binary literal table | 
					
						
							|  |  |  | SYMBOL: binary-literal-table | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : add-binary-literal ( obj -- label )
 | 
					
						
							|  |  |  |     <label> [ 2array binary-literal-table get push ] keep ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-13 05:18:43 -05:00
										 |  |  | ! Caching common symbol names reduces image size a bit | 
					
						
							|  |  |  | MEMO: cached-string>symbol ( symbol -- obj ) string>symbol ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-02 05:28:15 -05:00
										 |  |  | : add-dlsym-parameters ( symbol dll -- )
 | 
					
						
							| 
									
										
										
										
											2010-01-13 05:18:43 -05:00
										 |  |  |     [ cached-string>symbol add-parameter ] [ add-parameter ] bi* ;
 | 
					
						
							| 
									
										
										
										
											2008-09-10 23:11:03 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | : rel-dlsym ( name dll class -- )
 | 
					
						
							| 
									
										
										
										
											2009-12-02 05:28:15 -05:00
										 |  |  |     [ add-dlsym-parameters ] dip rt-dlsym rel-fixup ;
 | 
					
						
							| 
									
										
										
										
											2008-09-10 23:11:03 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | : rel-word ( word class -- )
 | 
					
						
							| 
									
										
										
										
											2010-01-18 02:51:27 -05:00
										 |  |  |     [ add-literal ] dip rt-entry-point rel-fixup ;
 | 
					
						
							| 
									
										
										
										
											2008-09-10 23:11:03 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-06 17:14:53 -04:00
										 |  |  | : rel-word-pic ( word class -- )
 | 
					
						
							| 
									
										
										
										
											2010-01-18 02:51:27 -05:00
										 |  |  |     [ add-literal ] dip rt-entry-point-pic rel-fixup ;
 | 
					
						
							| 
									
										
										
										
											2009-04-28 18:53:14 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-06 20:22:22 -04:00
										 |  |  | : rel-word-pic-tail ( word class -- )
 | 
					
						
							| 
									
										
										
										
											2010-01-18 02:51:27 -05:00
										 |  |  |     [ add-literal ] dip rt-entry-point-pic-tail rel-fixup ;
 | 
					
						
							| 
									
										
										
										
											2009-05-06 20:22:22 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-04-18 22:42:19 -04:00
										 |  |  | : rel-literal ( literal class -- )
 | 
					
						
							| 
									
										
										
										
											2009-12-15 07:20:09 -05:00
										 |  |  |     [ add-literal ] dip rt-literal rel-fixup ;
 | 
					
						
							| 
									
										
										
										
											2008-11-24 07:40:51 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-05-03 17:23:03 -04:00
										 |  |  | : rel-binary-literal ( literal class -- )
 | 
					
						
							|  |  |  |     [ add-binary-literal ] dip label-fixup ;
 | 
					
						
							| 
									
										
										
										
											2010-04-30 21:33:42 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-09-10 23:11:03 -04:00
										 |  |  | : rel-this ( class -- )
 | 
					
						
							| 
									
										
										
										
											2009-03-19 21:02:43 -04:00
										 |  |  |     rt-this rel-fixup ;
 | 
					
						
							| 
									
										
										
										
											2008-09-10 23:11:03 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-13 05:16:08 -05:00
										 |  |  | : rel-here ( offset class -- )
 | 
					
						
							| 
									
										
										
										
											2009-12-02 05:55:48 -05:00
										 |  |  |     [ add-literal ] dip rt-here rel-fixup ;
 | 
					
						
							| 
									
										
										
										
											2008-09-10 23:11:03 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-14 20:24:23 -04:00
										 |  |  | : rel-vm ( offset class -- )
 | 
					
						
							| 
									
										
										
										
											2009-12-02 05:28:15 -05:00
										 |  |  |     [ add-parameter ] dip rt-vm rel-fixup ;
 | 
					
						
							| 
									
										
										
										
											2009-10-14 03:06:01 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | : rel-cards-offset ( class -- )
 | 
					
						
							|  |  |  |     rt-cards-offset rel-fixup ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : rel-decks-offset ( class -- )
 | 
					
						
							|  |  |  |     rt-decks-offset rel-fixup ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-06-11 20:06:00 -04:00
										 |  |  | ! Labels | 
					
						
							| 
									
										
										
										
											2010-05-03 17:23:03 -04:00
										 |  |  | : compute-target ( label-fixup -- offset )
 | 
					
						
							| 
									
										
										
										
											2009-06-01 03:32:36 -04:00
										 |  |  |     label>> offset>> [ "Unresolved label" throw ] unless* ;
 | 
					
						
							| 
									
										
										
										
											2008-09-10 23:11:03 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-05-03 17:23:03 -04:00
										 |  |  | : compute-relative-label ( label-fixup -- label )
 | 
					
						
							|  |  |  |     [ class>> ] [ offset>> ] [ compute-target ] tri 3array ;
 | 
					
						
							| 
									
										
										
										
											2009-06-01 03:32:36 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-05-03 17:23:03 -04:00
										 |  |  | : compute-absolute-label ( label-fixup -- )
 | 
					
						
							|  |  |  |     [ compute-target neg add-literal ] | 
					
						
							|  |  |  |     [ [ rt-here ] dip [ class>> ] [ offset>> ] bi add-relocation-entry ] bi ;
 | 
					
						
							| 
									
										
										
										
											2009-06-01 03:32:36 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-05-03 17:23:03 -04:00
										 |  |  | : compute-labels ( label-fixups -- labels' )
 | 
					
						
							| 
									
										
										
										
											2009-06-01 03:32:36 -04:00
										 |  |  |     [ class>> rc-absolute? ] partition
 | 
					
						
							| 
									
										
										
										
											2010-05-03 17:23:03 -04:00
										 |  |  |     [ [ compute-absolute-label ] each ] | 
					
						
							|  |  |  |     [ [ compute-relative-label ] map concat ] | 
					
						
							| 
									
										
										
										
											2009-06-01 03:32:36 -04:00
										 |  |  |     bi* ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-06-11 20:06:00 -04:00
										 |  |  | ! Binary literals | 
					
						
							| 
									
										
										
										
											2010-05-03 17:23:03 -04:00
										 |  |  | : alignment ( align -- n )
 | 
					
						
							|  |  |  |     [ compiled-offset dup ] dip align swap - ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : (align-code) ( n -- )
 | 
					
						
							|  |  |  |     0 <repetition> % ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : align-code ( n -- )
 | 
					
						
							|  |  |  |     alignment (align-code) ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-05-07 18:26:00 -04:00
										 |  |  | : emit-data ( obj label -- )
 | 
					
						
							|  |  |  |     over length align-code | 
					
						
							| 
									
										
										
										
											2010-05-03 17:23:03 -04:00
										 |  |  |     resolve-label | 
					
						
							|  |  |  |     building get push-all ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : emit-binary-literals ( -- )
 | 
					
						
							|  |  |  |     binary-literal-table get [ emit-data ] assoc-each ;
 | 
					
						
							| 
									
										
										
										
											2008-09-10 23:11:03 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-06-11 20:06:00 -04:00
										 |  |  | ! GC info | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ! Every code block either ends with | 
					
						
							|  |  |  | !
 | 
					
						
							|  |  |  | ! uint 0 | 
					
						
							|  |  |  | !
 | 
					
						
							|  |  |  | ! or | 
					
						
							|  |  |  | !
 | 
					
						
							|  |  |  | ! bitmap, byte aligned, three subsequences: | 
					
						
							|  |  |  | ! - <scrubbed data stack locations> | 
					
						
							|  |  |  | ! - <scrubbed retain stack locations> | 
					
						
							|  |  |  | ! - <GC root spill slots> | 
					
						
							| 
									
										
										
										
											2010-09-27 01:20:50 -04:00
										 |  |  | ! uint[] <base pointers> | 
					
						
							| 
									
										
										
										
											2010-06-11 20:06:00 -04:00
										 |  |  | ! uint[] <return addresses> | 
					
						
							|  |  |  | ! uint <largest scrubbed data stack location> | 
					
						
							|  |  |  | ! uint <largest scrubbed retain stack location> | 
					
						
							|  |  |  | ! uint <largest GC root spill slot> | 
					
						
							| 
									
										
										
										
											2010-09-27 01:20:50 -04:00
										 |  |  | ! uint <largest derived root spill slot> | 
					
						
							|  |  |  | ! int <number of return addresses> | 
					
						
							|  |  |  | !
 | 
					
						
							| 
									
										
										
										
											2010-06-13 17:36:08 -04:00
										 |  |  | SYMBOLS: return-addresses gc-maps ;
 | 
					
						
							| 
									
										
										
										
											2010-06-11 20:06:00 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-06-13 17:36:08 -04:00
										 |  |  | : gc-map-needed? ( gc-map -- ? )
 | 
					
						
							| 
									
										
										
										
											2010-06-11 20:06:00 -04:00
										 |  |  |     ! If there are no stack locations to scrub and no GC roots, | 
					
						
							|  |  |  |     ! there's no point storing the GC map. | 
					
						
							| 
									
										
										
										
											2010-06-13 17:36:08 -04:00
										 |  |  |     dup [ | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             [ scrub-d>> empty? ] | 
					
						
							|  |  |  |             [ scrub-r>> empty? ] | 
					
						
							|  |  |  |             [ gc-roots>> empty? ] | 
					
						
							| 
									
										
										
										
											2010-09-27 01:20:50 -04:00
										 |  |  |             [ derived-roots>> empty? ] | 
					
						
							| 
									
										
										
										
											2010-06-13 17:36:08 -04:00
										 |  |  |         } 1&& not
 | 
					
						
							|  |  |  |     ] when ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : gc-map-here ( gc-map -- )
 | 
					
						
							|  |  |  |     dup gc-map-needed? [ | 
					
						
							| 
									
										
										
										
											2010-06-11 20:06:00 -04:00
										 |  |  |         gc-maps get push
 | 
					
						
							|  |  |  |         compiled-offset return-addresses get push
 | 
					
						
							|  |  |  |     ] [ drop ] if ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-27 01:20:50 -04:00
										 |  |  | : longest ( seqs -- n )
 | 
					
						
							|  |  |  |     [ length ] [ max ] map-reduce ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-06-13 17:36:08 -04:00
										 |  |  | : emit-scrub ( seqs -- n )
 | 
					
						
							|  |  |  |     ! seqs is a sequence of sequences of 0/1 | 
					
						
							| 
									
										
										
										
											2010-09-27 01:20:50 -04:00
										 |  |  |     dup longest
 | 
					
						
							| 
									
										
										
										
											2010-06-13 17:36:08 -04:00
										 |  |  |     [ '[ [ 0 = ] ?{ } map-as _ f pad-tail % ] each ] keep ;
 | 
					
						
							| 
									
										
										
										
											2010-06-11 20:06:00 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | : integers>bits ( seq n -- bit-array )
 | 
					
						
							|  |  |  |     <bit-array> [ '[ [ t ] dip _ set-nth ] each ] keep ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-27 01:20:50 -04:00
										 |  |  | : largest-spill-slot ( seqs -- n )
 | 
					
						
							|  |  |  |     [ [ 0 ] [ supremum 1 + ] if-empty ] [ max ] map-reduce ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-06-13 17:36:08 -04:00
										 |  |  | : emit-gc-roots ( seqs -- n )
 | 
					
						
							| 
									
										
										
										
											2010-06-11 20:06:00 -04:00
										 |  |  |     ! seqs is a sequence of sequences of integers 0..n-1 | 
					
						
							| 
									
										
										
										
											2010-09-27 01:20:50 -04:00
										 |  |  |     dup largest-spill-slot | 
					
						
							| 
									
										
										
										
											2010-06-13 17:36:08 -04:00
										 |  |  |     [ '[ _ integers>bits % ] each ] keep ;
 | 
					
						
							| 
									
										
										
										
											2010-06-11 20:06:00 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | : emit-uint ( n -- )
 | 
					
						
							|  |  |  |     building get push-uint ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-27 01:20:50 -04:00
										 |  |  | : emit-uints ( n -- )
 | 
					
						
							|  |  |  |     [ emit-uint ] each ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : gc-root-offsets ( gc-map -- offsets )
 | 
					
						
							|  |  |  |     gc-roots>> [ gc-root-offset ] map ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : emit-gc-info-bitmaps ( -- scrub-d-count scrub-r-count gc-root-count )
 | 
					
						
							|  |  |  |     [ | 
					
						
							|  |  |  |         gc-maps get { | 
					
						
							|  |  |  |             [ [ scrub-d>> ] map emit-scrub ] | 
					
						
							|  |  |  |             [ [ scrub-r>> ] map emit-scrub ] | 
					
						
							|  |  |  |             [ [ gc-root-offsets ] map emit-gc-roots ] | 
					
						
							|  |  |  |         } cleave
 | 
					
						
							|  |  |  |     ] ?{ } make underlying>> % ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : emit-base-table ( alist longest -- )
 | 
					
						
							|  |  |  |     -1 <array> <enum> swap assoc-union! seq>> emit-uints ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : derived-root-offsets ( gc-map -- offsets )
 | 
					
						
							|  |  |  |     derived-roots>> [ [ gc-root-offset ] bi@ ] assoc-map ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : emit-base-tables ( -- count )
 | 
					
						
							|  |  |  |     gc-maps get [ derived-root-offsets ] map
 | 
					
						
							|  |  |  |     dup [ keys ] map largest-spill-slot | 
					
						
							|  |  |  |     [ '[ _ emit-base-table ] each ] keep ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : emit-return-addresses ( -- )
 | 
					
						
							|  |  |  |     return-addresses get emit-uints ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-06-11 20:06:00 -04:00
										 |  |  | : gc-info ( -- byte-array )
 | 
					
						
							|  |  |  |     [ | 
					
						
							|  |  |  |         return-addresses get empty? [ 0 emit-uint ] [ | 
					
						
							| 
									
										
										
										
											2010-09-27 01:20:50 -04:00
										 |  |  |             emit-gc-info-bitmaps | 
					
						
							|  |  |  |             emit-base-tables | 
					
						
							|  |  |  |             emit-return-addresses | 
					
						
							|  |  |  |             4array emit-uints | 
					
						
							| 
									
										
										
										
											2010-06-11 20:06:00 -04:00
										 |  |  |             return-addresses get length emit-uint | 
					
						
							|  |  |  |         ] if
 | 
					
						
							|  |  |  |     ] B{ } make ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : emit-gc-info ( -- )
 | 
					
						
							|  |  |  |     ! We want to place the GC info so that the end is aligned | 
					
						
							|  |  |  |     ! on a 16-byte boundary. | 
					
						
							|  |  |  |     gc-info [ | 
					
						
							|  |  |  |         length compiled-offset +
 | 
					
						
							|  |  |  |         [ data-alignment get align ] keep -
 | 
					
						
							|  |  |  |         (align-code) | 
					
						
							|  |  |  |     ] [ % ] bi ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : init-fixup ( -- )
 | 
					
						
							|  |  |  |     V{ } clone parameter-table set
 | 
					
						
							|  |  |  |     V{ } clone literal-table set
 | 
					
						
							|  |  |  |     V{ } clone label-table set
 | 
					
						
							|  |  |  |     BV{ } clone relocation-table set
 | 
					
						
							|  |  |  |     V{ } clone binary-literal-table set
 | 
					
						
							|  |  |  |     V{ } clone return-addresses set
 | 
					
						
							| 
									
										
										
										
											2010-06-13 17:36:08 -04:00
										 |  |  |     V{ } clone gc-maps set ;
 | 
					
						
							| 
									
										
										
										
											2010-06-11 20:06:00 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | : check-fixup ( seq -- )
 | 
					
						
							| 
									
										
										
										
											2010-06-13 17:36:08 -04:00
										 |  |  |     length data-alignment get mod 0 assert= ;
 | 
					
						
							| 
									
										
										
										
											2010-06-11 20:06:00 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-05-10 00:42:03 -04:00
										 |  |  | : with-fixup ( quot -- code )
 | 
					
						
							| 
									
										
										
										
											2009-10-06 07:25:07 -04:00
										 |  |  |     '[ | 
					
						
							| 
									
										
										
										
											2010-06-11 20:06:00 -04:00
										 |  |  |         init-fixup | 
					
						
							| 
									
										
										
										
											2010-05-18 18:36:47 -04:00
										 |  |  |         [ | 
					
						
							|  |  |  |             @ | 
					
						
							|  |  |  |             emit-binary-literals | 
					
						
							| 
									
										
										
										
											2010-06-11 20:06:00 -04:00
										 |  |  |             emit-gc-info | 
					
						
							| 
									
										
										
										
											2010-05-18 18:36:47 -04:00
										 |  |  |             label-table [ compute-labels ] change
 | 
					
						
							|  |  |  |             parameter-table get >array
 | 
					
						
							|  |  |  |             literal-table get >array
 | 
					
						
							|  |  |  |             relocation-table get >byte-array | 
					
						
							|  |  |  |             label-table get
 | 
					
						
							|  |  |  |         ] B{ } make | 
					
						
							| 
									
										
										
										
											2010-06-11 20:06:00 -04:00
										 |  |  |         dup check-fixup | 
					
						
							| 
									
										
										
										
											2010-05-18 18:36:47 -04:00
										 |  |  |     ] output>array ; inline
 |