From ce985afd8970fa4997d41a274de00564e3ab75c2 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 10 May 2005 04:09:16 +0000 Subject: [PATCH] fix fixnum+ and fixnum- overflow --- library/compiler/x86/fixnum.factor | 36 ++++++++++++++++++------- library/compiler/x86/generator.factor | 2 +- library/test/compiler/intrinsics.factor | 3 +++ 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/library/compiler/x86/fixnum.factor b/library/compiler/x86/fixnum.factor index 4baffd5de6..ad588a5607 100644 --- a/library/compiler/x86/fixnum.factor +++ b/library/compiler/x86/fixnum.factor @@ -4,17 +4,33 @@ IN: compiler-backend USING: assembler compiler errors kernel math math-internals memory namespaces words ; -: simple-overflow ( dest -- ) +: literal-overflow + #! If the src operand is a literal. + ! Untag the operand. + over tag-bits SAR + tag-bits neg shift ; + +: computed-overflow + #! If the src operand is a register. + ! Untag both operands. + 2dup tag-bits SAR tag-bits SAR ; + +: simple-overflow ( dest src inv word -- ) #! If the previous arithmetic operation overflowed, then we - #! turn the result into a bignum and leave it in EAX. This - #! does not trigger a GC if memory is full -- is that bad? + #! turn the result into a bignum and leave it in EAX. + >r >r