From: Scott Wood Date: Sun, 28 Oct 2007 20:30:15 +0000 (-0500) Subject: Some weak symbol usage, and some marshalling stuff. X-Git-Url: http://git.buserror.net/cgi-bin/gitweb.cgi?p=polintos%2Fscott%2Fpriv.git;a=commitdiff_plain;h=b024710fe2b60cd4a42a8993b61333d6cdb56ca3;hp=188a395421d2ed7038735d0e3cac37255cf45755 Some weak symbol usage, and some marshalling stuff. --- diff --git a/doc/abi/x86 b/doc/abi/x86 index 7f3de36..1f9dbef 100644 --- a/doc/abi/x86 +++ b/doc/abi/x86 @@ -29,23 +29,3 @@ Out-of-Process Method Invocation: eax: pointer to exception, or NULL if none edx: length of exception segment, if any ebx, esi, edi, ebp, esp: may be clobbered - -Object registration: - eax: number of objects to register with initial refcount 1 - edx: pointer to list of NewObject structs - - Call the 32-bit address stored at 0x7fff0008. - - Upon return: - eax: pointer to exception, or NULL if none - edx: length of exception segment, if any - -GUID SHA-1 hash retrieval: - eax: object id - edx: 20-byte buffer - - Call the 32-bit address stored at 0x7fff000c. - - Upon return: - eax: pointer to exception, or NULL if none - edx: length of exception segment, if any diff --git a/doc/orb/parameter-info-block b/doc/orb/parameter-info-block index b868a44..a61c648 100644 --- a/doc/orb/parameter-info-block +++ b/doc/orb/parameter-info-block @@ -24,9 +24,9 @@ Parameter Info Block (PIB) This is like buffer_size, but for Copy segments. objlist_ptr pointer Pointer to the object list - newobj_ptr pointer Pointer to the new object list. + newobj_ptr pointer Pointer to the new object list. objlist_len 32-bit Length of the object list, in IDs - newobj_len 32-bit Length of the new object list. + newobj_len 32-bit Length of the new object list. The object list is a special segment that contains object IDs rather than arbitrary data. Each object ID will be translated @@ -35,12 +35,10 @@ Parameter Info Block (PIB) regardless of the pointer size. The first object in the list is the object to receive the message. - Objects which live in this address space have the high bit - clear; remote objects have the high bit set. When sending - an object reference that has not been exposed to the kernel - before, its interface hash should exist in the newobj list. - - + Objects which live in this address space have the high bit + clear; remote objects have the high bit set. When sending + an object reference that has not been exposed to the kernel + before, its interface hash should exist in the newobj list. num_segments 32-bit Number of data segments diff --git a/idlcomp/TODO b/idlcomp/TODO index fa745f2..772984b 100644 --- a/idlcomp/TODO +++ b/idlcomp/TODO @@ -26,12 +26,6 @@ Properties with automatic getters and setters (or just getters if read-only), which can be overridden with custom getters and setters in the class. -Methods can be specified as read-only; a read-only version of the -interface is then generated, and a secure read-only reference to an -object can be generated that can only access read-only methods. This -would save effort declaring a separate interface and a separate -class. - Implement marshalling/unmarshalling stubs. Implement async methods. @@ -50,3 +44,6 @@ Possibly implement out parameters on remote-only async methods that can only be used when invoked as a sync in-process method; the method implementation can check to see how it was invoked, and use the out parameters to avoid having to make a completion callback. + +Use linker section garbage collection to discard GUIDs, vtables, etc. for +interfaces/vstructs that aren't referenced. diff --git a/idlcomp/languages/c++/c++.h b/idlcomp/languages/c++/c++.h index a8fb246..ba7e769 100644 --- a/idlcomp/languages/c++/c++.h +++ b/idlcomp/languages/c++/c++.h @@ -54,6 +54,10 @@ class CPPFile : public LangCallback { // The implementation is delayed to avoid circular dependency problems. void output_casts(Interface *sym); + + //// Marshalling methods + + void output_marshall(Struct *sym, int pass); // Output the downcast and implicit upcast methods for // the given interface/superinterface pair. diff --git a/idlcomp/languages/c++/interface-caller.cc b/idlcomp/languages/c++/interface-caller.cc index 2d8c51d..0f0d139 100644 --- a/idlcomp/languages/c++/interface-caller.cc +++ b/idlcomp/languages/c++/interface-caller.cc @@ -260,7 +260,8 @@ void CPPFile::output_internal(Interface *iface) void CPPFile::output_downcast_proto(Interface *iface, Interface *super) { - file << '\n' << indent << "static inline " << **iface->name << " downcast("; + file << '\n' << indent << "static __attribute__((weak)) inline " + << **iface->name << " downcast("; cpp_output_type(file, super, false, false); file << "oldptr);\n"; } diff --git a/idlcomp/languages/c++/main.cc b/idlcomp/languages/c++/main.cc index 8fb4b72..57f9455 100644 --- a/idlcomp/languages/c++/main.cc +++ b/idlcomp/languages/c++/main.cc @@ -385,7 +385,7 @@ void CPPFile::output_guid(const uint64_t *guid64) const unsigned char *guid = reinterpret_cast(guid64); char guidhex[7]; - file << indent << "static const __attribute__((unused))\n" + file << indent << "__attribute__((weak))\n" << indent << "::System::RunTime::GUID _guid = {\n" << indent << "\t{ "; @@ -459,8 +459,8 @@ void CPPFile::output_vstruct_info(Struct *sym) { all_ns_in(sym, true, "VINFO_"); - file << indent << "static const __attribute__((unused)) " - "unsigned long *const _guids[] = {\n"; + file << indent << "__attribute__((weak)) " + "unsigned long * _guids[] = {\n"; stack supers; sym->chainlen = 0; @@ -480,12 +480,10 @@ void CPPFile::output_vstruct_info(Struct *sym) } file << indent << "};\n\n" - << indent << "static const __attribute__((unused)) " + << indent << "__attribute__((weak)) " "::System::RunTime::VStructInfo _info = {\n" << indent << "\t_guids, " << sym->chainlen << ",\n" -#if 0 - << indent << "\t_marshall, _unmarshall,\n" -#endif +// << indent << "\t_marshall, _unmarshall,\n" << indent << "};\n"; @@ -521,7 +519,7 @@ void CPPFile::output_vstruct_main(Struct *sym) if (super) file << '\n' - << indent << "static " << name << " *downcast(::System::VStruct *base)\n" + << indent << "static __attribute__((weak)) " << name << " *downcast(::System::VStruct *base)\n" << indent << "{\n" << indent << "\tif (!base)\n" << indent << "\t\treturn NULL;\n\n" @@ -642,9 +640,13 @@ void CPPFile::output(Struct *sym, int pass, void *arg2) output_nsdecl_begin(sym); output_nsdecl_children(sym); output_guid(sym->def.guid); + output_marshall(sym, trav_nsdecl); output_nsdecl_end(sym); } else { - output_nsdecl(sym); + output_nsdecl_begin(sym); + output_nsdecl_children(sym); + output_marshall(sym, trav_nsdecl); + output_nsdecl_end(sym); } break; diff --git a/idlcomp/languages/c++/marshall.cc b/idlcomp/languages/c++/marshall.cc index 8425ddd..6deb115 100644 --- a/idlcomp/languages/c++/marshall.cc +++ b/idlcomp/languages/c++/marshall.cc @@ -25,7 +25,7 @@ void CPPFile::output_ifaceinfo(Interface *iface) << indent << " int nsegs);\n\n"; #endif - file << indent << "static const __attribute__((unused))\n" + file << indent << "__attribute__((weak)) __attribute__((unused))\n" << indent << "::System::RunTime::IFaceInfo _info = {\n" << indent << "\t&_guid,\n" << indent << "};\n"; @@ -33,8 +33,24 @@ void CPPFile::output_ifaceinfo(Interface *iface) do_extra_newline = true; } -void CPPFile::output_marshall(Struct *sym) +void CPPFile::output_marshall(Struct *sym, int pass) { - file << indent; - + switch (pass) { + case trav_nsdecl: + extra_newline(); + + file << indent << "int _marshall(::System::RunTime::GrowableArray &buf,\n" + << indent << " ::System::RunTime::GrowableArray< ::System::RunTime::ID> &objlist,\n" + << indent << " ::System::RunTime::GrowableArray< ::System::RunTime::NewObject> &newobjlist,\n" + << indent << " ::System::RunTime::ParamInfoBlock::Segment *segs,\n" + << indent << " int nsegs);\n"; + + file << indent << "void _unmarshall(::System::RunTime::Array buf,\n" + << indent << " ::System::RunTime::Array< ::System::_i_Object *> objlist,\n" + << indent << " ::System::RunTime::ParamInfoBlock::Segment *segs,\n" + << indent << " int nsegs);\n"; + + do_extra_newline = true; + break; + } } diff --git a/include/c++/orb.h b/include/c++/orb.h index a20f44d..1f1a3e6 100644 --- a/include/c++/orb.h +++ b/include/c++/orb.h @@ -391,6 +391,12 @@ namespace System { int nsegs); ::System::_i_Object *(*wrapper)(ID id); }; + + struct NewObject { + uint32_t guid_hash[5]; // SHA-1 hash of Interface GUIDs + uint32_t id; + uint32_t reserved[3]; // must be zero + }; struct VStructInfo { // List of GUIDs of the struct and its superstructs, @@ -405,10 +411,11 @@ namespace System { int (*marshall)(GrowableArray &buf, GrowableArray &objlist, + GrowableArray &newobjlist, ParamInfoBlock::Segment *segs, int nsegs); void (*unmarshall)(Array buf, - Array objlist, + Array< ::System::_i_Object *> objlist, ParamInfoBlock::Segment *segs, int nsegs); };