Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Stop confusion over what is being mapped to what. Merge loops that should be merged. |
---|---|
Timelines: | family | ancestors | descendants | both | dkf-cheaper-autoconvert |
Files: | files | file ages | folders |
SHA3-256: |
a4634d05b699d72dbb6ed5e3481637ec |
User & Date: | dkf 2019-11-18 20:29:01.802 |
Original User & Date: | Donal 2019-11-18 20:29:01.802 |
Context
2019-11-19
| ||
00:48 | Fix a couple of typos ('target' s/b 'targetinfo') - code now compiles the test suite again. Closed-Leaf check-in: d9095e2b40 user: kbk tags: dkf-cheaper-autoconvert | |
2019-11-18
| ||
20:29 | Stop confusion over what is being mapped to what. Merge loops that should be merged. check-in: a4634d05b6 user: dkf tags: dkf-cheaper-autoconvert | |
2019-11-16
| ||
14:39 | Refactor stuff better (and more correctly) check-in: ebcd44d358 user: dkf tags: dkf-cheaper-autoconvert | |
Changes
Changes to codegen/struct.tcl.
︙ | ︙ | |||
2952 2953 2954 2955 2956 2957 2958 | # necessary, provided there is a way of generating the instruction # with DOUBLE in the first place. # First, extract the type signature that we're trying to generate. if {![regexp {^([^()]+)\(([\w, ]+)\)$} $signature -> name types]} { return 0 } | | | > > > > | | > | < < < < | | < | 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 | # necessary, provided there is a way of generating the instruction # with DOUBLE in the first place. # First, extract the type signature that we're trying to generate. if {![regexp {^([^()]+)\(([\w, ]+)\)$} $signature -> name types]} { return 0 } set types [split $types ","] set num [llength $types] # Get the type signatures we could go to set methods [info class methods [self class]] # Search the space of possible conversions for ones that are legal, # and compute the cost of each. set mapped {} foreach targetinfo $methods { if {![regexp {^([^()]+)\(([\w, ]+)\)$} $target -> tname ttypes]} { continue } if {$name ne $tname} { continue } set ttypes [split $ttypes ","] if {[llength $types] != [llength $ttypes]} { continue } set thiscost 0 set legal true set cvts [lmap st $types tt $ttypes { if {$st eq $tt} { # No-conversion is always legal and always very cheap set c $DefaultTypeConversion } else { # Look up if we have a conversion set typepair [list $st $tt] if {![dict exists $TypeConversions $typepair]} { set legal false # Continue the outer loop break } set c [dict get $TypeConversions $typepair] } # The cost of a conversion is just its length. That is WRONG, # but approximates the real cost. incr thiscost [string length $c] string cat $c }] if {$legal} { lappend mapped $thiscost $target $cvts } } set tock [clock microseconds] ::puts [format "Identified %d typecast candidates in %.6f s" \ [expr {[llength $mapped] / 3}] \ [expr {1.0e-6 * ($tock - $tick)}]] |
︙ | ︙ |