/***** Autogenerated from runbacktrace.in; changes will be overwritten *****/ #line 1 "runtimebase.in" /***** * runtimebase.in * Andy Hammerlindl 2009/07/28 * * Common declarations needed for all code-generating .in files. * *****/ #line 1 "runbacktrace.in" /***** * backtrace.in * Andy Hammerlindl 2009/07/28 * * Runtime functions for printing garbage collector backtraces. * *****/ #line 1 "runtimebase.in" #include "stack.h" #include "types.h" #include "builtin.h" #include "entry.h" #include "errormsg.h" #include "array.h" #include "triple.h" #include "callable.h" #include "opsymbols.h" using vm::stack; using vm::error; using vm::array; using vm::read; using vm::callable; using types::formal; using types::function; using camp::triple; #define PRIMITIVE(name,Name,asyName) using types::prim##Name; #include #undef PRIMITIVE typedef double real; void unused(void *); namespace run { array *copyArray(array *a); array *copyArray2(array *a); array *copyArray3(array *a); inline size_t checkdimension(const array *a, size_t dim) { size_t size=checkArray(a); if(dim && size != dim) { ostringstream buf; buf << "array of length " << dim << " expected"; error(buf); } return size; } template void copyArrayC(T* &dest, const array *a, size_t dim=0, GCPlacement placement=NoGC) { size_t size=checkdimension(a,dim); dest=(placement == NoGC) ? new T[size] : new(placement) T[size]; for(size_t i=0; i < size; i++) dest[i]=read(a,i); } template void copyArray2C(T* &dest, const array *a, bool square=true, size_t dim2=0, GCPlacement placement=NoGC) { size_t n=checkArray(a); size_t m=(square || n == 0) ? n : checkArray(read(a,0)); if(n > 0 && dim2 && m != dim2) { ostringstream buf; buf << "second matrix dimension must be " << dim2; error(buf); } dest=(placement == NoGC) ? new T[n*m] : new(placement) T[n*m]; for(size_t i=0; i < n; i++) { array *ai=read(a,i); size_t aisize=checkArray(ai); if(aisize == m) { T *desti=dest+i*m; for(size_t j=0; j < m; j++) desti[j]=read(ai,j); } else error(square ? "matrix must be square" : "matrix must be rectangular"); } } double *copyTripleArray2Components(array *a, bool square=true, size_t dim2=0, GCPlacement placement=NoGC); } function *realRealFunction(); #define CURRENTPEN processData().currentpen #line 11 "runbacktrace.in" // No extra code for .cc file. // Autogenerated routines: #include "runbacktrace.symbols.h" namespace run { #line 16 "runbacktrace.in" // void generate_random_backtrace(); void gen_runbacktrace0(stack *) { #line 17 "runbacktrace.in" #if defined(USEGC) && defined(GC_DEBUG) && defined(GC_BACKTRACE) GC_generate_random_backtrace(); #else error("generate_random_backtrace() requires ./configure --enable-gc-debug"); #endif } #line 25 "runbacktrace.in" // void print_random_addresses(Int n=1); void gen_runbacktrace1(stack *Stack) { Int n=vm::pop(Stack,1); #line 26 "runbacktrace.in" #if defined(USEGC) && defined(GC_DEBUG) && defined(GC_BACKTRACE) GC_gcollect(); for (Int i=0; i < n; ++i) GC_debug_print_heap_obj_proc(GC_base(GC_generate_random_valid_address())); #else error("print_random_addresses() requires ./configure --enable-gc-debug"); unused(&n); // Avoid unused variable warning message. #endif } } // namespace run namespace trans { void gen_runbacktrace_venv(venv &ve) { #line 16 "runbacktrace.in" addFunc(ve, run::gen_runbacktrace0, primVoid(), SYM(generate_random_backtrace)); #line 25 "runbacktrace.in" addFunc(ve, run::gen_runbacktrace1, primVoid(), SYM(print_random_addresses), formal(primInt(), SYM(n), true, false)); } } // namespace trans