pike.git/
src/
las.c
Branch:
Tag:
Non-build tags
All tags
No tags
2014-12-04
2014-12-04 19:24:11 by Arne Goedeke <el@laramies.com>
c49a106d74864889a10543c8a99be9449c21d6d7 (
129
lines) (+
73
/-
56
)
[
Show
|
Annotate
]
Branch:
bill/master_archive_support
compiler: use new block allocator for node_s
30:
#include "pikecode.h" #include "gc.h" #include "pike_compiler.h"
-
#include "block_
alloc
.h"
+
#include "block_
allocator
.h"
/* Define this if you want the optimizer to be paranoid about aliasing * effects to to indexing.
455:
return 1; }
-
#undef
BLOCK
_
ALLOC
_
NEXT
-
#define BLOCK
_
ALLOC_NEXT
u.node.a
+
void
init
_
node
_
s
_
blocks()
{ }
-
#undef
PRE
_
INIT
_
BLOCK
-
#define PRE
_
INIT_BLOCK
(
NODE)
do
{
\
-
(
NODE)
->
token = USHRT
_
MAX;
\
-
}
while (0)
+
void
really
_
free
_
node
_
s
(
node * n
) {
+
ba_free
(
&Pike_compiler
->
node_allocator,
n)
;
+
}
-
BLOCK
_
ALLOC
_
FILL_PAGES(
node_s
,
2
)
+
MALLOC
_
FUNCTION
+
node * alloc
_node_s
()
{
+
return (node*
)
ba_alloc(&Pike_compiler->node_allocator);
+
}
-
#undef
BLOCK
_
ALLOC
_
NEXT
-
#define
BLOCK
_
ALLOC_NEXT
next
+
void
count
_
memory
_
in_node_ss(size_t * num, size_t * size) {
+
struct program
_
state * state = Pike
_
compiler;
-
void
free_all_nodes(void)
-
{
-
if(!Pike_compiler->previous)
-
{
-
node
*
tmp
;
+
*num
= 0;
+
*size
= 0
;
-
#ifndef
PIKE_DEBUG
-
if
(
cumulative_parse_error
) {
-
#else
-
size_t
e=0
,
s=0
;
-
count_
memory_in_
node_
ss(
&
e
, &
s
);
-
if
(
e
) {
-
#endif
-
WALK
_
NONFREE
_
BLOCKS
(
node_s,
tmp
, tmp->token
!
= USHRT_MAX
,
{
+
while
(
state
) {
+
size_t
_num
,
_size
;
+
ba_
count_
all(&state->
node_
allocator,
&
_num
, &
_size
);
+
*num += _num;
+
*size += _size;
+
state = state->previous;
+
}
+
}
+
+
void node_walker
(
struct ba_iterator * it, void * data
) {
+
do {
+
node
*
tmp
=
ba
_
it
_
val
(
it);
+
+
/*
+
* since we free nodes from here
,
we might iterate over them again.
+
* to avoid that we check for the free mark.
+
*/
+
if (
tmp->token =
=
USHRT_MAX
)
continue;
+
#ifdef PIKE_DEBUG if(!cumulative_parse_error) {
513:
debug_malloc_touch(tmp->type); free_node(tmp); }
-
}
);
+
}
while
(ba_it_step(it));
+
}
+
+
void
free_all_nodes(void)
+
{
+
node
*tmp;
+
+
#ifndef PIKE_DEBUG
+
if(cumulative_parse_error
)
{
+
#endif
+
ba_walk(&Pike_compiler->node_allocator, &node_walker, NULL)
;
#ifdef PIKE_DEBUG if(!cumulative_parse_error) Pike_fatal("Failed to free %"PRINTSIZET"d nodes when compiling!\n",e);
-
}
+
#else } #endif
-
free_all_node_s_blocks();
+
cumulative_parse_error=0; }
-
}
+
void debug_free_node(node *n) {