]> gitweb.factorcode.org Git - factor.git/commitdiff
VM: removes the OBJ-ERROR special object in favor of a constant
authorBjörn Lindqvist <bjourne@gmail.com>
Tue, 22 Mar 2016 14:56:41 +0000 (15:56 +0100)
committerBjörn Lindqvist <bjourne@gmail.com>
Tue, 22 Mar 2016 16:52:19 +0000 (17:52 +0100)
The special object contained the string "kernel-error" which were used
to tag VM errors. But it is simplier and removes a little complexity to
just tag them with a fixnum constant.

15 files changed:
basis/debugger/debugger-tests.factor
basis/debugger/debugger.factor
basis/io/files/windows/windows-tests.factor
basis/math/floats/env/env-tests.factor
basis/typed/typed-tests.factor
core/arrays/arrays-tests.factor
core/classes/tuple/tuple-tests.factor
core/continuations/continuations.factor
core/kernel/kernel-tests.factor
core/kernel/kernel.factor
core/strings/strings-tests.factor
extra/decimals/decimals-tests.factor
vm/errors.cpp
vm/errors.hpp
vm/objects.hpp

index 52b5f559ba3d4fcbdd2541265b93485fbf886c6e..a2aaf0df9d4241210592237b5078e94673331eea 100644 (file)
@@ -1,5 +1,5 @@
-USING: accessors alien.syntax continuations debugger kernel literals
-namespaces tools.test ;
+USING: accessors alien.syntax continuations debugger kernel
+kernel.private literals namespaces tools.test ;
 IN: debugger.tests
 
 { } [ [ drop ] [ error. ] recover ] unit-test
@@ -11,7 +11,7 @@ IN: debugger.tests
     T{ test-failure
        { error
          {
-             "kernel-error"
+             $[ KERNEL-ERROR ]
              10
              {
                  B{
index 3857a0328a04e1c25d4aafa804344244d449918d..866a5685d3022a411e1e2c4ca0865c14ba228feb 100755 (executable)
@@ -151,7 +151,7 @@ HOOK: signal-error. os ( obj -- )
 PREDICATE: vm-error < array
     dup length 2 < [ drop f ] [
         {
-            [ first-unsafe "kernel-error" = ]
+            [ first-unsafe KERNEL-ERROR = ]
             [ second-unsafe 0 kernel-error-count 1 - between? ]
         } 1&&
     ] if ;
index c9fb8e1f9b28df81ebf08c15279dc56283f7514e..29f12f11f13cd1f3992773ffbd0f4e559bbe582e 100644 (file)
@@ -68,7 +68,7 @@ IN: io.files.windows.tests
 ] unit-test
 
 ! set-file-attributes & save-image
-{ ${ "kernel-error" ERROR-IO EIO f } } [
+{ ${ KERNEL-ERROR ERROR-IO EIO f } } [
     [
         "read-only.image" temp-file {
             [ ?delete-file ]
index 81ee34a26ab7bf6d2b6b5014e9c78d1fc51e599e..e2522e568ba63e93cdc0cb825ee52817e7799bf9 100755 (executable)
@@ -111,7 +111,7 @@ os linux? cpu x86.64? and [
 ] unit-test
 
 : fp-trap-error? ( error -- ? )
-    2 head ${ "kernel-error" ERROR-FP-TRAP } = ;
+    2 head ${ KERNEL-ERROR ERROR-FP-TRAP } = ;
 
 : test-traps ( traps inputs quot -- quot' fail-quot )
     append '[ _ _ with-fp-traps ] [ fp-trap-error? ] ;
index 78ec21dc2bbce80b03b81c58d8382327b3d21f02..62548139433abf0af6e94002f89c5c72deaab9a1 100644 (file)
@@ -1,7 +1,7 @@
-USING: accessors effects eval kernel layouts math namespaces
-quotations tools.test typed words words.symbol combinators.short-circuit
-compiler.tree.debugger prettyprint definitions compiler.units sequences
-classes.intersection strings classes.union ;
+USING: accessors compiler.units effects eval kernel kernel.private layouts
+literals math namespaces quotations tools.test typed words words.symbol
+combinators.short-circuit compiler.tree.debugger prettyprint definitions
+sequences classes.intersection strings classes.union ;
 IN: typed.tests
 
 TYPED: f+ ( a: float b: float -- c: float )
@@ -18,7 +18,7 @@ TYPED: fix+ ( a: fixnum b: fixnum -- c: fixnum )
 ! [ most-positive-fixnum 1 fix+ ] unit-test
 
 ! XXX: Check that we throw an error. This used to underflow to the least-positive-fixnum.
-[ most-positive-fixnum 1 fix+ ] [ { "kernel-error" 7 } head? ] must-fail-with
+[ most-positive-fixnum 1 fix+ ] [ ${ KERNEL-ERROR 7 } head? ] must-fail-with
 
 TUPLE: tweedle-dee ; final
 TUPLE: tweedle-dum ; final
index aa162751aff2759db1a94fbf99d5ba8b3ff95d9f..dc2683ee0fd752142c29d7a9552cac75c4a3f33d 100644 (file)
@@ -1,6 +1,5 @@
-USING: accessors arrays kernel kernel.private literals sequences
-sequences.private growable tools.test vectors layouts system math
-vectors.private ;
+USING: accessors arrays kernel kernel.private layouts literals math
+sequences tools.test vectors ;
 IN: arrays.tests
 
 [ -2 { "a" "b" "c" } nth ] must-fail
@@ -22,7 +21,7 @@ IN: arrays.tests
 [ cell-bits cell log2 - 2^ f <array> ] must-fail
 ! To big for a fixnum #1045
 [ 67 2^ 3 <array> ] [
-    ${ "kernel-error" ERROR-OUT-OF-FIXNUM-RANGE 147573952589676412928 f }
+    ${ KERNEL-ERROR ERROR-OUT-OF-FIXNUM-RANGE 147573952589676412928 f }
     =
 ] must-fail-with
 
index c702cc03a6174eb43c6f79ca34439091059691ee..7c2c1f0ca1398c0995824f3d1c4a9c47d7df296f 100644 (file)
@@ -548,7 +548,8 @@ must-fail-with
 
 [ 444444444444444444444444444444444444444444444444433333 >bignum "asdf" declared-types boa ]
 [
-    ${ "kernel-error" ERROR-OUT-OF-FIXNUM-RANGE 444444444444444444444444444444444444444444444444433333 f } =
+    ${ KERNEL-ERROR ERROR-OUT-OF-FIXNUM-RANGE
+       444444444444444444444444444444444444444444444444433333 f } =
 ] must-fail-with
 
 ! Check bignum coercer
index c7507a147a9c7ff3ebd2709a42ed4a8a31e82ff0..220cef3e8ddb303109b3b6bbed77964847c929ab 100644 (file)
@@ -204,9 +204,6 @@ M: condition compute-restarts
         OBJ-CURRENT-THREAD special-object error-thread set-global
         current-continuation error-continuation set-global
         [ original-error set-global ] [ rethrow ] bi
-    ] ERROR-HANDLER-QUOT set-special-object
-    ! VM adds this to kernel errors, so that user-space
-    ! can identify them
-    "kernel-error" OBJ-ERROR set-special-object ;
+    ] ERROR-HANDLER-QUOT set-special-object ;
 
 PRIVATE>
index c461bba7d288203a2d75adab545cc748be964b2b..f779a8744e9a0a4b4e965cd4189c9d239cc377c1 100644 (file)
@@ -30,14 +30,14 @@ IN: kernel.tests
 
 ! Make sure we report the correct error on stack underflow
 [ clear drop ] [
-    2 head ${ "kernel-error" ERROR-DATASTACK-UNDERFLOW } =
+    2 head ${ KERNEL-ERROR ERROR-DATASTACK-UNDERFLOW } =
 ] must-fail-with
 
 { } [ :c ] unit-test
 
 [
     3 [ { } set-retainstack ] dip ]
-    [ 2 head ${ "kernel-error" ERROR-RETAINSTACK-UNDERFLOW } =
+    [ 2 head ${ KERNEL-ERROR ERROR-RETAINSTACK-UNDERFLOW } =
 ] must-fail-with
 
 { } [ :c ] unit-test
@@ -56,19 +56,19 @@ IN: kernel.tests
 >>
 
 [ overflow-d ] [
-    2 head ${ "kernel-error" ERROR-DATASTACK-OVERFLOW } =
+    2 head ${ KERNEL-ERROR ERROR-DATASTACK-OVERFLOW } =
 ] must-fail-with
 
 { } [ :c ] unit-test
 
 [ overflow-d-alt ] [
-    2 head ${ "kernel-error" ERROR-DATASTACK-OVERFLOW } =
+    2 head ${ KERNEL-ERROR ERROR-DATASTACK-OVERFLOW } =
 ] must-fail-with
 
 { } [ [ :c ] with-string-writer drop ] unit-test
 
 [ overflow-r ] [
-    2 head ${ "kernel-error" ERROR-RETAINSTACK-OVERFLOW } =
+    2 head ${ KERNEL-ERROR ERROR-RETAINSTACK-OVERFLOW } =
 ] must-fail-with
 
 { } [ :c ] unit-test
index 7821a6abeab0d02f151f5055684d8ed2515d5eec..4b53ca0ac71183399a38def500cd906c9e4731fb 100644 (file)
@@ -316,7 +316,6 @@ CONSTANT: OBJ-WALKER-HOOK 3
 CONSTANT: OBJ-CALLCC-1 4
 
 CONSTANT: ERROR-HANDLER-QUOT 5
-CONSTANT: OBJ-ERROR 6
 
 CONSTANT: OBJ-CELL-SIZE 7
 CONSTANT: OBJ-CPU 8
@@ -428,6 +427,9 @@ CONSTANT: CONTEXT-OBJ-IN-CALLBACK-P 3
 !   basis/debugger/debugger.factor
 !   vm/errors.hpp
 
+! VM adds this to kernel errors, so that user-space can identify them.
+CONSTANT: KERNEL-ERROR 0xfac7
+
 CONSTANT: kernel-error-count 20
 
 CONSTANT: ERROR-EXPIRED 0
index 7429a8367600334b2c2fefd7bf91fadcc1296809..e676d924064424684dab10dce24176c15352fac6 100644 (file)
@@ -59,7 +59,7 @@ unit-test
 
 ! Random tester found this
 [ 2 -7 resize-string ]
-[ ${ "kernel-error" ERROR-TYPE 11 -7 } = ] must-fail-with
+[ ${ KERNEL-ERROR ERROR-TYPE 11 -7 } = ] must-fail-with
 
 ! Make sure 24-bit strings work
 "hello world" "s" set
index 3b09d3b19d657836e2b4a92b8eb37c6f96cd6af5..4a9baced073fb1bf0a025db5c27f49d24b5d970b 100644 (file)
@@ -1,8 +1,7 @@
 ! Copyright (C) 2009 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: continuations decimals grouping kernel literals locals
-math math.functions math.order math.ratios prettyprint random
-sequences tools.test kernel.private ;
+USING: continuations decimals grouping kernel kernel.private literals
+locals math math.functions math.order random tools.test ;
 IN: decimals.tests
 
 { t } [
@@ -33,7 +32,7 @@ ERROR: decimal-test-failure D1 D2 quot ;
     1000 [
         drop
         [ [ 100 D/ ] [ /f ] test-decimal-op ]
-        [ ${ "kernel-error" ERROR-DIVIDE-BY-ZERO f f } = ] recover
+        [ ${ KERNEL-ERROR ERROR-DIVIDE-BY-ZERO f f } = ] recover
     ] all-integers?
 ] unit-test
 
index 8a223371499f3e8bfe76a657af85e8a2de548583..c44574871106893b31a77a7b50543b710a799096 100644 (file)
@@ -57,7 +57,7 @@ void factor_vm::general_error(vm_error_type error, cell arg1_, cell arg2_) {
 
     /* Now its safe to allocate and GC */
     cell error_object =
-        allot_array_4(special_objects[OBJ_ERROR], tag_fixnum(error),
+        allot_array_4(tag_fixnum(KERNEL_ERROR), tag_fixnum(error),
                       arg1.value(), arg2.value());
     ctx->push(error_object);
 
index 57f0204831fc5e352492f402231db78b97196904..068fa104f96dab717c24b47de742f6e60e060bd1 100644 (file)
@@ -3,6 +3,8 @@ namespace factor {
 // Runtime errors must be kept in sync with:
 //   basis/debugger/debugger.factor
 //   core/kernel/kernel.factor
+#define KERNEL_ERROR 0xfac7
+
 enum vm_error_type {
   ERROR_EXPIRED = 0,
   ERROR_IO,
index 78ff2b23ab02b9e6af76006e8d7553aa894e433f..ee9ae61f2ca2a3dd2779aa24048e00593c4d0349 100644 (file)
@@ -11,7 +11,6 @@ enum special_object {
   OBJ_CALLCC_1,        /* used to pass the value in callcc1 */
 
   ERROR_HANDLER_QUOT = 5, /* quotation called when VM throws an error */
-  OBJ_ERROR,              /* a marker consed onto kernel errors */
 
   OBJ_CELL_SIZE = 7, /* sizeof(cell) */
   OBJ_CPU,           /* CPU architecture */