VM crash
tim Rowledge
tim at rowledge.org
Sun Jun 4 22:35:40 UTC 2006
On 4-Jun-06, at 3:05 PM, Bert Freudenberg wrote:
> Am 04.06.2006 um 23:42 schrieb Jecel Assumpcao Jr:
>
>> Bob Cowdery wrote on Sun, 4 Jun 2006 13:12:12 +0100
>>
>>> memcpy((void *)results, a, 4096*sizeof(float));
>>
>> I haven't looked into interfacing with the VM at all and so am
>> probably
>> saying something really stupid, but I would think that results[0]
>> would
>> hold the object's header and overwritting it would cause really bad
>> things to happen.
>
> That's what I suspected, too.
>
> So, you have to convert between Oops and C pointers, for example
> using #arrayValueOf: if you know your Oop is an array, or
> #firstIndexableField: for the general case. Also, be sure to look
> at the generated C code, and attach it for reference.
The plugin function is generated as:-
EXPORT(sqInt) test(void) {
float *data;
data = ((float *) (interpreterProxy->arrayValueOf(interpreterProxy-
>stackValue(0))));
if (interpreterProxy->failed()) {
return null;
}
process_test(data);
if (interpreterProxy->failed()) {
return null;
}
interpreterProxy->popthenPush(2, data);
return null;
}
so we can see it is handling the firstIndexableField issue via
arrayValueOf().
tim
--
tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
Diagnostics are the programs that run when nothing else will.
More information about the Squeak-dev
mailing list
|