4
* Copyright Ericsson AB 2001-2010. All Rights Reserved.
4
* Copyright Ericsson AB 2001-2011. All Rights Reserved.
6
6
* The contents of this file are subject to the Erlang Public License,
7
7
* Version 1.1, (the "License"); you may not use this file except in
453
* Memory area for constant Erlang terms.
455
* These constants must not be forwarded by the gc.
456
* Therefore, the gc needs to be able to distinguish between
457
* collectible objects and constants. Unfortunately, an Erlang
458
* process' collectible objects are scattered around in two
459
* heaps and a list of message buffers, so testing "is X a
460
* collectible object?" can be expensive.
462
* Instead, constants are placed in a single contiguous area,
463
* which allows for an inexpensive "is X a constant?" test.
465
* XXX: Allow this area to be grown.
453
* Statistics on hipe constants: size of HiPE constants, in words.
468
/* not static, needed by garbage collector */
469
Eterm *hipe_constants_start = NULL;
470
Eterm *hipe_constants_next = NULL;
471
static unsigned constants_avail_words = 0;
472
#define CONSTANTS_BYTES (1536*1024*sizeof(Eterm)) /* 1.5 M words */
474
static Eterm *constants_alloc(unsigned nwords)
478
/* initialise at the first call */
479
if ((next = hipe_constants_next) == NULL) {
480
next = (Eterm*)erts_alloc(ERTS_ALC_T_HIPE, CONSTANTS_BYTES);
481
hipe_constants_start = next;
482
hipe_constants_next = next;
483
constants_avail_words = CONSTANTS_BYTES / sizeof(Eterm);
485
if (nwords > constants_avail_words) {
486
fprintf(stderr, "Native code constants pool depleted!\r\n");
487
/* Must terminate immediately. erl_exit() seems to
488
continue running some code which then SIGSEGVs. */
491
constants_avail_words -= nwords;
492
hipe_constants_next = next + nwords;
455
unsigned int hipe_constants_size = 0;
496
457
BIF_RETTYPE hipe_bifs_constants_size_0(BIF_ALIST_0)
498
BIF_RET(make_small(hipe_constants_next - hipe_constants_start));
459
BIF_RET(make_small(hipe_constants_size));
530
492
struct const_term *p;
532
494
obj = (Eterm)tmpl;
533
495
ASSERT(is_not_immed(obj));
534
496
size = size_object(obj);
497
alloc_size = size + (offsetof(struct const_term, mem)/sizeof(Eterm));
498
hipe_constants_size += alloc_size;
536
p = (struct const_term*)constants_alloc(size + (offsetof(struct const_term, mem)/sizeof(Eterm)));
500
p = (struct const_term*)erts_alloc(ERTS_ALC_T_HIPE, alloc_size * sizeof(Eterm));
538
502
/* I have absolutely no idea if having a private 'off_heap'
539
503
works or not. _Some_ off_heap object is required for
988
#ifdef NO_FPE_SIGNALS
991
This is the current solution to make hipe run without FPE.
992
The native code is the same except that a call to this primop
993
is made after _every_ float operation to check the result.
994
The native fcheckerror still done later will detect if an
995
"emulated" FPE has occured.
996
We use p->hipe.float_result to avoid passing a 'double' argument,
997
which has its own calling convention (on amd64 at least).
1000
void hipe_emulate_fpe(Process* p)
1002
if (!finite(p->hipe.float_result)) {
1003
p->fp_exception = 1;
1024
1008
#if 0 /* XXX: unused */
1026
1010
* At least parts of this should be inlined in native code.