| 
									
										
										
										
											2014-11-23 22:20:34 -05:00
										 |  |  | USING: accessors alien.c-types arrays bit-arrays classes.struct | 
					
						
							| 
									
										
										
										
											2014-11-24 01:53:27 -05:00
										 |  |  | compiler.cfg.instructions compiler.cfg.stack-frame | 
					
						
							|  |  |  | compiler.codegen.gc-maps compiler.codegen.relocation cpu.architecture | 
					
						
							|  |  |  | cpu.x86 byte-arrays make namespaces kernel layouts math sequences | 
					
						
							|  |  |  | specialized-arrays system tools.test ;
 | 
					
						
							| 
									
										
										
										
											2014-11-23 22:20:34 -05:00
										 |  |  | QUALIFIED: vm | 
					
						
							| 
									
										
										
										
											2010-06-11 20:06:00 -04:00
										 |  |  | SPECIALIZED-ARRAY: uint | 
					
						
							| 
									
										
										
										
											2011-09-14 00:38:03 -04:00
										 |  |  | IN: compiler.codegen.gc-maps.tests | 
					
						
							| 
									
										
										
										
											2010-06-11 20:06:00 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-06-13 17:36:08 -04:00
										 |  |  | SINGLETON: fake-cpu | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | fake-cpu \ cpu set
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-27 01:20:50 -04:00
										 |  |  | M: fake-cpu gc-root-offset ;
 | 
					
						
							| 
									
										
										
										
											2010-06-13 17:36:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-08-25 22:44:03 -04:00
										 |  |  | [ | 
					
						
							|  |  |  |     init-relocation | 
					
						
							|  |  |  |     init-gc-maps | 
					
						
							| 
									
										
										
										
											2010-06-11 20:06:00 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-08-25 22:44:03 -04:00
										 |  |  |     50 <byte-array> % | 
					
						
							| 
									
										
										
										
											2010-06-11 20:06:00 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-08-25 22:44:03 -04:00
										 |  |  |     <gc-map> gc-map-here | 
					
						
							| 
									
										
										
										
											2010-06-11 20:06:00 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-08-25 22:44:03 -04:00
										 |  |  |     50 <byte-array> % | 
					
						
							| 
									
										
										
										
											2010-06-11 20:06:00 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-08-25 22:44:03 -04:00
										 |  |  |     T{ gc-map | 
					
						
							|  |  |  |        { scrub-d { 0 1 1 1 0 } } | 
					
						
							|  |  |  |        { scrub-r { 1 0 } } | 
					
						
							|  |  |  |        { gc-roots V{ 1 3 } } | 
					
						
							|  |  |  |        { derived-roots V{ { 2 4 } } } | 
					
						
							|  |  |  |     } gc-map-here | 
					
						
							|  |  |  |     emit-gc-maps | 
					
						
							|  |  |  | ] B{ } make | 
					
						
							|  |  |  | "result" set
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ 0 ] [ "result" get length 16 mod ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ | 
					
						
							|  |  |  |     100 <byte-array> % | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ! The below data is 46 bytes -- 14 bytes padding needed to | 
					
						
							|  |  |  |     ! align | 
					
						
							|  |  |  |     14 <byte-array> % | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ! Bitmap - 2 bytes | 
					
						
							|  |  |  |     ?{ | 
					
						
							|  |  |  |         ! scrub-d | 
					
						
							|  |  |  |         t f f f t
 | 
					
						
							|  |  |  |         ! scrub-r | 
					
						
							|  |  |  |         f t
 | 
					
						
							|  |  |  |         ! gc-roots | 
					
						
							|  |  |  |         f t f t
 | 
					
						
							|  |  |  |     } underlying>> % | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ! Derived pointers | 
					
						
							|  |  |  |     uint-array{ -1 -1 4 } underlying>> % | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ! Return addresses | 
					
						
							|  |  |  |     uint-array{ 100 } underlying>> % | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ! GC info footer - 28 bytes | 
					
						
							| 
									
										
										
										
											2014-11-23 22:20:34 -05:00
										 |  |  |     S{ vm:gc-info | 
					
						
							| 
									
										
										
										
											2014-08-25 22:44:03 -04:00
										 |  |  |        { scrub-d-count 5 } | 
					
						
							|  |  |  |        { scrub-r-count 2 } | 
					
						
							|  |  |  |        { check-d-count 0 } | 
					
						
							|  |  |  |        { check-r-count 0 } | 
					
						
							|  |  |  |        { gc-root-count 4 } | 
					
						
							|  |  |  |        { derived-root-count 3 } | 
					
						
							|  |  |  |        { return-address-count 1 } | 
					
						
							|  |  |  |     } (underlying)>> % | 
					
						
							|  |  |  | ] B{ } make | 
					
						
							|  |  |  | "expect" set
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ t ] [ "result" get length "expect" get length = ] unit-test | 
					
						
							|  |  |  | [ t ] [ "result" get "expect" get = ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-23 22:20:34 -05:00
										 |  |  | ! Fix the gc root offset calculations | 
					
						
							|  |  |  | SINGLETON: linux-x86.64 | 
					
						
							|  |  |  | M: linux-x86.64 reserved-stack-space 0 ;
 | 
					
						
							|  |  |  | M: linux-x86.64 gc-root-offset | 
					
						
							|  |  |  |     n>> spill-offset cell + cell /i ;
 | 
					
						
							| 
									
										
										
										
											2014-11-16 06:37:17 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | cpu x86.64? [ | 
					
						
							| 
									
										
										
										
											2014-11-23 22:20:34 -05:00
										 |  |  |     linux-x86.64 \ cpu set
 | 
					
						
							| 
									
										
										
										
											2014-11-16 06:37:17 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ! gc-root-offsets | 
					
						
							|  |  |  |     { { 1 3 } } [ | 
					
						
							|  |  |  |         T{ stack-frame { spill-area-base 0 } } stack-frame [ | 
					
						
							|  |  |  |             T{ gc-map | 
					
						
							|  |  |  |                { gc-roots { | 
					
						
							|  |  |  |                    T{ spill-slot { n 0 } } | 
					
						
							|  |  |  |                    T{ spill-slot { n 16 } } | 
					
						
							|  |  |  |                } } | 
					
						
							|  |  |  |             } gc-root-offsets | 
					
						
							|  |  |  |         ] with-variable
 | 
					
						
							|  |  |  |     ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     { { 6 10 } } [ | 
					
						
							|  |  |  |         T{ stack-frame { spill-area-base 32 } } stack-frame [ | 
					
						
							|  |  |  |             T{ gc-map | 
					
						
							|  |  |  |                { gc-roots { | 
					
						
							|  |  |  |                    T{ spill-slot { n 8 } } | 
					
						
							|  |  |  |                    T{ spill-slot { n 40 } } | 
					
						
							|  |  |  |                } } | 
					
						
							|  |  |  |             } gc-root-offsets | 
					
						
							|  |  |  |         ] with-variable
 | 
					
						
							|  |  |  |     ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ! scrub-d scrub-r check-d check-r gc-roots | 
					
						
							|  |  |  |     { { 0 0 0 0 5 } } [ | 
					
						
							|  |  |  |         T{ stack-frame { spill-area-base 0 } } stack-frame [ | 
					
						
							|  |  |  |             T{ gc-map | 
					
						
							|  |  |  |                { gc-roots { | 
					
						
							|  |  |  |                    T{ spill-slot { n 0 } } | 
					
						
							|  |  |  |                    T{ spill-slot { n 24 } } | 
					
						
							|  |  |  |                } } | 
					
						
							|  |  |  |             } 1array gc-maps set
 | 
					
						
							|  |  |  |             [ emit-gc-info-bitmaps ] B{ } make drop
 | 
					
						
							|  |  |  |         ] with-variable
 | 
					
						
							|  |  |  |     ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ! scrub-d scrub-r check-d check-r gc-roots | 
					
						
							|  |  |  |     { { 0 0 0 0 9 } } [ | 
					
						
							|  |  |  |         T{ stack-frame { spill-area-base 32 } } stack-frame [ | 
					
						
							|  |  |  |             T{ gc-map | 
					
						
							|  |  |  |                { gc-roots { | 
					
						
							|  |  |  |                    T{ spill-slot { n 0 } } | 
					
						
							|  |  |  |                    T{ spill-slot { n 24 } } | 
					
						
							|  |  |  |                } } | 
					
						
							|  |  |  |             } 1array gc-maps set
 | 
					
						
							|  |  |  |             [ emit-gc-info-bitmaps ] B{ } make drop
 | 
					
						
							|  |  |  |         ] with-variable
 | 
					
						
							|  |  |  |     ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     fake-cpu \ cpu set
 | 
					
						
							|  |  |  | ] when
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-08-25 22:44:03 -04:00
										 |  |  | ! gc-map-needed? | 
					
						
							|  |  |  | { t t } [ | 
					
						
							|  |  |  |     T{ gc-map { scrub-d { 0 1 1 1 0 } } { scrub-r { 1 0 } } } gc-map-needed? | 
					
						
							|  |  |  |     T{ gc-map { check-d { 0 1 1 1 } } } gc-map-needed? | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ! emit-scrub | 
					
						
							|  |  |  | { 3 V{ t t t f f f } } [ | 
					
						
							|  |  |  |     [ { { 0 0 0 } { 1 1 1 } } emit-scrub ] V{ } make | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ! emit-gc-info-bitmaps | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     { 4 2 0 0 0 } | 
					
						
							|  |  |  |     V{ 1 } | 
					
						
							|  |  |  | } [ | 
					
						
							|  |  |  |     { T{ gc-map { scrub-d { 0 1 1 1 } } { scrub-r { 1 1 } } } } gc-maps set
 | 
					
						
							|  |  |  |     [ emit-gc-info-bitmaps ] V{ } make | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     { 1 0 1 0 0 } | 
					
						
							|  |  |  |     V{ 3 } | 
					
						
							|  |  |  | } [ | 
					
						
							|  |  |  |     { T{ gc-map { scrub-d { 0 } } { check-d { 0 } } } } gc-maps set
 | 
					
						
							|  |  |  |     [ emit-gc-info-bitmaps ] V{ } make | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ! derived-root-offsets | 
					
						
							|  |  |  | USING: present prettyprint ;
 | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     V{ { 2 4 } } | 
					
						
							|  |  |  | } [ | 
					
						
							|  |  |  |     T{ gc-map { derived-roots V{ { 2 4 } } } } | 
					
						
							|  |  |  |     derived-root-offsets | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ! emit-base-tables | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     3 B{ 255 255 255 255 255 255 255 255 4 0 0 0 } | 
					
						
							|  |  |  | } [ | 
					
						
							|  |  |  |     { T{ gc-map { derived-roots V{ { 2 4 } } } } } gc-maps set
 | 
					
						
							|  |  |  |     [ emit-base-tables ] B{ } make | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ! serialize-gc-maps | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     B{ 0 0 0 0 } | 
					
						
							|  |  |  | } [ | 
					
						
							|  |  |  |     { } return-addresses set serialize-gc-maps | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     B{ | 
					
						
							|  |  |  |         17 123 0 0 0 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 | 
					
						
							|  |  |  |         1 0 0 0
 | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } [ | 
					
						
							|  |  |  |     { 123 } return-addresses set
 | 
					
						
							|  |  |  |     { T{ gc-map { scrub-d { 0 1 1 1 0 } } } } gc-maps set
 | 
					
						
							|  |  |  |     serialize-gc-maps | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ! gc-info + ret-addr + 9bits (5+2+2) = 28 + 4 + 2 = 34 | 
					
						
							|  |  |  | { 34 } [ | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2014-08-25 16:33:54 -04:00
										 |  |  |         T{ gc-map | 
					
						
							|  |  |  |            { scrub-d { 0 1 1 1 0 } } | 
					
						
							|  |  |  |            { scrub-r { 1 0 } } | 
					
						
							|  |  |  |            { gc-roots V{ 1 3 } } | 
					
						
							| 
									
										
										
										
											2014-08-25 22:44:03 -04:00
										 |  |  |         } | 
					
						
							|  |  |  |     } gc-maps set
 | 
					
						
							|  |  |  |     { 123 } return-addresses set
 | 
					
						
							|  |  |  |     serialize-gc-maps length
 | 
					
						
							| 
									
										
										
										
											2010-06-11 20:06:00 -04:00
										 |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-08-25 22:44:03 -04:00
										 |  |  | ! gc-info + ret-addr + 3 base-pointers + 9bits = 28 + 4 + 12 + 2 = 46 | 
					
						
							|  |  |  | { 46 } [ | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         T{ gc-map | 
					
						
							|  |  |  |            { scrub-d { 0 1 1 1 0 } } | 
					
						
							|  |  |  |            { scrub-r { 1 0 } } | 
					
						
							|  |  |  |            { gc-roots V{ 1 3 } } | 
					
						
							|  |  |  |            { derived-roots V{ { 2 4 } } } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } gc-maps set
 | 
					
						
							|  |  |  |     { 123 } return-addresses set
 | 
					
						
							|  |  |  |     serialize-gc-maps length
 | 
					
						
							| 
									
										
										
										
											2010-06-11 20:06:00 -04:00
										 |  |  | ] unit-test |