> On Jun 22, 2016, at 8:25 AM, Clément Bera <[email protected]> wrote:
> 
> It's a special case added a couple year ago to figure out why a primitive 
> fail.

That's right.  It was an exception to the rule in VisualWorks and its 
convenience is so strong I brought it over.  But the Squeak/Pharo code dates 
back to 2008 when I added this in Newspeak, which runs on Squeak.


> It's a special temporary variable that holds an error code. The special 
> object array defines a list of error code that the VM can use to explain to 
> the programmer why the primitive failed, which are currently symbols.

Right.  In the VM primitive failure is indicated by a variable called 
primFailCode being non-zero. On activating a method with a failing primitive, 
if the index is in bounds of the primitiveFailCodes array in the 
specialObjectsArray then the failure code substitutes the symbol in the 
primitiveFailCodes array, otherwise it supplies the integer value.

This is simpler than the VW scheme which allocates a PrimFailCode that has a 
name inst car and a parameter.  Our system has only the name.

> 
>> On Wed, Jun 22, 2016 at 4:22 PM, Max Leske <[email protected]> wrote:
>> 
>> > On 22 Jun 2016, at 15:59, stepharo <[email protected]> wrote:
>> >
>> > Hi
>> >
>> > I want to explain where ec is coming.
>> >
>> > I thought that the arguments of pragmas could only be literal and when I 
>> > see ec it looks like a variable set by the VM
>> >
>> >
>> > newMethod: numberOfBytes header: headerWord
>> >    "Primitive. Answer an instance of me. The number of literals (and other
>> >     information) is specified by the headerWord (see my class comment).
>> >     The first argument specifies the number of fields for bytecodes in the
>> >     method. Fail if either argument is not a SmallInteger, or if 
>> > numberOfBytes
>> >     is negative, or if memory is low. Once the header of a method is set by
>> >     this primitive, it cannot be changed to change the number of literals.
>> >     Essential. See Object documentation whatIsAPrimitive."
>> >
>> >    <primitive: 79 error: ec>
>> >    ec == #'insufficient object memory' ifTrue:
>> >        [^self handleFailingNewMethod: numberOfBytes header: headerWord].
>> >    ^self primitiveFailed
>> >
>> >
>> > Stef
>> >
>> >
>> 
>> That is correct. It’s still a literal though.
> 

Reply via email to