Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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