Fixing 64-bit image generation
parent
9a3ab15720
commit
120c9cacb7
|
@ -4,7 +4,7 @@ USING: bit-arrays byte-arrays float-arrays arrays
|
|||
generator.registers assocs kernel kernel.private libc math
|
||||
namespaces parser sequences strings words assocs splitting
|
||||
math.parser cpu.architecture alien alien.accessors quotations
|
||||
system compiler.units io.files io.encodings.binary ;
|
||||
layouts system compiler.units io.files io.encodings.binary ;
|
||||
IN: alien.c-types
|
||||
|
||||
DEFER: <int>
|
||||
|
|
|
@ -6,7 +6,7 @@ inference.state inference.backend inference.dataflow system
|
|||
math.parser classes alien.arrays alien.c-types alien.structs
|
||||
alien.syntax cpu.architecture alien inspector quotations assocs
|
||||
kernel.private threads continuations.private libc combinators
|
||||
compiler.errors continuations ;
|
||||
compiler.errors continuations layouts ;
|
||||
IN: alien.compiler
|
||||
|
||||
! Common protocol for alien-invoke/alien-callback/alien-indirect
|
||||
|
|
|
@ -191,7 +191,9 @@ M: bignum '
|
|||
M: fixnum '
|
||||
#! When generating a 32-bit image on a 64-bit system,
|
||||
#! some fixnums should be bignums.
|
||||
dup most-negative-fixnum most-positive-fixnum between?
|
||||
dup
|
||||
bootstrap-most-negative-fixnum
|
||||
bootstrap-most-positive-fixnum between?
|
||||
[ tag-fixnum ] [ >bignum ' ] if ;
|
||||
|
||||
! Floats
|
||||
|
|
|
@ -7,11 +7,6 @@ IN: classes
|
|||
ARTICLE: "builtin-classes" "Built-in classes"
|
||||
"Every object is an instance of exactly one canonical " { $emphasis "built-in class" } " which defines its layout in memory and basic behavior."
|
||||
$nl
|
||||
"Corresponding to every built-in class is a built-in type number. An object can be asked for its built-in type number:"
|
||||
{ $subsection type }
|
||||
"Built-in type numbers can be converted to classes, and vice versa:"
|
||||
{ $subsection type>class }
|
||||
{ $subsection type-number }
|
||||
"The set of built-in classes is a class:"
|
||||
{ $subsection builtin-class }
|
||||
{ $subsection builtin-class? }
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
USING: alien.c-types arrays cpu.x86.assembler
|
||||
cpu.x86.architecture cpu.x86.intrinsics cpu.x86.allot
|
||||
cpu.architecture kernel kernel.private math namespaces sequences
|
||||
generator.registers generator.fixup generator system
|
||||
generator.registers generator.fixup generator system layouts
|
||||
alien.compiler combinators command-line
|
||||
compiler compiler.units io vocabs.loader ;
|
||||
IN: cpu.x86.32
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: arrays generator.fixup io.binary kernel
|
||||
combinators kernel.private math namespaces parser sequences
|
||||
words system ;
|
||||
words system layouts ;
|
||||
IN: cpu.x86.assembler
|
||||
|
||||
! A postfix assembler for x86 and AMD64.
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: arrays generic assocs hashtables
|
||||
kernel kernel.private math namespaces sequences words
|
||||
quotations strings alien system combinators math.bitfields
|
||||
words.private cpu.architecture ;
|
||||
quotations strings alien layouts system combinators
|
||||
math.bitfields words.private cpu.architecture ;
|
||||
IN: generator.fixup
|
||||
|
||||
: no-stack-frame -1 ; inline
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
USING: layouts generic help.markup help.syntax kernel math
|
||||
memory namespaces sequences kernel.private classes ;
|
||||
USING: generic help.markup help.syntax kernel math
|
||||
memory namespaces sequences kernel.private classes
|
||||
sequences.private ;
|
||||
IN: layouts
|
||||
|
||||
HELP: tag-bits
|
||||
{ $var-description "Number of least significant bits reserved for a type tag in a tagged pointer." }
|
||||
|
@ -35,3 +37,88 @@ HELP: most-positive-fixnum
|
|||
|
||||
HELP: most-negative-fixnum
|
||||
{ $values { "n" "smallest negative integer representable by a fixnum" } } ;
|
||||
|
||||
HELP: bootstrap-first-bignum
|
||||
{ $values { "n" "smallest positive integer not representable by a fixnum" } }
|
||||
{ $description "Outputs the value for the target architecture when bootstrapping." } ;
|
||||
|
||||
HELP: bootstrap-most-positive-fixnum
|
||||
{ $values { "n" "largest positive integer representable by a fixnum" } }
|
||||
{ $description "Outputs the value for the target architecture when bootstrapping." } ;
|
||||
|
||||
HELP: bootstrap-most-negative-fixnum
|
||||
{ $values { "n" "smallest negative integer representable by a fixnum" } }
|
||||
{ $description "Outputs the value for the target architecture when bootstrapping." } ;
|
||||
|
||||
HELP: cell
|
||||
{ $values { "n" "a positive integer" } }
|
||||
{ $description "Outputs the pointer size in bytes of the current CPU architecture." } ;
|
||||
|
||||
HELP: cells
|
||||
{ $values { "m" integer } { "n" integer } }
|
||||
{ $description "Computes the number of bytes used by " { $snippet "m" } " CPU operand-sized cells." } ;
|
||||
|
||||
HELP: cell-bits
|
||||
{ $values { "n" integer } }
|
||||
{ $description "Outputs the number of bits in one CPU operand-sized cell." } ;
|
||||
|
||||
HELP: bootstrap-cell
|
||||
{ $values { "n" "a positive integer" } }
|
||||
{ $description "Outputs the pointer size in bytes for the target image (if bootstrapping) or the current CPU architecture (otherwise)." } ;
|
||||
|
||||
HELP: bootstrap-cells
|
||||
{ $values { "m" integer } { "n" integer } }
|
||||
{ $description "Computes the number of bytes used by " { $snippet "m" } " cells in the target image (if bootstrapping) or the current CPU architecture (otherwise)." } ;
|
||||
|
||||
HELP: bootstrap-cell-bits
|
||||
{ $values { "n" integer } }
|
||||
{ $description "Outputs the number of bits in one cell in the target image (if bootstrapping) or the current CPU architecture (otherwise)." } ;
|
||||
|
||||
ARTICLE: "layouts-types" "Type numbers"
|
||||
"Corresponding to every built-in class is a built-in type number. An object can be asked for its built-in type number:"
|
||||
{ $subsection type }
|
||||
"Built-in type numbers can be converted to classes, and vice versa:"
|
||||
{ $subsection type>class }
|
||||
{ $subsection type-number }
|
||||
{ $subsection num-types }
|
||||
{ $see-also "builtin-classes" } ;
|
||||
|
||||
ARTICLE: "layouts-tags" "Tagged pointers"
|
||||
"Every pointer stored on the stack or in the heap has a " { $emphasis "tag" } ", which is a small integer identifying the type of the pointer. If the tag is not equal to one of the two special tags, the remaining bits contain the memory address of a heap-allocated object. The two special tags are the " { $link fixnum } " tag and the " { $link f } " tag."
|
||||
$nl
|
||||
"Getting the tag of an object:"
|
||||
{ $link tag }
|
||||
"Words for working with tagged pointers:"
|
||||
{ $subsection tag-bits }
|
||||
{ $subsection num-tags }
|
||||
{ $subsection tag-mask }
|
||||
{ $subsection tag-number }
|
||||
"The Factor VM does not actually expose any words for working with tagged pointers directly. The above words operate on integers; they are used in the bootstrap image generator and the optimizing compiler." ;
|
||||
|
||||
ARTICLE: "layouts-limits" "Sizes and limits"
|
||||
"Processor cell size:"
|
||||
{ $subsection cell }
|
||||
{ $subsection cells }
|
||||
{ $subsection cell-bits }
|
||||
"Range of integers representable by " { $link fixnum } "s:"
|
||||
{ $subsection most-negative-fixnum }
|
||||
{ $subsection most-positive-fixnum }
|
||||
"Maximum array size:"
|
||||
{ $subsection max-array-capacity } ;
|
||||
|
||||
ARTICLE: "layouts-bootstrap" "Bootstrap support"
|
||||
"Bootstrap support:"
|
||||
{ $subsection bootstrap-cell }
|
||||
{ $subsection bootstrap-cells }
|
||||
{ $subsection bootstrap-cell-bits }
|
||||
{ $subsection bootstrap-most-negative-fixnum }
|
||||
{ $subsection bootstrap-most-positive-fixnum } ;
|
||||
|
||||
ARTICLE: "layouts" "VM memory layouts"
|
||||
"The words documented in this section do not ever need to be called by user code. They are documented for the benefit of those wishing to explore the internals of Factor's implementation."
|
||||
{ $subsection "layouts-types" }
|
||||
{ $subsection "layouts-tags" }
|
||||
{ $subsection "layouts-limits" }
|
||||
{ $subsection "layouts-bootstrap" } ;
|
||||
|
||||
ABOUT: "layouts"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
! Copyright (C) 2007 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: namespaces math words kernel assocs system classes ;
|
||||
USING: namespaces math words kernel assocs classes
|
||||
kernel.private ;
|
||||
IN: layouts
|
||||
|
||||
SYMBOL: tag-mask
|
||||
|
@ -24,8 +25,23 @@ SYMBOL: type-numbers
|
|||
: tag-fixnum ( n -- tagged )
|
||||
tag-bits get shift ;
|
||||
|
||||
: cell ( -- n ) 7 getenv ; foldable
|
||||
|
||||
: cells ( m -- n ) cell * ; inline
|
||||
|
||||
: cell-bits ( -- n ) 8 cells ; inline
|
||||
|
||||
: bootstrap-cell \ cell get cell or ; inline
|
||||
|
||||
: bootstrap-cells bootstrap-cell * ; inline
|
||||
|
||||
: bootstrap-cell-bits 8 bootstrap-cells ; inline
|
||||
|
||||
: (first-bignum) ( m -- n )
|
||||
tag-bits get - 1 - 2^ ;
|
||||
|
||||
: first-bignum ( -- n )
|
||||
bootstrap-cell-bits tag-bits get - 1 - 2^ ;
|
||||
cell-bits (first-bignum) ;
|
||||
|
||||
: most-positive-fixnum ( -- n )
|
||||
first-bignum 1- ;
|
||||
|
@ -33,6 +49,15 @@ SYMBOL: type-numbers
|
|||
: most-negative-fixnum ( -- n )
|
||||
first-bignum neg ;
|
||||
|
||||
: bootstrap-first-bignum ( -- n )
|
||||
bootstrap-cell-bits (first-bignum) ;
|
||||
|
||||
: bootstrap-most-positive-fixnum ( -- n )
|
||||
bootstrap-first-bignum 1- ;
|
||||
|
||||
: bootstrap-most-negative-fixnum ( -- n )
|
||||
bootstrap-first-bignum neg ;
|
||||
|
||||
M: bignum >integer
|
||||
dup most-negative-fixnum most-positive-fixnum between?
|
||||
[ >fixnum ] when ;
|
||||
|
|
|
@ -15,10 +15,6 @@ ARTICLE: "os" "System interface"
|
|||
{ $subsection wince? }
|
||||
"Processor detection:"
|
||||
{ $subsection cpu }
|
||||
"Processor cell size:"
|
||||
{ $subsection cell }
|
||||
{ $subsection cells }
|
||||
{ $subsection cell-bits }
|
||||
"Reading environment variables:"
|
||||
{ $subsection os-env }
|
||||
{ $subsection os-envs }
|
||||
|
@ -114,7 +110,15 @@ HELP: os-envs
|
|||
}
|
||||
{ $errors "Windows CE has no concept of environment variables, so this word throws an error there." } ;
|
||||
|
||||
{ os-env os-envs } related-words
|
||||
HELP: set-os-envs
|
||||
{ $values { "assoc" "an association mapping strings to strings" } }
|
||||
{ $description "Replaces the current set of environment variables." }
|
||||
{ $notes
|
||||
"Names and values of environment variables are operating system-specific."
|
||||
}
|
||||
{ $errors "Windows CE has no concept of environment variables, so this word throws an error there." } ;
|
||||
|
||||
{ os-env os-envs set-os-envs } related-words
|
||||
|
||||
HELP: win32?
|
||||
{ $values { "?" "a boolean" } }
|
||||
|
@ -135,27 +139,3 @@ HELP: vm
|
|||
HELP: unix?
|
||||
{ $values { "?" "a boolean" } }
|
||||
{ $description "Tests if Factor is running on a Unix-like system. While this is a rather vague notion, one can use it to make certain assumptions about system calls and file structure which are not valid on Windows." } ;
|
||||
|
||||
HELP: cell
|
||||
{ $values { "n" "a positive integer" } }
|
||||
{ $description "Outputs the pointer size in bytes of the current CPU architecture." } ;
|
||||
|
||||
HELP: cells
|
||||
{ $values { "m" integer } { "n" integer } }
|
||||
{ $description "Computes the number of bytes used by " { $snippet "m" } " CPU operand-sized cells." } ;
|
||||
|
||||
HELP: cell-bits
|
||||
{ $values { "n" integer } }
|
||||
{ $description "Outputs the number of bits in one CPU operand-sized cell." } ;
|
||||
|
||||
HELP: bootstrap-cell
|
||||
{ $values { "n" "a positive integer" } }
|
||||
{ $description "Outputs the pointer size in bytes for the target image (if bootstrapping) or the current CPU architecture (otherwise)." } ;
|
||||
|
||||
HELP: bootstrap-cells
|
||||
{ $values { "m" integer } { "n" integer } }
|
||||
{ $description "Computes the number of bytes used by " { $snippet "m" } " cells in the target image (if bootstrapping) or the current CPU architecture (otherwise)." } ;
|
||||
|
||||
HELP: bootstrap-cell-bits
|
||||
{ $values { "n" integer } }
|
||||
{ $description "Outputs the number of bits in one cell in the target image (if bootstrapping) or the current CPU architecture (otherwise)." } ;
|
||||
|
|
|
@ -2,13 +2,7 @@
|
|||
! See http://factorcode.org/license.txt for BSD license.
|
||||
IN: system
|
||||
USING: kernel kernel.private sequences math namespaces
|
||||
splitting assocs system.private ;
|
||||
|
||||
: cell ( -- n ) 7 getenv ; foldable
|
||||
|
||||
: cells ( m -- n ) cell * ; inline
|
||||
|
||||
: cell-bits ( -- n ) 8 cells ; inline
|
||||
splitting assocs system.private layouts ;
|
||||
|
||||
: cpu ( -- cpu ) 8 getenv ; foldable
|
||||
|
||||
|
@ -51,12 +45,6 @@ splitting assocs system.private ;
|
|||
: solaris? ( -- ? )
|
||||
os "solaris" = ;
|
||||
|
||||
: bootstrap-cell \ cell get cell or ; inline
|
||||
|
||||
: bootstrap-cells bootstrap-cell * ; inline
|
||||
|
||||
: bootstrap-cell-bits 8 bootstrap-cells ; inline
|
||||
|
||||
: os-envs ( -- assoc )
|
||||
(os-envs) [ "=" split1 ] H{ } map>assoc ;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ db.tuples db.types unicode.case ;
|
|||
IN: db.postgresql.tests
|
||||
|
||||
: test-db ( -- postgresql-db )
|
||||
{ "localhost" "postgres" "" "factor-test" } postgresql-db ;
|
||||
{ "localhost" "postgres" "foob" "factor-test" } postgresql-db ;
|
||||
|
||||
[ ] [ test-db [ ] with-db ] unit-test
|
||||
|
||||
|
|
|
@ -186,7 +186,7 @@ TUPLE: annotation n paste-id summary author mode contents ;
|
|||
>r "tuples-test.db" temp-file sqlite-db r> with-db ;
|
||||
|
||||
: test-postgresql ( -- )
|
||||
>r { "localhost" "postgres" "" "factor-test" } postgresql-db r> with-db ;
|
||||
>r { "localhost" "postgres" "foob" "factor-test" } postgresql-db r> with-db ;
|
||||
|
||||
[ native-person-schema test-tuples ] test-sqlite
|
||||
[ assigned-person-schema test-tuples ] test-sqlite
|
||||
|
|
|
@ -116,6 +116,7 @@ ARTICLE: "objects" "Objects"
|
|||
{ $subsection "classes" }
|
||||
{ $subsection "tuples" }
|
||||
{ $subsection "generic" }
|
||||
{ $subsection "slots" }
|
||||
{ $subsection "mirrors" } ;
|
||||
|
||||
USE: random
|
||||
|
@ -235,7 +236,7 @@ ARTICLE: "program-org" "Program organization"
|
|||
USING: help.cookbook help.tutorial ;
|
||||
|
||||
ARTICLE: "handbook" "Factor documentation"
|
||||
"Welcome to Factor. Factor is dynamically-typed, stack-based, and very expressive. It is one of the most powerful and flexible programming languages ever invented. Have fun with Factor!"
|
||||
"Welcome to Factor."
|
||||
{ $heading "Starting points" }
|
||||
{ $subsection "cookbook" }
|
||||
{ $subsection "first-program" }
|
||||
|
@ -261,6 +262,7 @@ ARTICLE: "handbook" "Factor documentation"
|
|||
{ $subsection "help" }
|
||||
{ $subsection "inference" }
|
||||
{ $subsection "compiler" }
|
||||
{ $subsection "layouts" }
|
||||
{ $heading "User interface" }
|
||||
{ $about "ui" }
|
||||
{ $about "ui.tools" }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
USING: help.markup help.syntax kernel layouts ;
|
||||
USING: help.markup help.syntax kernel ;
|
||||
IN: math.constants
|
||||
|
||||
ARTICLE: "math-constants" "Constants"
|
||||
|
@ -7,9 +7,6 @@ ARTICLE: "math-constants" "Constants"
|
|||
{ $subsection euler }
|
||||
{ $subsection phi }
|
||||
{ $subsection pi }
|
||||
"Various limits:"
|
||||
{ $subsection most-positive-fixnum }
|
||||
{ $subsection most-negative-fixnum }
|
||||
{ $subsection epsilon } ;
|
||||
|
||||
ABOUT: "math-constants"
|
||||
|
|
Loading…
Reference in New Issue