new stubs ...



Hi Mark,

	The thread stuff practically kills the point of having the stubs
invocations unrolled there; so - I just binned them - and the result is
rather beautiful. We could even turn the (ORBit_small_flags &
ORBIT_SMALL_FAST_LOCALS) flag off in future, which used to be in the old
stubs - and that would free us from exporting any ABI from the ORB apart
from ORBit_c_stub_invoke [ I think ] - thus we can privatize
CORBA_Object and re-arrange that to our heart's content.

	Anyhow, a new style stub is a single function call, that simply does
the argument unwinding - which is IMHO rather nice.

	Regards,

		Michael.

-- 
 michael@ximian.com  <><, Pseudo Engineer, itinerant idiot
? test/everything/core.607
? test/poa/poatest-basic11
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/ORBit2/ChangeLog,v
retrieving revision 1.499
diff -u -p -u -r1.499 ChangeLog
--- ChangeLog	27 May 2003 21:25:16 -0000	1.499
+++ ChangeLog	28 May 2003 13:24:18 -0000
@@ -1,3 +1,20 @@
+2003-05-28  Michael Meeks  <michael@ximian.com>
+
+	* src/idl-compiler/orbit-idl-c-skels.c:
+	move ck_output_skels (and deps) into:
+
+	* src/idl-compiler/orbit-idl-c-common.c: here.
+	(orbit_idl_output_c_common): hook in, but only on
+	stub/skelish builds.
+
+	* src/orb/poa/poa.c (ORBit_stub_post_invoke): kill.
+	(ORBit_stub_pre_get_epv): rename to 
+	(get_c_method): this and re-hash.
+	(ORBit_c_stub_invoke): impl. - a new plan.
+
+	* include/orbit/poa/poa-basics.h: bin old/stale
+	ORBitSkeleton typedef.
+
 2003-05-27  Michael Meeks  <michael@ximian.com>
 
 	* src/orb/poa/poa.c (ORBit_stub_pre_get_epv) 
Index: TODO
===================================================================
RCS file: /cvs/gnome/ORBit2/TODO,v
retrieving revision 1.37
diff -u -p -u -r1.37 TODO
--- TODO	22 May 2003 16:35:33 -0000	1.37
+++ TODO	28 May 2003 13:24:19 -0000
@@ -1,5 +1,8 @@
 TODO:
 
+* Turn off the global 'fast_calls' variable, to knobble
+  old stubs, and go with the new ABI.
+
 * Cross thread Object references
 	+ I think the way to fix this is by using a different
 	  interface->adaptor_type: ORBIT_ADAPTOR_POA_THREADED,
Index: include/orbit/poa/poa-basics.h
===================================================================
RCS file: /cvs/gnome/ORBit2/include/orbit/poa/poa-basics.h,v
retrieving revision 1.7
diff -u -p -u -r1.7 poa-basics.h
--- include/orbit/poa/poa-basics.h	10 Feb 2003 15:03:37 -0000	1.7
+++ include/orbit/poa/poa-basics.h	28 May 2003 13:24:19 -0000
@@ -55,11 +55,6 @@ typedef struct ORBit_OAObject_type  *ORB
 
 typedef gshort ORBit_VepvIdx;
 
-typedef void               (*ORBitSkeleton)      (PortableServer_ServantBase *servant,
-						  gpointer                    recv_buffer,
-						  CORBA_Environment          *ev,
-						  gpointer                    implementation);
-
 typedef void               (*ORBitSmallSkeleton) (PortableServer_ServantBase *servant,
 						  gpointer                    ret,
 						  gpointer                   *args,
Index: include/orbit/poa/poa-types.h
===================================================================
RCS file: /cvs/gnome/ORBit2/include/orbit/poa/poa-types.h,v
retrieving revision 1.29
diff -u -p -u -r1.29 poa-types.h
--- include/orbit/poa/poa-types.h	27 May 2003 21:25:17 -0000	1.29
+++ include/orbit/poa/poa-types.h	28 May 2003 13:24:19 -0000
@@ -49,12 +49,17 @@ struct ORBit_POAObject_type {
 
 #if defined(ORBIT2_INTERNAL_API) || defined (ORBIT2_STUBS_API)
 
-gpointer ORBit_stub_pre_get_epv (CORBA_Object obj,
-				 glong        class_id,
-				 gpointer    *servant,
-				 glong        method_offset);
-void     ORBit_stub_post_invoke (CORBA_Object obj, gpointer epv);
-
+void
+ORBit_c_stub_invoke (CORBA_Object        obj,
+		     ORBit_IMethods     *methods,
+		     glong               method_index,
+		     gpointer            ret,
+		     gpointer            args,
+		     CORBA_Context       ctx,
+		     CORBA_Environment  *ev,
+		     glong               class_id,
+		     glong               method_offset,
+		     ORBitSmallSkeleton  skel_impl);
 
 #define ORBIT_VEPV_OFFSET(vepv_type,epv_member) \
 	((CORBA_unsigned_long) ((long)((guint8 *) &((vepv_type *) 0)->epv_member)) / sizeof (GFunc))
Index: src/idl-compiler/orbit-idl-c-common.c
===================================================================
RCS file: /cvs/gnome/ORBit2/src/idl-compiler/orbit-idl-c-common.c,v
retrieving revision 1.55
diff -u -p -u -r1.55 orbit-idl-c-common.c
--- src/idl-compiler/orbit-idl-c-common.c	2 Oct 2002 07:35:29 -0000	1.55
+++ src/idl-compiler/orbit-idl-c-common.c	28 May 2003 13:24:19 -0000
@@ -520,6 +520,108 @@ cc_build_interfaces (GSList *list, IDL_t
 	return list;
 }
 
+static void
+cc_output_skel (IDL_tree     tree,
+		OIDL_C_Info *ci,
+		int         *idx)
+{
+	IDL_tree  intf;
+	gboolean  has_args;
+	gboolean  has_retval;
+	char     *opname;
+	char     *ifname;
+
+	g_return_if_fail (idx != NULL);
+
+	intf = IDL_get_parent_node (tree, IDLN_INTERFACE, NULL);
+
+	has_args   = IDL_OP_DCL (tree).parameter_dcls != NULL;
+	has_retval = IDL_OP_DCL (tree).op_type_spec != NULL;
+
+	opname = IDL_ns_ident_to_qstring (IDL_IDENT_TO_NS (IDL_OP_DCL (tree).ident), "_", 0);
+	ifname = IDL_ns_ident_to_qstring (IDL_IDENT_TO_NS (IDL_INTERFACE (intf).ident), "_", 0);
+
+	fprintf (ci->fh, "void _ORBIT_skel_small_%s("
+				"POA_%s             *_o_servant, "
+				"gpointer            _o_retval,"
+				"gpointer           *_o_args,"
+				"CORBA_Context       _o_ctx,"
+				"CORBA_Environment  *_o_ev,\n", opname, ifname);
+
+	orbit_cbe_op_write_proto (ci->fh, tree, "_impl_", TRUE);
+
+	fprintf (ci->fh, ") {\n");
+
+	if (has_retval) {
+		fprintf (ci->fh, "*(");
+		orbit_cbe_write_param_typespec (ci->fh, tree);
+		fprintf (ci->fh, " *)_o_retval = ");
+	}
+
+	fprintf (ci->fh, "_impl_%s (_o_servant, ", IDL_IDENT (IDL_OP_DCL (tree).ident).str);
+  
+	orbit_cbe_unflatten_args (tree, ci->fh, "_o_args");
+
+	if (IDL_OP_DCL (tree).context_expr)
+		fprintf (ci->fh, "_o_ctx, ");
+
+	fprintf (ci->fh, "_o_ev);\n");
+
+	fprintf (ci->fh, "}\n");
+
+	g_free (opname);
+	g_free (ifname);
+
+	(*idx)++;
+}
+
+static void
+cc_output_skels (IDL_tree       tree,
+		 OIDL_Run_Info *rinfo,
+		 OIDL_C_Info   *ci,
+		 int           *idx)
+{
+	if (!tree || (tree->declspec & IDLF_DECLSPEC_PIDL))
+		return;
+
+	switch (IDL_NODE_TYPE (tree)) {
+	case IDLN_MODULE:
+		cc_output_skels (IDL_MODULE (tree).definition_list, rinfo, ci, idx);
+		break;
+	case IDLN_LIST: {
+		IDL_tree node;
+
+		for (node = tree; node; node = IDL_LIST (node).next)
+			cc_output_skels (IDL_LIST (node).data, rinfo, ci, idx);
+		break;
+		}
+	case IDLN_ATTR_DCL: {
+		OIDL_Attr_Info *ai = tree->data;
+		IDL_tree        node;
+      
+		for (node = IDL_ATTR_DCL (tree).simple_declarations; node; node = IDL_LIST (node).next) {
+			ai = IDL_LIST (node).data->data;
+	
+			cc_output_skels (ai->op1, rinfo, ci, idx);
+			if (ai->op2)
+				cc_output_skels (ai->op2, rinfo, ci, idx);
+		}
+		break;
+		}
+	case IDLN_INTERFACE: {
+		int real_idx = 0;
+
+		cc_output_skels (IDL_INTERFACE (tree).body, rinfo, ci, &real_idx);
+		}
+		break;
+	case IDLN_OP_DCL:
+		cc_output_skel (tree, ci, idx);
+		break;
+	default:
+		break;
+	}
+}
+
 void
 orbit_idl_output_c_common (IDL_tree       tree,
 			   OIDL_Run_Info *rinfo,
@@ -532,6 +634,12 @@ orbit_idl_output_c_common (IDL_tree     
 	fprintf (ci->fh, "#define %s_COMMON\n", ci->c_base_name);
 	fprintf (ci->fh, "#include \"%s.h\"\n\n", ci->base_name);
 	fprintf (ci->fh, "static const CORBA_unsigned_long ORBit_zero_int = 0;\n");
+
+	/* FIXME: this is slightly nasty, but we need these in common,
+	   and this fixes an internal build issue */
+	if (rinfo->enabled_passes & OUTPUT_SKELS ||
+	    rinfo->enabled_passes & OUTPUT_STUBS)
+		cc_output_skels (tree, rinfo, ci, NULL);
 
 	cc_output_typecodes (tree, ci);
 
Index: src/idl-compiler/orbit-idl-c-skels.c
===================================================================
RCS file: /cvs/gnome/ORBit2/src/idl-compiler/orbit-idl-c-skels.c,v
retrieving revision 1.43
diff -u -p -u -r1.43 orbit-idl-c-skels.c
--- src/idl-compiler/orbit-idl-c-skels.c	13 May 2003 14:56:37 -0000	1.43
+++ src/idl-compiler/orbit-idl-c-skels.c	28 May 2003 13:24:19 -0000
@@ -17,111 +17,6 @@ typedef struct {
 	int       idx;
 } CBESkelOpInfo;
 
-static void
-ck_output_skel (IDL_tree     tree,
-		OIDL_C_Info *ci,
-		int         *idx)
-{
-	IDL_tree  intf;
-	gboolean  has_args;
-	gboolean  has_retval;
-	char     *opname;
-	char     *ifname;
-
-	g_return_if_fail (idx != NULL);
-
-	intf = IDL_get_parent_node (tree, IDLN_INTERFACE, NULL);
-
-	has_args   = IDL_OP_DCL (tree).parameter_dcls != NULL;
-	has_retval = IDL_OP_DCL (tree).op_type_spec != NULL;
-
-	opname = IDL_ns_ident_to_qstring (IDL_IDENT_TO_NS (IDL_OP_DCL (tree).ident), "_", 0);
-	ifname = IDL_ns_ident_to_qstring (IDL_IDENT_TO_NS (IDL_INTERFACE (intf).ident), "_", 0);
-
-	fprintf (ci->fh, "void _ORBIT_skel_small_%s("
-				"POA_%s             *_o_servant, "
-				"gpointer            _o_retval,"
-				"gpointer           *_o_args,"
-				"CORBA_Context       _o_ctx,"
-				"CORBA_Environment  *_o_ev,\n", opname, ifname);
-
-	orbit_cbe_op_write_proto (ci->fh, tree, "_impl_", TRUE);
-
-	fprintf (ci->fh, ") {\n");
-
-	if (has_retval) {
-		fprintf (ci->fh, "*(");
-		orbit_cbe_write_param_typespec (ci->fh, tree);
-		fprintf (ci->fh, " *)_o_retval = ");
-	}
-
-	fprintf (ci->fh, "_impl_%s (_o_servant, ", IDL_IDENT (IDL_OP_DCL (tree).ident).str);
-  
-	orbit_cbe_unflatten_args (tree, ci->fh, "_o_args");
-
-	if (IDL_OP_DCL (tree).context_expr)
-		fprintf (ci->fh, "_o_ctx, ");
-
-	fprintf (ci->fh, "_o_ev);\n");
-
-	fprintf (ci->fh, "}\n");
-
-	g_free (opname);
-	g_free (ifname);
-
-	(*idx)++;
-}
-
-static void
-ck_output_skels (IDL_tree       tree,
-		 OIDL_Run_Info *rinfo,
-		 OIDL_C_Info   *ci,
-		 int           *idx)
-{
-	if (!tree || (tree->declspec & IDLF_DECLSPEC_PIDL))
-		return;
-
-	switch (IDL_NODE_TYPE (tree)) {
-	case IDLN_MODULE:
-		ck_output_skels (IDL_MODULE (tree).definition_list, rinfo, ci, idx);
-		break;
-	case IDLN_LIST: {
-		IDL_tree node;
-
-		for (node = tree; node; node = IDL_LIST (node).next)
-			ck_output_skels (IDL_LIST (node).data, rinfo, ci, idx);
-		break;
-		}
-	case IDLN_ATTR_DCL: {
-		OIDL_Attr_Info *ai = tree->data;
-		IDL_tree        node;
-      
-		for (node = IDL_ATTR_DCL (tree).simple_declarations; node; node = IDL_LIST (node).next) {
-			ai = IDL_LIST (node).data->data;
-	
-			ck_output_skels (ai->op1, rinfo, ci, idx);
-			if (ai->op2)
-				ck_output_skels (ai->op2, rinfo, ci, idx);
-		}
-		break;
-		}
-	case IDLN_INTERFACE: {
-		int real_idx = 0;
-
-		ck_output_skels (IDL_INTERFACE (tree).body, rinfo, ci, &real_idx);
-		}
-		break;
-	case IDLN_OP_DCL:
-		ck_output_skel (tree, ci, idx);
-		break;
-	default:
-		break;
-	}
-}
-
-
-/* POA stuff */
-
 static void cbe_skel_do_interface(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci);
 
 static void
@@ -165,7 +60,7 @@ cbe_skel_free_op_info(CBESkelOpInfo *op)
 }
 
 static void
-cbe_skel_interface_add_relayer(IDL_tree intf, CBESkelInterfaceTraverseInfo *iti)
+cbe_skel_interface_add_relayer (IDL_tree intf, CBESkelInterfaceTraverseInfo *iti)
 {
   CBESkelOpInfo *newopi;
   IDL_tree curitem, curdcl, curattr, curattrdcl;
@@ -394,8 +289,6 @@ orbit_idl_output_c_skeletons (IDL_tree  
 	fprintf (ci->fh, "#include <string.h>\n");
 	fprintf (ci->fh, "#define ORBIT2_STUBS_API\n");
 	fprintf (ci->fh, "#include \"%s.h\"\n\n", ci->base_name);
-
-	ck_output_skels (tree, rinfo, ci, NULL);
 
 	ck_output_poastuff (tree, rinfo, ci);
 }
Index: src/idl-compiler/orbit-idl-c-stubs.c
===================================================================
RCS file: /cvs/gnome/ORBit2/src/idl-compiler/orbit-idl-c-stubs.c,v
retrieving revision 1.65
diff -u -p -u -r1.65 orbit-idl-c-stubs.c
--- src/idl-compiler/orbit-idl-c-stubs.c	30 Sep 2002 16:08:51 -0000	1.65
+++ src/idl-compiler/orbit-idl-c-stubs.c	28 May 2003 13:24:19 -0000
@@ -11,8 +11,8 @@ cs_output_stub (IDL_tree     tree,
 {
 	FILE     *of = ci->fh;
 	char     *iface_id;
+	char     *opname;
 	gboolean  has_retval, has_args;
-	IDL_tree  node;
 
 	g_return_if_fail (idx != NULL);
 
@@ -20,6 +20,7 @@ cs_output_stub (IDL_tree     tree,
 			IDL_IDENT_TO_NS (IDL_INTERFACE (
 				IDL_get_parent_node (tree, IDLN_INTERFACE, NULL)
 					).ident), "_", 0);
+	opname = IDL_ns_ident_to_qstring (IDL_IDENT_TO_NS (IDL_OP_DCL (tree).ident), "_", 0);
 
 	has_retval = IDL_OP_DCL (tree).op_type_spec != NULL;
 	has_args   = IDL_OP_DCL (tree).parameter_dcls != NULL;
@@ -32,10 +33,16 @@ cs_output_stub (IDL_tree     tree,
 		orbit_cbe_write_param_typespec (of, tree);
 		fprintf (of, " " ORBIT_RETVAL_VAR_NAME ";\n");
 	}
-
+#if 0
 	fprintf (ci->fh, "POA_%s__epv *%s;\n", iface_id, ORBIT_EPV_VAR_NAME);
+	fprintf (ci->fh, "gpointer _ORBIT_servant;\n");
 
 	/* in-proc part */
+	fprintf (ci->fh, "if ((%s = ORBit_c_stub_invoke\n", ORBIT_EPV_VAR_NAME);
+	fprintf (ci->fh, "		(_obj, %s__classid, &_ORBIT_servant,\n", iface_id);
+	fprintf (ci->fh, "               G_STRUCT_OFFSET (POA_%s__epv, %s)))) {\n",
+		 iface_id, IDL_IDENT (IDL_OP_DCL (tree).ident).str);
+
 	fprintf (ci->fh, "if (ORBit_small_flags & ORBIT_SMALL_FAST_LOCALS && \n");
 	fprintf (ci->fh, "    ORBIT_STUB_IsBypass (_obj, %s__classid) && \n", iface_id);
 	fprintf (ci->fh, "    (%s = (POA_%s__epv*) ORBIT_STUB_GetEpv (_obj, %s__classid))->%s) {\n",
@@ -43,7 +50,7 @@ cs_output_stub (IDL_tree     tree,
 
 	fprintf (ci->fh, "ORBIT_STUB_PreCall (_obj);\n");
 
-	fprintf (ci->fh, "%s%s->%s (ORBIT_STUB_GetServant (_obj), ",
+	fprintf (ci->fh, "%s%s->%s (_ORBIT_servant, ",
 		 IDL_OP_DCL (tree).op_type_spec? ORBIT_RETVAL_VAR_NAME " = ":"",
 		 ORBIT_EPV_VAR_NAME,
 		 IDL_IDENT (IDL_OP_DCL (tree).ident).str);
@@ -57,15 +64,16 @@ cs_output_stub (IDL_tree     tree,
 
 	fprintf (ci->fh, "ev);\n");
 
-	fprintf (ci->fh, "ORBIT_STUB_PostCall (_obj);\n");
+	fprintf (ci->fh, "ORBit_stub_post_invoke (_obj, %s);\n", ORBIT_EPV_VAR_NAME);
 
 	fprintf (of, " } else { /* remote marshal */\n");
+#endif
 
 	/* remote invocation part */
 	if (has_args)
 		orbit_cbe_flatten_args (tree, of, "_args");
 
-	fprintf (of, "ORBit_small_invoke_stub_n (_obj, "
+	fprintf (of, "ORBit_c_stub_invoke (_obj, "
 		 "&%s__iinterface.methods, %d, ", iface_id, *idx);
 
 	if (has_retval)
@@ -83,9 +91,11 @@ cs_output_stub (IDL_tree     tree,
 	else
 		fprintf (ci->fh, "NULL, ");
 		
-	fprintf (of, "ev);\n\n");
+	fprintf (of, "ev, ");
 
-	fprintf (of, "}\n");
+	fprintf (of, "%s__classid, G_STRUCT_OFFSET (POA_%s__epv, %s),\n",
+		 iface_id, iface_id, IDL_IDENT (IDL_OP_DCL (tree).ident).str);
+	fprintf (of, "(ORBitSmallSkeleton) _ORBIT_skel_small_%s);\n\n", opname);
 
 	if (has_retval)
 		fprintf (of, "return " ORBIT_RETVAL_VAR_NAME ";\n");
Index: src/orb/poa/poa.c
===================================================================
RCS file: /cvs/gnome/ORBit2/src/orb/poa/poa.c,v
retrieving revision 1.97
diff -u -p -u -r1.97 poa.c
--- src/orb/poa/poa.c	12 May 2003 19:47:53 -0000	1.97
+++ src/orb/poa/poa.c	28 May 2003 13:24:21 -0000
@@ -2320,3 +2320,64 @@ ORBit_poa_init (void)
 	_ORBit_poa_manager_lock = linc_mutex_new ();
 	giop_thread_set_main_handler (ORBit_POAObject_invoke_incoming_request);
 }
+
+static gpointer
+get_c_method (CORBA_Object obj,
+	      glong        class_id,
+	      gpointer    *servant,
+	      glong        method_offset)
+{
+	guchar *epv_start;
+	ORBit_POAObject pobj;
+
+	if (!obj ||
+	    !(pobj = (ORBit_POAObject) obj->adaptor_obj) ||
+	    !(*servant = pobj->servant))
+		return NULL;
+
+	if (method_offset <= 0 || class_id <= 0)
+		return NULL;
+
+	if (!(ORBit_small_flags & ORBIT_SMALL_FAST_LOCALS))
+		return NULL;
+
+	if (!ORBIT_STUB_IsBypass (obj, class_id))
+		return NULL;
+
+	epv_start = (guchar *)ORBIT_POAOBJECT_TO_EPVPTR (pobj, class_id);
+	if (!epv_start)
+		return NULL;
+
+	return *(gpointer *)(epv_start + method_offset);
+}
+
+void
+ORBit_c_stub_invoke (CORBA_Object        obj,
+		     ORBit_IMethods     *methods,
+		     glong               method_index,
+		     gpointer            ret,
+		     gpointer            args,
+		     CORBA_Context       ctx,
+		     CORBA_Environment  *ev,
+
+		     glong               class_id,
+		     glong               method_offset,
+		     ORBitSmallSkeleton  skel_impl)
+{
+	gpointer method_impl, servant;
+
+	if (skel_impl &&
+	    (method_impl = get_c_method (obj, class_id,
+					 &servant, method_offset))) {
+		
+		ORBIT_STUB_PreCall (obj);
+
+		skel_impl (servant, ret, args, ctx, ev, method_impl);
+		
+		ORBIT_STUB_PostCall (obj);
+		
+	} else
+		ORBit_small_invoke_stub_n
+			(obj, methods, method_index,
+			 ret, args, ctx, ev);
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]