From 09ad5bd61771c550a4634146121f05c93b3d0f6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Lindqvist?= Date: Mon, 21 Sep 2015 11:31:33 +0200 Subject: [PATCH] compiler.tree.propagation.slots: docs & tests for the vocab --- .../tree/propagation/slots/slots-docs.factor | 16 +++++++ .../tree/propagation/slots/slots-tests.factor | 46 +++++++++++++++++++ .../tree/propagation/slots/slots.factor | 9 ---- 3 files changed, 62 insertions(+), 9 deletions(-) create mode 100644 basis/compiler/tree/propagation/slots/slots-docs.factor create mode 100644 basis/compiler/tree/propagation/slots/slots-tests.factor diff --git a/basis/compiler/tree/propagation/slots/slots-docs.factor b/basis/compiler/tree/propagation/slots/slots-docs.factor new file mode 100644 index 0000000000..64fcb1c4f9 --- /dev/null +++ b/basis/compiler/tree/propagation/slots/slots-docs.factor @@ -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" diff --git a/basis/compiler/tree/propagation/slots/slots-tests.factor b/basis/compiler/tree/propagation/slots/slots-tests.factor new file mode 100644 index 0000000000..2f1117033c --- /dev/null +++ b/basis/compiler/tree/propagation/slots/slots-tests.factor @@ -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 } [ + \ sequence-constructor? +] unit-test + +{ 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 } [ ] map setup-value-infos + { 0 1 } { 2 } \ <#call> dup word>> + propagate-sequence-constructor first +] unit-test diff --git a/basis/compiler/tree/propagation/slots/slots.factor b/basis/compiler/tree/propagation/slots/slots.factor index bde048825a..84814baf3f 100644 --- a/basis/compiler/tree/propagation/slots/slots.factor +++ b/basis/compiler/tree/propagation/slots/slots.factor @@ -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 -- ? ) { (byte-array) } 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? ]