pike.git
/
src
/
builtin.cmod
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/builtin.cmod:23:
#include "cyclic.h" #include "bignum.h" #include "main.h" #include "operators.h" #include "builtin_functions.h" #include "fsort.h" #include "port.h" #include "gc.h" #include "block_alloc.h" #include "pikecode.h"
+
#include "opcodes.h"
#include <ctype.h> #include <errno.h> #include <math.h> DECLARATIONS /*! @decl array(array(int|string|type)) describe_program(program p) *! @belongs Debug *!
pike.git/src/builtin.cmod:598:
}, { \ SET_SVAL(get, T_FLOAT, 0, float_number, \ DO_NOT_WARN ((FLOAT_TYPE) VAR)); \ }); HANDLE_PARAM ("enabled", { if (TYPEOF(*set) != T_INT || set->u.integer < -1 || set->u.integer > 1) SIMPLE_BAD_ARG_ERROR ("Pike.gc_parameters", 1, "integer in the range -1..1 for 'enabled'"); if (gc_enabled != set->u.integer) {
-
if (gc_enabled > 0)
-
gc_
enabled
=
set
->u.integer;
-
else
{
-
gc_
enabled
=
1;
-
if (
alloc_threshold =
=
GC
_
MAX_ALLOC_THRESHOLD)
-
alloc_threshold = GC_
MIN
_ALLOC_THRESHOLD;
+
if (gc_enabled > 0)
{
+
/* Disabling automatic
gc
- save the old alloc
_
threshold
and
set
it to
+
*
the
maximum
value
to
avoid
getting
gc_
evaluator_callback
added.
*/
+
saved_
alloc_threshold =
alloc
_
threshold;
+
alloc_threshold = GC_
MAX
_ALLOC_THRESHOLD;
}
-
+
else if (set->u.integer > 0) {
+
/* Enabling automatic gc - restore the old alloc_threshold. If the
+
* gc interval has gotten longer than it should be then the
+
* multiplier calculation in do_gc should compensate. */
+
alloc_threshold = saved_alloc_threshold;
}
-
+
gc_enabled = set->u.integer;
+
}
}, { SET_SVAL(get, T_INT, NUMBER_NUMBER, integer, gc_enabled); }); HANDLE_FLOAT_FACTOR ("garbage_ratio_low", gc_garbage_ratio_low); HANDLE_FLOAT_FACTOR ("time_ratio", gc_time_ratio); HANDLE_FLOAT_FACTOR ("garbage_ratio_high", gc_garbage_ratio_high); HANDLE_FLOAT_FACTOR ("min_gc_time_ratio", gc_min_time_ratio); HANDLE_FLOAT_FACTOR ("average_slowness", gc_average_slowness); #undef HANDLE_PARAM
pike.git/src/builtin.cmod:1674:
* assume no other entities are naughty enough to modify it). */ mapping_string_insert_string (env_allocs, env_alloc_var, putenv_str); else { struct svalue key; SET_SVAL(key, T_STRING, 0, string, env_alloc_var); map_delete (env_allocs, &key); } #endif /* !USE_SETENV */ }
+
#if defined(PIKE_DEBUG) && defined(PIKE_PORTABLE_BYTECODE)
+
+
/*! @decl void disassemble(function fun)
+
*! @belongs Debug
+
*!
+
*! Disassemble a Pike function to @[Stdio.stderr].
+
*!
+
*! @note
+
*! This function is only available if the Pike runtime
+
*! has been compiled with debug enabled.
+
*/
+
PIKEFUN void _disassemble(function fun)
+
{
+
if ((TYPEOF(*fun) != T_FUNCTION) ||
+
(SUBTYPEOF(*fun) == FUNCTION_BUILTIN)) {
+
fprintf(stderr,
+
"Disassembly only supported for functions implemented in Pike.\n");
+
} else if (!fun->u.object->prog) {
+
fprintf(stderr, "Function in destructed object.\n");
+
} else {
+
int f = SUBTYPEOF(*fun);
+
struct reference *ptr = PTR_FROM_INT(fun->u.object->prog, f);
+
struct program *p = PROG_FROM_PTR(fun->u.object->prog, ptr);
+
struct identifier *id = p->identifiers + ptr->identifier_offset;
+
if (id->func.offset >= 0) {
+
struct pike_string *tripples =
+
p->strings[read_program_data(p->program + id->func.offset, -1)];
+
switch(tripples->size_shift) {
+
#define CASE(SHIFT) \
+
case SHIFT: \
+
{ \
+
PIKE_CONCAT(p_wchar, SHIFT) *str = \
+
PIKE_CONCAT(STR, SHIFT)(tripples); \
+
int i=0; \
+
while(i < tripples->len) { \
+
fprintf(stderr, "@@@ %d: %s, %d, %d\n", \
+
i/3, \
+
instrs[*str - F_OFFSET]. \
+
name, \
+
str[1], str[2]); \
+
str += 3; \
+
i += 3; \
+
} \
+
} \
+
break
+
CASE(0);
+
CASE(1);
+
CASE(2);
+
#undef CASE
+
}
+
} else {
+
fprintf(stderr, "Prototype.\n");
+
}
+
}
+
pop_n_elems(args);
+
push_int(0);
+
}
+
+
#endif /* PIKE_DEBUG && PIKE_PORTABLE_BYTECODE */
+
/* * Backtrace handling. */ /*! @module Pike */ /*! @class BacktraceFrame */