Hi,
As per the cage/todo.pod I ran CPD (http://pmd.sourceforge.net) on src/,
the attached file contains the output.
With some pointers, I can figure out how to eliminate the code
duplication, please advice.
Regards,
Juan Jose
Skipping /home/juanjose/projects/parrot-bleed/src/exec_save.c due to parse error
=====================================================================
Found a 126 line (421 tokens) duplication in the following files:
Starting at line 954 of
/home/juanjose/projects/parrot-bleed/src/jit/sun4/jit_emit.h
Starting at line 2618 of
/home/juanjose/projects/parrot-bleed/src/jit/i386/jit_emit.h
break;
}
}
/* emit a call to a vtable func
* $1->vtable(interp, $1)
*/
static void
Parrot_jit_vtable1_op(Parrot_jit_info_t *jit_info,
Interp * interpreter)
{
int a[] = { 1 };
Parrot_jit_vtable_n_op(jit_info, interpreter, 1, a);
}
/* emit a call to a vtable func
* $1 = $2->vtable(interp, $2)
*/
static void
Parrot_jit_vtable1r_op(Parrot_jit_info_t *jit_info,
Interp * interpreter)
{
int a[] = { 2 };
Parrot_jit_vtable_n_op(jit_info, interpreter, 1, a);
Parrot_jit_store_retval(jit_info, interpreter);
}
/* emit a call to a vtable func
* $1 = $2->vtable(interp, $2, $3)
*/
static void
Parrot_jit_vtable_1r223_op(Parrot_jit_info_t *jit_info,
Interp * interpreter)
{
int a[] = { 2 , 3};
Parrot_jit_vtable_n_op(jit_info, interpreter, 2, a);
Parrot_jit_store_retval(jit_info, interpreter);
}
/* emit a call to a vtable func
* $1 = $3->vtable(interp, $3, $2)
*/
static void
Parrot_jit_vtable_1r332_op(Parrot_jit_info_t *jit_info,
Interp * interpreter)
{
int a[] = { 3 , 2};
Parrot_jit_vtable_n_op(jit_info, interpreter, 2, a);
Parrot_jit_store_retval(jit_info, interpreter);
}
/* emit a call to a vtable func
* $1->vtable(interp, $1, $2)
*/
static void
Parrot_jit_vtable_112_op(Parrot_jit_info_t *jit_info,
Interp * interpreter)
{
int a[] = { 1, 2 };
Parrot_jit_vtable_n_op(jit_info, interpreter, 2, a);
}
/* emit a call to a vtable func
* $1->vtable(interp, $1, $1)
*/
static void
Parrot_jit_vtable_111_op(Parrot_jit_info_t *jit_info,
Interp * interpreter)
{
int a[] = { 1, 1 };
Parrot_jit_vtable_n_op(jit_info, interpreter, 2, a);
}
/* emit a call to a vtable func
* $2->vtable(interp, $2, $1)
*/
static void
Parrot_jit_vtable_221_op(Parrot_jit_info_t *jit_info,
Interp * interpreter)
{
int a[] = { 2, 1 };
Parrot_jit_vtable_n_op(jit_info, interpreter, 2, a);
}
/* emit a call to a vtable func
* $2->vtable(interp, $2, $3, $1)
*/
static void
Parrot_jit_vtable_2231_op(Parrot_jit_info_t *jit_info,
Interp * interpreter)
{
int a[] = { 2, 3, 1 };
Parrot_jit_vtable_n_op(jit_info, interpreter, 3, a);
}
/* emit a call to a vtable func
* $1->vtable(interp, $1, $2, $3)
*/
static void
Parrot_jit_vtable_1123_op(Parrot_jit_info_t *jit_info,
Interp * interpreter)
{
int a[] = { 1, 2, 3 };
Parrot_jit_vtable_n_op(jit_info, interpreter, 3, a);
}
/* emit a call to a vtable func
* $1->vtable(interp, $1, $2, $1)
*/
static void
Parrot_jit_vtable_1121_op(Parrot_jit_info_t *jit_info,
Interp * interpreter)
{
int a[] = { 1, 2, 1 };
Parrot_jit_vtable_n_op(jit_info, interpreter, 3, a);
}
/* if_p_ic, unless_p_ic */
static void
Parrot_jit_vtable_if_unless_op(Parrot_jit_info_t *jit_info,
Interp * interpreter, int unless)
{
int ic = *(jit_info->cur_op + 2); /* branch offset */
/* emit call vtable function i.e. get_bool, result eax */
Parrot_jit_vtable1_op(jit_info, interpreter);
=====================================================================
Found a 50 line (268 tokens) duplication in the following files:
Starting at line 1409 of /home/juanjose/projects/parrot-bleed/src/string.c
Starting at line 1478 of /home/juanjose/projects/parrot-bleed/src/string.c
string_bitwise_xor(Interp *interpreter, STRING *s1, STRING *s2, STRING **dest)
{
STRING *res;
size_t maxlen = 0;
if (s1) {
if (s1->encoding != Parrot_fixed_8_encoding_ptr) {
real_exception(interpreter, NULL, INVALID_ENCODING,
"string bitwise_and (%s/%s) unsupported",
((ENCODING *)(s1->encoding))->name,
((ENCODING *)(s2->encoding))->name);
}
maxlen = s1->bufused;
}
if (s2) {
if (s2->encoding != Parrot_fixed_8_encoding_ptr) {
real_exception(interpreter, NULL, INVALID_ENCODING,
"string bitwise_and (%s/%s) unsupported",
((ENCODING *)(s2->encoding))->name,
((ENCODING *)(s2->encoding))->name);
}
if (s2->bufused > maxlen)
maxlen = s2->bufused;
}
if (dest && *dest) {
res = *dest;
res->encoding = Parrot_fixed_8_encoding_ptr;
res->charset = Parrot_binary_charset_ptr;
}
else
res = string_make_direct(interpreter, NULL, maxlen,
Parrot_fixed_8_encoding_ptr, Parrot_binary_charset_ptr, 0);
if (!maxlen) {
res->bufused = 0;
res->strlen = 0;
return res;
}
#if ! DISABLE_GC_DEBUG
/* trigger GC for debug */
if (interpreter && GC_DEBUG(interpreter))
Parrot_do_dod_run(interpreter, DOD_trace_stack_FLAG);
#endif
make_writable(interpreter, &res, maxlen, enum_stringrep_one);
BITWISE_OR_STRINGS(Parrot_UInt1, Parrot_UInt1, Parrot_UInt1,
s1, s2, res, maxlen, ^);
=====================================================================
Found a 17 line (261 tokens) duplication in the following files:
Starting at line 17 of /home/juanjose/projects/parrot-bleed/src/charset/tables.c
Starting at line 51 of /home/juanjose/projects/parrot-bleed/src/charset/tables.c
const PARROT_CCLASS_FLAGS Parrot_iso_8859_1_typetable[256] = {
0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, /* 0-7 */
0x0200, 0x0320, 0x1220, 0x0220, 0x1220, 0x1220, 0x0200, 0x0200, /* 8-15 */
0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, /* 16-23 */
0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, /* 24-31 */
0x0160, 0x04c0, 0x04c0, 0x04c0, 0x04c0, 0x04c0, 0x04c0, 0x04c0, /* 32-39 */
0x04c0, 0x04c0, 0x04c0, 0x04c0, 0x04c0, 0x04c0, 0x04c0, 0x04c0, /* 40-47 */
0x28d8, 0x28d8, 0x28d8, 0x28d8, 0x28d8, 0x28d8, 0x28d8, 0x28d8, /* 48-55 */
0x28d8, 0x28d8, 0x04c0, 0x04c0, 0x04c0, 0x04c0, 0x04c0, 0x04c0, /* 56-63 */
0x04c0, 0x28d5, 0x28d5, 0x28d5, 0x28d5, 0x28d5, 0x28d5, 0x28c5, /* 64-71 */
0x28c5, 0x28c5, 0x28c5, 0x28c5, 0x28c5, 0x28c5, 0x28c5, 0x28c5, /* 72-79 */
0x28c5, 0x28c5, 0x28c5, 0x28c5, 0x28c5, 0x28c5, 0x28c5, 0x28c5, /* 80-87 */
0x28c5, 0x28c5, 0x28c5, 0x04c0, 0x04c0, 0x04c0, 0x04c0, 0x24c0, /* 88-95 */
0x04c0, 0x28d6, 0x28d6, 0x28d6, 0x28d6, 0x28d6, 0x28d6, 0x28c6, /* 96-103 */
0x28c6, 0x28c6, 0x28c6, 0x28c6, 0x28c6, 0x28c6, 0x28c6, 0x28c6, /* 104-111 */
0x28c6, 0x28c6, 0x28c6, 0x28c6, 0x28c6, 0x28c6, 0x28c6, 0x28c6, /* 112-119 */
0x28c6, 0x28c6, 0x28c6, 0x04c0, 0x04c0, 0x04c0, 0x04c0, 0x0200, /* 120-127 */
=====================================================================
Found a 41 line (256 tokens) duplication in the following files:
Starting at line 256 of
/home/juanjose/projects/parrot-bleed/src/jit_debug_xcoff.c
Starting at line 288 of /home/juanjose/projects/parrot-bleed/src/jit_debug.c
struct PackFile_Debug *debug;
if (interpreter->code->debugs) {
char *ext;
char *src = string_to_cstring(interpreter,
Parrot_debug_pc_to_filename(interpreter,
interpreter->code->debugs, 0));
pasmfile = string_make(interpreter, src, strlen(src), NULL,
PObj_external_FLAG);
file = string_copy(interpreter, pasmfile);
/* chop pasm/pir */
ext = strrchr(src, '.');
if (ext && strcmp (ext, ".pasm") == 0)
file = string_chopn(interpreter, file, 4, 1);
else if (ext && strcmp (ext, ".pir") == 0)
file = string_chopn(interpreter, file, 3, 1);
else if (!ext) /* EVAL_n */
file = string_append(interpreter, file,
string_make(interpreter, ".", 1, NULL, PObj_external_FLAG),
0);
}
else {
/* chop pbc */
file = string_chopn(interpreter, file, 3, 1);
pasmfile = debug_file(interpreter, file, "pasm");
}
stabsfile = debug_file(interpreter, file, "stabs.s");
ofile = debug_file(interpreter, file, "o");
{
char *temp = string_to_cstring(interpreter,stabsfile);
stabs = fopen(temp, "w");
free(temp);
}
if (stabs == NULL)
return;
{
char *temp = string_to_cstring(interpreter, pasmfile);
/* filename info */
fprintf(stabs, ".data\n.text\n"); /* darwin wants it */
=====================================================================
Found a 48 line (230 tokens) duplication in the following files:
Starting at line 163 of
/home/juanjose/projects/parrot-bleed/src/encodings/utf16.c
Starting at line 404 of
/home/juanjose/projects/parrot-bleed/src/encodings/utf8.c
utf8_encode(p, codepoint);
}
static UINTVAL
get_byte(Interp *interpreter, const STRING *src, UINTVAL offset)
{
unsigned char *contents = src->strstart;
if (offset >= src->bufused) {
/* internal_exception(0,
"get_byte past the end of the buffer (%i of %i)",
offset, src->bufused);*/
return 0;
}
return contents[offset];
}
static void
set_byte(Interp *interpreter, const STRING *src,
UINTVAL offset, UINTVAL byte)
{
unsigned char *contents;
if (offset >= src->bufused) {
internal_exception(0, "set_byte past the end of the buffer");
}
contents = src->strstart;
contents[offset] = (unsigned char)byte;
}
static STRING *
get_codepoints(Interp *interpreter, STRING *src,
UINTVAL offset, UINTVAL count)
{
String_iter iter;
UINTVAL start;
STRING *return_string = Parrot_make_COW_reference(interpreter,
src);
iter_init(interpreter, src, &iter);
iter.set_position(interpreter, &iter, offset);
start = iter.bytepos;
return_string->strstart = (char *)return_string->strstart + start ;
iter.set_position(interpreter, &iter, offset + count);
return_string->bufused = iter.bytepos - start;
return_string->strlen = count;
return_string->hashval = 0;
return return_string;
}
static STRING *
=====================================================================
Found a 6 line (192 tokens) duplication in the following files:
Starting at line 28 of /home/juanjose/projects/parrot-bleed/src/encodings/utf8.c
Starting at line 34 of /home/juanjose/projects/parrot-bleed/src/encodings/utf8.c
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* ascii */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* ascii */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* bogus */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* bogus */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* bogus */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* bogus */
=====================================================================
Found a 23 line (182 tokens) duplication in the following files:
Starting at line 291 of /home/juanjose/projects/parrot-bleed/src/byteorder.c
Starting at line 316 of /home/juanjose/projects/parrot-bleed/src/byteorder.c
fetch_buf_be_16(unsigned char *rb, unsigned char *b)
{
#if PARROT_BIGENDIAN
memcpy(rb, b, 16);
#else
rb[0] = b[15];
rb[1] = b[14];
rb[2] = b[13];
rb[3] = b[12];
rb[4] = b[11];
rb[5] = b[10];
rb[6] = b[9];
rb[7] = b[8];
rb[8] = b[7];
rb[9] = b[6];
rb[10] = b[5];
rb[11] = b[4];
rb[12] = b[3];
rb[13] = b[2];
rb[14] = b[1];
rb[15] = b[0];
#endif
}
=====================================================================
Found a 55 line (172 tokens) duplication in the following files:
Starting at line 234 of
/home/juanjose/projects/parrot-bleed/src/encodings/utf16.c
Starting at line 485 of
/home/juanjose/projects/parrot-bleed/src/encodings/utf8.c
return return_string;
}
static STRING *
get_bytes_inplace(Interp *interpreter, STRING *src,
UINTVAL offset, UINTVAL count, STRING *return_string)
{
UNIMPL;
return NULL;
}
static void
set_codepoints(Interp *interpreter, STRING *src,
UINTVAL offset, UINTVAL count, STRING *new_codepoints)
{
UNIMPL;
}
static void
set_bytes(Interp *interpreter, STRING *src,
UINTVAL offset, UINTVAL count, STRING *new_bytes)
{
UNIMPL;
}
/* Unconditionally makes the string be in this encoding, if that's
valid */
static void
become_encoding(Interp *interpreter, STRING *src)
{
UNIMPL;
}
static UINTVAL
codepoints(Interp *interpreter, STRING *src)
{
String_iter iter;
/*
* this is used to initially calculate src->strlen,
* therefore we must scan the whole string
*/
iter_init(interpreter, src, &iter);
while (iter.bytepos < src->bufused)
iter.get_and_advance(interpreter, &iter);
return iter.charpos;
}
static UINTVAL
bytes(Interp *interpreter, STRING *src)
{
return src->bufused;
}
static void
=====================================================================
Found a 25 line (171 tokens) duplication in the following files:
Starting at line 1116 of /home/juanjose/projects/parrot-bleed/src/jit.c
Starting at line 1187 of /home/juanjose/projects/parrot-bleed/src/jit.c
Parrot_jit_save_registers(Parrot_jit_info_t *jit_info,
Interp * interpreter, int volatiles)
{
Parrot_jit_optimizer_section_t *sect = jit_info->optimizer->cur_section;
Parrot_jit_register_usage_t *ru = sect->ru;
int i, typ;
size_t offs;
int base_reg = 0; /* -O3 warning */
int lasts[] = { 0, 0, 0, 0 };
const char * maps[] = {0, 0, 0, 0};
int first = 1;
int code_type;
const jit_arch_info *arch_info;
const jit_arch_regs *reg_info;
arch_info = jit_info->arch_info;
code_type = jit_info->code_type;
reg_info = arch_info->regs + code_type;
maps[0] = reg_info->map_I;
maps[3] = reg_info->map_F;
lasts[0] = reg_info->n_preserved_I;
lasts[3] = reg_info->n_preserved_F;
for (typ = 0; typ < 4; typ++) {
if (maps[typ])
=====================================================================
Found a 30 line (168 tokens) duplication in the following files:
Starting at line 968 of
/home/juanjose/projects/parrot-bleed/src/jit/ppc/jit_emit.h
Starting at line 3084 of
/home/juanjose/projects/parrot-bleed/src/jit/i386/jit_emit.h
reg_info = &jit_info->arch_info->regs[jit_info->code_type];
if (!recursive) {
/* create args array */
internal_exception(1, "set_args_jit - can't do that yet ");
}
constants = CONTEXT(interpreter->ctx)->constants;
sig_args = constants[CUR_OPCODE[1]]->u.key;
if (!SIG_ELEMS(sig_args))
return;
params = jit_info->optimizer->sections->begin;
sig_params = constants[params[1]]->u.key;
ASSERT_SIG_PMC(sig_params);
sig_bits = SIG_ARRAY(sig_args);
n = SIG_ELEMS(sig_args);
/*
* preserve registers - need get_results, because we skip the
* return value
*/
result = CUR_OPCODE + 2 + n + 3; /* set_args, set_p_pc */
assert(*result == PARROT_OP_get_results_pc);
sig_result = constants[result[1]]->u.key;
ASSERT_SIG_PMC(sig_result);
if (!SIG_ELEMS(sig_result))
skip = -1;
else
skip = MAP(2 + n + 3 + 2);
used_n = jit_save_regs_call(jit_info, interpreter, skip);
=====================================================================
Found a 21 line (143 tokens) duplication in the following files:
Starting at line 249 of /home/juanjose/projects/parrot-bleed/src/byteorder.c
Starting at line 270 of /home/juanjose/projects/parrot-bleed/src/byteorder.c
fetch_buf_be_12(unsigned char *rb, unsigned char *b)
{
#if PARROT_BIGENDIAN
memcpy(rb, b, 12);
#else
rb[0] = b[11];
rb[1] = b[10];
rb[2] = b[9];
rb[3] = b[8];
rb[4] = b[7];
rb[5] = b[6];
rb[6] = b[5];
rb[7] = b[4];
rb[8] = b[3];
rb[9] = b[2];
rb[10] = b[1];
rb[11] = b[0];
#endif
}
void
=====================================================================
Found a 21 line (142 tokens) duplication in the following files:
Starting at line 28 of
/home/juanjose/projects/parrot-bleed/src/jit/arm/exec_dep.h
Starting at line 951 of
/home/juanjose/projects/parrot-bleed/src/jit/arm/jit_emit.h
Parrot_jit_normal_op(Parrot_jit_info_t *jit_info,
Interp * interpreter)
{
jit_info->native_ptr = emit_mov (jit_info->native_ptr, r1, r4);
#ifndef ARM_K_BUG
jit_info->native_ptr = emit_mov (jit_info->native_ptr, REG14_lr, REG15_pc);
jit_info->native_ptr = emit_ldmstm (jit_info->native_ptr,
cond_AL, is_load, dir_IA,
is_writeback,
REG14_lr,
reg2mask(0) | reg2mask(REG15_pc));
#else
jit_info->native_ptr = emit_arith_immediate (jit_info->native_ptr, cond_AL,
ADD, 0, REG14_lr, REG15_pc,
4, 0);
jit_info->native_ptr = emit_ldmstm (jit_info->native_ptr,
cond_AL, is_load, dir_IA,
is_writeback,
REG14_lr,
reg2mask(0) | reg2mask(REG12_ip));
jit_info->native_ptr = emit_mov (jit_info->native_ptr, REG15_pc, REG12_ip);
=====================================================================
Found a 28 line (141 tokens) duplication in the following files:
Starting at line 204 of
/home/juanjose/projects/parrot-bleed/src/encodings/utf16.c
Starting at line 461 of
/home/juanjose/projects/parrot-bleed/src/encodings/utf8.c
return_string->bufused = count;
return_string->strlen = count;
return_string->hashval = 0;
return return_string;
}
static STRING *
get_codepoints_inplace(Interp *interpreter, STRING *src,
UINTVAL offset, UINTVAL count, STRING *return_string)
{
String_iter iter;
UINTVAL start;
Parrot_reuse_COW_reference(interpreter, src, return_string);
iter_init(interpreter, src, &iter);
iter.set_position(interpreter, &iter, offset);
start = iter.bytepos;
return_string->strstart = (char *)return_string->strstart + start ;
iter.set_position(interpreter, &iter, offset + count);
return_string->bufused = iter.bytepos - start;
return_string->strlen = count;
return_string->hashval = 0;
return return_string;
}
static STRING *
=====================================================================
Found a 22 line (129 tokens) duplication in the following files:
Starting at line 25 of
/home/juanjose/projects/parrot-bleed/src/jit/i386/exec_dep.h
Starting at line 3524 of
/home/juanjose/projects/parrot-bleed/src/jit/i386/jit_emit.h
int last_is_branch = 0;
void ** offset;
extern PARROT_API char **Parrot_exec_rel_addr;
extern PARROT_API int Parrot_exec_rel_count;
assert(op_jit[*jit_info->cur_op].extcall == 1);
if (cur_section->done == 1)
return;
else if (cur_section->done == -1 && --cur_section->ins_count > 0)
return;
/* check, where section ends
*/
if (interpreter->op_info_table[*cur_section->end].jump)
last_is_branch = 1;
else if (cur_section->next && !cur_section->next->isjit)
last_is_branch = 1;
/* if more then 1 op, then jump to CGP, branches are never
* executed in CGP, they are handled below */
if (cur_section->done >= 0 &&
(INTVAL)cur_section->op_count >= 2 + last_is_branch) {
int saved = 0;
offset = (jit_info->cur_op - interpreter->code->base.data) +
=====================================================================
Found a 23 line (128 tokens) duplication in the following files:
Starting at line 113 of /home/juanjose/projects/parrot-bleed/src/byteorder.c
Starting at line 138 of /home/juanjose/projects/parrot-bleed/src/byteorder.c
fetch_op_le(opcode_t w)
{
#if !PARROT_BIGENDIAN
return w;
#else
# if OPCODE_T_SIZE == 4
return (w << 24) | ((w & 0x0000ff00) << 8) | ((w & 0x00ff0000) >> 8) |
((w & 0xff000000) >> 24);
# else
opcode_t r;
r = w << 56;
r |= (w & 0xff00) << 40;
r |= (w & 0xff0000) << 24;
r |= (w & 0xff000000) << 8;
r |= (w & 0xff00000000) >> 8;
r |= (w & 0xff0000000000) >> 24;
r |= (w & 0xff000000000000) >> 40;
r |= (w & 0xff00000000000000) >> 56;
return r;
# endif
#endif
}
=====================================================================
Found a 24 line (124 tokens) duplication in the following files:
Starting at line 2530 of /home/juanjose/projects/parrot-bleed/src/bignum.c
Starting at line 2559 of /home/juanjose/projects/parrot-bleed/src/bignum.c
if (!result->sign) {
if (BN_getd(result, 0) != 0 ||
!BN_is_zero(PINT_ result, context)) {
BN_nonfatal(PINT_ context, BN_INEXACT,
"Loss of precision in divide");
}
BN_round_down(PINT_ result, context);
}
else if (BN_getd(result, 0) != 0) {
BN_nonfatal(PINT_ context, BN_INEXACT,
"Loss of precision in divide");
BN_round_up(PINT_ result, context);
}
else if (!BN_is_zero(PINT_ rem, context)) {
BN_nonfatal(PINT_ context, BN_INEXACT,
"Loss of precision in divide");
BN_round_up(PINT_ result, context);
}
else {
BN_round_down(PINT_ result, context);
}
}
}
else { /* Other roundings just need digits to play with */
=====================================================================
Found a 21 line (124 tokens) duplication in the following files:
Starting at line 43 of /home/juanjose/projects/parrot-bleed/src/byteorder.c
Starting at line 78 of /home/juanjose/projects/parrot-bleed/src/byteorder.c
fetch_iv_be(INTVAL w)
{
#if PARROT_BIGENDIAN
return w;
#else
# if INTVAL_SIZE == 4
return (w << 24) | ((w & 0xff00) << 8) | ((w & 0xff0000) >> 8) | (w >> 24);
# else
INTVAL r;
r = w << 56;
r |= (w & 0xff00) << 40;
r |= (w & 0xff0000) << 24;
r |= (w & 0xff000000) << 8;
r |= (w & 0xff00000000) >> 8;
r |= (w & 0xff0000000000) >> 24;
r |= (w & 0xff000000000000) >> 40;
r |= (w & 0xff00000000000000) >> 56;
return r;
# endif
#endif
}
=====================================================================
Found a 41 line (119 tokens) duplication in the following files:
Starting at line 231 of
/home/juanjose/projects/parrot-bleed/src/encodings/utf16.c
Starting at line 127 of
/home/juanjose/projects/parrot-bleed/src/encodings/ucs2.c
UINTVAL offset, UINTVAL count, STRING *dest_string)
{
UNIMPL;
return NULL;
}
static STRING *
get_bytes_inplace(Interp *interpreter, STRING *src,
UINTVAL offset, UINTVAL count, STRING *return_string)
{
UNIMPL;
return NULL;
}
static void
set_codepoints(Interp *interpreter, STRING *src,
UINTVAL offset, UINTVAL count, STRING *new_codepoints)
{
UNIMPL;
}
static void
set_bytes(Interp *interpreter, STRING *src,
UINTVAL offset, UINTVAL count, STRING *new_bytes)
{
UNIMPL;
}
/* Unconditionally makes the string be in this encoding, if that's
valid */
static void
become_encoding(Interp *interpreter, STRING *src)
{
UNIMPL;
}
static UINTVAL
codepoints(Interp *interpreter, STRING *src)
{
=====================================================================
Found a 21 line (119 tokens) duplication in the following files:
Starting at line 444 of
/home/juanjose/projects/parrot-bleed/src/charset/unicode.c
Starting at line 482 of
/home/juanjose/projects/parrot-bleed/src/charset/unicode.c
find_not_cclass(Interp *interpreter, PARROT_CCLASS_FLAGS flags, STRING
*source_string, UINTVAL offset, UINTVAL count)
{
UINTVAL pos = offset;
UINTVAL end = offset + count;
UINTVAL codepoint;
#if PARROT_HAS_ICU
int bit, mask;
#endif
assert(source_string != 0);
end = source_string->strlen < end ? source_string->strlen : end;
for (; pos < end; ++pos) {
codepoint = ENCODING_GET_CODEPOINT(interpreter, source_string, pos);
if (codepoint >= 256) {
#if PARROT_HAS_ICU
for (mask = enum_cclass_uppercase;
mask <= enum_cclass_word ; mask <<= 1) {
bit = mask & flags;
if (!bit)
continue;
if (!is_foo(interpreter, codepoint, bit))
=====================================================================
Found a 26 line (115 tokens) duplication in the following files:
Starting at line 2317 of
/home/juanjose/projects/parrot-bleed/src/jit/i386/jit_emit.h
Starting at line 2386 of
/home/juanjose/projects/parrot-bleed/src/jit/i386/jit_emit.h
jit_emit_mov_RM_i(NATIVECODE, emit_ECX, ROFFS_INT(2));
}
/* range check */
jit_emit_cmp_ri_i(NATIVECODE, emit_ECX, 0);
L2 = NATIVECODE;
emitm_jxs(NATIVECODE, emitm_js, 0);
emitm_movl_m_r(NATIVECODE, emit_EAX, emit_EDI, 0, 1,
offsetof(struct pobj_t, u._i._int_val));
jit_emit_cmp_rr_i(NATIVECODE, emit_ECX, emit_EAX);
L3 = NATIVECODE;
emitm_jxs(NATIVECODE, emitm_jnl, 0);
/*
* mov (pmc_ext)%edi, %eax
* mov (data)%eax, %eax
* mov $3, %edx
* mov $edx, (%eax, %ecx, 4)
* jmp L4
*/
# if ! PMC_DATA_IN_EXT
#error "todo"
#else
emitm_movl_m_r(NATIVECODE, emit_EAX, emit_EDI, 0, 1,
offsetof(struct PMC, pmc_ext));
emitm_movl_m_r(NATIVECODE, emit_EAX, emit_EAX, 0, 1,
offsetof(struct PMC_EXT, data));
=====================================================================
Found a 19 line (114 tokens) duplication in the following files:
Starting at line 1710 of
/home/juanjose/projects/parrot-bleed/src/jit/i386/jit_emit.h
Starting at line 1749 of
/home/juanjose/projects/parrot-bleed/src/jit/i386/jit_emit.h
mod_rr_n(Parrot_jit_info_t *jit_info, int r)
{
char *L1;
static const char* div_by_zero = "Divide by zero";
char *pc = jit_info->native_ptr;
jit_emit_test_r_n(pc, (char)0); /* TOS */
L1 = pc;
emitm_jxs(pc, emitm_jnz, 0);
emitm_pushl_i(pc, div_by_zero);
emitm_pushl_i(pc, E_ZeroDivisionError);
emitm_pushl_i(pc, 0); /* NULL */
Parrot_jit_emit_get_INTERP(pc, emit_ECX);
emitm_pushl_r(pc, emit_ECX);
jit_info->native_ptr = pc;
call_func(jit_info, (void*) real_exception);
pc = jit_info->native_ptr;
/* L1: */
L1[1] = pc - L1 - 2;
=====================================================================
Found a 37 line (113 tokens) duplication in the following files:
Starting at line 485 of
/home/juanjose/projects/parrot-bleed/src/encodings/utf8.c
Starting at line 131 of
/home/juanjose/projects/parrot-bleed/src/encodings/ucs2.c
return NULL;
}
static STRING *
get_bytes_inplace(Interp *interpreter, STRING *src,
UINTVAL offset, UINTVAL count, STRING *return_string)
{
UNIMPL;
return NULL;
}
static void
set_codepoints(Interp *interpreter, STRING *src,
UINTVAL offset, UINTVAL count, STRING *new_codepoints)
{
UNIMPL;
}
static void
set_bytes(Interp *interpreter, STRING *src,
UINTVAL offset, UINTVAL count, STRING *new_bytes)
{
UNIMPL;
}
/* Unconditionally makes the string be in this encoding, if that's
valid */
static void
become_encoding(Interp *interpreter, STRING *src)
{
UNIMPL;
}
static UINTVAL
codepoints(Interp *interpreter, STRING *src)
{
=====================================================================
Found a 18 line (112 tokens) duplication in the following files:
Starting at line 708 of
/home/juanjose/projects/parrot-bleed/src/jit/ppc/jit_emit.h
Starting at line 741 of
/home/juanjose/projects/parrot-bleed/src/jit/ppc/jit_emit.h
jit_emit_cmp_rr_n(pc, B, f1); /* XXX be sure it's unmapped */
/* remember PC */
jmp_ptr = pc;
/* emit jump past exception code, dummy offset */
_emit_bc(pc, BNE, 0, 0, 0);
jit_emit_mov_rr(pc, r3, r16); /* interp */
jit_emit_mov_ri_i(pc, r4, 0); /* NULL */
jit_emit_mov_ri_i(pc, r5, E_ZeroDivisionError); /* type */
jit_emit_mov_ri_i(pc, r6, div_by_zero);
jit_info->native_ptr = pc;
jit_emit_call_func(pc, (void*) real_exception);
pc = jit_info->native_ptr;
/* fixup above jump */
sav_ptr = pc;
pc = jmp_ptr;
_emit_bc(pc, BNE, ((long)(sav_ptr - jmp_ptr)), 0, 0);
/* restore PC */
pc = sav_ptr;
=====================================================================
Found a 18 line (111 tokens) duplication in the following files:
Starting at line 2454 of /home/juanjose/projects/parrot-bleed/src/bignum.c
Starting at line 2688 of /home/juanjose/projects/parrot-bleed/src/bignum.c
"division by zero in divide-integer");
BN_set_inf(PINT_ result);
result->sign = 1 & (one->sign ^ two->sign);
return;
}
/* We're left with the case that only arg 1 is zero */
if (BN_is_zero(PINT_ one, context) ) {
result->expn = 0;
result->digits = 1;
BN_setd(result, 0 ,0);
result->sign = 1 & (one->sign ^ two->sign);
return;
}
rem = BN_new(PINT_ 1);
BN_arith_setup(PINT_ result, one, two, context, NULL);
BN_idivide(PINT_ result, one, two, context, BN_DIV_DIVINT, rem);
=====================================================================
Found a 11 line (108 tokens) duplication in the following files:
Starting at line 5053 of /home/juanjose/projects/parrot-bleed/src/malloc.c
Starting at line 5273 of /home/juanjose/projects/parrot-bleed/src/malloc.c
result = g_last->top_allocated;
}
/* Assert invariants */
assert (g_last);
assert ((char *) g_last->top_reserved - g_last->reserve_size <= (char *)
g_last->top_allocated &&
g_last->top_allocated <= g_last->top_committed);
assert ((char *) g_last->top_reserved - g_last->reserve_size <= (char *)
g_last->top_committed &&
g_last->top_committed <= g_last->top_reserved &&
(unsigned) g_last->top_committed % g_pagesize == 0);
assert ((unsigned) g_last->top_reserved % g_regionsize == 0);
assert ((unsigned) g_last->reserve_size % g_regionsize == 0);
=====================================================================
Found a 30 line (106 tokens) duplication in the following files:
Starting at line 740 of /home/juanjose/projects/parrot-bleed/src/list.c
Starting at line 2175 of /home/juanjose/projects/parrot-bleed/src/malloc.c
if (x >= 0x10000) return NBINS-1;
/* On intel, use BSRL instruction to find highest bit */
#if defined(__GNUC__) && defined(i386)
__asm__("bsrl %1,%0\n\t"
: "=r" (m)
: "g" (x));
#else
{
/*
Based on branch-free nlz algorithm in chapter 5 of Henry
S. Warren Jr's book "Hacker's Delight".
*/
unsigned int n = ((x - 0x100) >> 16) & 8;
x <<= n;
m = ((x - 0x1000) >> 16) & 4;
n += m;
x <<= m;
m = ((x - 0x4000) >> 16) & 2;
n += m;
x = (x << m) >> 14;
m = 13 - n + (x & ~(x>>1));
}
#endif
/* Use next 2 bits to create finer-granularity bins */
return NSMALLBINS + (m << 2) + ((sz >> (m + 6)) & 3);
=====================================================================
Found a 14 line (104 tokens) duplication in the following files:
Starting at line 698 of /home/juanjose/projects/parrot-bleed/src/inter_call.c
Starting at line 1037 of /home/juanjose/projects/parrot-bleed/src/inter_call.c
switch (st->dest.sig & PARROT_ARG_TYPE_MASK) {
case PARROT_ARG_INTVAL:
CTX_REG_INT(st->dest.ctx, idx) = UVal_int(st->val);
break;
case PARROT_ARG_FLOATVAL:
CTX_REG_NUM(st->dest.ctx, idx) = UVal_num(st->val);
break;
case PARROT_ARG_STRING:
CTX_REG_STR(st->dest.ctx, idx) = UVal_str(st->val);
break;
case PARROT_ARG_PMC:
CTX_REG_PMC(st->dest.ctx, idx) = UVal_pmc(st->val);
break;
}
=====================================================================
Found a 17 line (103 tokens) duplication in the following files:
Starting at line 215 of /home/juanjose/projects/parrot-bleed/src/byteorder.c
Starting at line 232 of /home/juanjose/projects/parrot-bleed/src/byteorder.c
fetch_buf_le_8(unsigned char *rb, unsigned char *b)
{
#if !PARROT_BIGENDIAN
memcpy(rb, b, 8);
#else
rb[0] = b[7];
rb[1] = b[6];
rb[2] = b[5];
rb[3] = b[4];
rb[4] = b[3];
rb[5] = b[2];
rb[6] = b[1];
rb[7] = b[0];
#endif
}
void
=====================================================================
Found a 19 line (102 tokens) duplication in the following files:
Starting at line 289 of
/home/juanjose/projects/parrot-bleed/src/charset/iso-8859-1.c
Starting at line 385 of /home/juanjose/projects/parrot-bleed/src/charset/ascii.c
if ((Parrot_ascii_typetable[codepoint] & flags) != 0) {
return pos;
}
}
return end;
}
static INTVAL
find_not_cclass(Interp *interpreter, PARROT_CCLASS_FLAGS flags, STRING
*source_string, UINTVAL offset, UINTVAL count)
{
UINTVAL pos = offset;
UINTVAL end = offset + count;
UINTVAL codepoint;
assert(source_string != 0);
end = source_string->strlen < end ? source_string->strlen : end;
for (; pos < end; ++pos) {
codepoint = ENCODING_GET_CODEPOINT(interpreter, source_string, pos);
if ((Parrot_ascii_typetable[codepoint] & flags) == 0) {