1 const size_t X_COUNT
=1<<8;
2 const size_t INSTR_COUNT
=PP_INSTR_COUNT
;
9 struct StackFrameHeader
{
10 StackFrameHeader
* next
;
13 struct ContStackFrame
:public StackFrameHeader
{
20 struct GCContStackFrame
:public StackFrameHeader
{
26 //struct LocalStackFrame:public StackFrameHeader{};
31 struct XStackFrame
:public StackFrameHeader
{
37 VM(BlockAllocator
&ba
,
38 bool (*_scheduleNext
)(),
39 bool (*_interrupted
)() ):
49 smallEmulAllocShadow(),
52 scheduleNext(_scheduleNext
),
53 interrupted(_interrupted
)
56 void pushCall(Node
&thread
, Node
& proc
);
57 void schedule(UnstableNode
&thread
){
58 threads
.schedule(*this, thread
);
61 void gcStack(GC
&gc
, StackFrameHeader
* &from
, StackFrameHeader
* &to
);
62 Instr instrTable
[INSTR_COUNT
];
63 Instr stackTable
[STACK_COUNT
];
64 UnstableNode X
[X_COUNT
];
65 UniqueController uniques
;
67 friend void* operator new(size_t s
, VM
& vm
);
70 FastAllocator
<4,6> bigEmulAlloc
;
71 FastAllocator
<0,6> smallEmulAlloc
;
72 FastAllocator
<4,6> bigEmulAllocShadow
;
73 FastAllocator
<0,6> smallEmulAllocShadow
;
74 template<class T
> T
* alloc(size_t count
){
75 size_t s
=((count
*sizeof(T
))+(sizeof(void*)-1))/sizeof(void*);
77 return (T
*)smallEmulAlloc
.alloc(active
,s
);
79 return (T
*)bigEmulAlloc
.alloc(active
,s
);
82 template<class T
> void free(T
* ptr
, size_t count
){
83 size_t s
=((count
*sizeof(T
))+(sizeof(void*)-1))/sizeof(void*);
85 smallEmulAlloc
.free((char*)ptr
,s
);
87 bigEmulAlloc
.free((char*)ptr
,s
);
90 template<class T
> T
* allocShadow(size_t count
){
91 size_t s
=((count
*sizeof(T
))+(sizeof(void*)-1))/sizeof(void*);
93 return (T
*)smallEmulAllocShadow
.alloc(shadow
,s
);
95 return (T
*)bigEmulAllocShadow
.alloc(shadow
,s
);
98 template<class T
> void freeShadow(T
* ptr
, size_t count
){
99 size_t s
=((count
*sizeof(T
))+(sizeof(void*)-1))/sizeof(void*);
101 smallEmulAllocShadow
.free((char*)ptr
,s
);
103 bigEmulAllocShadow
.free((char*)ptr
,s
);
106 friend class ThreadPool
;
109 bool (*scheduleNext
)();
110 bool (*interrupted
)();
112 void* operator new(size_t s
, VM
& vm
){
113 return vm
.active
.alloc(s
,DEFAULT_ALIGNMENT
);
115 //PP_FOR_EACH_INSTR(«
116 struct s_«»PP_INSTR_NAME
{
118 PP_FOR_EACH_INSTR_PARAM(«
119 m4_ifelse(m4_defn(«PP_INSTR_PARAM_TYPE»
),«WX»
,«UnstableNode
* »PP_INSTR_PARAM_NAME«
;»
,
120 m4_defn(«PP_INSTR_PARAM_TYPE»
),«RX»
,«UnstableNode
* »PP_INSTR_PARAM_NAME«
;»
,
121 m4_defn(«PP_INSTR_PARAM_TYPE»
),«WY»
,«
size_t »PP_INSTR_PARAM_NAME«
;»
,
122 m4_defn(«PP_INSTR_PARAM_TYPE»
),«RY»
,«
size_t »PP_INSTR_PARAM_NAME«
;»
,
123 m4_defn(«PP_INSTR_PARAM_TYPE»
),«RG»
,«
size_t »PP_INSTR_PARAM_NAME«
;»
,
124 m4_defn(«PP_INSTR_PARAM_TYPE»
),«V»
,«StableNode »PP_INSTR_PARAM_NAME«
;»
,
125 m4_defn(«PP_INSTR_PARAM_TYPE»
),«S»
,«
size_t »PP_INSTR_PARAM_NAME«
;»
,
126 m4_defn(«PP_INSTR_PARAM_TYPE»
),«I»
,«Instr
* »PP_INSTR_PARAM_NAME«
;»
,
127 m4_defn(«PP_INSTR_PARAM_TYPE»
),«PA»
,«
size_t »PP_INSTR_PARAM_NAME«
;»
,
128 m4_defn(«PP_INSTR_PARAM_TYPE»
),«LX»
,«
long »PP_INSTR_PARAM_NAME«
;»
,
129 m4_regexp(m4_defn(«PP_INSTR_PARAM_TYPE»
),«X\
[\
([0-9]*\
)\
]»
,«UnstableNode
* »PP_INSTR_PARAM_NAME«
[\
1];»
))»
,«»
)
133 PP_FOR_EACH_INSTR(«I_«»PP_INSTR_NAME»
,«
,»
)