Skip to content
Newer
Older
100644 431 lines (312 sloc) 11.1 KB
c64e58f pmc docs update 3
Michael Scott authored Feb 17, 2004
1 /*
0e36289 @allisonrandal [cage] Updating all copyrights in src/ to Parrot Foundation.
allisonrandal authored Feb 17, 2009
2 Copyright (C) 2001-2008, Parrot Foundation.
c64e58f pmc docs update 3
Michael Scott authored Feb 17, 2004
3 $Id$
4
5 =head1 NAME
6
f474cd7 @bschmalhofer [perl #38235] Rename (dyn)?classes to (dyn)?pmc
bschmalhofer authored Jan 18, 2006
7 src/pmc/nci.pmc - Native Call Interface
c64e58f pmc docs update 3
Michael Scott authored Feb 17, 2004
8
9 =head1 DESCRIPTION
10
11 The vtable functions for the native C call functions.
12
13 =head2 Methods
14
15 =over 4
16
17 =cut
18
19 */
2a2c19b Added in code to properly do native calls to library routines loaded via
Dan Sugalski authored Nov 21, 2002
20
811a7df @cotto [PMC] make NCI PMCs use ATTRs, with one temporary workaround for i386…
cotto authored Feb 21, 2009
21 typedef INTVAL (*nci_sub_t)(PARROT_INTERP, PMC *);
22 typedef INTVAL (*nci_jit_sub_t)(PARROT_INTERP, PMC *, char *);
23
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored Sep 8, 2008
24 void pcc_params(PARROT_INTERP, STRING *sig, Parrot_NCI_attributes * const nci_info);
25 void pcc_params(PARROT_INTERP, STRING *sig, Parrot_NCI_attributes * const nci_info) {
b6bc0c3 @allisonrandal [pdd28str] Merging the pdd27mmd branch into trunk for r36123 to r36318.
allisonrandal authored Feb 3, 2009
26 char *sig_c = Parrot_str_to_cstring(interp, sig);
03918bc @chromatic [PMC] Fixed a read of unitialized memory in NCI PMC reported by Valgr…
chromatic authored Nov 9, 2008
27 size_t sig_length = strlen(sig_c);
89ea27b @chromatic [PMC] Modified PMC initializations to avoid unnecessary use of
chromatic authored May 16, 2009
28 char *param_sig = mem_allocate_n_typed(sig_length, char);
03918bc @chromatic [PMC] Fixed a read of unitialized memory in NCI PMC reported by Valgr…
chromatic authored Nov 9, 2008
29 size_t j = 0;
30 size_t i;
31
32 for (i = 1; i < sig_length; i++) {
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored Aug 22, 2008
33 switch (sig_c[i]) {
34 case '0': /* null ptr or such - doesn't consume a reg */
35 break;
36 case 'f':
37 case 'N':
38 case 'd':
39 param_sig[j++] = 'N';
40 break;
41 case 'I': /* INTVAL */
42 case 'l': /* long */
43 case 'i': /* int */
44 case 's': /* short */
45 case 'c': /* char */
46 param_sig[j++] = 'I';
47 break;
48 case 'S':
49 case 't': /* string, pass a cstring */
50 param_sig[j++] = 'S';
51 break;
52 case 'J': /* interpreter */
53 break;
54 case 'p': /* push pmc->data */
55 case 'O': /* push PMC * object in P2 */
56 case 'P': /* push PMC * */
57 case 'V': /* push PMC * */
58 param_sig[j++] = 'P';
59 case 'v':
60 break;
61 /* I have no idea how to handle these */
62 case '2':
63 case '3':
64 case '4':
65 param_sig[j++] = 'I';
66 break;
67 case '@':
4d00214 @tewk [jitted NCI] fixed "@" signature bug
tewk authored Oct 30, 2008
68 param_sig[j++] = '@';
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored Aug 22, 2008
69 break;
70 case 'b': /* buffer (void*) pass PObj_bufstart(SReg) */
71 case 'B': /* buffer (void**) pass &PObj_bufstart(SReg) */
72 param_sig[j++] = 'S';
73 break;
74 default:
03918bc @chromatic [PMC] Fixed a read of unitialized memory in NCI PMC reported by Valgr…
chromatic authored Nov 9, 2008
75 Parrot_ex_throw_from_c_args(interp, NULL,
76 EXCEPTION_JIT_ERROR,
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored Aug 22, 2008
77 "Unknown param Signature %c\n", sig_c[i]);
78 break;
79 }
80 }
81
03918bc @chromatic [PMC] Fixed a read of unitialized memory in NCI PMC reported by Valgr…
chromatic authored Nov 9, 2008
82 PARROT_ASSERT(j <= sig_length);
33d35c5 @tewk [NCI] ensure that nci_info members are CONSTANT STRINGS
tewk authored Oct 27, 2008
83
03918bc @chromatic [PMC] Fixed a read of unitialized memory in NCI PMC reported by Valgr…
chromatic authored Nov 9, 2008
84 /* use only the signature-significant part of the string buffer */
85 if (j) {
86 nci_info->pcc_params_signature = string_make(interp, param_sig, j,
87 NULL, PObj_constant_FLAG);
88 }
89 else
90 nci_info->pcc_params_signature = CONST_STRING(interp, "");
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored Aug 22, 2008
91
37fe639 @chromatic [PMC] Fixed a memory leak in the NCI PMC introduced in r32463. Also f…
chromatic authored Nov 9, 2008
92 mem_sys_free(param_sig);
b6bc0c3 @allisonrandal [pdd28str] Merging the pdd27mmd branch into trunk for r36123 to r36318.
allisonrandal authored Feb 3, 2009
93 Parrot_str_free_cstring(sig_c);
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored Aug 22, 2008
94 }
95
96
0c0850c use need_ext flag
Leopold Toetsch authored Aug 28, 2003
97 pmclass NCI need_ext {
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored Aug 22, 2008
98 ATTR STRING *signature; /* The signature. */
9ed2bdc @chromatic [MMD] Changed MULTI initialization to delay generating type typles of…
chromatic authored May 14, 2009
99 ATTR void *func; /* Function pointer to call. */
100 ATTR void *orig_func; /* Function pointer
101 * used to create func */
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored Aug 22, 2008
102 ATTR STRING *pcc_params_signature; /* The signature. */
9ed2bdc @chromatic [MMD] Changed MULTI initialization to delay generating type typles of…
chromatic authored May 14, 2009
103 ATTR STRING *long_signature; /* The full signature. */
104 ATTR PMC *multi_sig; /* type tuple array (?) */
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored Aug 22, 2008
105 ATTR INTVAL arity; /* Cached arity of the NCI. */
106 ATTR INTVAL jitted; /* Is this a jitted NCI stub. */
2a2c19b Added in code to properly do native calls to library routines loaded via
Dan Sugalski authored Nov 21, 2002
107
c64e58f pmc docs update 3
Michael Scott authored Feb 17, 2004
108 /*
109
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
110 =item C<METHOD get_multisig()>
1415cda add introspection method get_multisig
Leopold Toetsch authored Mar 21, 2006
111
112 Return the MMD signature PMC, if any or a Null PMC.
113
114 =cut
115
116 */
117
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
118 METHOD get_multisig() {
26f7d7b @cotto [PMC] replace PMC_pmc_val with an ATTR in the NCI PMC
cotto authored Feb 19, 2009
119 PMC *sig;
120 GET_ATTR_multi_sig(INTERP, SELF, sig);
121 if (sig == PMCNULL)
122 sig = PMCNULL;
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
123 RETURN(PMC *sig);
1415cda add introspection method get_multisig
Leopold Toetsch authored Mar 21, 2006
124 }
125
126 /*
127
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
128 =item C<METHOD set_raw_nci_ptr(void *func)>
d1c84dd @tewk [IMCC] added full calling conventions to C PMC methods.
tewk authored Jan 17, 2007
129
130 Sets the specified function pointer and raw flag.
131
132 =cut
133
134 */
135
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
136 METHOD make_raw_nci(PMC *func) {
137 VTABLE_set_pointer(interp, SELF, (void *)func);
d1c84dd @tewk [IMCC] added full calling conventions to C PMC methods.
tewk authored Jan 17, 2007
138 }
139
140 /*
141
c64e58f pmc docs update 3
Michael Scott authored Feb 17, 2004
142 =item C<void init()>
143
144 Initializes the NCI with a C<NULL> function pointer.
145
146 =cut
147
148 */
149
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
150 VTABLE void init() {
811a7df @cotto [PMC] make NCI PMCs use ATTRs, with one temporary workaround for i386…
cotto authored Feb 21, 2009
151 PMC_data(SELF) = mem_allocate_zeroed_typed(Parrot_NCI_attributes);
62e3049 @petdance consting, and fixed embedded tabs
petdance authored Dec 17, 2007
152
637246f @jnthn Refactor the NCI PMC to have an underlying structure, in preparation …
jnthn authored Dec 15, 2007
153 /* Mark that we're not a raw NCI. */
d1c84dd @tewk [IMCC] added full calling conventions to C PMC methods.
tewk authored Jan 17, 2007
154 PObj_flag_CLEAR(private2, SELF);
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored Aug 22, 2008
155 PObj_custom_mark_SET(SELF);
0176661 @chromatic [PMC] Actually clean up memory allocated in the NCI PMC. This fixes a…
chromatic authored Dec 23, 2007
156 PObj_active_destroy_SET(SELF);
f7fc86b nci
Leopold Toetsch authored Jan 21, 2003
157 }
158
c64e58f pmc docs update 3
Michael Scott authored Feb 17, 2004
159 /*
160
380c0ba fix NCI related DOD problem
Leopold Toetsch authored May 7, 2004
161 =item C<void set_pointer_keyed_str(STRING *key, void *func)>
c64e58f pmc docs update 3
Michael Scott authored Feb 17, 2004
162
380c0ba fix NCI related DOD problem
Leopold Toetsch authored May 7, 2004
163 Sets the specified function pointer and signature (C<*key>).
c64e58f pmc docs update 3
Michael Scott authored Feb 17, 2004
164
165 =cut
166
167 */
168
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
169 VTABLE void set_pointer(void *ptr) {
811a7df @cotto [PMC] make NCI PMCs use ATTRs, with one temporary workaround for i386…
cotto authored Feb 21, 2009
170 SET_ATTR_orig_func(INTERP, SELF, ptr);
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
171 PObj_flag_SET(private2, SELF);
172 }
173
4108fd8 @cotto [JIT] remove undocumented dependency of jit code on PMC internals, fi…
cotto authored Apr 9, 2009
174 VTABLE void *get_pointer() {
175 return PARROT_NCI(SELF)->orig_func;
176 }
177
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
178 VTABLE void set_pointer_keyed_str(STRING *key, void *func) {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored Sep 8, 2008
179 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
3bb127b @cotto [style] a bunch of consting
cotto authored Jan 17, 2009
180 int jitted = 0;
637246f @jnthn Refactor the NCI PMC to have an underlying structure, in preparation …
jnthn authored Dec 15, 2007
181
62e3049 @petdance consting, and fixed embedded tabs
petdance authored Dec 17, 2007
182 /* Store the original function and signature. */
811a7df @cotto [PMC] make NCI PMCs use ATTRs, with one temporary workaround for i386…
cotto authored Feb 21, 2009
183 SET_ATTR_orig_func(INTERP, SELF, func);
c4cd281 @chromatic [PMC] Avoided an unnecessary STRING copying and creation in NCI's
chromatic authored May 14, 2009
184
185 /* ensure that the STRING signature is constant */
186 if (!PObj_constant_TEST(key)) {
187 char * const key_c = Parrot_str_to_cstring(INTERP, key);
188 key = string_make(interp, key_c, strlen(key_c),
03918bc @chromatic [PMC] Fixed a read of unitialized memory in NCI PMC reported by Valgr…
chromatic authored Nov 9, 2008
189 NULL, PObj_constant_FLAG);
c4cd281 @chromatic [PMC] Avoided an unnecessary STRING copying and creation in NCI's
chromatic authored May 14, 2009
190 Parrot_str_free_cstring(key_c);
191 }
192
193 nci_info->signature = key;
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored Aug 22, 2008
194 pcc_params(INTERP, key, nci_info);
637246f @jnthn Refactor the NCI PMC to have an underlying structure, in preparation …
jnthn authored Dec 15, 2007
195
62e3049 @petdance consting, and fixed embedded tabs
petdance authored Dec 17, 2007
196 /* Arity is length of that string minus one (the return type). */
b6bc0c3 @allisonrandal [pdd28str] Merging the pdd27mmd branch into trunk for r36123 to r36318.
allisonrandal authored Feb 3, 2009
197 nci_info->arity = Parrot_str_byte_length(INTERP, key) - 1;
637246f @jnthn Refactor the NCI PMC to have an underlying structure, in preparation …
jnthn authored Dec 15, 2007
198
62e3049 @petdance consting, and fixed embedded tabs
petdance authored Dec 17, 2007
199 /* Build call function. */
03918bc @chromatic [PMC] Fixed a read of unitialized memory in NCI PMC reported by Valgr…
chromatic authored Nov 9, 2008
200 nci_info->func = (PMC *)(build_call_func(INTERP, SELF,
201 key, &jitted));
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored Aug 22, 2008
202 nci_info->jitted = jitted;
203 }
03918bc @chromatic [PMC] Fixed a read of unitialized memory in NCI PMC reported by Valgr…
chromatic authored Nov 9, 2008
204
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored Aug 22, 2008
205 /*
206
207 =item C<void mark()>
208
209 Mark any referenced strings and PMCs.
210
211 =cut
212
213 */
214 VTABLE void mark() {
215 if (PARROT_NCI(SELF)) {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored Sep 8, 2008
216 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored Aug 22, 2008
217
218 if (nci_info->signature)
b354cdb @Whiteknight [gc_api] Behold! Parrot is entering an age of slightly less lousy GC!…
Whiteknight authored May 9, 2009
219 Parrot_gc_mark_PObj_alive(interp, (PObj*)nci_info->signature);
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored Aug 22, 2008
220 if (nci_info->pcc_params_signature)
b354cdb @Whiteknight [gc_api] Behold! Parrot is entering an age of slightly less lousy GC!…
Whiteknight authored May 9, 2009
221 Parrot_gc_mark_PObj_alive(interp, (PObj*)nci_info->pcc_params_signature);
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored Aug 22, 2008
222 }
65bd9bf eval #1
Leopold Toetsch authored Jan 16, 2003
223 }
11b723d fixed memory leak in jitted i386 nci code; clone nci
Leopold Toetsch authored Dec 14, 2002
224
c64e58f pmc docs update 3
Michael Scott authored Feb 17, 2004
225 /*
226
227 =item C<void destroy()>
228
229 Destroys the NCI, freeing any allocated memory.
230
231 =cut
232
233 */
234
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
235 VTABLE void destroy() {
637246f @jnthn Refactor the NCI PMC to have an underlying structure, in preparation …
jnthn authored Dec 15, 2007
236 if (PMC_data(SELF)) {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored Sep 8, 2008
237 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
0176661 @chromatic [PMC] Actually clean up memory allocated in the NCI PMC. This fixes a…
chromatic authored Dec 23, 2007
238
62e3049 @petdance consting, and fixed embedded tabs
petdance authored Dec 17, 2007
239 mem_sys_free(nci_info);
0176661 @chromatic [PMC] Actually clean up memory allocated in the NCI PMC. This fixes a…
chromatic authored Dec 23, 2007
240 PMC_data(SELF) = NULL;
62e3049 @petdance consting, and fixed embedded tabs
petdance authored Dec 17, 2007
241 }
11b723d fixed memory leak in jitted i386 nci code; clone nci
Leopold Toetsch authored Dec 14, 2002
242 }
243
c64e58f pmc docs update 3
Michael Scott authored Feb 17, 2004
244 /*
245
246 =item C<PMC *clone()>
247
248 Creates and returns a clone of the NCI.
249
250 =cut
251
252 */
253
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
254 VTABLE PMC *clone() {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored Sep 8, 2008
255 Parrot_NCI_attributes * const nci_info_self = PARROT_NCI(SELF);
256 Parrot_NCI_attributes *nci_info_ret;
811a7df @cotto [PMC] make NCI PMCs use ATTRs, with one temporary workaround for i386…
cotto authored Feb 21, 2009
257 void *orig_func;
62e3049 @petdance consting, and fixed embedded tabs
petdance authored Dec 17, 2007
258
26f7d7b @cotto [PMC] replace PMC_pmc_val with an ATTR in the NCI PMC
cotto authored Feb 19, 2009
259 PMC * const ret = pmc_new(INTERP, SELF->vtable->base_type);
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored Sep 8, 2008
260 PMC_data(ret) = mem_allocate_zeroed_typed(Parrot_NCI_attributes);
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
261 nci_info_ret = PARROT_NCI(ret);
82c7cf6 @chromatic [PMC] Minor cleanups and tidyings.
chromatic authored Aug 30, 2007
262
c64e58f pmc docs update 3
Michael Scott authored Feb 17, 2004
263 /* FIXME if data is malloced (JIT/i386!) then we need
264 * the length of data here, to memcpy it
265 * ManagedStruct or Buffer?
266 */
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored Aug 22, 2008
267 nci_info_ret->func = nci_info_self->func;
811a7df @cotto [PMC] make NCI PMCs use ATTRs, with one temporary workaround for i386…
cotto authored Feb 21, 2009
268 nci_info_ret->orig_func = nci_info_self->orig_func;
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored Aug 22, 2008
269 nci_info_ret->signature = nci_info_self->signature;
270 nci_info_ret->pcc_params_signature = nci_info_self->pcc_params_signature;
271 nci_info_ret->arity = nci_info_self->arity;
37fe639 @chromatic [PMC] Fixed a memory leak in the NCI PMC introduced in r32463. Also f…
chromatic authored Nov 9, 2008
272 nci_info_ret->jitted = nci_info_self->jitted;
4108fd8 @cotto [JIT] remove undocumented dependency of jit code on PMC internals, fi…
cotto authored Apr 9, 2009
273 PObj_get_FLAGS(ret) |= (PObj_get_FLAGS(SELF) & 0x7);
82c7cf6 @chromatic [PMC] Minor cleanups and tidyings.
chromatic authored Aug 30, 2007
274
c64e58f pmc docs update 3
Michael Scott authored Feb 17, 2004
275 return ret;
2a2c19b Added in code to properly do native calls to library routines loaded via
Dan Sugalski authored Nov 21, 2002
276 }
277
c64e58f pmc docs update 3
Michael Scott authored Feb 17, 2004
278 /*
279
280 =item C<INTVAL defined()>
281
282 Returns whether the NCI is defined.
283
284 =cut
285
286 */
287
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
288 VTABLE INTVAL defined() {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored Sep 8, 2008
289 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
637246f @jnthn Refactor the NCI PMC to have an underlying structure, in preparation …
jnthn authored Dec 15, 2007
290 return nci_info->func != NULL;
2a2c19b Added in code to properly do native calls to library routines loaded via
Dan Sugalski authored Nov 21, 2002
291 }
292
c64e58f pmc docs update 3
Michael Scott authored Feb 17, 2004
293 /*
294
0ae5d55 @paultcochrane Patch courtesy of Steve Peters <steve at fisharerojo dot org>, his co…
paultcochrane authored Mar 30, 2007
295 =item C<opcode_t *invoke(void *next)>
c64e58f pmc docs update 3
Michael Scott authored Feb 17, 2004
296
8838c7f builtins 1 - first shot
Leopold Toetsch authored Mar 19, 2005
297 Calls the associated C function, returning C<*next>. If
298 the invocant is a class, the PMC arguments are
299 shifted down.
c64e58f pmc docs update 3
Michael Scott authored Feb 17, 2004
300
301 =cut
302
303 */
304
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
305 VTABLE opcode_t *invoke(void *next) {
637246f @jnthn Refactor the NCI PMC to have an underlying structure, in preparation …
jnthn authored Dec 15, 2007
306
811a7df @cotto [PMC] make NCI PMCs use ATTRs, with one temporary workaround for i386…
cotto authored Feb 21, 2009
307 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
308 nci_sub_t func;
309 void *orig_func;
310 PMC *cont;
82c7cf6 @chromatic [PMC] Minor cleanups and tidyings.
chromatic authored Aug 30, 2007
311
811a7df @cotto [PMC] make NCI PMCs use ATTRs, with one temporary workaround for i386…
cotto authored Feb 21, 2009
312 GET_ATTR_orig_func(INTERP, SELF, orig_func);
313 func = PObj_flag_TEST(private2, SELF)
314 ? (nci_sub_t) D2FPTR(orig_func)
637246f @jnthn Refactor the NCI PMC to have an underlying structure, in preparation …
jnthn authored Dec 15, 2007
315 : (nci_sub_t) D2FPTR(nci_info->func);
82c7cf6 @chromatic [PMC] Minor cleanups and tidyings.
chromatic authored Aug 30, 2007
316
b9b6c03 fix MMD wrapping for __is_equal
Leopold Toetsch authored Jun 2, 2005
317 if (!func)
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored Aug 2, 2008
318 Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_INVALID_OPERATION,
b9b6c03 fix MMD wrapping for __is_equal
Leopold Toetsch authored Jun 2, 2005
319 "attempt to call NULL function");
82c7cf6 @chromatic [PMC] Minor cleanups and tidyings.
chromatic authored Aug 30, 2007
320
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored Aug 22, 2008
321 if (nci_info->jitted) {
322
323 nci_jit_sub_t jit_func = (nci_jit_sub_t) D2FPTR(nci_info->func);
324
325 /* Parrot_eprintf(interp, "JITTED %S\n", nci_info->signature); */
4108fd8 @cotto [JIT] remove undocumented dependency of jit code on PMC internals, fi…
cotto authored Apr 9, 2009
326 jit_func(INTERP, SELF, (char *) nci_info->pcc_params_signature->strstart);
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored Aug 22, 2008
327 }
328 else {
329 if (PObj_flag_TEST(private2, SELF)) {
330 /* Parrot_eprintf(interp, "RAW NCI CALL\n"); */
331 }
332 else {
333 /* Parrot_eprintf(interp, "HACKED %S\n", nci_info->signature); */
334 }
335 func(INTERP, SELF);
336 }
92c390d Fix tailcalls to NCI, #38724
Leopold Toetsch authored Mar 14, 2006
337 cont = INTERP->current_cont;
82c7cf6 @chromatic [PMC] Minor cleanups and tidyings.
chromatic authored Aug 30, 2007
338
8838c7f builtins 1 - first shot
Leopold Toetsch authored Mar 19, 2005
339 /*
92c390d Fix tailcalls to NCI, #38724
Leopold Toetsch authored Mar 14, 2006
340 * If the NCI function was tailcalled, the return result
341 * is already passed back to the caller of this frame
342 * - see Parrot_init_ret_nci(). We therefore invoke the
343 * return continuation here, which gets rid of this frame
344 * and returns the real return address
8838c7f builtins 1 - first shot
Leopold Toetsch authored Mar 19, 2005
345 */
bf41b66 @particle [PDD07]: ws cleanup in src/, src/dynpmc/, and src/pmc/
particle authored Oct 25, 2006
346 if (cont && cont != NEED_CONTINUATION &&
92c390d Fix tailcalls to NCI, #38724
Leopold Toetsch authored Mar 14, 2006
347 (PObj_get_FLAGS(cont) & SUB_FLAG_TAILCALL)) {
637cc2a @chromatic [src] Changed CONTEXT(interp->ctx) to CONTEXT(interp), which seems cl…
chromatic authored Mar 19, 2008
348 cont = CONTEXT(interp)->current_cont;
92c390d Fix tailcalls to NCI, #38724
Leopold Toetsch authored Mar 14, 2006
349 next = VTABLE_invoke(INTERP, cont, next);
350 }
82c7cf6 @chromatic [PMC] Minor cleanups and tidyings.
chromatic authored Aug 30, 2007
351
e063e49 @chromatic Continuing Parrot/C++ cleanups (Steve Peters, RT #42746).
chromatic authored Apr 26, 2007
352 return (opcode_t *)next;
2a2c19b Added in code to properly do native calls to library routines loaded via
Dan Sugalski authored Nov 21, 2002
353 }
380c0ba fix NCI related DOD problem
Leopold Toetsch authored May 7, 2004
354
c64e58f pmc docs update 3
Michael Scott authored Feb 17, 2004
355 /*
356
357 =item C<INTVAL get_integer()>
358
359 Returns the function pointer as an integer.
360
361 =cut
362
363 */
364
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
365 VTABLE INTVAL get_integer() {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored Sep 8, 2008
366 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
637246f @jnthn Refactor the NCI PMC to have an underlying structure, in preparation …
jnthn authored Dec 15, 2007
367 return (INTVAL)nci_info->func;
3168931 Forth can now generate code for words on the fly and execute them.
Dan Sugalski authored Oct 24, 2003
368 }
369
f35b03c @rubys Initial support for sort
rubys authored Dec 20, 2004
370 /*
371
372 =item C<INTVAL get_bool()>
373
374 Returns the boolean value of the pointer.
375
376 =cut
377
378 */
379
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
380 VTABLE INTVAL get_bool() {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored Sep 8, 2008
381 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
62e3049 @petdance consting, and fixed embedded tabs
petdance authored Dec 17, 2007
382 return (0 != (INTVAL)nci_info->func);
f35b03c @rubys Initial support for sort
rubys authored Dec 20, 2004
383 }
384
6586a2c @jnthn Implement arity method on NCI PMCs, plus a test for it.
jnthn authored Dec 15, 2007
385 /*
386
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
387 =item C<METHOD arity()>
6586a2c @jnthn Implement arity method on NCI PMCs, plus a test for it.
jnthn authored Dec 15, 2007
388
01e804c @Util [pmc] Typo corrections
Util authored Mar 13, 2009
389 Return the arity of the NCI (the number of arguments).
6586a2c @jnthn Implement arity method on NCI PMCs, plus a test for it.
jnthn authored Dec 15, 2007
390
391 =cut
392
393 */
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
394 METHOD arity() {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored Sep 8, 2008
395 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
48d2796 @NotFound Another unreachable warning, codingstd in jit_emit ppc
NotFound authored Jul 10, 2008
396 INTVAL arity = 0;
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
397
48d2796 @NotFound Another unreachable warning, codingstd in jit_emit ppc
NotFound authored Jul 10, 2008
398 if (nci_info && nci_info->func)
399 arity = nci_info->arity;
62e3049 @petdance consting, and fixed embedded tabs
petdance authored Dec 17, 2007
400 else
37fe639 @chromatic [PMC] Fixed a memory leak in the NCI PMC introduced in r32463. Also f…
chromatic authored Nov 9, 2008
401 Parrot_ex_throw_from_c_args(INTERP, NULL,
402 EXCEPTION_INVALID_OPERATION,
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored Aug 2, 2008
403 "You cannot get the arity of an undefined NCI.");
6586a2c @jnthn Implement arity method on NCI PMCs, plus a test for it.
jnthn authored Dec 15, 2007
404
48d2796 @NotFound Another unreachable warning, codingstd in jit_emit ppc
NotFound authored Jul 10, 2008
405 RETURN(INTVAL arity);
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
406 }
2a2c19b Added in code to properly do native calls to library routines loaded via
Dan Sugalski authored Nov 21, 2002
407 }
c64e58f pmc docs update 3
Michael Scott authored Feb 17, 2004
408
409 /*
410
411 =back
412
413 =head1 SEE ALSO
414
415 F<docs/pdds/pdd03_calling_conventions.pod>.
416
417 =head1 HISTORY
418
419 Initial revision by sean 2002/08/04.
420
421 =cut
422
423 */
424
0eb3eb3 added formatting footer and detabbed
Michael Scott authored Feb 22, 2004
425 /*
426 * Local variables:
72575ae @bschmalhofer #40481: [PATCH] C-code coda in pmc files
bschmalhofer authored Oct 9, 2006
427 * c-file-style: "parrot"
0eb3eb3 added formatting footer and detabbed
Michael Scott authored Feb 22, 2004
428 * End:
429 * vim: expandtab shiftwidth=4:
72575ae @bschmalhofer #40481: [PATCH] C-code coda in pmc files
bschmalhofer authored Oct 9, 2006
430 */
Something went wrong with that request. Please try again.