Remove sieve_direct

This commit is contained in:
Remko Tronçon 2022-05-01 17:02:44 +02:00
parent f5df37a12f
commit fffd982121
3 changed files with 7 additions and 86 deletions

View file

@ -975,6 +975,12 @@
(data (i32.const 136164) "\d4\13\02\00" "\2b" (; HIDDEN ;) "UNUSED1____" "X\00\00\00")
(elem (i32.const 0x58) $UNUSED1)
;; TODO: Remove
(func $UNUSED2 (param $tos i32) (result i32)
(call $fail (local.get $tos) (i32.const 0x20084))) ;; not implemented
(data (i32.const 137224) "\f8\17\02\00" "\2c" "UNUSED______\00\00\00" "\9f\00\00\00")
(elem (i32.const 0x9f) $UNUSED2)
;; 6.1.1345
(func $ENVIRONMENT? (param $tos i32) (result i32)
(local $addr i32)
@ -2759,74 +2765,4 @@
;; Used for experiments
(func (export "set_state") (param $latest i32) (param $here i32)
(global.set $latest (local.get $latest))
(global.set $here (local.get $here)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; A sieve with direct calls. Only here for benchmarking
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(func $sieve_prime (param $tos i32) (result i32)
(local.get $tos)
(call $HERE) (call $+)
(call $C@) (call $0=))
(func $sieve_composite (param $tos i32) (result i32)
(local.get $tos)
(call $HERE)
(call $+)
(local.set $tos)
(i32.store (local.get $tos) (i32.const 1))
(i32.add (local.get $tos) (i32.const 4))
(call $SWAP)
(call $C!))
(func $sieve (param $tos i32) (result i32)
(local $i i32)
(local $end i32)
(local.get $tos)
(call $HERE)
(call $OVER)
(call $ERASE)
(call $push (i32.const 2))
(block $endLoop1 (param i32) (result i32)
(loop $loop1 (param i32) (result i32)
(call $2DUP)
(call $DUP)
(call $*)
(call $>)
(br_if $endLoop1 (i32.eqz (call $pop)))
(call $DUP)
(call $sieve_prime)
(if (param i32) (result i32) (i32.ne (call $pop) (i32.const 0))
(then
(call $2DUP)
(call $DUP)
(call $*)
(local.set $i (call $pop))
(local.set $end (call $pop))
(loop $loop2 (param i32) (result i32)
(call $push (local.get $i))
(call $sieve_composite)
(call $DUP)
(local.set $i (i32.add (call $pop) (local.get $i)))
(br_if $loop2 (i32.lt_s (local.get $i) (local.get $end))))))
(call $1+)
(br $loop1)))
(call $DROP)
(call $push (i32.const 1))
(call $SWAP)
(call $push (i32.const 2))
(local.set $i (call $pop))
(local.set $end (call $pop))
(loop $loop (param i32) (result i32)
(call $push (local.get $i))
(call $sieve_prime)
(if (param i32) (result i32) (i32.ne (call $pop) (i32.const 0))
(then
(call $DROP)
(call $push (local.get $i))))
(local.set $i (i32.add (i32.const 1) (local.get $i)))
(br_if $loop (i32.lt_s (local.get $i) (local.get $end)))))
(data (i32.const 137224) "\f8\17\02\00" "\0c" "sieve_direct\00\00\00" "\9f\00\00\00")
(elem (i32.const 0x9f) $sieve)
(global.set $here (local.get $here)))

View file

@ -47,14 +47,6 @@ const benchmarks = [
return outputBuffer.join("");
},
},
{
name: "sieve-direct",
fn: () => {
outputBuffer = [];
forth.run(`${LIMIT} sieve_direct .`);
return outputBuffer.join("");
},
},
{
name: "sieve-vanilla",
fn: () => {

View file

@ -1557,12 +1557,6 @@ function loadTests() {
run("100 sieve");
expect(output.trim()).to.eql("97");
});
it("should run direct sieve", () => {
run(sieve);
run("100 sieve_direct");
expect(stackValues()[0]).to.eql(97);
});
});
describe("standard test suite", () => {
@ -1595,7 +1589,6 @@ function loadTests() {
expect(output).to.include(
"YOU SHOULD SEE TWO SEPARATE LINES:\nLINE 1\nLINE 2\n"
);
// These 2 are wrong
expect(output).to.include(
"YOU SHOULD SEE THE NUMBER RANGES OF SIGNED AND UNSIGNED NUMBERS:\n SIGNED: -80000000 7FFFFFFF \n"
);