Hi. I am trying to call #primitiveBitOr which inside calls #popPos32BitInteger which calls #positive32BitValueOf , with two LargePositiveInteger. Example:
9999999999 bitOr: 8888888888.
Now, this seems to fail since the #bitOr: of LargePositiveInteger is failing, and thus, super (Integer) is being used. Now, I don't understand why it fails.
If I read the comment of positive32BitValueOf it says "Convert the given object into an integer value. The object may be either a positive ST integer or a four-byte LargePositiveInteger."
Its code is:
positive32BitValueOf: oop "Convert the given object into an integer value. The object may be either a positive ST integer or a four-byte LargePositiveInteger."
| sz value | (self isIntegerObject: oop) ifTrue: [ value := self integerValueOf: oop. value < 0 ifTrue: [^ self primitiveFail]. ^ value].
self assertClassOf: oop is: (self splObj: ClassLargePositiveInteger). successFlag ifTrue: [ sz := self lengthOf: oop. sz = 4 ifFalse: [^ self primitiveFail]]. successFlag ifTrue: [ ^ (self fetchByte: 0 ofObject: oop) + ((self fetchByte: 1 ofObject: oop) << 8) + ((self fetchByte: 2 ofObject: oop) << 16) + ((self fetchByte: 3 ofObject: oop) << 24) ].
as you can see, I am supposed to use ClassLargePositiveInteger.
But, in addition, LargePositiveInteger >> #bitOr comment says: "Primitive. Answer an Integer whose bits are the logical OR of the receiver's bits and those of the argument. Fail if the receiver or argument is greater than 32 bits. See Object documentation whatIsAPrimitive."
So....I don't understand...how can I have a LargePositiveInteger but that is less than 32 bits? Wouldn't that be a SmallInteger?
I put some printf in the VM and seems that with my numbers (9999999999 and 8888888888.) when I sent positive32BitValueOf: I got : -65536 and 65535
Thanks in advance for any help.
Mariano
2010/10/8 Mariano Martinez Peck marianopeck@gmail.com:
Hi. I am trying to call #primitiveBitOr which inside calls #popPos32BitInteger which calls #positive32BitValueOf , with two LargePositiveInteger. Example:
9999999999 bitOr: 8888888888.
Now, this seems to fail since the #bitOr: of LargePositiveInteger is failing, and thus, super (Integer) is being used. Now, I don't understand why it fails.
If I read the comment of positive32BitValueOf it says "Convert the given object into an integer value. The object may be either a positive ST integer or a four-byte LargePositiveInteger."
Its code is:
positive32BitValueOf: oop "Convert the given object into an integer value. The object may be either a positive ST integer or a four-byte LargePositiveInteger."
| sz value | (self isIntegerObject: oop) ifTrue: [ value := self integerValueOf: oop. value < 0 ifTrue: [^ self primitiveFail]. ^ value].
self assertClassOf: oop is: (self splObj: ClassLargePositiveInteger). successFlag ifTrue: [ sz := self lengthOf: oop. sz = 4 ifFalse: [^ self primitiveFail]]. successFlag ifTrue: [ ^ (self fetchByte: 0 ofObject: oop) + ((self fetchByte: 1 ofObject: oop) << 8) + ((self fetchByte: 2 ofObject: oop) << 16) + ((self fetchByte: 3 ofObject: oop) << 24) ].
as you can see, I am supposed to use ClassLargePositiveInteger.
But, in addition, LargePositiveInteger >> #bitOr comment says: "Primitive. Answer an Integer whose bits are the logical OR of the receiver's bits and those of the argument. Fail if the receiver or argument is greater than 32 bits. See Object documentation whatIsAPrimitive."
So....I don't understand...how can I have a LargePositiveInteger but that is less than 32 bits? Wouldn't that be a SmallInteger?
If you don't want to read the blue book, maybe you should try this:
^SmallInteger maxVal highBit
Then observe how the low bits of an oop are used to distinguish a true object pointer from an immediate SmallInteger value in the VM.
Nicolas
I put some printf in the VM and seems that with my numbers (9999999999 and 8888888888.) when I sent positive32BitValueOf: I got : -65536 and 65535
Thanks in advance for any help.
Mariano
On 08.10.2010, at 10:12, Mariano Martinez Peck wrote:
Hi. I am trying to call #primitiveBitOr which inside calls #popPos32BitInteger which calls #positive32BitValueOf , with two LargePositiveInteger. Example:
9999999999 bitOr: 8888888888.
Now, this seems to fail since the #bitOr: of LargePositiveInteger is failing, and thus, super (Integer) is being used. Now, I don't understand why it fails.
Because 9999999999 does not fit into 32 bits.
So....I don't understand...how can I have a LargePositiveInteger but that is less than 32 bits? Wouldn't that be a SmallInteger?
SmallIntegers are 31 bits. Positive SmallIntegers are 30 bits:
SmallInteger maxVal 1073741823
You *really* should start learning about the Squeak VM basics first.
- Bert -
Why do you all think that mariano is not trying to learn? He is! He read all the chapters available and books on the topics. Now may be tell him simply that he is an idiot. This would be more efficient. But Mariano is a really smart guy so may be we can also tell him to do ruby or python and we can stay in our nice little club or we can consider that learning alone is difficult.
Stef
Hi. I am trying to call #primitiveBitOr which inside calls #popPos32BitInteger which calls #positive32BitValueOf , with two LargePositiveInteger. Example:
9999999999 bitOr: 8888888888.
Now, this seems to fail since the #bitOr: of LargePositiveInteger is failing, and thus, super (Integer) is being used. Now, I don't understand why it fails.
Because 9999999999 does not fit into 32 bits.
So....I don't understand...how can I have a LargePositiveInteger but that is less than 32 bits? Wouldn't that be a SmallInteger?
SmallIntegers are 31 bits. Positive SmallIntegers are 30 bits:
SmallInteger maxVal 1073741823
You *really* should start learning about the Squeak VM basics first.
- Bert -
On 9 October 2010 23:28, stephane ducasse stephane.ducasse@gmail.com wrote:
Why do you all think that mariano is not trying to learn? He is! He read all the chapters available and books on the topics. Now may be tell him simply that he is an idiot. This would be more efficient. But Mariano is a really smart guy so may be we can also tell him to do ruby or python and we can stay in our nice little club or we can consider that learning alone is difficult.
I could say, that even if you know something well, you still not guaranteed from making silly mistakes. This happens often , especially in such hard area as VM development.
Stef
Hi. I am trying to call #primitiveBitOr which inside calls #popPos32BitInteger which calls #positive32BitValueOf , with two LargePositiveInteger. Example:
9999999999 bitOr: 8888888888.
Now, this seems to fail since the #bitOr: of LargePositiveInteger is failing, and thus, super (Integer) is being used. Now, I don't understand why it fails.
Because 9999999999 does not fit into 32 bits.
So....I don't understand...how can I have a LargePositiveInteger but that is less than 32 bits? Wouldn't that be a SmallInteger?
SmallIntegers are 31 bits. Positive SmallIntegers are 30 bits:
SmallInteger maxVal 1073741823
You *really* should start learning about the Squeak VM basics first.
- Bert -
2010/10/9 stephane ducasse stephane.ducasse@gmail.com:
Why do you all think that mariano is not trying to learn? He is! He read all the chapters available and books on the topics. Now may be tell him simply that he is an idiot. This would be more efficient. But Mariano is a really smart guy so may be we can also tell him to do ruby or python and we can stay in our nice little club or we can consider that learning alone is difficult.
Stef
Apologize to Mariano, Sure we got a little upset by the gap between the level of the question and the hard task of modifying the VM. But stephane is right, we all have the right to be idiot, and most of us are, sometimes (I recently asked a very stupid question about Heap). The spirit behind Smalltalk is not to build walls around complex things, and reserve the knowledge to a happy few cast, and ideally this should apply to the VM too (otherwise, no use to specify it in pseudo Smalltalk code).
But Steph, you must see the good side of this community: despite the tone of the answers, Mariano got 3 responses driving him to the answer. In other languages I bet this would have been just RTFM.
Nicolas
Yes I saw and I appreciated. Now my point is that some assumptions (like that mariano did not read books are bad). Now mariano told me that he will check more. And this is bad because mariano is helping a lot people so we all lost something.
Stef
Why do you all think that mariano is not trying to learn? He is! He read all the chapters available and books on the topics. Now may be tell him simply that he is an idiot. This would be more efficient. But Mariano is a really smart guy so may be we can also tell him to do ruby or python and we can stay in our nice little club or we can consider that learning alone is difficult.
Stef
Apologize to Mariano, Sure we got a little upset by the gap between the level of the question and the hard task of modifying the VM. But stephane is right, we all have the right to be idiot, and most of us are, sometimes (I recently asked a very stupid question about Heap). The spirit behind Smalltalk is not to build walls around complex things, and reserve the knowledge to a happy few cast, and ideally this should apply to the VM too (otherwise, no use to specify it in pseudo Smalltalk code).
But Steph, you must see the good side of this community: despite the tone of the answers, Mariano got 3 responses driving him to the answer. In other languages I bet this would have been just RTFM.
Nicolas
On 10.10.2010, at 13:05, stephane ducasse wrote:
Yes I saw and I appreciated. Now my point is that some assumptions (like that mariano did not read books are bad). Now mariano told me that he will check more. And this is bad because mariano is helping a lot people so we all lost something.
Stef
I don't see how "we all lost something", we gained something instead. Knowing which question is basic and which is advanced is not easy. How SmallIntegers are represented in the Squeak VM is something very basic, so it was appropriate to mention that.
And as Nicolas pointed out, not a single answer was "RTFM", nobody called anyone an idiot. There were 3 different actual explanations. No reason you get all upset about it. Relax, all is fine :)
That is, unless there is a hidden problem you did not mention. But in that case it would be better to name it.
- Bert -
Why do you all think that mariano is not trying to learn? He is! He read all the chapters available and books on the topics. Now may be tell him simply that he is an idiot. This would be more efficient. But Mariano is a really smart guy so may be we can also tell him to do ruby or python and we can stay in our nice little club or we can consider that learning alone is difficult.
Stef
Apologize to Mariano, Sure we got a little upset by the gap between the level of the question and the hard task of modifying the VM. But stephane is right, we all have the right to be idiot, and most of us are, sometimes (I recently asked a very stupid question about Heap). The spirit behind Smalltalk is not to build walls around complex things, and reserve the knowledge to a happy few cast, and ideally this should apply to the VM too (otherwise, no use to specify it in pseudo Smalltalk code).
But Steph, you must see the good side of this community: despite the tone of the answers, Mariano got 3 responses driving him to the answer. In other languages I bet this would have been just RTFM.
Nicolas
On Mon, Oct 11, 2010 at 10:43 PM, Bert Freudenberg bert@freudenbergs.dewrote:
On 10.10.2010, at 13:05, stephane ducasse wrote:
Yes I saw and I appreciated. Now my point is that some assumptions (like
that mariano did not read books
are bad). Now mariano told me that he will check more. And this is bad
because mariano is helping a lot
people so we all lost something.
Stef
I don't see how "we all lost something", we gained something instead. Knowing which question is basic and which is advanced is not easy. How SmallIntegers are represented in the Squeak VM is something very basic, so it was appropriate to mention that.
Yes, I agree. That's very basic. It was confusing for just realising that there is a range (those 2 bits) of difference where I can have LargePositiveInteger that fits in 32 bits. That was all.
And as Nicolas pointed out, not a single answer was "RTFM", nobody called anyone an idiot. There were 3 different actual explanations. No reason you get all upset about it. Relax, all is fine :)
No problem. Fine with you and I appreaciate the help.
Cheers
Mariano
That is, unless there is a hidden problem you did not mention. But in that case it would be better to name it.
- Bert -
Why do you all think that mariano is not trying to learn? He is! He read all the chapters available and books on the topics. Now may be tell him simply that he is an idiot. This would be more efficient. But Mariano is a really smart guy so may
be
we can also tell him to do ruby or python and we can stay in our nice
little
club or we can consider that learning alone is difficult.
Stef
Apologize to Mariano, Sure we got a little upset by the gap between the level of the question and the hard task of modifying the VM. But stephane is right, we all have the right to be idiot, and most of us are, sometimes (I recently asked a very stupid question about Heap). The spirit behind Smalltalk is not to build walls around complex things, and reserve the knowledge to a happy few cast, and ideally this should apply to the VM too (otherwise, no use to specify it in pseudo Smalltalk code).
But Steph, you must see the good side of this community: despite the tone of the answers, Mariano got 3 responses driving him to the answer. In other languages I bet this would have been just RTFM.
Nicolas
Yes I saw and I appreciated. Now my point is that some assumptions (like that mariano did not read books are bad). Now mariano told me that he will check more. And this is bad because mariano is helping a lot people so we all lost something.
Stef
I don't see how "we all lost something", we gained something instead. Knowing which question is basic and which is advanced is not easy. How SmallIntegers are represented in the Squeak VM is something very basic, so it was appropriate to mention that.
And as Nicolas pointed out, not a single answer was "RTFM", nobody called anyone an idiot. There were 3 different actual explanations. No reason you get all upset about it. Relax, all is fine :)
I was not upset just sad and not for me.
That is, unless there is a hidden problem you did not mention. But in that case it would be better to name it.
There is no other problems. Read the mails. And guess what was the state of mind of mariano or other people reading the mailing-list to learn. Having people learning and understanding the VM is important. And as mariano mentioned it, the state of books and documentation is suboptimal in our wonderful community.
Stef
PS: do you expect people to tell in public that they felt ridiculous? Not everybody does not care like me.
On Sun, Oct 10, 2010 at 2:19 PM, Nicolas Cellier < nicolas.cellier.aka.nice@gmail.com> wrote:
2010/10/9 stephane ducasse stephane.ducasse@gmail.com:
Why do you all think that mariano is not trying to learn? He is! He read all the chapters available and books on the topics. Now may be tell him simply that he is an idiot. This would be more efficient. But Mariano is a really smart guy so may be we can also tell him to do ruby or python and we can stay in our nice
little
club or we can consider that learning alone is difficult.
Stef
Apologize to Mariano, Sure we got a little upset by the gap between the level of the question and the hard task of modifying the VM. But stephane is right, we all have the right to be idiot, and most of us are, sometimes (I recently asked a very stupid question about Heap). The spirit behind Smalltalk is not to build walls around complex things, and reserve the knowledge to a happy few cast, and ideally this should apply to the VM too (otherwise, no use to specify it in pseudo Smalltalk code).
But Steph, you must see the good side of this community: despite the tone of the answers, Mariano got 3 responses driving him to the answer. In other languages I bet this would have been just RTFM.
But probably because in those other communities, there ARE manuals. Come on, the blue book is nice, and I like it. But not everything is there (I am not talking in particular about this problem). And several things have changed since the blue book. We don't have OT anymore, I think the GC is also completly different, etc. And the documentation almost ends there....few wiki pages. Here in my lab they are trying to bootstrap from a new image and the same problem...the documentation is very bad.
Cheers
Mariano
Nicolas
On Fri, Oct 08, 2010 at 07:12:13PM +0200, Mariano Martinez Peck wrote:
So....I don't understand...how can I have a LargePositiveInteger but that is less than 32 bits? Wouldn't that be a SmallInteger?
SmallInteger maxVal hex ==> '16r3FFFFFFF'.
The largest positive two-compliment integer that fits into 32 bits is 16rEFFFFFFF, so any Integer in the range 16r4000000 through 16rEFFFFFFF is a LargePositiveInteger that can fit into a signed 32-bit C int.
Thus the number of LargePositiveInteger values that fit into a 32-bit twos-compliment representation is (16r4000000 to: 16rEFFFFFFF) size ==> 3959422976
Note that a SmallInteger is represented internally as a 31-bit value, which accounts for the difference. It's a bit confusing when you are used to thinking of 32-bit int values.
Dave
On Fri, Oct 8, 2010 at 11:47 PM, David T. Lewis lewis@mail.msen.com wrote:
On Fri, Oct 08, 2010 at 07:12:13PM +0200, Mariano Martinez Peck wrote:
So....I don't understand...how can I have a LargePositiveInteger but that
is
less than 32 bits? Wouldn't that be a SmallInteger?
SmallInteger maxVal hex ==> '16r3FFFFFFF'.
The largest positive two-compliment integer that fits into 32 bits is 16rEFFFFFFF, so any Integer in the range 16r4000000 through 16rEFFFFFFF is a LargePositiveInteger that can fit into a signed 32-bit C int.
Thus the number of LargePositiveInteger values that fit into a 32-bit twos-compliment representation is (16r4000000 to: 16rEFFFFFFF) size ==> 3959422976
Note that a SmallInteger is represented internally as a 31-bit value, which accounts for the difference. It's a bit confusing when you are used to thinking of 32-bit int values.
Thanks Dave for the clarification. This was exactly my question and my problem. I do know that SmallInteger are 31 bits sine the last bit is used to distinguish from oop. What I didn't understand is how can I have a LargePositiveIntener in 32 bits.....because less than that it would be a SmallIntegr.
Then, I didn't understand why positive32BitValueOf: has this part:
self assertClassOf: oop is: (self splObj: ClassLargePositiveInteger). successFlag ifTrue: [ sz := self lengthOf: oop. sz = 4 ifFalse: [^ self primitiveFail]]. successFlag ifTrue: [ ^ (self fetchByte: 0 ofObject: oop) + ((self fetchByte: 1 ofObject: oop) << 8) + ((self fetchByte: 2 ofObject: oop) << 16) + ((self fetchByte: 3 ofObject: oop) << 24) ].
In summary, I forgot about this bit of difference and the possible rang of values between being 31 and 32 bits and this is how I can have LargePositive integer with 32 bits.
Thanks Dave.
Mariano
Dave
Thanks dave!
So....I don't understand...how can I have a LargePositiveInteger but that is less than 32 bits? Wouldn't that be a SmallInteger?
SmallInteger maxVal hex ==> '16r3FFFFFFF'.
The largest positive two-compliment integer that fits into 32 bits is 16rEFFFFFFF, so any Integer in the range 16r4000000 through 16rEFFFFFFF is a LargePositiveInteger that can fit into a signed 32-bit C int.
Thus the number of LargePositiveInteger values that fit into a 32-bit twos-compliment representation is (16r4000000 to: 16rEFFFFFFF) size ==> 3959422976
Note that a SmallInteger is represented internally as a 31-bit value, which accounts for the difference. It's a bit confusing when you are used to thinking of 32-bit int values.
Dave
On Fri, 8 Oct 2010, David T. Lewis wrote:
On Fri, Oct 08, 2010 at 07:12:13PM +0200, Mariano Martinez Peck wrote:
So....I don't understand...how can I have a LargePositiveInteger but that is less than 32 bits? Wouldn't that be a SmallInteger?
SmallInteger maxVal hex ==> '16r3FFFFFFF'.
The largest positive two-compliment integer that fits into 32 bits is 16rEFFFFFFF, so any Integer in the range 16r4000000 through 16rEFFFFFFF is a LargePositiveInteger that can fit into a signed 32-bit C int.
Thus the number of LargePositiveInteger values that fit into a 32-bit twos-compliment representation is (16r4000000 to: 16rEFFFFFFF) size ==> 3959422976
Note that a SmallInteger is represented internally as a 31-bit value, which accounts for the difference. It's a bit confusing when you are used to thinking of 32-bit int values.
Shouldn't those 16rEFFFFFFF's be 167FFFFFF?
Levente
Dave
On Sun, Oct 10, 2010 at 03:24:35AM +0200, Levente Uzonyi wrote:
On Fri, 8 Oct 2010, David T. Lewis wrote:
On Fri, Oct 08, 2010 at 07:12:13PM +0200, Mariano Martinez Peck wrote:
So....I don't understand...how can I have a LargePositiveInteger but that is less than 32 bits? Wouldn't that be a SmallInteger?
SmallInteger maxVal hex ==> '16r3FFFFFFF'.
The largest positive two-compliment integer that fits into 32 bits is 16rEFFFFFFF, so any Integer in the range 16r4000000 through 16rEFFFFFFF is a LargePositiveInteger that can fit into a signed 32-bit C int.
Thus the number of LargePositiveInteger values that fit into a 32-bit twos-compliment representation is (16r4000000 to: 16rEFFFFFFF) size ==> 3959422976
Note that a SmallInteger is represented internally as a 31-bit value, which accounts for the difference. It's a bit confusing when you are used to thinking of 32-bit int values.
Shouldn't those 16rEFFFFFFF's be 167FFFFFF?
Levente
Umm, yes of course. Sorry about that.
Dave
On Sun, 10 Oct 2010, David T. Lewis wrote:
On Sun, Oct 10, 2010 at 03:24:35AM +0200, Levente Uzonyi wrote:
On Fri, 8 Oct 2010, David T. Lewis wrote:
On Fri, Oct 08, 2010 at 07:12:13PM +0200, Mariano Martinez Peck wrote:
So....I don't understand...how can I have a LargePositiveInteger but that is less than 32 bits? Wouldn't that be a SmallInteger?
SmallInteger maxVal hex ==> '16r3FFFFFFF'.
The largest positive two-compliment integer that fits into 32 bits is 16rEFFFFFFF, so any Integer in the range 16r4000000 through 16rEFFFFFFF is a LargePositiveInteger that can fit into a signed 32-bit C int.
Thus the number of LargePositiveInteger values that fit into a 32-bit twos-compliment representation is (16r4000000 to: 16rEFFFFFFF) size ==> 3959422976
Note that a SmallInteger is represented internally as a 31-bit value, which accounts for the difference. It's a bit confusing when you are used to thinking of 32-bit int values.
Shouldn't those 16rEFFFFFFF's be 167FFFFFF?
Levente
Umm, yes of course. Sorry about that.
I missed an F too. It's 167FFFFFFF.
Levente
Dave
vm-dev@lists.squeakfoundation.org