Check-in [7b85bdfca9]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:merge trunk
Timelines: family | ancestors | descendants | both | poly1305
Files: files | file ages | folders
SHA3-256: 7b85bdfca9f371b99a51a9b042549e0ed20beb406eb3b97e1f42e782204a61b9
User & Date: dkf 2018-11-04 23:49:40.933
Context
2018-12-07
02:19
Increase recursion limit to allow compilation of longer procedures. Correct a bug in expandInlines that left dangling references to procedure args. Correct a bug in analyzeTypes where the INT/ENTIER break was set to int32 rather than int64. Add shift operations to constfold. Improve auditing. Merge trunk. Closed-Leaf check-in: 1984824c19 user: kbk tags: mistake
2018-12-06
21:17
merge trunk check-in: c2a6505ae9 user: dkf tags: poly1305
2018-11-04
23:49
merge trunk check-in: 7b85bdfca9 user: dkf tags: poly1305
2018-11-01
22:04
Allow IMPURE values to builtin mathfuncs check-in: dfc7885448 user: kbk tags: trunk
2018-10-31
11:32
Also ask for critical math function to be compiled check-in: fb47c5a2cd user: dkf tags: poly1305
Changes
Unified Diff Ignore Whitespace Patch
Changes to demos/perftest/tester.tcl.
1332
1333
1334
1335
1336
1337
1338




1339
1340
1341
1342
1343
1344
1345
proc impure {a b c} {
    set x 0
    for {set i $a} {$i < $b} {incr i $c} {
	set x [expr {$x + $i}]
    }
    return $x
}





proc impure-typecheck-int {a b c} {
    if {[string is int -strict $a]
	&& [string is int -strict $b]
	&& [string is int -strict $c]} {
	set x 0
	for {set i $a} {$i < $b} {incr i $c} {







>
>
>
>







1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
proc impure {a b c} {
    set x 0
    for {set i $a} {$i < $b} {incr i $c} {
	set x [expr {$x + $i}]
    }
    return $x
}

proc wideimpure {x} {
    expr {wide($x)}
}

proc impure-typecheck-int {a b c} {
    if {[string is int -strict $a]
	&& [string is int -strict $b]
	&& [string is int -strict $c]} {
	set x 0
	for {set i $a} {$i < $b} {incr i $c} {
2461
2462
2463
2464
2465
2466
2467

2468
2469
2470
2471
2472
2473
2474
    upvartest0::check2
    upvartest1::check1
    upvartest1::check2
    upvartest2::test1
    upvartest2::test2
    upvartest2::test3
    upvartest2::test4


    {hash::H9fast ultraantidisestablishmentarianistically}
    {hash::H9mid ultraantidisestablishmentarianistically}
    {hash::H9slow ultraantidisestablishmentarianistically}

    {toHex [poly1305 compute $key $msg]}
    {poly1305 verify $key $msg $tag}







>







2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
    upvartest0::check2
    upvartest1::check1
    upvartest1::check2
    upvartest2::test1
    upvartest2::test2
    upvartest2::test3
    upvartest2::test4
    {wideimpure 3.0}

    {hash::H9fast ultraantidisestablishmentarianistically}
    {hash::H9mid ultraantidisestablishmentarianistically}
    {hash::H9slow ultraantidisestablishmentarianistically}

    {toHex [poly1305 compute $key $msg]}
    {poly1305 verify $key $msg $tag}
2637
2638
2639
2640
2641
2642
2643

2644
2645
2646
2647
2648
2649
2650
    upvar0
    upvar0a
    upvartest0::*
    upvartest1::*
    upvartest2::*
    flightawarebench::*
    hash::*

    poly1305::*
    poly1305::tcl::mathfunc::*
}
set toCompile'slow' {
    parseBuiltinsTxt::main
}








>







2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
    upvar0
    upvar0a
    upvartest0::*
    upvartest1::*
    upvartest2::*
    flightawarebench::*
    hash::*
    wideimpure
    poly1305::*
    poly1305::tcl::mathfunc::*
}
set toCompile'slow' {
    parseBuiltinsTxt::main
}

Changes to quadcode/translate.tcl.
1727
1728
1729
1730
1731
1732
1733

1734
1735
1736
1737
1738
1739
1740
1741
# generate-function-param-check --
#
#	Generates a check to make sure that a value conforms with a function's
#	requirement for its parameter type. Do not call from anywhere but
#	bytecode-to-quads!
#
# Parameters:

#	q - The quadruple that will consume the value
#
# Results:
#	None.
#
# Side effects:
#	Inserts a parameter type checking sequence.
#







>
|







1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
# generate-function-param-check --
#
#	Generates a check to make sure that a value conforms with a function's
#	requirement for its parameter type. Do not call from anywhere but
#	bytecode-to-quads!
#
# Parameters:
#	q - A list comprising the function name and arguments expressed as
#           quadcode values.
#
# Results:
#	None.
#
# Side effects:
#	Inserts a parameter type checking sequence.
#
1771
1772
1773
1774
1775
1776
1777


1778
1779
1780
1781
1782
1783
1784
1785
	# 2
	my quads [list initParamTypeException $i] {temp @exception} \
	    $val $functionName
	# 3
	my quads extractFail {temp @exception} {temp @exception}
	# 4
	my generate-jump $target


	# 5
	# (next instruction)
	
    }
}

# quads --
#







>
>
|







1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
	# 2
	my quads [list initParamTypeException $i] {temp @exception} \
	    $val $functionName
	# 3
	my quads extractFail {temp @exception} {temp @exception}
	# 4
	my generate-jump $target
	# 5 - ok:
        my quads [list purifyParam $i] $val $val $functionName
	# 6
	# (next instruction)
	
    }
}

# quads --
#
Changes to quadcode/typecheck.tcl.
269
270
271
272
273
274
275

276
277
278
279
280
281
282
283

284
285
286
287
288
289














290
291
292
293
294
295
296
			lset bbcontent $b $j \
			    [list initException $result $msgLit $exn \
				 {literal 1} {literal 0}]
			incr j
		    } else {
			my removeUse $src $b
			my replaceUses $result Nothing

		    }

		}

		"instanceOfParamType" {
		    lassign $q op result src fref
		    set t [my determineFunctionParamType $op $fref]
		    if {$t != $quadcode::dataType::STRING} {

			set op [list "instanceOf" $t [nameOfType $t]]
			lset bbcontent $b $j [list $op $result $src]
			incr j
		    } else {
			my removeUse $src $b
			my replaceUses $result {literal 1}














		    }
		}

		default {
		    lset bbcontent $b $j $q
		    incr j
		}







>








>






>
>
>
>
>
>
>
>
>
>
>
>
>
>







269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
			lset bbcontent $b $j \
			    [list initException $result $msgLit $exn \
				 {literal 1} {literal 0}]
			incr j
		    } else {
			my removeUse $src $b
			my replaceUses $result Nothing
			# delete the quad
		    }

		}

		"instanceOfParamType" {
		    lassign $q op result src fref
		    set t [my determineFunctionParamType $op $fref]
		    if {$t != $quadcode::dataType::STRING} {
			set t [expr {$t | $quadcode::dataType::IMPURE}]
			set op [list "instanceOf" $t [nameOfType $t]]
			lset bbcontent $b $j [list $op $result $src]
			incr j
		    } else {
			my removeUse $src $b
			my replaceUses $result {literal 1}
			# delete the quad
		    }
		}

		"purifyParam" {
		    lassign $q op result src fref
		    set t [my determineFunctionParamType $op $fref]
		    if {$t != $quadcode::dataType::STRING} {
			lset bbcontent $b $j [list purify $result $src]
			incr j
		    } else {
			my removeUse $src $b
			my replaceUses $result $src
			# delete the quad
		    }
		}

		default {
		    lset bbcontent $b $j $q
		    incr j
		}
Changes to quadcode/types.tcl.
579
580
581
582
583
584
585





586
587
588
589
590
591
592
	}
	copy {
	    return [typeOfOperand $types [lindex $q 2]]
	}
	purify {
	    return [expr {[typeOfOperand $types [lindex $q 2]] & ~$IMPURE}]
	}





	unset {
	    return $NEXIST
	}
	setReturnCode {
	    return $FAIL
	}
	initException {







>
>
>
>
>







579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
	}
	copy {
	    return [typeOfOperand $types [lindex $q 2]]
	}
	purify {
	    return [expr {[typeOfOperand $types [lindex $q 2]] & ~$IMPURE}]
	}
	purifyParam {
	    # Will be replaced with 'purify' when type is known, but must
	    # be at most a subset of the type of the source operand
	    return [typeOfOperand $types [lindex $q 2]]
	}
	unset {
	    return $NEXIST
	}
	setReturnCode {
	    return $FAIL
	}
	initException {
Changes to quadcodes.txt.
243
244
245
246
247
248
249








250
251
252
253
   1 or 0 according to the result.
{{instanceOfParamType N} TGT SRC CMD}
   Sets TGT to 1 or 0 depending on whether the type of SRC is appropriate
   as parameter #N to the command CMD
{{initParamTypeException N} TGT SRC CMD}
   Sets TGT to a FAIL value indicating that SRC is inappropriate for parameter
   #N to the command CMD.









For these operations, the data types that must be implemented are INT32,
INT, ENTIER, DOUBLE; the same four data types unioned with EMPTY; and the
complements of these eight types, so there are sixteen variants in all. 







>
>
>
>
>
>
>
>




243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
   1 or 0 according to the result.
{{instanceOfParamType N} TGT SRC CMD}
   Sets TGT to 1 or 0 depending on whether the type of SRC is appropriate
   as parameter #N to the command CMD
{{initParamTypeException N} TGT SRC CMD}
   Sets TGT to a FAIL value indicating that SRC is inappropriate for parameter
   #N to the command CMD.
{purify TGT SRC}
   Sets TGT to SRC, with any IMPURE indication removed
{{purifyParam N} TGT SRC FUNC}
   Sets TGT to SRC, with any IMPURE indication removed, if FUNC is a built-in
   math function requiring a pure value as argument #N.
   Otherwise, simply sets TGT to SRC. This operation is
   replaced with 'purify' or removed during optimization. It is there to
   purify the operands of built-in mathfuncs.

For these operations, the data types that must be implemented are INT32,
INT, ENTIER, DOUBLE; the same four data types unioned with EMPTY; and the
complements of these eight types, so there are sixteen variants in all.