compiler.tree.propagation.slots: docs & tests for the vocab
parent
4ee88bdc3d
commit
09ad5bd617
|
@ -0,0 +1,16 @@
|
|||
USING: compiler.tree.propagation.info help.markup help.syntax kernel math ;
|
||||
IN: compiler.tree.propagation.slots
|
||||
|
||||
HELP: literal-info-slot
|
||||
{ $values
|
||||
{ "slot" integer }
|
||||
{ "object" object }
|
||||
{ "info/f" { $link value-info } " or " { $link f } }
|
||||
}
|
||||
{ $description "literal-info-slot makes an unsafe call to 'slot'. Check that the layout is up to date to avoid accessing the wrong slot during a compilation unit where reshaping took place. This could happen otherwise because the 'slots' word property would reflect the new layout, but instances in the heap would use the old layout since instances are updated immediately after compilation." } ;
|
||||
|
||||
ARTICLE: "compiler.tree.propagation"
|
||||
"Propagation for read-only tuple slots and array lengths"
|
||||
"Propagation of immutable slots and array lengths." ;
|
||||
|
||||
ABOUT: "compiler.tree.propagation"
|
|
@ -0,0 +1,46 @@
|
|||
USING: accessors arrays byte-arrays compiler.tree
|
||||
compiler.tree.propagation.copy compiler.tree.propagation.info
|
||||
compiler.tree.propagation.slots hashtables kernel math math.intervals
|
||||
namespaces sequences strings tools.test ;
|
||||
IN: compiler.tree.propagation.slots.tests
|
||||
|
||||
: indexize ( seq -- assoc )
|
||||
[ swap 2array ] map-index ;
|
||||
|
||||
: setup-value-infos ( value-infos -- )
|
||||
indexize >hashtable 1array value-infos set
|
||||
H{ { 0 0 } { 1 1 } { 2 2 } } copies set ;
|
||||
|
||||
{ t } [
|
||||
\ <array> sequence-constructor?
|
||||
] unit-test
|
||||
|
||||
{ array byte-array string } [
|
||||
\ <array> \ <byte-array> \ <string> [ constructor-output-class ] tri@
|
||||
] unit-test
|
||||
|
||||
{
|
||||
T{ value-info-state
|
||||
{ class array }
|
||||
{ interval full-interval }
|
||||
{ slots
|
||||
{
|
||||
T{ value-info-state
|
||||
{ class fixnum }
|
||||
{ interval
|
||||
T{ interval
|
||||
{ from { 7 t } }
|
||||
{ to { 7 t } }
|
||||
}
|
||||
}
|
||||
{ literal 7 }
|
||||
{ literal? t }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} [
|
||||
{ 7 f } [ <literal-info> ] map setup-value-infos
|
||||
{ 0 1 } { 2 } \ <array> <#call> dup word>>
|
||||
propagate-sequence-constructor first
|
||||
] unit-test
|
|
@ -6,8 +6,6 @@ combinators.short-circuit compiler.tree.propagation.info kernel
|
|||
math sequences slots.private strings ;
|
||||
IN: compiler.tree.propagation.slots
|
||||
|
||||
! Propagation of immutable slots and array lengths
|
||||
|
||||
: sequence-constructor? ( word -- ? )
|
||||
{ <array> <byte-array> (byte-array) <string> } member-eq? ;
|
||||
|
||||
|
@ -51,13 +49,6 @@ IN: compiler.tree.propagation.slots
|
|||
dup [ read-only>> ] when ;
|
||||
|
||||
: literal-info-slot ( slot object -- info/f )
|
||||
! literal-info-slot makes an unsafe call to 'slot'.
|
||||
! Check that the layout is up to date to avoid accessing the
|
||||
! wrong slot during a compilation unit where reshaping took
|
||||
! place. This could happen otherwise because the "slots" word
|
||||
! property would reflect the new layout, but instances in the
|
||||
! heap would use the old layout since instances are updated
|
||||
! immediately after compilation.
|
||||
{
|
||||
[ class-of read-only-slot? ]
|
||||
[ nip layout-up-to-date? ]
|
||||
|
|
Loading…
Reference in New Issue