// note: ComplexPower_bn() returns need to be +shiftfactor'ed BNComplex *ComplexPower_bn(BNComplex *t, BNComplex *xx, BNComplex *yy) { BNComplex tmp; bn_t e2x, siny, cosy; int saved; saved = save_stack(); e2x = alloc_stack(bnlength); siny = alloc_stack(bnlength); cosy = alloc_stack(bnlength); tmp.x = alloc_stack(rlength); tmp.y = alloc_stack(rlength); // 0 raised to anything is 0 if (is_bn_zero(xx->x) && is_bn_zero(xx->y)) { clear_bn(t->x); clear_bn(t->y); return (t); } cmplxlog_bn(t, xx); cplxmul_bn(&tmp, t, yy); exp_bn(e2x, tmp.x); sincos_bn(siny, cosy, tmp.y); mult_bn(t->x, e2x, cosy); mult_bn(t->y, e2x, siny); restore_stack(saved); return (t); }
static void process_function_graph_exit(struct pevent *pevent, struct pevent_record *record) { unsigned long long depth; unsigned long long val; int pid; int ret; ret = pevent_read_number_field(common_pid_field, record->data, &val); if (ret < 0) die("no pid field for function graph exit?"); ret = pevent_read_number_field(function_graph_exit_depth_field, record->data, &depth); if (ret < 0) die("no parent ip field for function?"); pid = val; if (current_pid >= 0 && pid != current_pid) { save_stack(); restore_stack(pid); } current_pid = pid; if (ips_idx != depth) { save_call_chain(pid, ips, ips_idx, 0); while (ips_idx > depth) pop_stack_func(); } func_depth = depth - 1; }
void VM::resolve() { save_stack(); m_bootport = (scm_port_t)m_heap->forward(m_bootport); m_current_input = (scm_port_t)m_heap->forward(m_current_input); m_current_output = (scm_port_t)m_heap->forward(m_current_output); m_current_error = (scm_port_t)m_heap->forward(m_current_error); m_current_exception_handler = m_heap->forward(m_current_exception_handler); m_current_environment = (scm_environment_t)m_heap->forward(m_current_environment); m_current_dynamic_environment = (scm_weakhashtable_t)m_heap->forward(m_current_dynamic_environment); m_current_dynamic_wind_record = m_heap->forward(m_current_dynamic_wind_record); m_current_source_comments = m_heap->forward(m_current_source_comments); m_pc = m_heap->forward(m_pc); m_value = m_heap->forward(m_value); m_trace = m_heap->forward(m_trace); m_trace_tail = m_heap->forward(m_trace_tail); if (m_fp != m_sp) { int argc = m_sp - m_fp; for (int i = 0; i < argc; i++) m_fp[i] = m_heap->forward(m_fp[i]); } if (m_cont) { assert(m_heap->is_collectible(m_cont)); m_cont = m_heap->interior_forward(m_cont); } if (m_env) { assert(m_heap->is_collectible(m_env)); m_env = m_heap->interior_forward(m_env); } }
void zoomoutbf(void) /* for ctl-enter, calc corners for zooming out */ { /* (xxmin,yymax), etc, are already set to zoombox corners; (sxmin,symax), etc, are still the screen's corners; use the same logic as plot_orbit stuff to first calculate current screen corners relative to the zoombox, as if the zoombox were a square with upper left (0,0) and width/depth 1; ie calc the current screen corners as if plotting them from the zoombox; then extend these co-ords from current real screen corners to get new actual corners */ bf_t savbfxmin,savbfymax,bfftemp; bf_t tmp1, tmp2, tmp3, tmp4, tmp5, tmp6,bfplotmx1,bfplotmx2,bfplotmy1,bfplotmy2; int saved; saved = save_stack(); savbfxmin = alloc_stack(rbflength+2); savbfymax = alloc_stack(rbflength+2); bfftemp = alloc_stack(rbflength+2); tmp1 = alloc_stack(rbflength+2); tmp2 = alloc_stack(rbflength+2); tmp3 = alloc_stack(rbflength+2); tmp4 = alloc_stack(rbflength+2); tmp5 = alloc_stack(rbflength+2); tmp6 = alloc_stack(rbflength+2); bfplotmx1 = alloc_stack(rbflength+2); bfplotmx2 = alloc_stack(rbflength+2); bfplotmy1 = alloc_stack(rbflength+2); bfplotmy2 = alloc_stack(rbflength+2); /* ftemp = (yymin-yy3rd)*(xx3rd-xxmin) - (xxmax-xx3rd)*(yy3rd-yymax); */ sub_bf(tmp1,bfymin,bfy3rd); sub_bf(tmp2,bfx3rd,bfxmin); sub_bf(tmp3,bfxmax,bfx3rd); sub_bf(tmp4,bfy3rd,bfymax); mult_bf(tmp5,tmp1,tmp2); mult_bf(tmp6,tmp3,tmp4); sub_bf(bfftemp,tmp5,tmp6); /* plotmx1 = (xx3rd-xxmin); */ ; /* reuse the plotxxx vars is safe */ copy_bf(bfplotmx1,tmp2); /* plotmx2 = (yy3rd-yymax); */ copy_bf(bfplotmx2,tmp4); /* plotmy1 = (yymin-yy3rd); */ copy_bf(bfplotmy1,tmp1); /* plotmy2 = (xxmax-xx3rd); */; copy_bf(bfplotmy2,tmp3); /* savxxmin = xxmin; savyymax = yymax; */ copy_bf(savbfxmin,bfxmin); copy_bf(savbfymax,bfymax); sub_bf(tmp1,bfsxmin,savbfxmin); sub_bf(tmp2,bfsymax,savbfymax); zmo_calcbf(tmp1,tmp2,bfxmin,bfymax,bfplotmx1,bfplotmx2,bfplotmy1, bfplotmy2,bfftemp); sub_bf(tmp1,bfsxmax,savbfxmin); sub_bf(tmp2,bfsymin,savbfymax); zmo_calcbf(tmp1,tmp2,bfxmax,bfymin,bfplotmx1,bfplotmx2,bfplotmy1, bfplotmy2,bfftemp); sub_bf(tmp1,bfsx3rd,savbfxmin); sub_bf(tmp2,bfsy3rd,savbfymax); zmo_calcbf(tmp1,tmp2,bfx3rd,bfy3rd,bfplotmx1,bfplotmx2,bfplotmy1, bfplotmy2,bfftemp); restore_stack(saved); }
static void process_function(struct pevent *pevent, struct pevent_record *record) { unsigned long long parent_ip; unsigned long long ip; unsigned long long val; const char *parent; const char *func; int pid; int ret; ret = pevent_read_number_field(common_pid_field, record->data, &val); if (ret < 0) die("no pid field for function?"); ret = pevent_read_number_field(function_ip_field, record->data, &ip); if (ret < 0) die("no ip field for function?"); ret = pevent_read_number_field(function_parent_ip_field, record->data, &parent_ip); if (ret < 0) die("no parent ip field for function?"); pid = val; func = pevent_find_function(pevent, ip); parent = pevent_find_function(pevent, parent_ip); if (current_pid >= 0 && pid != current_pid) { save_stack(); restore_stack(pid); } current_pid = pid; if (ips_idx) { if (ips[ips_idx - 1] == parent) push_stack_func(func); else { save_call_chain(pid, ips, ips_idx, 0); while (ips_idx) { pop_stack_func(); if (ips[ips_idx - 1] == parent) { push_stack_func(func); break; } } } } /* The above check can set ips_idx to zero again */ if (!ips_idx) { push_stack_func(parent); push_stack_func(func); } }
static void _fastcall zmo_calcbf(bf_t bfdx, bf_t bfdy, bf_t bfnewx, bf_t bfnewy,bf_t bfplotmx1, bf_t bfplotmx2, bf_t bfplotmy1, bf_t bfplotmy2, bf_t bfftemp) { bf_t btmp1, btmp2, btmp3, btmp4, btempx, btempy ; bf_t btmp2a, btmp4a; int saved; saved = save_stack(); btmp1 = alloc_stack(rbflength+2); btmp2 = alloc_stack(rbflength+2); btmp3 = alloc_stack(rbflength+2); btmp4 = alloc_stack(rbflength+2); btmp2a = alloc_stack(rbflength+2); btmp4a = alloc_stack(rbflength+2); btempx = alloc_stack(rbflength+2); btempy = alloc_stack(rbflength+2); /* calc cur screen corner relative to zoombox, when zoombox co-ords are taken as (0,0) topleft thru (1,1) bottom right */ /* tempx = dy * plotmx1 - dx * plotmx2; */ mult_bf(btmp1,bfdy,bfplotmx1); mult_bf(btmp2,bfdx,bfplotmx2); sub_bf(btempx,btmp1,btmp2); /* tempy = dx * plotmy1 - dy * plotmy2; */ mult_bf(btmp1,bfdx,bfplotmy1); mult_bf(btmp2,bfdy,bfplotmy2); sub_bf(btempy,btmp1,btmp2); /* calc new corner by extending from current screen corners */ /* *newx = sxmin + tempx*(sxmax-sx3rd)/ftemp + tempy*(sx3rd-sxmin)/ftemp; */ sub_bf(btmp1,bfsxmax,bfsx3rd); mult_bf(btmp2,btempx,btmp1); /* show_three_bf("fact1",btempx,"fact2",btmp1,"prod ",btmp2,70); */ div_bf(btmp2a,btmp2,bfftemp); /* show_three_bf("num ",btmp2,"denom",bfftemp,"quot ",btmp2a,70); */ sub_bf(btmp3,bfsx3rd,bfsxmin); mult_bf(btmp4,btempy,btmp3); div_bf(btmp4a,btmp4,bfftemp); add_bf(bfnewx,bfsxmin,btmp2a); add_a_bf(bfnewx,btmp4a); /* *newy = symax + tempy*(sy3rd-symax)/ftemp + tempx*(symin-sy3rd)/ftemp; */ sub_bf(btmp1,bfsy3rd,bfsymax); mult_bf(btmp2,btempy,btmp1); div_bf(btmp2a,btmp2,bfftemp); sub_bf(btmp3,bfsymin,bfsy3rd); mult_bf(btmp4,btempx,btmp3); div_bf(btmp4a,btmp4,bfftemp); add_bf(bfnewy,bfsymax,btmp2a); add_a_bf(bfnewy,btmp4a); restore_stack(saved); }
// Save current continuation. int save() { long tos; // top of stack if(!setjmp(registers)) // Save registers { save_stack(pbos,&tos); // Save stack next = gcont; gcont = this; return 0; } else { return 1; } }
noinline void __set_page_owner(struct page *page, unsigned int order, gfp_t gfp_mask) { struct page_ext *page_ext = lookup_page_ext(page); depot_stack_handle_t handle; if (unlikely(!page_ext)) return; handle = save_stack(gfp_mask); __set_page_owner_handle(page_ext, handle, order, gfp_mask); }
BFComplex *cplxmul_bf(BFComplex *t, BFComplex *x, BFComplex *y) { bf_t tmp1; int saved; saved = save_stack(); tmp1 = alloc_stack(rbflength+2); mult_bf(t->x, x->x, y->x); mult_bf(t->y, x->y, y->y); sub_bf(t->x, t->x, t->y); mult_bf(tmp1, x->x, y->y); mult_bf(t->y, x->y, y->x); add_bf(t->y, tmp1, t->y); restore_stack(saved); return (t); }
BNComplex *cplxmul_bn(BNComplex *t, BNComplex *x, BNComplex *y) { bn_t tmp1; int saved; saved = save_stack(); tmp1 = alloc_stack(rlength); mult_bn(t->x, x->x, y->x); mult_bn(t->y, x->y, y->y); sub_bn(t->x, t->x+shiftfactor, t->y+shiftfactor); mult_bn(tmp1, x->x, y->y); mult_bn(t->y, x->y, y->x); add_bn(t->y, tmp1+shiftfactor, t->y+shiftfactor); restore_stack(saved); return (t); }
/* big number declarations */ void calc_corner(bf_t target,bf_t p1,double p2,bf_t p3,double p4,bf_t p5) { bf_t btmp1, btmp2 ,btmp3; int saved; saved = save_stack(); btmp1 = alloc_stack(rbflength+2); btmp2 = alloc_stack(rbflength+2); btmp3 = alloc_stack(rbflength+2); /* use target as temporary variable */ floattobf(btmp3, p2); mult_bf(btmp1,btmp3,p3); mult_bf(btmp2,floattobf(target, p4),p5); add_bf(target,btmp1,btmp2); add_a_bf(target,p1); restore_stack(saved); }
cont *getcontext() { cont *c = (cont *)malloc(sizeof(cont)); long tos; /* * Save registers */ if (!setjmp(c->registers)) { /* * Save stack */ save_stack(c,pbos,&tos); return c; } else { return 0; } }
static void process_function_graph_entry(struct pevent *pevent, struct pevent_record *record) { unsigned long long depth; unsigned long long ip; unsigned long long val; const char *func; int pid; int ret; ret = pevent_read_number_field(common_pid_field, record->data, &val); if (ret < 0) die("no pid field for function graph entry?"); ret = pevent_read_number_field(function_graph_entry_func_field, record->data, &ip); if (ret < 0) die("no ip field for function graph entry?"); ret = pevent_read_number_field(function_graph_entry_depth_field, record->data, &depth); if (ret < 0) die("no parent ip field for function entry?"); pid = val; func = pevent_find_function(pevent, ip); if (current_pid >= 0 && pid != current_pid) { save_stack(); restore_stack(pid); } current_pid = pid; if (depth != ips_idx) { save_call_chain(pid, ips, ips_idx, 0); while (ips_idx > depth) pop_stack_func(); } func_depth = depth; push_stack_func(func); }
int JuliaZpowerbfFractal() { BFComplex parm2; int saved; saved = save_stack(); parm2.x = alloc_stack(bflength+2); parm2.y = alloc_stack(bflength+2); floattobf(parm2.x, param[2]); floattobf(parm2.y, param[3]); ComplexPower_bf(&bfnew, &bfold, &parm2); add_bf(bfnew.x, bfparm.x, bfnew.x); add_bf(bfnew.y, bfparm.y, bfnew.y); restore_stack(saved); return bigfltbailout(); }
int JuliaZpowerbnFractal() { BNComplex parm2; int saved; saved = save_stack(); parm2.x = alloc_stack(bnlength); parm2.y = alloc_stack(bnlength); floattobn(parm2.x, param[2]); floattobn(parm2.y, param[3]); ComplexPower_bn(&bnnew, &bnold, &parm2); add_bn(bnnew.x, bnparm.x, bnnew.x+shiftfactor); add_bn(bnnew.y, bnparm.y, bnnew.y+shiftfactor); restore_stack(saved); return bignumbailout(); }
int fileop_save_by_name( char *file_name ) { FILE *fp; char name[ MAX_TOKEN_LENGTH ]; char s[80]; strcpy( name, file_name ); file_handle_path( name, MAX_TOKEN_LENGTH ); if ( NULL == (fp = fopen( name, "w" )) ) { cprintf( ERROR, CONT, "fail to save file \"%s\"\n", name ); return ( ERROR ); } fprintf( fp, "###\n" ); fprintf( fp, "### CaFE file made by \"save\" command.\n" ); fprintf( fp, "### --- %s ---\n", version_string( s ) ); time_now( s ); fprintf( fp, "###\n### ### saved : %s\n###\n", s ); fprintf( fp, "\n\n### user stack operation functions\n\n" ); fprintf( fp, "0 >newlydefined_{\n" ); fprintf( fp, "0 >newlydefined_k}\n\n" ); fprintf( fp, "fisdef { if z :@ :{ =new =target ; 1 >newlydefined_{ ; pop\n\n" ); fprintf( fp, "fisdef k} if z :@ :k} =parent =target ; 1 >newlydefined_k} ; pop\n\n\n" ); fprintf( fp, "### content of stack\n\n" ); save_stack( NULL, fp ); fprintf( fp, "\n\n### content of stack end\n\n" ); fprintf( fp, "<newlydefined_{ if t :@ forget { ; pop\n" ); fprintf( fp, "<newlydefined_k} if t :@ forget k} ; pop\n" ); fclose( fp ); return ( NO_ERROR ); }
// for aspect ratio debugging void showaspect(char *s) { bf_t bt1, bt2, aspect; char msg[100], str[100]; int saved; saved = save_stack(); bt1 = alloc_stack(rbflength+2); bt2 = alloc_stack(rbflength+2); aspect = alloc_stack(rbflength+2); sub_bf(bt1, bfxmax, bfxmin); sub_bf(bt2, bfymax, bfymin); div_bf(aspect, bt2, bt1); bftostr(str, 10, aspect); sprintf(msg, "aspect %s\nfloat %13.10f\nbf %s\n\n", s, (yymax-yymin)/(xxmax-xxmin), str); if (stopmsg(STOPMSG_NONE, msg) == -1) goodbye(); restore_stack(saved); }
void save_stack( stack *trg_p, FILE *fp ) { stack *stack_p; stack_item *si_p; string_object s; if ( trg_p ) fprintf( fp, "\n{ " ); if ( NULL == (stack_p = make_stack()) ) { cprintf( ERROR, CONT, "unrecoverable @ show_stack (1)\n" ); exit ( 1 ); } stack_rcopy( stack_p, trg_p ); si_p = stack_p->stack_top_p; while ( si_p ) { if ( si_p->type == STACK ) { save_stack( *((stack **)si_p->item_p), fp ); } else { s = ui_stack_item_to_string( si_p, -1, STRING_WITH_QUOTE ); fprintf( fp, "%s ", s ); dispose_string_object( s ); } si_p = si_p->next; } dispose_stack( stack_p ); if ( trg_p ) fprintf( fp, "k}\n" ); }
static inline depot_stack_handle_t save_stack(gfp_t flags) { unsigned long entries[KASAN_STACK_DEPTH]; struct stack_trace trace = { .nr_entries = 0, .entries = entries, .max_entries = KASAN_STACK_DEPTH, .skip = 0 }; save_stack_trace(&trace); filter_irq_stacks(&trace); if (trace.nr_entries != 0 && trace.entries[trace.nr_entries-1] == ULONG_MAX) trace.nr_entries--; return depot_save_stack(&trace, flags); } static inline void set_track(struct kasan_track *track, gfp_t flags) { track->pid = current->pid; track->stack = save_stack(flags); }
static void my_signal_handler(int signo) { char prompt[1024]; switch (signo) { case SIGTSTP: /* program stopped (e.g., ^Z) */ if (macsbug_screen) position_cursor_for_shell_input(); if (log_stream) /* close log in case we don't come back */ fclose(log_stream); /* ...are we paranoid or what? */ signal(SIGTSTP, SIG_DFL); /* we need to do what gdb does or we */ sigsetmask(0); /* don't get control back here because */ kill(getpid(), SIGTSTP); /* of this kill() call */ signal(SIGTSTP, my_signal_handler); break; /* Note: SIGTSTP is currently not used since gdb reestablishes its own */ /* every time a command is processed. Sigh :-( */ case SIGCONT: /* continue execution (e.g., after ^Z) */ if (prev_SIGCONT_handler) prev_SIGCONT_handler(signo); signal(SIGCONT, my_signal_handler); if (macsbug_screen) { restore_current_prompt(); refresh(NULL, 0); } #if 0 if (log_stream) { /* reopen log now that we're back :-) */ log_stream = fopen(log_filename, "a"); if (!log_stream) gdb_fprintf(gdb_current_stderr, "Cannot reopen log file: %s", strerror(errno)); } #endif fprintf(stderr, "%s", gdb_get_prompt(prompt)); if (macsbug_screen && target_is_running) raise(SIGINT); break; case SIGWINCH: /* terminal screen changed */ if (prev_SIGWINCH_handler) prev_SIGWINCH_handler(signo); signal(SIGWINCH, my_signal_handler); __window_size(NULL, 0); get_screen_size(&max_rows, &max_cols); save_stack(max_rows); if (macsbug_screen) { if (max_rows < MIN_SCREEN_ROWS || max_cols < MIN_SCREEN_COLS) { macsbug_off(0); gdb_error(COLOR_RED "Terminal window too small (must be at least %ld rows and %ld columns)." COLOR_OFF "\n", MIN_SCREEN_ROWS, MIN_SCREEN_COLS); return; } restore_current_prompt(); refresh(NULL, 0); fprintf(stderr, "%s", gdb_get_prompt(prompt)); if (macsbug_screen && target_is_running) raise(SIGINT); } break; /* It looks like this one is reset by just like SIGTSTP is...damit :-( */ case SIGINT: /* terminal interrupt (^C) */ //printf("My SIGINT\n"); control_level = reading_raw = 0; if (prev_SIGINT_handler) prev_SIGINT_handler(signo); signal(SIGINT, my_signal_handler); break; default: gdb_internal_error("Unexpected signal detected in MacsBug signal handler"); break; } }
static void process_kernel_stack(struct pevent *pevent, struct pevent_record *record) { struct format_field *field = kernel_stack_caller_field; unsigned long long val; void *data = record->data; int do_restore = 0; int pid; int ret; ret = pevent_read_number_field(common_pid_field, record->data, &val); if (ret < 0) die("no pid field for function?"); pid = val; if (pending_pid >= 0 && pid != pending_pid) { reset_pending_stack(); return; } if (!field) die("no caller field for kernel stack?"); if (pending_pid >= 0) { if (current_pid >= 0) { save_stack(); do_restore = 1; } } else { /* function stack trace? */ if (current_pid >= 0) { copy_stack_to_pending(current_pid); free(ips); reset_stack(); } } current_pid = pid; /* Need to start at the end of the callers and work up */ for (data += field->offset; data < record->data + record->size; data += long_size) { unsigned long long addr; addr = pevent_read_number(pevent, data, long_size); if ((long_size == 8 && addr == (unsigned long long)-1) || ((int)addr == -1)) break; } for (data -= long_size; data >= record->data + field->offset; data -= long_size) { unsigned long long addr; const char *func; addr = pevent_read_number(pevent, data, long_size); func = pevent_find_function(pevent, addr); if (func) push_stack_func(func); } if (pending_pid >= 0) { push_stack_func(pending_ips[pending_ips_idx - 1]); reset_pending_stack(); } save_call_chain(current_pid, ips, ips_idx, 1); if (do_restore) restore_stack(current_pid); }
void drawbox(int drawit) { struct coords tl,bl,tr,br; /* dot addr of topleft, botleft, etc */ double tmpx,tmpy,dx,dy,rotcos,rotsin,ftemp1,ftemp2; double fxwidth,fxskew,fydepth,fyskew,fxadj; bf_t bffxwidth, bffxskew, bffydepth, bffyskew, bffxadj; int saved; if (zwidth==0) { /* no box to draw */ if (boxcount!=0) { /* remove the old box from display */ clearbox(); /* asm routine */ boxcount = 0; } reset_zoom_corners(); return; } if(bf_math) { saved = save_stack(); bffxwidth = alloc_stack(rbflength+2); bffxskew = alloc_stack(rbflength+2); bffydepth = alloc_stack(rbflength+2); bffyskew = alloc_stack(rbflength+2); bffxadj = alloc_stack(rbflength+2); } ftemp1 = PI*zrotate/72; /* convert to radians */ rotcos = cos(ftemp1); /* sin & cos of rotation */ rotsin = sin(ftemp1); /* do some calcs just once here to reduce fp work a bit */ fxwidth = sxmax-sx3rd; fxskew = sx3rd-sxmin; fydepth = sy3rd-symax; fyskew = symin-sy3rd; fxadj = zwidth*zskew; if(bf_math) { /* do some calcs just once here to reduce fp work a bit */ sub_bf(bffxwidth,bfsxmax,bfsx3rd); sub_bf(bffxskew,bfsx3rd,bfsxmin); sub_bf(bffydepth,bfsy3rd,bfsymax); sub_bf(bffyskew,bfsymin,bfsy3rd); floattobf(bffxadj, fxadj); } /* calc co-ords of topleft & botright corners of box */ tmpx = zwidth/-2+fxadj; /* from zoombox center as origin, on xdots scale */ tmpy = zdepth*finalaspectratio/2; dx = (rotcos*tmpx - rotsin*tmpy) - tmpx; /* delta x to rotate topleft */ dy = tmpy - (rotsin*tmpx + rotcos*tmpy); /* delta y to rotate topleft */ /* calc co-ords of topleft */ ftemp1 = zbx + dx + fxadj; ftemp2 = zby + dy/finalaspectratio; tl.x = (int)(ftemp1*(dxsize+PIXELROUND)); /* screen co-ords */ tl.y = (int)(ftemp2*(dysize+PIXELROUND)); xxmin = sxmin + ftemp1*fxwidth + ftemp2*fxskew; /* real co-ords */ yymax = symax + ftemp2*fydepth + ftemp1*fyskew; if(bf_math) { calc_corner(bfxmin,bfsxmin,ftemp1,bffxwidth,ftemp2,bffxskew); calc_corner(bfymax,bfsymax,ftemp2,bffydepth,ftemp1,bffyskew); } /* calc co-ords of bottom right */ ftemp1 = zbx + zwidth - dx - fxadj; ftemp2 = zby - dy/finalaspectratio + zdepth; br.x = (int)(ftemp1*(dxsize+PIXELROUND)); br.y = (int)(ftemp2*(dysize+PIXELROUND)); xxmax = sxmin + ftemp1*fxwidth + ftemp2*fxskew; yymin = symax + ftemp2*fydepth + ftemp1*fyskew; if(bf_math) { calc_corner(bfxmax,bfsxmin,ftemp1,bffxwidth,ftemp2,bffxskew); calc_corner(bfymin,bfsymax,ftemp2,bffydepth,ftemp1,bffyskew); } /* do the same for botleft & topright */ tmpx = zwidth/-2 - fxadj; tmpy = 0.0-tmpy; dx = (rotcos*tmpx - rotsin*tmpy) - tmpx; dy = tmpy - (rotsin*tmpx + rotcos*tmpy); ftemp1 = zbx + dx - fxadj; ftemp2 = zby + dy/finalaspectratio + zdepth; bl.x = (int)(ftemp1*(dxsize+PIXELROUND)); bl.y = (int)(ftemp2*(dysize+PIXELROUND)); xx3rd = sxmin + ftemp1*fxwidth + ftemp2*fxskew; yy3rd = symax + ftemp2*fydepth + ftemp1*fyskew; if(bf_math) { calc_corner(bfx3rd,bfsxmin,ftemp1,bffxwidth,ftemp2,bffxskew); calc_corner(bfy3rd,bfsymax,ftemp2,bffydepth,ftemp1,bffyskew); restore_stack(saved); } ftemp1 = zbx + zwidth - dx + fxadj; ftemp2 = zby - dy/finalaspectratio; tr.x = (int)(ftemp1*(dxsize+PIXELROUND)); tr.y = (int)(ftemp2*(dysize+PIXELROUND)); if (boxcount!=0) { /* remove the old box from display */ clearbox(); /* asm routine */ boxcount = 0; } if (drawit) { /* caller wants box drawn as well as co-ords calc'd */ #ifndef XFRACT /* build the list of zoom box pixels */ addbox(tl); addbox(tr); /* corner pixels */ addbox(bl); addbox(br); drawlines(tl,tr,bl.x-tl.x,bl.y-tl.y); /* top & bottom lines */ drawlines(tl,bl,tr.x-tl.x,tr.y-tl.y); /* left & right lines */ #else boxx[0] = tl.x + sxoffs; boxy[0] = tl.y + syoffs; boxx[1] = tr.x + sxoffs; boxy[1] = tr.y + syoffs; boxx[2] = br.x + sxoffs; boxy[2] = br.y + syoffs; boxx[3] = bl.x + sxoffs; boxy[3] = bl.y + syoffs; boxcount = 1; #endif dispbox(); /* asm routine to paint it */ } }
void VM::stop() { #define ARGC_TH 8 collector_usage_t last_usage = m_heap->m_usage; if (last_usage.m_recorded) m_heap->m_usage.clear(); double t1 = msec(); #if HPDEBUG if (m_heap->m_root_snapshot == ROOT_SNAPSHOT_CONSISTENCY_CHECK) save_stack(); #endif if ((m_heap->m_root_snapshot == ROOT_SNAPSHOT_EVERYTHING) || (m_heap->m_root_snapshot == ROOT_SNAPSHOT_RETRY) || (m_heap->m_root_snapshot == ROOT_SNAPSHOT_GLOBALS)) { m_heap->enqueue_root(m_bootport); m_heap->enqueue_root(m_current_input); m_heap->enqueue_root(m_current_output); m_heap->enqueue_root(m_current_error); m_heap->enqueue_root(m_current_exception_handler); m_heap->enqueue_root(m_current_environment); m_heap->enqueue_root(m_current_dynamic_environment); m_heap->enqueue_root(m_current_dynamic_wind_record); m_heap->enqueue_root(m_current_source_comments); } if ((m_heap->m_root_snapshot == ROOT_SNAPSHOT_EVERYTHING) || (m_heap->m_root_snapshot == ROOT_SNAPSHOT_RETRY) || (m_heap->m_root_snapshot == ROOT_SNAPSHOT_LOCALS)) { save_stack(); m_heap->enqueue_root(m_pc); m_heap->enqueue_root(m_value); m_heap->enqueue_root(m_trace); m_heap->enqueue_root(m_trace_tail); if (m_fp != m_sp) { int argc = m_sp - m_fp; if (argc > ARGC_TH) { scm_vector_t vector = make_vector(m_heap, argc, scm_nil); for (int i = 0; i < argc; i++) vector->elts[i] = m_fp[i]; m_heap->enqueue_root(vector); } else { for (int i = 0; i < argc; i++) m_heap->enqueue_root(m_fp[i]); } } if (m_cont) { assert(m_heap->is_collectible(m_cont)); m_heap->enqueue_root(OBJECT_SLAB_TRAITS_OF(m_cont)->cache->lookup(m_cont)); } if (m_env) { assert(m_heap->is_collectible(m_env)); m_heap->enqueue_root(OBJECT_SLAB_TRAITS_OF(m_env)->cache->lookup(m_env)); } } #if USE_PARALLEL_VM if (m_interp->live_thread_count() > 1) { if (m_heap->m_root_snapshot == ROOT_SNAPSHOT_EVERYTHING) m_interp->snapshot(this, false); if (m_heap->m_root_snapshot == ROOT_SNAPSHOT_RETRY) m_interp->snapshot(this, true); } #endif m_heap->m_collector_lock.lock(); while (m_heap->m_stop_the_world) { m_heap->m_mutator_stopped = true; m_heap->m_collector_wake.signal(); m_heap->m_mutator_wake.wait(m_heap->m_collector_lock); m_heap->m_mutator_stopped = false; } m_heap->m_collector_wake.signal(); m_heap->m_collector_lock.unlock(); double t2 = msec(); switch (m_heap->m_root_snapshot) { case ROOT_SNAPSHOT_GLOBALS: m_heap->m_usage.m_pause1 = t2 - t1; break; case ROOT_SNAPSHOT_LOCALS: m_heap->m_usage.m_pause2 = t2 - t1; break; case ROOT_SNAPSHOT_RETRY: case ROOT_SNAPSHOT_EVERYTHING: { double d = t2 - t1; if (d > m_heap->m_usage.m_pause3) m_heap->m_usage.m_pause3 = d; } break; } char usage[128]; if (flags.m_collect_notify != scm_false) { if (last_usage.m_recorded) { if (DETAILED_STATISTIC) { if (last_usage.m_synchronized) { snprintf(usage, sizeof(usage), ";; [collect synchronize: %.2fms]", last_usage.m_duration); } else { snprintf(usage, sizeof(usage), ";; [collect concurrent: %.2fms sync: %.2fms/%.2fms pause: %.2fms/%.2fms/%.2fms barrier: %dR/%dW/%dA]", last_usage.m_duration, last_usage.m_sync1, last_usage.m_sync2, last_usage.m_pause1, last_usage.m_pause2, last_usage.m_pause3, last_usage.m_barriered_read, last_usage.m_barriered_write, last_usage.m_barriered_alloc); } } else { if (last_usage.m_synchronized) { snprintf(usage, sizeof(usage), ";; [collect synchronize: %.2fms]", last_usage.m_duration); } else { snprintf(usage, sizeof(usage), ";; [collect concurrent: %.2fms pause: %.2fms/%.2fms/%.2fms]", last_usage.m_duration, last_usage.m_pause1, last_usage.m_pause2, last_usage.m_pause3); } } scoped_lock lock(m_current_output->lock); printer_t prt(this, m_current_output); prt.format("~&%s", usage); if (last_usage.m_shade_queue_hazard) prt.format("[shade queue overflow: %d]", last_usage.m_shade_queue_hazard); if (last_usage.m_expand_mark_stack) prt.format("[mark stack overflow: %d]", last_usage.m_expand_mark_stack); prt.format("~%~!"); } } else { if (last_usage.m_recorded) { if (CONCURRENT_COLLECT) { if (last_usage.m_synchronized) { snprintf(usage, sizeof(usage), "warning: low heap memory (collect: %.2fms)", last_usage.m_duration); scoped_lock lock(m_current_error->lock); printer_t prt(this, m_current_error); prt.format("~&%s~%~!", usage); } } } } }
static noinline depot_stack_handle_t save_stack(gfp_t flags) { unsigned long entries[PAGE_OWNER_STACK_DEPTH]; struct stack_trace trace = { .nr_entries = 0, .entries = entries, .max_entries = PAGE_OWNER_STACK_DEPTH, .skip = 2 }; depot_stack_handle_t handle; save_stack_trace(&trace); if (trace.nr_entries != 0 && trace.entries[trace.nr_entries-1] == ULONG_MAX) trace.nr_entries--; /* * We need to check recursion here because our request to stackdepot * could trigger memory allocation to save new entry. New memory * allocation would reach here and call depot_save_stack() again * if we don't catch it. There is still not enough memory in stackdepot * so it would try to allocate memory again and loop forever. */ if (check_recursive_alloc(&trace, _RET_IP_)) return dummy_handle; handle = depot_save_stack(&trace, flags); if (!handle) handle = failure_handle; return handle; } static inline void __set_page_owner_handle(struct page_ext *page_ext, depot_stack_handle_t handle, unsigned int order, gfp_t gfp_mask) { struct page_owner *page_owner; page_owner = get_page_owner(page_ext); page_owner->handle = handle; page_owner->order = order; page_owner->gfp_mask = gfp_mask; page_owner->last_migrate_reason = -1; __set_bit(PAGE_EXT_OWNER, &page_ext->flags); } noinline void __set_page_owner(struct page *page, unsigned int order, gfp_t gfp_mask) { struct page_ext *page_ext = lookup_page_ext(page); depot_stack_handle_t handle; if (unlikely(!page_ext)) return; handle = save_stack(gfp_mask); __set_page_owner_handle(page_ext, handle, order, gfp_mask); } void __set_page_owner_migrate_reason(struct page *page, int reason) { struct page_ext *page_ext = lookup_page_ext(page); struct page_owner *page_owner; if (unlikely(!page_ext)) return; page_owner = get_page_owner(page_ext); page_owner->last_migrate_reason = reason; } void __split_page_owner(struct page *page, unsigned int order) { int i; struct page_ext *page_ext = lookup_page_ext(page); struct page_owner *page_owner; if (unlikely(!page_ext)) return; page_owner = get_page_owner(page_ext); page_owner->order = 0; for (i = 1; i < (1 << order); i++) __copy_page_owner(page, page + i); }
bool MandelbfSetup() { // this should be set up dynamically based on corners bf_t bftemp1, bftemp2; int saved; saved = save_stack(); bftemp1 = alloc_stack(bflength+2); bftemp2 = alloc_stack(bflength+2); bf_math = bf_math_type::BIGFLT; // bfxdel = (bfxmax - bfx3rd)/(xdots-1) sub_bf(bfxdel, bfxmax, bfx3rd); div_a_bf_int(bfxdel, (U16)(xdots - 1)); // bfydel = (bfymax - bfy3rd)/(ydots-1) sub_bf(bfydel, bfymax, bfy3rd); div_a_bf_int(bfydel, (U16)(ydots - 1)); // bfxdel2 = (bfx3rd - bfxmin)/(ydots-1) sub_bf(bfxdel2, bfx3rd, bfxmin); div_a_bf_int(bfxdel2, (U16)(ydots - 1)); // bfydel2 = (bfy3rd - bfymin)/(xdots-1) sub_bf(bfydel2, bfy3rd, bfymin); div_a_bf_int(bfydel2, (U16)(xdots - 1)); abs_bf(bfclosenuff, bfxdel); if (cmp_bf(abs_bf(bftemp1, bfxdel2), bfclosenuff) > 0) copy_bf(bfclosenuff, bftemp1); if (cmp_bf(abs_bf(bftemp1, bfydel), abs_bf(bftemp2, bfydel2)) > 0) { if (cmp_bf(bftemp1, bfclosenuff) > 0) copy_bf(bfclosenuff, bftemp1); } else if (cmp_bf(bftemp2, bfclosenuff) > 0) copy_bf(bfclosenuff, bftemp2); { int t; t = abs(periodicitycheck); while (t--) half_a_bf(bfclosenuff); } c_exp = (int)param[2]; switch (fractype) { case fractal_type::JULIAFP: copy_bf(bfparm.x, bfparms[0]); copy_bf(bfparm.y, bfparms[1]); break; case fractal_type::FPMANDELZPOWER: init_big_pi(); if ((double)c_exp == param[2] && (c_exp & 1)) // odd exponents symmetry = symmetry_type::XY_AXIS_NO_PARAM; if (param[3] != 0) symmetry = symmetry_type::NONE; break; case fractal_type::FPJULIAZPOWER: init_big_pi(); copy_bf(bfparm.x, bfparms[0]); copy_bf(bfparm.y, bfparms[1]); if ((c_exp & 1) || param[3] != 0.0 || (double)c_exp != param[2]) symmetry = symmetry_type::NONE; break; default: break; } restore_stack(saved); return true; }