/* * begin a GSYM block */ void CVmImageWriter::begin_gsym_block() { /* * begin the block - GSYM blocks are always optional, since they're * purely for debugging purposes */ begin_block("GSYM", FALSE); /* remember where the prefix goes so we can fix it up later */ gsym_prefix_ = fp_->get_pos(); /* write a placehodler object count and the metaclass index */ fp_->write_uint4(0); }
/* * begin a SRCF block */ void CVmImageWriter::begin_srcf_block(int count) { /* * begin the block - SRCF blocks are always optional, since they're * purely for debugging purposes */ begin_block("SRCF", FALSE); /* write the number of entries */ fp_->write_uint2(count); /* each source line record is 8 bytes in the current format */ fp_->write_uint2(8); }
/* * Write a constant pool definition block */ void CVmImageWriter::write_pool_def(uint pool_id, uint32 page_count, uint32 page_size, int mandatory) { char buf[16]; /* prepare the block's data */ oswp2(buf, pool_id); oswp4(buf+2, page_count); oswp4(buf+6, page_size); /* open the block, write the data, and end the block */ begin_block("CPDF", mandatory); fp_->write_bytes(buf, 10); end_block(); }
/* * Begin writing a constant pool page. This constructs the header and * prepares for writing the bytes making up the page. */ void CVmImageWriter::begin_pool_page(uint pool_id, uint32 page_index, int mandatory, uchar xor_mask) { char buf[16]; /* begin the block */ begin_block("CPPG", mandatory); /* prepare the prefix */ oswp2(buf, pool_id); oswp4(buf+2, page_index); buf[6] = xor_mask; /* write the prefix */ fp_->write_bytes(buf, 7); }
/* * begin an MHLS block */ void CVmImageWriter::begin_mhls_block() { /* * begin the block - MHLS blocks are always optional, since they're * purely for debugging purposes */ begin_block("MHLS", FALSE); /* remember where the count goes so we can fix it up later */ mhls_cnt_pos_ = fp_->get_pos(); /* write a placehodler count */ fp_->write_uint4(0); /* there are no entries yet */ mhls_cnt_ = 0; }
/* * Begin a symbolic names block */ void CVmImageWriter::begin_sym_block() { char buf[4]; /* begin the block */ begin_block("SYMD", FALSE); /* remember where our placeholder goes */ symd_prefix_ = fp_->get_pos(); /* prepare the placeholder prefix, using a zero count for now */ oswp2(buf, 0); /* write the prefix */ fp_->write_bytes(buf, 2); /* we haven't written any symbolic name items yet */ symd_cnt_ = 0; }
/* * begin an SINI block */ void CVmImageWriter::begin_sini_block(ulong static_cs_ofs, ulong init_cnt) { /* * begin the block - SINI blocks are mandatory, since the program * depends upon static initializers being evaluated immediately * after compilation */ begin_block("SINI", TRUE); /* * write the size of our header (including the size prefix); this * serves as a simple versioning flag so we can tell if fields added * at a later date are part of a given image file's data or not (if * the header is too small to contain them, they're not present) */ fp_->write_uint4(12); /* write the starting static code segment offset */ fp_->write_uint4(static_cs_ofs); /* write the initializer count */ fp_->write_uint4(init_cnt); }
/* * Write a constant pool page */ void CVmImageWriter::write_pool_page(uint pool_id, uint32 page_index, const char *page_data, uint32 page_data_size, int mandatory, uchar xor_mask) { char buf[16]; /* begin the block */ begin_block("CPPG", mandatory); /* prepare the prefix */ oswp2(buf, pool_id); oswp4(buf+2, page_index); buf[6] = xor_mask; /* write the prefix */ fp_->write_bytes(buf, 7); /* write the page data, XOR'ing the data with the mask byte */ xor_and_write_bytes(page_data, page_data_size, xor_mask); /* end the block */ end_block(); }
void Profiler::begin_frame() { // End the previous frame if any end_frame(); begin_block("RunFrame"); }