~clint-fewbar/ubuntu/precise/erlang/merge-15b

« back to all changes in this revision

Viewing changes to erts/emulator/hipe/hipe_bif0.c

  • Committer: Package Import Robot
  • Author(s): Sergei Golovan
  • Date: 2011-12-15 19:20:10 UTC
  • mfrom: (1.1.18) (3.5.15 sid)
  • mto: (3.5.16 sid)
  • mto: This revision was merged to the branch mainline in revision 33.
  • Revision ID: package-import@ubuntu.com-20111215192010-jnxcfe3tbrpp0big
Tags: 1:15.b-dfsg-1
* New upstream release.
* Upload to experimental because this release breaks external drivers
  API along with ABI, so several applications are to be fixed.
* Removed SSL patch because the old SSL implementation is removed from
  the upstream distribution.
* Removed never used patch which added native code to erlang beam files.
* Removed the erlang-docbuilder binary package because the docbuilder
  application was dropped by upstream.
* Documented dropping ${erlang-docbuilder:Depends} substvar in
  erlang-depends(1) manpage.
* Made erlang-base and erlang-base-hipe provide virtual package
  erlang-abi-15.b (the number means the first erlang version, which
  provides current ABI).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * %CopyrightBegin%
3
3
 *
4
 
 * Copyright Ericsson AB 2001-2010. All Rights Reserved.
 
4
 * Copyright Ericsson AB 2001-2011. All Rights Reserved.
5
5
 *
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
450
450
}
451
451
 
452
452
/*
453
 
 * Memory area for constant Erlang terms.
454
 
 *
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.
461
 
 *
462
 
 * Instead, constants are placed in a single contiguous area,
463
 
 * which allows for an inexpensive "is X a constant?" test.
464
 
 *
465
 
 * XXX: Allow this area to be grown.
 
453
 * Statistics on hipe constants: size of HiPE constants, in words.
466
454
 */
467
 
 
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 */
473
 
 
474
 
static Eterm *constants_alloc(unsigned nwords)
475
 
{
476
 
    Eterm *next;
477
 
 
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);
484
 
    }
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. */
489
 
        exit(1);
490
 
    }
491
 
    constants_avail_words -= nwords;
492
 
    hipe_constants_next = next + nwords;
493
 
    return next;
494
 
}
 
455
unsigned int hipe_constants_size = 0;
495
456
 
496
457
BIF_RETTYPE hipe_bifs_constants_size_0(BIF_ALIST_0)
497
458
{
498
 
    BIF_RET(make_small(hipe_constants_next - hipe_constants_start));
 
459
    BIF_RET(make_small(hipe_constants_size));
499
460
}
500
461
 
501
462
/*
526
487
{
527
488
    Eterm obj;
528
489
    Uint size;
 
490
    Uint alloc_size;
529
491
    Eterm *hp;
530
492
    struct const_term *p;
531
493
 
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;
535
499
 
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));
537
501
 
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
1021
985
    BIF_RET(res);
1022
986
}
1023
987
 
 
988
#ifdef NO_FPE_SIGNALS
 
989
 
 
990
/* 
 
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).
 
998
   Simple and slow...
 
999
*/
 
1000
void hipe_emulate_fpe(Process* p)
 
1001
{
 
1002
    if (!finite(p->hipe.float_result)) {
 
1003
        p->fp_exception = 1;
 
1004
    }
 
1005
}
 
1006
#endif
 
1007
 
1024
1008
#if 0 /* XXX: unused */
1025
1009
/*
1026
1010
 * At least parts of this should be inlined in native code.