Yes.
But there are multiple places like that,
because initially i made it working on squeak vm, where primitives has
no error codes.
now, of course, with Cog, we can report more details , as to what is
wrong and where.

Javier, i preparing a new config, which will update a debugging
support for NB primitives,
which will work past 14402 pharo.
Because without it, you cannot debug the NB calls.

See http://code.google.com/p/pharo/issues/detail?id=5459 for details.


On 19 March 2012 16:21, Javier Pimás <elpochodelage...@gmail.com> wrote:
> this method doesn't tell why it fails when coercion fails, here is a change
> proposed that will save many debugging hours.
>
> pushAsPointer: gen
> "by default, push argument as a bytearray ptr"
> "may accept:
> - nil
> - variable bytes oop
> - external address "
> | asm proxy notNil done oop  notExternalAddress |
> asm := gen asm.
> proxy := gen proxy.
> done := asm uniqueLabelName: 'done'.
> oop := gen reserveTemp.
> "load argument oop"
> loader emitLoad: gen to: oop.
> "handle nils, if we care"
> gen optCoerceNilToNull ifTrue: [
> notNil := asm uniqueLabelName: 'notNil'.
> proxy nilObject.
> asm cmp: asm EAX with: oop;
> jne: notNil;
> xor: asm EAX with: asm EAX;
> push: asm EAX;
> jmp: done;
> label: notNil.
> ].
>
> "handle ExternalAddress, if we care"
> gen optAllowExternalAddressPtr ifTrue: [ | oopClass |
> oopClass := gen reserveTemp.
> notExternalAddress := asm uniqueLabelName: 'notExternalAddress'.
> proxy fetchClassOf: oop.
> asm mov: asm EAX to: oopClass.
>
> gen emitFetchClass: NBExternalAddress.
> asm cmp: asm EAX with: oopClass.
> asm jne: notExternalAddress.
> proxy fetchPointer: 0 ofObject: oop.
> asm push: asm EAX.
> asm jmp: done.
> asm label: notExternalAddress.
> gen releaseTemps: 1.
> ].
>
> "the last case is a byte/word array,
> simply push a pointer to first indexable field of oop"
>
> gen optAllowByteArraysPtr ifTrue: [
> proxy isBytesOrWords: oop ifNotJumpTo: gen failedLabel.
> proxy firstIndexableField: oop.
> asm push: asm EAX.
> asm jmp: done.
> ].
> asm jmp: gen failedLabel.  <----- change to: gen failWithCode:
> NBPrimErrBadArgument .
> asm label: done.
>
> gen releaseTemps: 1.
>
>
>
>
> --
> Lic. Javier Pimás
> Ciudad de Buenos Aires



-- 
Best regards,
Igor Stasenko.

Reply via email to