void stack_tests() { stack_init(); //printf("%p, %p\n", ebp, esp); enter(16); //printf("%p, %p\n", ebp, esp); setl(24, ebp+0); setl(18, ebp+4); /* simulate another function call */ enter(16); //printf("%p, %p\n", ebp, esp); setl(5, ebp+0); setl(3, ebp+4); movl(ebp+4, eax); addl(ebp+0, eax); leave(); //printf("%p, %p\n", ebp, esp); assert(*(int32_t *)eax == 8); /* end inner function */ movl(ebp+4, eax); addl(ebp+0, eax); leave(); //printf("%p, %p\n", ebp, esp); stack_end(); assert(*(int32_t *)eax == 42); }
inline size_t JavaThread::stack_available(address cur_sp) { // This code assumes java stacks grow down address low_addr; // Limit on the address for deepest stack depth if (_stack_guard_state == stack_guard_unused) { low_addr = stack_end(); } else { low_addr = stack_reserved_zone_base(); } return cur_sp > low_addr ? cur_sp - low_addr : 0; }
GlyphToType3::GlyphToType3(TTStreamWriter& stream, struct TTFONT *font, int charindex, bool embedded /* = false */) { BYTE *glyph; tt_flags = NULL; xcoor = NULL; ycoor = NULL; epts_ctr = NULL; area_ctr = NULL; check_ctr = NULL; ctrset = NULL; stack_depth = 0; pdf_mode = font->target_type < 0; /* Get a pointer to the data. */ glyph = find_glyph_data( font, charindex ); /* If the character is blank, it has no bounding box, */ /* otherwise read the bounding box. */ if ( glyph == (BYTE*)NULL ) { llx=lly=urx=ury=0; /* A blank char has an all zero BoundingBox */ num_ctr=0; /* Set this for later if()s */ } else { /* Read the number of contours. */ num_ctr = getSHORT(glyph); /* Read PostScript bounding box. */ llx = getFWord(glyph + 2); lly = getFWord(glyph + 4); urx = getFWord(glyph + 6); ury = getFWord(glyph + 8); /* Advance the pointer. */ glyph += 10; } /* If it is a simple character, load its data. */ if (num_ctr > 0) { load_char(font, glyph); } else { num_pts=0; } /* Consult the horizontal metrics table to determine */ /* the character width. */ if ( charindex < font->numberOfHMetrics ) { advance_width = getuFWord( font->hmtx_table + (charindex * 4) ); } else { advance_width = getuFWord( font->hmtx_table + ((font->numberOfHMetrics-1) * 4) ); } /* Execute setcachedevice in order to inform the font machinery */ /* of the character bounding box and advance width. */ stack(stream, 7); if (pdf_mode) { if (!embedded) { stream.printf("%d 0 %d %d %d %d d1\n", topost(advance_width), topost(llx), topost(lly), topost(urx), topost(ury) ); } } else if (font->target_type == PS_TYPE_42_3_HYBRID) { stream.printf("pop gsave .001 .001 scale %d 0 %d %d %d %d setcachedevice\n", topost(advance_width), topost(llx), topost(lly), topost(urx), topost(ury) ); } else { stream.printf("%d 0 %d %d %d %d _sc\n", topost(advance_width), topost(llx), topost(lly), topost(urx), topost(ury) ); } /* If it is a simple glyph, convert it, */ /* otherwise, close the stack business. */ if ( num_ctr > 0 ) /* simple */ { PSConvert(stream); } else if ( num_ctr < 0 ) /* composite */ { do_composite(stream, font, glyph); } if (font->target_type == PS_TYPE_42_3_HYBRID) { stream.printf("\ngrestore\n"); } stack_end(stream); }