⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 erl_nmgc.h

📁 OTP是开放电信平台的简称
💻 H
📖 第 1 页 / 共 2 页
字号:
#ifndef __ERL_NMGC_H__#define __ERL_NMGC_H__#ifdef INCREMENTAL#include <stddef.h>      /* offsetof() */#include "erl_process.h"#define INC_FULLPAGE (INC_PAGESIZE + offsetof(INC_Page,start) / sizeof(void*))#define BOXED_NEED(PTR,HDR)                                             \  (((HDR) & _HEADER_SUBTAG_MASK) == SUB_BINARY_SUBTAG ?                 \    header_arity(HDR) + 2 :                                             \   ((HDR) & _HEADER_SUBTAG_MASK) == FUN_SUBTAG ?                        \    header_arity(HDR) + ((ErlFunThing*)(PTR))->num_free + 2 :           \   header_arity(HDR) + 1)#define INC_DECREASE_WORK(n) inc_words_to_go -= (n);#define INC_COPY_CONS(FROM,TO,PTR)					\do {									\    TO[0] = FROM[0];							\    TO[1] = FROM[1];							\    INC_MARK_FORWARD(FROM,TO);						\    *(PTR) = make_list(TO);						\    INC_DECREASE_WORK(2);						\    (TO) += 2;								\} while(0)#define INC_COPY_BOXED(FROM,TO,PTR)					\do {									\    Sint nelts;								\    Eterm hdr = *(FROM);						\									\    ASSERT(is_header(hdr));						\    INC_MARK_FORWARD(FROM,TO);						\    *(PTR) = make_boxed(TO);						\    *(TO)++ = *(FROM)++;       						\    nelts = header_arity(hdr);						\    switch ((hdr) & _HEADER_SUBTAG_MASK) {				\    case SUB_BINARY_SUBTAG: nelts++; break;				\    case FUN_SUBTAG: nelts+=((ErlFunThing*)(FROM-1))->num_free+1; break;\    }									\    INC_DECREASE_WORK(nelts + 1);					\    while (nelts--)							\	*(TO)++ = *(FROM)++;						\} while(0)/* Things copied to the old generation are not marked in the blackmap.  * This is ok since the page they are copied to (aging) is not part of * the sweep. */#define COPYMARK_CONS(FROM,TO,PTR,LIMIT)                                \do {							                \    if (ptr_within(FROM,inc_fromspc,inc_fromend)) {                     \        if (INC_IS_FORWARDED(FROM)) {                                   \            *PTR = make_list(INC_FORWARD_VALUE(FROM));                  \        } else if (TO + 2 <= LIMIT) {                                   \            INC_STORE(gray,TO,2);                                       \            INC_COPY_CONS(FROM,TO,PTR);                                 \        } else {                                                        \            Eterm *hp = erts_inc_alloc(2);                              \            INC_STORE(gray,hp,2);                                       \            INC_COPY_CONS(FROM,hp,PTR);                                 \        }                                                               \    } else if (ptr_within(FROM,global_old_heap,global_old_hend) &&     	\               (blackmap[FROM - global_old_heap] == 0)) {               \        blackmap[FROM - global_old_heap] = 2;                           \        INC_DECREASE_WORK(2);                                           \        INC_STORE(gray,FROM,2);                                         \    }                                                                   \} while(0)#define COPYMARK_BOXED(FROM,TO,PTR,LIMIT)                               \do {							                \    if (ptr_within(FROM,inc_fromspc,inc_fromend)) {                     \        int size = BOXED_NEED(FROM,*FROM);                              \        if (INC_IS_FORWARDED(FROM)) {                                   \            *PTR = make_boxed(INC_FORWARD_VALUE(FROM));                 \        } else if (TO + size <= LIMIT) {                                \            INC_STORE(gray,TO,size);                                    \            INC_COPY_BOXED(FROM,TO,PTR);                                \        } else {                                                        \            Eterm *hp = erts_inc_alloc(size);                           \            INC_STORE(gray,hp,size);                                    \            INC_COPY_BOXED(FROM,hp,PTR);                                \        }                                                               \    } else if (ptr_within(FROM,global_old_heap,global_old_hend) &&     	\               (blackmap[FROM - global_old_heap] == 0)) {               \        int size = BOXED_NEED(FROM,*FROM);                              \        if (size > 254) {                                               \            blackmap[FROM - global_old_heap] = 255;                     \            *(int*)((long)(&blackmap[FROM -                             \                                     global_old_heap] + 4) & ~3) = size; \        } else                                                          \            blackmap[FROM - global_old_heap] = size;                    \        INC_DECREASE_WORK(size);                                        \        INC_STORE(gray,FROM,size);                                      \    }                                                                   \} while(0)#define INC_MARK_FORWARD(ptr,dst) fwdptrs[(ptr) - inc_fromspc] = (dst);#define INC_IS_FORWARDED(ptr) (fwdptrs[(ptr) - inc_fromspc] != 0)#define INC_FORWARD_VALUE(ptr) fwdptrs[(ptr) - inc_fromspc]/* Note for BM_TIMER: Active timer should always be 'system' when IncAlloc * is called! */#define IncAlloc(p, sz, objv, nobj)                                     \    (ASSERT_EXPR((sz) >= 0),                                            \     (((inc_alloc_limit - global_htop) <= (sz)) ?                       \      erts_incremental_gc((p),(sz),(objv),(nobj)) : 0),                 \     ASSERT_EXPR(global_hend - global_htop > (sz)),                     \     global_htop += (sz), global_htop - (sz))/************************************************************************ * INC_STORAGE, a dynamic circular storage for objects (INC_Object).    * * Use INC_STORE to add objects to the storage. The storage can then    * * be used either as a queue, using INC_STORAGE_GET to retreive         * * values, or as a stack, using INC_STORAGE_POP. It is OK to mix calls  * * to GET and POP if that is desired.                                   * * An iterator can be declared to traverse the storage without removing * * any elements, and INC_STORAGE_STEP will then return each element in  * * turn, oldest first.                                                  * ***********************************************************************//* Declare a new storage; must be in the beginning of a block. Give * the storage a name that is used in all later calls to the storage.  * If this is an external declaration of the storage, pass the keyword * external as the first argument, otherwise leave it empty. */#define INC_STORAGE_DECLARATION(ext,name)                               \    ext INC_Storage *name##head;                                        \    ext INC_Storage *name##tail;                                        \    ext INC_Object *name##free;                                         \    ext INC_Object *name##last_free;                                    \    ext int name##size;/* Initialize the storage. Note that memory allocation is involved - * don't forget to erase the storage when you are done. */#define INC_STORAGE_INIT(name) do {                                     \    name##head = (INC_Storage*)erts_alloc(ERTS_ALC_T_OBJECT_STACK,      \                                          sizeof(INC_Storage));         \    name##head->next = name##head;                                      \    name##head->prev = name##head;                                      \    name##tail = name##head;                                            \    name##free = name##head->data;                                      \    name##last_free = name##free + INC_STORAGE_SIZE - 1;                \    name##size = 0;                                                     \} while(0)/*#define INC_STORAGE_SWAP(s1,s2) do {                                    \    INC_Storage *tmphead = s1##head;                                    \    INC_Storage *tmptail = s1##tail;                                    \    INC_Object *tmpfree = s1##free;                                     \    INC_Object *tmplast = s1##last_free;                                \    int tmpsize = s1##size;                                             \    s1##head = s2##head;                                                \    s1##tail = s2##tail;                                                \    s1##free = s2##free;                                                \    s1##last_free = s2##last_free;                                      \    s1##size = s2##size;                                                \    s2##head = tmphead;                                                 \    s2##tail = tmptail;                                                 \    s2##free = tmpfree;                                                 \    s2##last_free = tmplast;                                            \    s2##size = tmpsize;                                                 \

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -