~ubuntu-branches/debian/squeeze/erlang/squeeze

« back to all changes in this revision

Viewing changes to erts/emulator/beam/erl_gc.c

  • Committer: Bazaar Package Importer
  • Author(s): Sergei Golovan
  • Date: 2009-05-07 15:07:37 UTC
  • mfrom: (1.2.1 upstream) (5.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20090507150737-i4yb5elwinm7r0hc
Tags: 1:13.b-dfsg1-1
* Removed another bunch of non-free RFCs from original tarball
  (closes: #527053).
* Fixed build-dependencies list by adding missing comma. This requires
  libsctp-dev again. Also, added libsctp1 dependency to erlang-base and
  erlang-base-hipe packages because the shared library is loaded via
  dlopen now and cannot be added using dh_slibdeps (closes: #526682).
* Weakened dependency of erlang-webtool on erlang-observer to recommends
  to avoid circular dependencies (closes: #526627).
* Added solaris-i386 to HiPE enabled architectures.
* Made script sources in /usr/lib/erlang/erts-*/bin directory executable,
  which is more convenient if a user wants to create a target Erlang system.
* Shortened extended description line for erlang-dev package to make it
  fit 80x25 terminals.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* ``The contents of this file are subject to the Erlang Public License,
 
1
/*
 
2
 * %CopyrightBegin%
 
3
 * 
 
4
 * Copyright Ericsson AB 2002-2009. All Rights Reserved.
 
5
 * 
 
6
 * The contents of this file are subject to the Erlang Public License,
2
7
 * Version 1.1, (the "License"); you may not use this file except in
3
8
 * compliance with the License. You should have received a copy of the
4
9
 * Erlang Public License along with this software. If not, it can be
5
 
 * retrieved via the world wide web at http://www.erlang.org/.
 
10
 * retrieved online at http://www.erlang.org/.
6
11
 * 
7
12
 * Software distributed under the License is distributed on an "AS IS"
8
13
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
9
14
 * the License for the specific language governing rights and limitations
10
15
 * under the License.
11
16
 * 
12
 
 * The Initial Developer of the Original Code is Ericsson Utvecklings AB.
13
 
 * Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings
14
 
 * AB. All Rights Reserved.''
15
 
 * 
16
 
 *     $Id$
 
17
 * %CopyrightEnd%
17
18
 */
18
19
#ifdef HAVE_CONFIG_H
19
20
#  include "config.h"
30
31
#include "error.h"
31
32
#include "big.h"
32
33
#include "erl_gc.h"
33
 
#include "erl_misc_utils.h"
34
34
#if HIPE
35
35
#include "hipe_stack.h"
36
36
#endif
52
52
# define STACK_SZ_ON_HEAP(p) ((p)->hend - (p)->stop)
53
53
# define OverRunCheck(P) \
54
54
    if ((P)->stop < (P)->htop) { \
 
55
        erts_fprintf(stderr, "hend=%p\n", (p)->hend); \
 
56
        erts_fprintf(stderr, "stop=%p\n", (p)->stop); \
 
57
        erts_fprintf(stderr, "htop=%p\n", (p)->htop); \
 
58
        erts_fprintf(stderr, "heap=%p\n", (p)->heap); \
55
59
        erl_exit(ERTS_ABORT_EXIT, "%s, line %d: %T: Overrun stack and heap\n", \
56
60
                 __FILE__,__LINE__,(P)->id); \
57
61
    }
341
345
{
342
346
    Uint reclaimed_now = 0;
343
347
    int done = 0;
344
 
    Uint saved_status = p->status;
345
348
    Uint ms1, s1, us1;
346
349
 
347
350
    if (IS_TRACED_FL(p, F_TRACE_GC)) {
349
352
    }
350
353
 
351
354
    erts_smp_proc_lock(p, ERTS_PROC_LOCK_STATUS);
 
355
    p->gcstatus = p->status;
352
356
    p->status = P_GARBING;
353
357
    if (erts_system_monitor_long_gc != 0) {
354
358
        get_now(&ms1, &s1, &us1);
384
388
    ErtsGcQuickSanityCheck(p);
385
389
 
386
390
    erts_smp_proc_lock(p, ERTS_PROC_LOCK_STATUS);
387
 
    p->status = saved_status;
 
391
    p->status = p->gcstatus;
388
392
    erts_smp_proc_unlock(p, ERTS_PROC_LOCK_STATUS);
389
393
    if (IS_TRACED_FL(p, F_TRACE_GC)) {
390
394
        trace_gc(p, am_gc_end);
449
453
void
450
454
erts_garbage_collect_hibernate(Process* p)
451
455
{
452
 
    Uint saved_status = p->status;
453
456
    Uint heap_size;
454
457
    Eterm* heap;
455
458
    Eterm* htop;
466
469
     * Preliminaries.
467
470
     */
468
471
    erts_smp_proc_lock(p, ERTS_PROC_LOCK_STATUS);
 
472
    p->gcstatus = p->status;
469
473
    p->status = P_GARBING;
470
474
    erts_smp_proc_unlock(p, ERTS_PROC_LOCK_STATUS);
471
475
    erts_smp_locked_activity_begin(ERTS_ACTIVITY_GC);
580
584
    ErtsGcQuickSanityCheck(p);
581
585
 
582
586
    erts_smp_proc_lock(p, ERTS_PROC_LOCK_STATUS);
583
 
    p->status = saved_status;
 
587
    p->status = p->gcstatus;
584
588
    erts_smp_proc_unlock(p, ERTS_PROC_LOCK_STATUS);
585
589
    erts_smp_locked_activity_end(ERTS_ACTIVITY_GC);
586
590
}
589
593
void
590
594
erts_garbage_collect_literals(Process* p, Eterm* literals, Uint lit_size)
591
595
{
592
 
    Uint saved_status = p->status;
593
596
    Uint byte_lit_size = sizeof(Eterm)*lit_size;
594
597
    Uint old_heap_size;
595
598
    Eterm* temp_lit;
605
608
     * Set GC state.
606
609
     */
607
610
    erts_smp_proc_lock(p, ERTS_PROC_LOCK_STATUS);
 
611
    p->gcstatus = p->status;
608
612
    p->status = P_GARBING;
609
613
    erts_smp_proc_unlock(p, ERTS_PROC_LOCK_STATUS);
610
614
    erts_smp_locked_activity_begin(ERTS_ACTIVITY_GC);
708
712
     * Restore status.
709
713
     */
710
714
    erts_smp_proc_lock(p, ERTS_PROC_LOCK_STATUS);
711
 
    p->status = saved_status;
 
715
    p->status = p->gcstatus;
712
716
    erts_smp_proc_unlock(p, ERTS_PROC_LOCK_STATUS);
713
717
    erts_smp_locked_activity_end(ERTS_ACTIVITY_GC);
714
718
}
759
763
        /*
760
764
         * Copy newly received message onto the end of the new heap.
761
765
         */
 
766
        ErtsGcQuickSanityCheck(p);
762
767
        for (msgp = p->msg.first; msgp; msgp = msgp->next) {
763
768
            if (msgp->bp) {
764
769
                erts_move_msg_mbuf_to_heap(&p->htop, &p->off_heap, msgp);
 
770
                ErtsGcQuickSanityCheck(p);
765
771
            }
766
772
        }
767
 
        OverRunCheck(p);
 
773
        ErtsGcQuickSanityCheck(p);
768
774
 
769
775
        GEN_GCS(p)++;
770
776
        size_after = HEAP_TOP(p) - HEAP_START(p);
1294
1300
 
1295
1301
    HIGH_WATER(p) = HEAP_TOP(p);
1296
1302
 
 
1303
    ErtsGcQuickSanityCheck(p);
1297
1304
    /*
1298
1305
     * Copy newly received message onto the end of the new heap.
1299
1306
     */
1300
1307
    for (msgp = p->msg.first; msgp; msgp = msgp->next) {
1301
1308
        if (msgp->bp) {
1302
1309
            erts_move_msg_mbuf_to_heap(&p->htop, &p->off_heap, msgp);
 
1310
            ErtsGcQuickSanityCheck(p);
1303
1311
        }
1304
1312
    }
1305
1313