Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rurban/f625d47aa9dbbbe25565 to your computer and use it in GitHub Desktop.
Save rurban/f625d47aa9dbbbe25565 to your computer and use it in GitHub Desktop.
From cb4f723b4b5ec38c82cad4c85dd87f2f42da517b Mon Sep 17 00:00:00 2001
From: Reini Urban <rurban@cpanel.net>
Date: Mon, 14 Jul 2014 13:07:58 -0500
Subject: [PATCH] [pcc] inline pcc_add_invocant and its attr accessor
This is a hot path, and we skip the GETATTR_CallContext_arg_flags checks.
call_obj is always a CallContext object.
Unfortunately the vtable methods are not exported so we need to call them
indirectly.
---
src/call/pcc.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git src/call/pcc.c src/call/pcc.c
index 1611e4eb..fa8d928 100644
--- src/call/pcc.c
+++ src/call/pcc.c
@@ -1,5 +1,5 @@
/*
-Copyright (C) 2001-2011, Parrot Foundation.
+Copyright (C) 2001-2014, Parrot Foundation.
=head1 NAME
@@ -24,6 +24,7 @@ value passing to and from subroutines.
#include "pcc.str"
#include "pmc/pmc_key.h"
#include "pmc/pmc_continuation.h"
+#include "pmc/pmc_callcontext.h"
/* HEADERIZER HFILE: include/parrot/call.h */
@@ -161,12 +162,10 @@ static void
Parrot_pcc_add_invocant(PARROT_INTERP, ARGIN(PMC *call_obj), ARGIN(PMC *pmc))
{
ASSERT_ARGS(Parrot_pcc_add_invocant)
- PMC *arg_flags;
- GETATTR_CallContext_arg_flags(interp, call_obj, arg_flags);
- VTABLE_unshift_integer(interp, arg_flags,
- PARROT_ARG_PMC | PARROT_ARG_INVOCANT);
- VTABLE_unshift_pmc(interp, call_obj, pmc);
+ PMC *arg_flags = PARROT_CALLCONTEXT(call_obj)->arg_flags;
+ VTABLE_unshift_integer(interp, arg_flags, PARROT_ARG_PMC | PARROT_ARG_INVOCANT);
+ VTABLE_unshift_pmc(interp, call_obj, pmc);
}
/*
@@ -196,6 +195,7 @@ Parrot_pcc_invoke_method_from_c_args(PARROT_INTERP, ARGIN(PMC* pmc),
PMC *sub_obj;
va_list args;
const char *arg_sig, *ret_sig;
+ PMC *arg_flags;
PMC * const old_call_obj =
Parrot_pcc_get_signature(interp, CURRENT_CONTEXT(interp));
@@ -203,7 +203,11 @@ Parrot_pcc_invoke_method_from_c_args(PARROT_INTERP, ARGIN(PMC* pmc),
va_start(args, signature);
call_obj = Parrot_pcc_build_call_from_varargs(interp, PMCNULL, arg_sig, &args);
- Parrot_pcc_add_invocant(interp, call_obj, pmc);
+
+ /* inlined version of pcc_add_invocant */
+ arg_flags = PARROT_CALLCONTEXT(call_obj)->arg_flags;
+ VTABLE_unshift_integer(interp, arg_flags, PARROT_ARG_PMC | PARROT_ARG_INVOCANT);
+ VTABLE_unshift_pmc(interp, call_obj, pmc);
Parrot_pcc_set_signature(interp, CURRENT_CONTEXT(interp), call_obj);
--
2.0.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment