vm: add def for the segment struct, it's useful for testing

db4
Björn Lindqvist 2015-08-14 23:20:21 +02:00 committed by John Benediktsson
parent 5d7fb5da60
commit 50822c1a8a
2 changed files with 48 additions and 21 deletions

18
basis/vm/vm-tests.factor Normal file
View File

@ -0,0 +1,18 @@
USING: accessors classes.struct kernel math math.order threads.private
tools.test ;
QUALIFIED: vm
IN: vm.tests
: get-ctx ( -- ctx )
context vm:context memory>struct ;
{ t } [
get-ctx [ callstack-bottom>> ] [ callstack-top>> ] bi - 0 >
] unit-test
{ t } [
! Callstack is in the callstack segment
get-ctx [ callstack-top>> ] [
callstack-seg>> [ start>> ] [ end>> ] bi
] bi between?
] unit-test

View File

@ -5,34 +5,43 @@ IN: vm
TYPEDEF: uintptr_t cell_t TYPEDEF: uintptr_t cell_t
STRUCT: segment
{ start cell_t }
{ size cell_t }
{ end cell_t } ;
STRUCT: context STRUCT: context
{ callstack-top void* } { callstack-top cell_t }
{ callstack-bottom void* } { callstack-bottom cell_t }
{ datastack cell_t } { datastack cell_t }
{ retainstack cell_t } { retainstack cell_t }
{ callstack-save cell_t } { callstack-save cell_t }
{ datastack-region void* } { datastack-seg segment* }
{ retainstack-region void* } { retainstack-seg segment* }
{ callstack-region void* } { callstack-seg segment* }
{ context-objects cell_t[context-object-count] } ; { context-objects cell_t[context-object-count] } ;
: context-field-offset ( field -- offset ) context offset-of ; inline : context-field-offset ( field -- offset ) context offset-of ; inline
STRUCT: zone STRUCT: zone
{ here cell_t } { here cell_t }
{ start cell_t } { start cell_t }
{ end cell_t } { end cell_t }
{ size cell_t } ; { size cell_t } ;
STRUCT: vm STRUCT: vm
{ ctx context* } { ctx context* }
{ spare-ctx context* } { spare-ctx context* }
{ nursery zone } { nursery zone }
{ cards-offset cell_t } { cards-offset cell_t }
{ decks-offset cell_t } { decks-offset cell_t }
{ signal-handler-addr cell_t } { signal-handler-addr cell_t }
{ faulting? cell_t } { faulting? cell_t }
{ special-objects cell_t[special-object-count] } ; { special-objects cell_t[special-object-count] }
{ thread void* }
{ datastack-size cell_t }
{ retainstack-size cell_t }
{ callstack-size cell_t } ;
: vm-field-offset ( field -- offset ) vm offset-of ; inline : vm-field-offset ( field -- offset ) vm offset-of ; inline