Skip to content

Commit

Permalink
Readd CallSignature pmc and fix few build errors
Browse files Browse the repository at this point in the history
  • Loading branch information
bacek committed Apr 2, 2012
1 parent 8a3e561 commit c15e96a
Show file tree
Hide file tree
Showing 43 changed files with 457 additions and 361 deletions.
2 changes: 2 additions & 0 deletions MANIFEST
Expand Up @@ -1336,9 +1336,11 @@ src/pmc/boolean.pmc []
src/pmc/bytebuffer.pmc []
src/pmc/callback.pmc []
src/pmc/callcontext.pmc []
src/pmc/callsignature.pmc []
src/pmc/capture.pmc []
src/pmc/class.pmc []
src/pmc/complex.pmc []
src/pmc/context.pmc []
src/pmc/continuation.pmc []
src/pmc/coroutine.pmc []
src/pmc/default.pmc []
Expand Down
3 changes: 2 additions & 1 deletion MANIFEST.generated
Expand Up @@ -43,7 +43,8 @@ include/pmc/pmc_bignum.h [devel]include
include/pmc/pmc_boolean.h [devel]include
include/pmc/pmc_bytebuffer.h [devel]include
include/pmc/pmc_callback.h [devel]include
include/pmc/pmc_callcontext.h [devel]include
include/pmc/pmc_callsignature.h [devel]include
include/pmc/pmc_context.h [devel]include
include/pmc/pmc_capture.h [devel]include
include/pmc/pmc_class.h [devel]include
include/pmc/pmc_codestring.h [devel]include
Expand Down
1 change: 0 additions & 1 deletion compilers/imcc/imcc.y
Expand Up @@ -20,7 +20,6 @@
#define PARSER_MAIN
#include "imc.h"
#include "parrot/dynext.h"
#include "pmc/pmc_callcontext.h"
#include "pbc.h"
#include "parser.h"
#include "optimizer.h"
Expand Down
1 change: 0 additions & 1 deletion compilers/imcc/instructions.c
Expand Up @@ -8,7 +8,6 @@
#include "imc.h"
#include "pbc.h"
#include "optimizer.h"
#include "pmc/pmc_callcontext.h"
#include "parrot/oplib/core_ops.h"

/*
Expand Down
1 change: 0 additions & 1 deletion compilers/imcc/main.c
Expand Up @@ -32,7 +32,6 @@ IMCC helpers.
#include "parrot/parrot.h"
#include "parrot/longopt.h"
#include "parrot/runcore_api.h"
#include "pmc/pmc_callcontext.h"
#include "pmc/pmc_sub.h"
#include "pbc.h"
#include "parser.h"
Expand Down
1 change: 0 additions & 1 deletion compilers/imcc/optimizer.c
Expand Up @@ -72,7 +72,6 @@ e.g. eliminate new Px .PerlUndef because Px where different before
#include "imc.h"
#include "pbc.h"
#include "optimizer.h"
#include "pmc/pmc_callcontext.h"
#include "parrot/oplib/core_ops.h"

/* HEADERIZER HFILE: compilers/imcc/optimizer.h */
Expand Down
1 change: 0 additions & 1 deletion compilers/imcc/parser_util.c
Expand Up @@ -20,7 +20,6 @@
#include "imc.h"
#include "parrot/dynext.h"
#include "pmc/pmc_sub.h"
#include "pmc/pmc_callcontext.h"
#include "pbc.h"
#include "parser.h"
#include "optimizer.h"
Expand Down
1 change: 0 additions & 1 deletion compilers/imcc/pbc.c
Expand Up @@ -7,7 +7,6 @@
#include "parrot/packfile.h"
#include "parrot/pmc_freeze.h"
#include "pmc/pmc_sub.h"
#include "pmc/pmc_callcontext.h"
#include "parrot/oplib/core_ops.h"
#include "pmc/pmc_key.h"

Expand Down
1 change: 0 additions & 1 deletion compilers/opsc/src/Ops/Emitter.pm
Expand Up @@ -213,7 +213,6 @@ method _emit_source_preamble($fh) {
$fh.print(qq|
#include "{self<include>}"
#include "pmc/pmc_parrotlibrary.h"
#include "pmc/pmc_callcontext.h"
{self.trans.defines(self)}
Expand Down
3 changes: 2 additions & 1 deletion config/auto/pmc.pm
Expand Up @@ -429,7 +429,8 @@ include/parrot/packfile.h
include/parrot/exceptions.h
include/parrot/string_funcs.h
include/parrot/compiler.h
include/pmc/pmc_callcontext.h
include/pmc/pmc_context.h
include/pmc/pmc_callsignature.h
include/pmc/pmc_continuation.h
# Local Variables:
Expand Down
4 changes: 2 additions & 2 deletions config/gen/makefiles/root.in
Expand Up @@ -416,7 +416,7 @@ PARROT_H_HEADERS = \
$(INC_DIR)/core_pmcs.h \
$(INC_DIR)/compiler.h \
$(INC_DIR)/cclass.h \
$(INC_PMC_DIR)/pmc_callcontext.h
$(INC_PMC_DIR)/pmc_context.h

CLASS_PMC_FILES = @TEMP_pmc_classes_pmc@
CLASS_O_FILES = @TEMP_pmc_classes_o@
Expand Down Expand Up @@ -945,7 +945,7 @@ $(INSTALLABLEPARROT) : $(FRPTWO_DIR)/main$(O) $(GEN_HEADERS) $(LIBPARROT) \
$(FRPTWO_DIR)/prt0.pbc$(O) @rpath_lib@ $(ALL_PARROT_LIBS) $(LINKFLAGS)
#IF(win32): if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;1

$(INC_DIR)/context.h : $(INC_PMC_DIR)/pmc_callcontext.h
$(INC_DIR)/context.h : $(INC_PMC_DIR)/pmc_context.h

$(INC_DIR)/pbcversion.h : PBC_COMPAT
$(PERL) $(BUILD_TOOLS_DIR)/pbcversion_h.pl > $(INC_DIR)/pbcversion.h
Expand Down
2 changes: 1 addition & 1 deletion ext/nqp-rx/src/stage0/HLL-s0.pir
Expand Up @@ -964,7 +964,7 @@ An operator precedence parser.
# vim: expandtab shiftwidth=4 ft=pir:

### .include 'src/cheats/parrot-callcontext.pir'
.namespace ['CallContext']
.namespace ['Context']
.sub 'lexpad_full' :method
.local pmc ctx, lexall, lexpad, lexpad_it
ctx = self
Expand Down
4 changes: 2 additions & 2 deletions include/parrot/context.h
Expand Up @@ -22,9 +22,9 @@ typedef union {
INTVAL *regs_i;
} Regs_ni;

#include "pmc/pmc_callcontext.h"
#include "pmc/pmc_context.h"

typedef struct Parrot_CallContext_attributes Parrot_Context;
typedef struct Parrot_Context_attributes Parrot_Context;

#define CONTEXT_STRUCT(c) (PMC_data_typed((c), Parrot_Context *))

Expand Down
2 changes: 1 addition & 1 deletion lib/Parrot/Pmc2c/PMC.pm
Expand Up @@ -508,7 +508,7 @@ sub generate_c_file {

# The PCC code needs Continuation-related macros from these headers.
$c->emit("#include \"pmc_continuation.h\"\n");
$c->emit("#include \"pmc_callcontext.h\"\n");
$c->emit("#include \"pmc_context.h\"\n");

$c->emit( $self->preamble );

Expand Down
55 changes: 28 additions & 27 deletions src/call/args.c
Expand Up @@ -23,7 +23,8 @@ passing to and from subroutines following the Parrot Calling Conventions.
#include "args.str"
#include "pmc/pmc_key.h"
#include "pmc/pmc_fixedintegerarray.h"
#include "pmc/pmc_callcontext.h"
#include "pmc/pmc_callsignature.h"
#include "pmc/pmc_context.h"

/* HEADERIZER HFILE: include/parrot/call.h */

Expand Down Expand Up @@ -318,7 +319,7 @@ static STRING** string_param_from_op(PARROT_INTERP,
PMC *raw_sig, opcode_t *raw_args)>
Take a raw signature and argument list from a set_args opcode and
convert it to a CallContext PMC.
convert it to a CallSignature PMC.
=cut
Expand All @@ -340,15 +341,15 @@ Parrot_pcc_build_sig_object_from_op(PARROT_INTERP, ARGIN_NULLOK(PMC *signature),
INTVAL arg_named_count = 0;

if (PMC_IS_NULL(signature))
call_object = Parrot_pmc_new(interp, enum_class_CallContext);
call_object = Parrot_pmc_new(interp, enum_class_CallSignature);
else {
call_object = signature;
VTABLE_morph(interp, call_object, PMCNULL);
}

/* this macro is much, much faster than the VTABLE STRING comparisons */
PARROT_GC_WRITE_BARRIER(interp, call_object);
SETATTR_CallContext_arg_flags(interp, call_object, raw_sig);
SETATTR_CallSignature_arg_flags(interp, call_object, raw_sig);
GETATTR_FixedIntegerArray_size(interp, raw_sig, arg_count);
GETATTR_FixedIntegerArray_int_array(interp, raw_sig, int_array);

Expand Down Expand Up @@ -428,7 +429,7 @@ Parrot_pcc_build_sig_object_from_op(PARROT_INTERP, ARGIN_NULLOK(PMC *signature),
STRING *name, PMC *raw_sig, opcode_t *raw_args, INTVAL arg_index)>
Pulls in the next argument from a set_args opcode, and sets it as the
value of a named argument in the CallContext PMC.
value of a named argument in the CallSignature PMC.
=cut
Expand Down Expand Up @@ -476,7 +477,7 @@ extract_named_arg_from_op(PARROT_INTERP, ARGMOD(PMC *call_object), ARGIN(STRING
*aggregate)>
Takes an aggregate PMC and splits it up into individual arguments,
adding each one to the CallContext PMC. If the aggregate is an array,
adding each one to the CallSignature PMC. If the aggregate is an array,
its elements are added as positional arguments. If the aggregate is a
hash, its key/value pairs are added as named arguments.
Expand Down Expand Up @@ -515,8 +516,8 @@ dissect_aggregate_arg(PARROT_INTERP, ARGMOD(PMC *call_object), ARGIN(PMC *aggreg
=item C<void Parrot_pcc_set_call_from_c_args(PARROT_INTERP, PMC *signature,
const char *sig, ...)>
Converts a variable list of C args into an existent CallContext PMC.
The CallContext stores the original short signature string and an array of
Converts a variable list of C args into an existent CallSignature PMC.
The CallSignature stores the original short signature string and an array of
integer types to pass on to the multiple dispatch search.
=cut
Expand All @@ -541,8 +542,8 @@ Parrot_pcc_set_call_from_c_args(PARROT_INTERP,
=item C<PMC* Parrot_pcc_build_call_from_c_args(PARROT_INTERP, PMC *signature,
const char *sig, ...)>
Converts a variable list of C args into a CallContext PMC, creating a new one
if needed. The CallContext stores the original short signature string and an
Converts a variable list of C args into a CallSignature PMC, creating a new one
if needed. The CallSignature stores the original short signature string and an
array of integer types to pass on to the multiple dispatch search.
=cut
Expand Down Expand Up @@ -587,7 +588,7 @@ set_call_from_varargs(PARROT_INTERP,
INTVAL i = 0;

parse_signature_string(interp, sig, &arg_flags);
SETATTR_CallContext_arg_flags(interp, signature, arg_flags);
SETATTR_CallSignature_arg_flags(interp, signature, arg_flags);

/* Process the varargs list */
for (; sig[i] != '\0'; ++i) {
Expand Down Expand Up @@ -643,8 +644,8 @@ set_call_from_varargs(PARROT_INTERP,
=item C<void Parrot_pcc_set_call_from_varargs(PARROT_INTERP, PMC *signature,
const char *sig, va_list *args)>
Coverts a varargs list into an existent CallContext PMC.
The CallContext stores the original short signature string and an array of
Coverts a varargs list into an existent CallSignature PMC.
The CallSignature stores the original short signature string and an array of
integer types to pass on to the multiple dispatch search.
=cut
Expand All @@ -668,8 +669,8 @@ Parrot_pcc_set_call_from_varargs(PARROT_INTERP,
=item C<PMC* Parrot_pcc_build_call_from_varargs(PARROT_INTERP, PMC *signature,
const char *sig, va_list *args)>
Converts a varargs list into a CallContext PMC, creating a new one if needed.
The CallContext stores the original short signature string and an array of
Converts a varargs list into a CallSignature PMC, creating a new one if needed.
The CallSignature stores the original short signature string and an array of
integer types to pass on to the multiple dispatch search.
=cut
Expand All @@ -688,7 +689,7 @@ Parrot_pcc_build_call_from_varargs(PARROT_INTERP,
PMC *call_object;

if (PMC_IS_NULL(signature))
call_object = Parrot_pmc_new(interp, enum_class_CallContext);
call_object = Parrot_pmc_new(interp, enum_class_CallSignature);
else {
call_object = signature;
VTABLE_morph(interp, call_object, PMCNULL);
Expand All @@ -704,7 +705,7 @@ Parrot_pcc_build_call_from_varargs(PARROT_INTERP,
=item C<PMC* Parrot_pcc_build_sig_object_from_varargs(PARROT_INTERP, PMC *obj,
const char *sig, va_list args)>
Converts a varargs list into a CallContext PMC. The CallContext stores the
Converts a varargs list into a CallSignature PMC. The CallSignature stores the
original short signature string and an array of integer types to pass on to the
multiple dispatch search.
Expand All @@ -721,7 +722,7 @@ Parrot_pcc_build_sig_object_from_varargs(PARROT_INTERP, ARGIN_NULLOK(PMC *obj),
{
ASSERT_ARGS(Parrot_pcc_build_sig_object_from_varargs)
PMC * arg_flags = PMCNULL;
PMC * const call_object = Parrot_pmc_new(interp, enum_class_CallContext);
PMC * const call_object = Parrot_pmc_new(interp, enum_class_CallSignature);
INTVAL in_return_sig = 0;
INTVAL i;
int append_pi = 1;
Expand All @@ -731,7 +732,7 @@ Parrot_pcc_build_sig_object_from_varargs(PARROT_INTERP, ARGIN_NULLOK(PMC *obj),
return call_object;

parse_signature_string(interp, sig, &arg_flags);
SETATTR_CallContext_arg_flags(interp, call_object, arg_flags);
SETATTR_CallSignature_arg_flags(interp, call_object, arg_flags);

/* Process the varargs list */
for (i = 0; sig[i] != '\0'; ++i) {
Expand Down Expand Up @@ -839,7 +840,7 @@ fill_params(PARROT_INTERP, ARGMOD_NULLOK(PMC *call_object),
call_object = NULL; /* so we don't need to use PMC_IS_NULL below */
}
else {
GETATTR_CallContext_num_positionals(interp, call_object, positional_args);
GETATTR_CallSignature_num_positionals(interp, call_object, positional_args);
}

GETATTR_FixedIntegerArray_int_array(interp, raw_sig, raw_params);
Expand Down Expand Up @@ -1058,7 +1059,7 @@ fill_params(PARROT_INTERP, ARGMOD_NULLOK(PMC *call_object),
Hash *h = NULL;
/* Early exit to avoid vtable call */
if (call_object)
GETATTR_CallContext_hash(interp, call_object, h);
GETATTR_CallSignature_hash(interp, call_object, h);

if (h && h->entries) {
/* Named argument iteration. */
Expand Down Expand Up @@ -1193,7 +1194,7 @@ fill_params(PARROT_INTERP, ARGMOD_NULLOK(PMC *call_object),
Hash *h = NULL;
/* Early exit to avoid vtable call */
if (call_object)
GETATTR_CallContext_hash(interp, call_object, h);
GETATTR_CallSignature_hash(interp, call_object, h);
if (!h || !h->entries) {
if (named_used_list != NULL)
Parrot_hash_destroy(interp, named_used_list);
Expand Down Expand Up @@ -1588,15 +1589,15 @@ Parrot_pcc_merge_signature_for_tailcall(PARROT_INTERP, ARGMOD(PMC *parent), ARGM
if (PMC_IS_NULL(parent) || PMC_IS_NULL(tailcall) || (parent == tailcall))
return;
else {
/* Broke encapuslation. Direct poking into CallContext is much faster */
/* Broke encapuslation. Direct poking into CallSignature is much faster */
PMC * temp;

/* Store raw signature */
GETATTR_CallContext_return_flags(interp, parent, temp);
SETATTR_CallContext_return_flags(interp, tailcall, temp);
GETATTR_CallSignature_return_flags(interp, parent, temp);
SETATTR_CallSignature_return_flags(interp, tailcall, temp);

GETATTR_CallContext_current_cont(interp, parent, temp);
SETATTR_CallContext_current_cont(interp, tailcall, temp);
// FIXME GETATTR_CallSignature_current_cont(interp, parent, temp);
// FIXME SETATTR_CallSignature_current_cont(interp, tailcall, temp);
PARROT_GC_WRITE_BARRIER(interp, tailcall);
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/call/context.c
Expand Up @@ -16,7 +16,7 @@ Parrot_Context functions.
#include "parrot/parrot.h"
#include "parrot/call.h"
#include "pmc/pmc_sub.h"
#include "pmc/pmc_callcontext.h"
#include "pmc/pmc_context.h"
#include "pmc/pmc_continuation.h"

/*
Expand Down Expand Up @@ -230,9 +230,9 @@ init_context(ARGMOD(PMC *pmcctx), ARGIN_NULLOK(PMC *pmcold))
ASSERT_ARGS(init_context)
Parrot_Context * const ctx = CONTEXT_STRUCT(pmcctx);

PARROT_ASSERT_MSG(!PMC_IS_NULL(pmcctx), "Can't initialise Null CallContext");
PARROT_ASSERT_MSG(!PMC_IS_NULL(pmcctx), "Can't initialise Null Context");

PARROT_ASSERT(PMC_IS_NULL(pmcold) || pmcold->vtable->base_type == enum_class_CallContext);
PARROT_ASSERT(PMC_IS_NULL(pmcold) || pmcold->vtable->base_type == enum_class_Context);

/*
* FIXME Invoking corotine shouldn't initialise context. So just
Expand Down Expand Up @@ -393,7 +393,7 @@ static void
allocate_registers(PARROT_INTERP, ARGIN(PMC *pmcctx), ARGIN(const UINTVAL *number_regs_used))
{
ASSERT_ARGS(allocate_registers)
Parrot_CallContext_attributes *ctx = PARROT_CALLCONTEXT(pmcctx);
Parrot_Context_attributes *ctx = PARROT_CONTEXT(pmcctx);

const size_t size_i = sizeof (INTVAL) * number_regs_used[REGNO_INT];
const size_t size_n = sizeof (FLOATVAL) * number_regs_used[REGNO_NUM];
Expand Down Expand Up @@ -502,7 +502,7 @@ void
Parrot_pcc_free_registers(PARROT_INTERP, ARGIN(PMC *pmcctx))
{
ASSERT_ARGS(Parrot_pcc_free_registers)
Parrot_CallContext_attributes * const ctx = PARROT_CALLCONTEXT(pmcctx);
Parrot_Context_attributes * const ctx = PARROT_CONTEXT(pmcctx);

const size_t reg_size =
Parrot_pcc_calculate_registers_size(interp, ctx->n_regs_used);
Expand Down Expand Up @@ -535,7 +535,7 @@ Parrot_alloc_context(PARROT_INTERP, ARGIN(const UINTVAL *number_regs_used),
ARGIN_NULLOK(PMC *old))
{
ASSERT_ARGS(Parrot_alloc_context)
PMC * const pmcctx = Parrot_pmc_new(interp, enum_class_CallContext);
PMC * const pmcctx = Parrot_pmc_new(interp, enum_class_Context);

allocate_registers(interp, pmcctx, number_regs_used);
return init_context(pmcctx, old);
Expand All @@ -559,7 +559,7 @@ PMC *
Parrot_pcc_allocate_empty_context(PARROT_INTERP, ARGIN_NULLOK(PMC *old))
{
ASSERT_ARGS(Parrot_pcc_allocate_empty_context)
PMC * const pmcctx = Parrot_pmc_new(interp, enum_class_CallContext);
PMC * const pmcctx = Parrot_pmc_new(interp, enum_class_Context);

return init_context(pmcctx, old);
}
Expand Down Expand Up @@ -838,7 +838,7 @@ void
Parrot_pcc_reuse_continuation(PARROT_INTERP, ARGIN(PMC *call_context), ARGIN_NULLOK(opcode_t *next))
{
ASSERT_ARGS(Parrot_pcc_reuse_continuation)
Parrot_CallContext_attributes * const c = CONTEXT_STRUCT(call_context);
Parrot_Context_attributes * const c = PARROT_CONTEXT(call_context);
INTVAL reuse = 0;

if (!PMC_IS_NULL(c->continuation)) {
Expand Down

0 comments on commit c15e96a

Please sign in to comment.