C-Blocks
view release on metacpan or search on metacpan
* It is now possible to indicate filter functions by name, rather than
by package.
[BUG FIXES]
* Build.PL now removes names.txt and share/perl.h.cache. This is not
important for basic installation, but shows up when the distribution
is repeatedly compiled in the same directory against different
versions of Perl.
* Executable code is now relocated to a location in memory that is
properly aligned with modern CPU page alignments. This is hard-coded
at the moment at 4096 bytes. Without this alignment, code compiled in
clex blocks would sometimes perform dismally. This showed up most
obviously in the rng and random-access benchmarks that were recently
added to the benchmarks folder. Before this fix, the C::Blocks rng
implementation would often perform as slowly as the Perl one.
0.41 Mon, Nov 28, 2016
[API CHANGES]
lib/C/Blocks.xs view on Meta::CPAN
/* Ask to save state if it's a cshare or clex block*/
if (keyword_type == IS_CSHARE || keyword_type == IS_CLEX) {
tcc_save_extended_symtab(state);
}
/* Compile the extracted code */
execute_compiler(aTHX_ state, &data, keyword_type);
/******************************************/
/* Apply the list of symbols and relocate */
/******************************************/
/* test symbols */
if (SvOK(data.add_test_SV)) {
tcc_add_symbol(state, "c_blocks_send_msg", _c_blocks_send_msg);
tcc_add_symbol(state, "c_blocks_send_bytes", _c_blocks_send_bytes);
tcc_add_symbol(state, "c_blocks_get_msg", _c_blocks_get_msg);
}
/* prepare for relocation; store in a global so that we can free everything
* at the end of the Perl program's execution. Allocate up to on page size
* more memory than we need so that we can align the code at the start of
* the page. */
int machine_code_size = tcc_relocate(state, 0);
if (machine_code_size > 0) {
/* XXX uses hard-coded page sizes. This could stand to be cleaned up, I suspect */
SV * machine_code_SV = newSV(machine_code_size + 4096);
AV * machine_code_cache = get_av("C::Blocks::__code_cache_array", GV_ADDMULTI | GV_ADD);
uintptr_t machine_code_loc = (uintptr_t)SvPVX(machine_code_SV);
unsigned int PAGESIZE = 4096;
if ((machine_code_loc & 0xfff) != 0) {
machine_code_loc &= ~0xfff;
machine_code_loc += 4096;
}
int relocate_returned = tcc_relocate(state, (void*)machine_code_loc);
av_push(machine_code_cache, machine_code_SV);
if (SvPOK(data.error_msg_sv)) {
/* Look for errors and croak */
if (strstr(SvPV_nolen(data.error_msg_sv), "error")) {
croak("C::Blocks linker error:\n%s", SvPV_nolen(data.error_msg_sv));
}
/* Otherwise report warnings */
my_warnif(aTHX_ "linker", sv_2mortal(newSVsv(data.error_msg_sv)));
}
if (relocate_returned < 0) {
croak("C::Blocks linker error: unable to relocate\n");
}
}
/********************************************************/
/* Build op tree or serialize the symbol table; cleanup */
/********************************************************/
*op_ptr = build_op(aTHX_ state, keyword_type);
if (keyword_type == IS_CSUB) extract_xsub(aTHX_ state, &data);
else if (keyword_type == IS_CSHARE || keyword_type == IS_CLEX) {
magic_sizepack|||
magic_wipepack|||
make_matcher|||
make_trie_failtable|||
make_trie|||
malloc_good_size|||n
malloced_size|||n
malloc||5.007002|n
markstack_grow|||
matcher_matches_sv|||
mayberelocate|||
measure_struct|||
memEQs|5.009005||p
memEQ|5.004000||p
memNEs|5.009005||p
memNE|5.004000||p
mem_collxfrm|||
mem_log_common|||n
mess_alloc|||
mess_nocontext|||vn
mess_sv||5.013001|
( run in 2.101 seconds using v1.01-cache-2.11-cpan-71847e10f99 )