From 8bd2273e44e3792f68203abbd202dfd092780ee9 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 2 Nov 2009 20:11:29 -0600 Subject: [PATCH 1/2] compiler.cfg: don't generate useless methods in instruction meta-programming. reduces bootstrap time --- basis/compiler/cfg/def-use/def-use.factor | 28 +++++++++++++------ .../compiler/cfg/intrinsics/intrinsics.factor | 2 +- .../cfg/renaming/functor/functor.factor | 14 +++++++--- .../preferred/preferred.factor | 28 +++++++++++++------ 4 files changed, 49 insertions(+), 23 deletions(-) diff --git a/basis/compiler/cfg/def-use/def-use.factor b/basis/compiler/cfg/def-use/def-use.factor index 825ff71b9b..54cff2ccaa 100644 --- a/basis/compiler/cfg/def-use/def-use.factor +++ b/basis/compiler/cfg/def-use/def-use.factor @@ -11,6 +11,10 @@ GENERIC: defs-vreg ( insn -- vreg/f ) GENERIC: temp-vregs ( insn -- seq ) GENERIC: uses-vregs ( insn -- seq ) +M: insn defs-vreg drop f ; +M: insn temp-vregs drop { } ; +M: insn uses-vregs drop { } ; + M: ##phi uses-vregs inputs>> values ; > values ; } case ; : define-defs-vreg-method ( insn -- ) - [ \ defs-vreg create-method ] - [ insn-def-slot [ name>> reader-word 1quotation ] [ [ drop f ] ] if* ] bi - define ; + dup insn-def-slot dup [ + [ \ defs-vreg create-method ] + [ name>> reader-word 1quotation ] bi* + define + ] [ 2drop ] if ; : define-uses-vregs-method ( insn -- ) - [ \ uses-vregs create-method ] - [ insn-use-slots [ name>> ] map slot-array-quot ] bi - define ; + dup insn-use-slots [ drop ] [ + [ \ uses-vregs create-method ] + [ [ name>> ] map slot-array-quot ] bi* + define + ] if-empty ; : define-temp-vregs-method ( insn -- ) - [ \ temp-vregs create-method ] - [ insn-temp-slots [ name>> ] map slot-array-quot ] bi - define ; + dup insn-temp-slots [ drop ] [ + [ \ temp-vregs create-method ] + [ [ name>> ] map slot-array-quot ] bi* + define + ] if-empty ; PRIVATE> diff --git a/basis/compiler/cfg/intrinsics/intrinsics.factor b/basis/compiler/cfg/intrinsics/intrinsics.factor index a03f04f182..e8933d38fc 100644 --- a/basis/compiler/cfg/intrinsics/intrinsics.factor +++ b/basis/compiler/cfg/intrinsics/intrinsics.factor @@ -59,7 +59,7 @@ IN: compiler.cfg.intrinsics { byte-arrays: [ emit- ] } { byte-arrays:(byte-array) [ emit-(byte-array) ] } { kernel: [ emit-simple-allot ] } - { alien: [ emit- ] } + ! { alien: [ emit- ] } { alien.accessors:alien-unsigned-1 [ 1 emit-alien-unsigned-getter ] } { alien.accessors:set-alien-unsigned-1 [ 1 emit-alien-integer-setter ] } { alien.accessors:alien-signed-1 [ 1 emit-alien-signed-getter ] } diff --git a/basis/compiler/cfg/renaming/functor/functor.factor b/basis/compiler/cfg/renaming/functor/functor.factor index 2af68e9175..261aab6c54 100644 --- a/basis/compiler/cfg/renaming/functor/functor.factor +++ b/basis/compiler/cfg/renaming/functor/functor.factor @@ -20,15 +20,19 @@ WHERE GENERIC: rename-insn-defs ( insn -- ) -insn-classes get [ +M: insn rename-insn-defs drop ; + +insn-classes get [ insn-def-slot ] filter [ [ \ rename-insn-defs create-method-in ] - [ insn-def-slot dup [ name>> 1array ] when DEF-QUOT slot-change-quot ] bi + [ insn-def-slot name>> 1array DEF-QUOT slot-change-quot ] bi define ] each GENERIC: rename-insn-uses ( insn -- ) -insn-classes get { ##phi } diff [ +M: insn rename-insn-uses drop ; + +insn-classes get { ##phi } diff [ insn-use-slots empty? not ] filter [ [ \ rename-insn-uses create-method-in ] [ insn-use-slots [ name>> ] map USE-QUOT slot-change-quot ] bi define @@ -39,7 +43,9 @@ M: ##phi rename-insn-uses GENERIC: rename-insn-temps ( insn -- ) -insn-classes get [ +M: insn rename-insn-temps drop ; + +insn-classes get [ insn-temp-slots empty? not ] filter [ [ \ rename-insn-temps create-method-in ] [ insn-temp-slots [ name>> ] map TEMP-QUOT slot-change-quot ] bi define diff --git a/basis/compiler/cfg/representations/preferred/preferred.factor b/basis/compiler/cfg/representations/preferred/preferred.factor index 1e07e56b35..726521cfe1 100644 --- a/basis/compiler/cfg/representations/preferred/preferred.factor +++ b/basis/compiler/cfg/representations/preferred/preferred.factor @@ -11,6 +11,10 @@ GENERIC: defs-vreg-rep ( insn -- rep/f ) GENERIC: temp-vreg-reps ( insn -- reps ) GENERIC: uses-vreg-reps ( insn -- reps ) +M: insn defs-vreg-rep drop f ; +M: insn temp-vreg-reps drop { } ; +M: insn uses-vreg-reps drop { } ; + > rep-getter-quot ] [ [ drop f ] ] if* ] - bi define ; + dup insn-def-slot dup [ + [ \ defs-vreg-rep create-method ] + [ rep>> rep-getter-quot ] + bi* define + ] [ 2drop ] if ; : reps-getter-quot ( reps -- quot ) dup [ rep>> { f scalar-rep } member-eq? not ] all? [ @@ -38,14 +44,18 @@ GENERIC: uses-vreg-reps ( insn -- reps ) ] if ; : define-uses-vreg-reps-method ( insn -- ) - [ \ uses-vreg-reps create-method ] - [ insn-use-slots reps-getter-quot ] - bi define ; + dup insn-use-slots [ drop ] [ + [ \ uses-vreg-reps create-method ] + [ reps-getter-quot ] + bi* define + ] if-empty ; : define-temp-vreg-reps-method ( insn -- ) - [ \ temp-vreg-reps create-method ] - [ insn-temp-slots reps-getter-quot ] - bi define ; + dup insn-temp-slots [ drop ] [ + [ \ temp-vreg-reps create-method ] + [ reps-getter-quot ] + bi* define + ] if-empty ; PRIVATE> From 0a15ae4d6bb563a751e505d0d5bd7a093de03662 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 2 Nov 2009 20:33:14 -0600 Subject: [PATCH 2/2] compiler.cfg.intrinsics: uncomment line commented out by mistake --- basis/compiler/cfg/intrinsics/intrinsics.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/compiler/cfg/intrinsics/intrinsics.factor b/basis/compiler/cfg/intrinsics/intrinsics.factor index e8933d38fc..a03f04f182 100644 --- a/basis/compiler/cfg/intrinsics/intrinsics.factor +++ b/basis/compiler/cfg/intrinsics/intrinsics.factor @@ -59,7 +59,7 @@ IN: compiler.cfg.intrinsics { byte-arrays: [ emit- ] } { byte-arrays:(byte-array) [ emit-(byte-array) ] } { kernel: [ emit-simple-allot ] } - ! { alien: [ emit- ] } + { alien: [ emit- ] } { alien.accessors:alien-unsigned-1 [ 1 emit-alien-unsigned-getter ] } { alien.accessors:set-alien-unsigned-1 [ 1 emit-alien-integer-setter ] } { alien.accessors:alien-signed-1 [ 1 emit-alien-signed-getter ] }