From 7f7a0a057eb3beb4b4922ed6d19f2e36ebc59e24 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 5 Sep 2005 07:06:47 +0000 Subject: [PATCH] working on PowerPC overflow checks --- library/bootstrap/primitives.factor | 26 +++++++- library/collections/hashtables.factor | 2 +- library/compiler/assembler.factor | 8 +-- library/compiler/ppc/assembler.factor | 2 +- library/compiler/ppc/fixnum.factor | 42 +++++++++---- library/generic/early-generic.factor | 8 ++- library/io/buffer.factor | 4 +- library/kernel.factor | 12 ---- native/primitives.c | 13 +++- native/stack.c | 91 ++++++++++++++++++++++++++- native/stack.h | 13 +++- 11 files changed, 182 insertions(+), 39 deletions(-) diff --git a/library/bootstrap/primitives.factor b/library/bootstrap/primitives.factor index fa089c8af3..ca2b40d219 100644 --- a/library/bootstrap/primitives.factor +++ b/library/bootstrap/primitives.factor @@ -103,10 +103,21 @@ vocabularies get [ "syntax" set [ reveal ] each ] bind { "update-xt" "words" } { "compiled?" "words" } { "drop" "kernel" } + { "2drop" "kernel" } + { "3drop" "kernel" } { "dup" "kernel" } - { "swap" "kernel" } + { "2dup" "kernel" } + { "3dup" "kernel" } + { "rot" "kernel" } + { "-rot" "kernel" } + { "dupd" "kernel" } + { "swapd" "kernel" } + { "nip" "kernel" } + { "2nip" "kernel" } + { "tuck" "kernel" } { "over" "kernel" } { "pick" "kernel" } + { "swap" "kernel" } { ">r" "kernel" } { "r>" "kernel" } { "eq?" "kernel" } @@ -202,10 +213,21 @@ vocabularies get [ "syntax" set [ reveal ] each ] bind { { "drop" "kernel" " x -- " } + { "2drop" "kernel" " x y -- " } + { "3drop" "kernel" " x y z -- " } { "dup" "kernel" " x -- x x " } - { "swap" "kernel" " x y -- y x " } + { "2dup" "kernel" " x y -- x y x y " } + { "3dup" "kernel" " x y z -- x y z x y z " } + { "rot" "kernel" " x y z -- y z x " } + { "-rot" "kernel" " x y z -- z x y " } + { "dupd" "kernel" " x y -- x x y " } + { "swapd" "kernel" " x y z -- y x z " } + { "nip" "kernel" " x y -- y " } + { "2nip" "kernel" " x y z -- z " } + { "tuck" "kernel" " x y -- y x y " } { "over" "kernel" " x y -- x y x " } { "pick" "kernel" " x y z -- x y z x " } + { "swap" "kernel" " x y -- y x " } { ">r" "kernel" " x -- r: x " } { "r>" "kernel" " r: x -- x " } { "datastack" "kernel" " -- ds " } diff --git a/library/collections/hashtables.factor b/library/collections/hashtables.factor index 88b34ea49d..9e6355858f 100644 --- a/library/collections/hashtables.factor +++ b/library/collections/hashtables.factor @@ -13,7 +13,7 @@ kernel-internals ; ! if it is somewhat 'implementation detail', is in the ! public 'hashtables' vocabulary. -: bucket-count ( hash -- n ) hash-array length ; +: bucket-count ( hash -- n ) hash-array array-capacity ; IN: kernel-internals diff --git a/library/compiler/assembler.factor b/library/compiler/assembler.factor index 31dfc34c34..83a192ccac 100644 --- a/library/compiler/assembler.factor +++ b/library/compiler/assembler.factor @@ -9,13 +9,13 @@ SYMBOL: interned-literals : compiled-header HEX: 01c3babe ; inline : compiled-byte ( a -- n ) - 0 alien-signed-1 ; inline + f swap alien-signed-1 ; inline : set-compiled-byte ( n a -- ) - 0 set-alien-signed-1 ; inline + f swap set-alien-signed-1 ; inline : compiled-cell ( a -- n ) - 0 alien-signed-cell ; inline + f swap alien-signed-cell ; inline : set-compiled-cell ( n a -- ) - 0 set-alien-signed-cell ; inline + f swap set-alien-signed-cell ; inline : compile-aligned ( n -- ) compiled-offset cell 2 * align set-compiled-offset ; inline diff --git a/library/compiler/ppc/assembler.factor b/library/compiler/ppc/assembler.factor index 4e7503e7a1..c8fff8f58e 100644 --- a/library/compiler/ppc/assembler.factor +++ b/library/compiler/ppc/assembler.factor @@ -70,7 +70,7 @@ USING: compiler errors generic kernel math memory words ; : (DIVW) 491 xo-form 31 insn ; : DIVW 0 0 (DIVW) ; : DIVW. 0 1 (DIVW) ; -: DIVWO 1 0 (DIVW) ; : DIVWO 1 1 (DIVW) ; +: DIVWO 1 0 (DIVW) ; : DIVWO. 1 1 (DIVW) ; : (DIVWU) 459 xo-form 31 insn ; : DIVWU 0 0 (DIVWU) ; : DIVWU. 0 1 (DIVWU) ; diff --git a/library/compiler/ppc/fixnum.factor b/library/compiler/ppc/fixnum.factor index b73fd719c6..23f616a805 100644 --- a/library/compiler/ppc/fixnum.factor +++ b/library/compiler/ppc/fixnum.factor @@ -41,22 +41,39 @@ M: %fixnum* generate-node ( vop -- ) #! Note that this assumes the output will be in r3. >3-vop< dup dup tag-bits SRAWI 0 MTXER - [ >r >r drop 4 r> r> MULLWO. 3 ] 2keep + [ >r >r drop 6 r> r> MULLWO. 3 ] 2keep