Skip to content

Commit

Permalink
kill dead code
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.parrot.org/parrot/branches/gsoc_nci@49708 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information
plobsing committed Oct 28, 2010
1 parent f631eb3 commit 7723c62
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 278 deletions.
155 changes: 16 additions & 139 deletions config/gen/libffi/nci-ffi.pmc.in
Expand Up @@ -26,29 +26,25 @@ The vtable functions for the native C call functions.
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */ /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */


PARROT_IGNORABLE_RESULT PARROT_IGNORABLE_RESULT
static nci_thunk_t /*@alt void@*/ static ffi_cif* build_libffi_func(PARROT_INTERP,
build_func(PARROT_INTERP,
ARGMOD(Parrot_NCI_attributes *nci_info)) ARGMOD(Parrot_NCI_attributes *nci_info))
__attribute__nonnull__(1) __attribute__nonnull__(1)
__attribute__nonnull__(2) __attribute__nonnull__(2)
FUNC_MODIFIES(*nci_info); FUNC_MODIFIES(*nci_info);


static void pcc_params(PARROT_INTERP, static INTVAL parse_prefix(INTVAL c);
ARGIN(STRING *sig), static INTVAL parse_sig(PARROT_INTERP,
ARGMOD(Parrot_NCI_attributes *nci_info), STRING *sig,
size_t sig_length) size_t sig_length,
__attribute__nonnull__(1) Parrot_NCI_attributes *nci_info)
__attribute__nonnull__(2) __attribute__nonnull__(1);
__attribute__nonnull__(3)
FUNC_MODIFIES(*nci_info);


#define ASSERT_ARGS_build_func __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ #define ASSERT_ARGS_build_libffi_func __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(nci_info))
#define ASSERT_ARGS_pcc_params __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \ PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(sig) \
, PARROT_ASSERT_ARG(nci_info)) , PARROT_ASSERT_ARG(nci_info))
#define ASSERT_ARGS_parse_prefix __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
#define ASSERT_ARGS_parse_sig __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */ /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: static */ /* HEADERIZER END: static */


Expand Down Expand Up @@ -132,8 +128,8 @@ typedef struct pmc_holder_t {


/* /*


=item C<static INTVAL parse_sig(PARROT_INTERP, STRING *sig, =item C<static INTVAL parse_sig(PARROT_INTERP, STRING *sig, size_t sig_length,
size_t sig_length, Parrot_NCI_attributes *nci_info)> Parrot_NCI_attributes *nci_info)>


Parse a full signature. All signatures should contain a return type and a list of Parse a full signature. All signatures should contain a return type and a list of
arguments. "vv" Would be the shortest "void fn(void)" signature you can legally make. arguments. "vv" Would be the shortest "void fn(void)" signature you can legally make.
Expand Down Expand Up @@ -665,104 +661,11 @@ count_args(PARROT_INTERP, STRING* sig, size_t start, size_t sig_length) {
return length; return length;
} }


static void
pcc_params(PARROT_INTERP, ARGIN(STRING *sig), ARGMOD(Parrot_NCI_attributes *nci_info),
size_t sig_length)
{
ASSERT_ARGS(pcc_params)

/* NCI and PCC have a 1 to 1 mapping except an
extra char in PCC for invocant and slurpy */
size_t buf_length = sig_length + 2 + 1;

/* avoid malloc churn on common signatures */
char static_buf[16];
char * const sig_buf = sig_length <= sizeof static_buf ?
static_buf :
(char *)mem_sys_allocate(buf_length);

size_t j = 0;
size_t i;

for (i = 0; i < sig_length; ++i) {
const INTVAL c = Parrot_str_indexed(interp, sig, i);

PARROT_ASSERT(j < buf_length - 1);

switch (c) {
case (INTVAL)'0': /* null ptr or such - doesn't consume a reg */
break;
case (INTVAL)'f':
case (INTVAL)'N':
case (INTVAL)'d':
sig_buf[j++] = 'N';
break;
case (INTVAL)'I': /* INTVAL */
case (INTVAL)'l': /* long */
case (INTVAL)'i': /* int */
case (INTVAL)'s': /* short */
case (INTVAL)'c': /* char */
sig_buf[j++] = 'I';
break;
case (INTVAL)'S':
case (INTVAL)'t': /* string, pass a cstring */
sig_buf[j++] = 'S';
break;
case (INTVAL)'J': /* interpreter */
break;
case (INTVAL)'p': /* push pmc->data */
case (INTVAL)'P': /* push PMC * */
case (INTVAL)'V': /* push PMC * */
case (INTVAL)'2':
case (INTVAL)'3':
case (INTVAL)'4':
sig_buf[j++] = 'P';
break;
case (INTVAL)'v':
/* null return */
if (j == 0)
sig_buf[j++] = '\0';
break;
case (INTVAL)'O': /* push PMC * invocant */
sig_buf[j++] = 'P';
sig_buf[j++] = 'i';
break;
case (INTVAL)'@': /* push PMC * slurpy */
sig_buf[j++] = 'P';
sig_buf[j++] = 's';
break;
case (INTVAL)'b': /* buffer (void*) pass Buffer_bufstart(SReg) */
case (INTVAL)'B': /* buffer (void**) pass &Buffer_bufstart(SReg) */
sig_buf[j++] = 'S';
break;
default:
Parrot_ex_throw_from_c_args(interp, NULL,
EXCEPTION_JIT_ERROR,
"Unknown param Signature %c\n", (char)c);
break;
}
}

PARROT_ASSERT(j < buf_length);
sig_buf[j++] = '\0';


nci_info->pcc_return_signature =
Parrot_str_new(interp, sig_buf, 1);

nci_info->pcc_params_signature = j ?
Parrot_str_new(interp, sig_buf + 1, j - 1) :
CONST_STRING(interp, "");

if (sig_buf != static_buf)
mem_sys_free(sig_buf);
}

PARROT_IGNORABLE_RESULT PARROT_IGNORABLE_RESULT
static ffi_cif* static ffi_cif*
build_libffi_func(PARROT_INTERP, ARGMOD(Parrot_NCI_attributes *nci_info)) build_libffi_func(PARROT_INTERP, ARGMOD(Parrot_NCI_attributes *nci_info))
{ {
ASSERT_ARGS(build_func) ASSERT_ARGS(build_libffi_func)


STRING * const key = nci_info->signature; STRING * const key = nci_info->signature;
const size_t key_length = Parrot_str_byte_length(interp, key); const size_t key_length = Parrot_str_byte_length(interp, key);
Expand All @@ -772,30 +675,6 @@ build_libffi_func(PARROT_INTERP, ARGMOD(Parrot_NCI_attributes *nci_info))
return (ffi_cif*)nci_info->cif; return (ffi_cif*)nci_info->cif;
} }


/* actually build the NCI thunk */

PARROT_IGNORABLE_RESULT
static nci_thunk_t
build_func(PARROT_INTERP, ARGMOD(Parrot_NCI_attributes *nci_info))
{
ASSERT_ARGS(build_func)

STRING * const key = nci_info->signature;
const size_t key_length = Parrot_str_byte_length(interp, key);

pcc_params(interp, key, nci_info, key_length);

/* Arity is length of that string minus one (the return type). */
nci_info->arity = key_length - 1;

/* Build call function. */
nci_info->fb_info = build_call_func(interp, key);
nci_info->func = F2DPTR(VTABLE_get_pointer(interp, nci_info->fb_info));

return (nci_thunk_t)nci_info->func;
}


pmclass NCI auto_attrs provides invokable { pmclass NCI auto_attrs provides invokable {
/* NCI thunk handling attributes */ /* NCI thunk handling attributes */
/* NCI thunk handling attributes */ /* NCI thunk handling attributes */
Expand Down Expand Up @@ -1398,10 +1277,8 @@ Returns the function pointer as an integer.
*/ */


VTABLE INTVAL get_integer() { VTABLE INTVAL get_integer() {
Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF); // XXX: TODO
if (!nci_info->func) return 0;
build_func(INTERP, nci_info);
return (INTVAL)nci_info->func;
} }


/* /*
Expand Down

0 comments on commit 7723c62

Please sign in to comment.