Dear Marc,
Something I was curious about for long:
So fixnums are passed around in Gambit by value and all objects like closures, pairs, vectors and bignums are passed around by reference.
What about flonums?
Also, what's the flonum bit width (exponent & fraction respectively) on 32 and 64bit architectures?
Thanks, Mikael
Afficher les réponses par date
On 11/13/2012 11:01 AM, Mikael wrote:
Dear Marc,
Something I was curious about for long:
So fixnums are passed around in Gambit by value and all objects like closures, pairs, vectors and bignums are passed around by reference.
The objects that are boxed are listed in gambit.h:
* ___sVECTOR = tag for vectors * ___sPAIR = tag for pairs * ___sRATNUM = tag for ratnums * ___sCPXNUM = tag for cpxnums * ___sSTRUCTURE = tag for structures * ___sBOXVALUES = tag for box and multiple-values objects * ___sMEROON = tag for Meroon objects * ___sJAZZ = tag for Jazz objects * ___sSYMBOL = tag for symbols * ___sKEYWORD = tag for keywords * ___sFRAME = tag for continuation frames * ___sCONTINUATION = tag for continuations * ___sPROMISE = tag for promises * ___sWEAK = tag for weak objects (wills and GC hash tables) * ___sPROCEDURE = tag for procedures * ___sRETURN = tag for returns * ___sFOREIGN = tag for foreign data * ___sSTRING = tag for strings * ___sS8VECTOR = tag for 8-bit signed integer vectors * ___sU8VECTOR = tag for 8-bit unsigned integer vectors * ___sS16VECTOR = tag for 16-bit signed integer vectors * ___sU16VECTOR = tag for 16-bit unsigned integer vectors * ___sS32VECTOR = tag for 32-bit signed integer vectors * ___sU32VECTOR = tag for 32-bit unsigned integer vectors * ___sF32VECTOR = tag for 32-bit floating point number vectors * ___sS64VECTOR = tag for 64-bit signed integer vectors * ___sU64VECTOR = tag for 64-bit unsigned integer vectors * ___sF64VECTOR = tag for 64-bit floating point number vectors * ___sFLONUM = tag for flonums * ___sBIGNUM = tag for bignums
What about flonums?
Also, what's the flonum bit width (exponent & fraction respectively) on 32 and 64bit architecture
32-bit and 64-bit architectures both use 64-bit IEEE arithmetic. (At least, on an architecture where this doesn't happen, some things will be computed incorrectly.) That's binary64 in the following table:
https://en.wikipedia.org/wiki/IEEE_floating_point#Basic_formats
Thanks, Mikael
Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
Ok so this means for every flonum op there's a *new* object allocation on the heap right?
And, does Gambit do any fast reclaims? (I.e. effectively GC:ing some objects that are provenly not in use anymore right on the spot instead of at the next ___GC(); )
Mikael
2012/11/13 Bradley Lucier lucier@math.purdue.edu
On 11/13/2012 11:01 AM, Mikael wrote:
Dear Marc,
Something I was curious about for long:
So fixnums are passed around in Gambit by value and all objects like closures, pairs, vectors and bignums are passed around by reference.
The objects that are boxed are listed in gambit.h:
- ___sVECTOR = tag for vectors
- ___sPAIR = tag for pairs
- ___sRATNUM = tag for ratnums
- ___sCPXNUM = tag for cpxnums
- ___sSTRUCTURE = tag for structures
- ___sBOXVALUES = tag for box and multiple-values objects
- ___sMEROON = tag for Meroon objects
- ___sJAZZ = tag for Jazz objects
- ___sSYMBOL = tag for symbols
- ___sKEYWORD = tag for keywords
- ___sFRAME = tag for continuation frames
- ___sCONTINUATION = tag for continuations
- ___sPROMISE = tag for promises
- ___sWEAK = tag for weak objects (wills and GC hash tables)
- ___sPROCEDURE = tag for procedures
- ___sRETURN = tag for returns
- ___sFOREIGN = tag for foreign data
- ___sSTRING = tag for strings
- ___sS8VECTOR = tag for 8-bit signed integer vectors
- ___sU8VECTOR = tag for 8-bit unsigned integer vectors
- ___sS16VECTOR = tag for 16-bit signed integer vectors
- ___sU16VECTOR = tag for 16-bit unsigned integer vectors
- ___sS32VECTOR = tag for 32-bit signed integer vectors
- ___sU32VECTOR = tag for 32-bit unsigned integer vectors
- ___sF32VECTOR = tag for 32-bit floating point number vectors
- ___sS64VECTOR = tag for 64-bit signed integer vectors
- ___sU64VECTOR = tag for 64-bit unsigned integer vectors
- ___sF64VECTOR = tag for 64-bit floating point number vectors
- ___sFLONUM = tag for flonums
- ___sBIGNUM = tag for bignums
What about flonums?
Also, what's the flonum bit width (exponent & fraction respectively) on 32 and 64bit architecture
32-bit and 64-bit architectures both use 64-bit IEEE arithmetic. (At least, on an architecture where this doesn't happen, some things will be computed incorrectly.) That's binary64 in the following table:
https://en.wikipedia.org/wiki/IEEE_floating_point#Basic_formats
Thanks, Mikael
Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
Bradley's answer is correct in saying that Gambit's floats are boxed values but...
Gambit also supports a very clever mechanism where floats accessed in the same basic block (a block of code with no branching if my understanding is correct) are kept and manipulated as unboxed values and only boxed when they go out of the basic block scope. This feature is key to enable efficient floating point computation using Gambit.
For example, the following code should generate code equivalent to C code:
(define (foo a b) (let ((x (##fl+ a b))) (let ((y (##fl* x x))) (let ((result (##fl+ x y))) result))))
where 'a' and 'b' are unboxed upon function entry, and 'result' is boxed upon function return.
Guillaume
On Tue, Nov 13, 2012 at 11:10 AM, Bradley Lucier lucier@math.purdue.eduwrote:
On 11/13/2012 11:01 AM, Mikael wrote:
Dear Marc,
Something I was curious about for long:
So fixnums are passed around in Gambit by value and all objects like closures, pairs, vectors and bignums are passed around by reference.
The objects that are boxed are listed in gambit.h:
- ___sVECTOR = tag for vectors
- ___sPAIR = tag for pairs
- ___sRATNUM = tag for ratnums
- ___sCPXNUM = tag for cpxnums
- ___sSTRUCTURE = tag for structures
- ___sBOXVALUES = tag for box and multiple-values objects
- ___sMEROON = tag for Meroon objects
- ___sJAZZ = tag for Jazz objects
- ___sSYMBOL = tag for symbols
- ___sKEYWORD = tag for keywords
- ___sFRAME = tag for continuation frames
- ___sCONTINUATION = tag for continuations
- ___sPROMISE = tag for promises
- ___sWEAK = tag for weak objects (wills and GC hash tables)
- ___sPROCEDURE = tag for procedures
- ___sRETURN = tag for returns
- ___sFOREIGN = tag for foreign data
- ___sSTRING = tag for strings
- ___sS8VECTOR = tag for 8-bit signed integer vectors
- ___sU8VECTOR = tag for 8-bit unsigned integer vectors
- ___sS16VECTOR = tag for 16-bit signed integer vectors
- ___sU16VECTOR = tag for 16-bit unsigned integer vectors
- ___sS32VECTOR = tag for 32-bit signed integer vectors
- ___sU32VECTOR = tag for 32-bit unsigned integer vectors
- ___sF32VECTOR = tag for 32-bit floating point number vectors
- ___sS64VECTOR = tag for 64-bit signed integer vectors
- ___sU64VECTOR = tag for 64-bit unsigned integer vectors
- ___sF64VECTOR = tag for 64-bit floating point number vectors
- ___sFLONUM = tag for flonums
- ___sBIGNUM = tag for bignums
What about flonums?
Also, what's the flonum bit width (exponent & fraction respectively) on 32 and 64bit architecture
32-bit and 64-bit architectures both use 64-bit IEEE arithmetic. (At least, on an architecture where this doesn't happen, some things will be computed incorrectly.) That's binary64 in the following table:
https://en.wikipedia.org/wiki/IEEE_floating_point#Basic_formats
Thanks, Mikael
Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
On 2012-11-13, at 11:01 AM, Mikael mikael.rcv@gmail.com wrote:
Dear Marc,
Something I was curious about for long:
So fixnums are passed around in Gambit by value and all objects like closures, pairs, vectors and bignums are passed around by reference.
I prefer to use a different terminology. Values of type "Scheme objects" (the C type ___SCMOBJ) are encoded using a machine word (32 or 64 bits) which I call an "object reference". The bottom 2 bits of an object reference give some primary information on the object's type. For example, when the bottom 2 bits are zero, the object is a fixnum (the upper bits encode an integer). When the bottom bit is 1, the object is memory allocated. This means that the object reference is in fact a pointer to a block of memory where the object's content is stored. The first word of this block is the "header", which gives some secondary type information (is it a pair, vector, bignum, flonum, string, etc and the length of the object).
Object references are always passed by value.
What about flonums?
Also, what's the flonum bit width (exponent & fraction respectively) on 32 and 64bit architectures?
On both architectures, a flonum is a memory allocated object with a header and a 64 bit IEEE-754 floating point number. When doing floating point calculations, the code generator can avoid the allocation of flonums for temporary values if their life is bound by the basic block where they are calculated. For example, in this function:
(define (f x y) (flsqrt (fl+ (fl* x x) (fl* y y))))
there is only one flonum that will be allocated on the heap (the result of flsqrt). The intermediate results (i.e. x*x, y*y, and x*x+y*y) are stored in C local variables.
Marc