The Inbox: Kernel-nice.1039.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

The Inbox: Kernel-nice.1039.mcz

commits-2
Nicolas Cellier uploaded a new version of Kernel to project The Inbox:
http://source.squeak.org/inbox/Kernel-nice.1039.mcz

==================== Summary ====================

Name: Kernel-nice.1039
Author: nice
Time: 20 September 2016, 11:00:27.302558 pm
UUID: b0aeabf6-f73d-44c4-be8b-d2c66a73486f
Ancestors: Kernel-bf.1038

Introduce HalfWord (16 bits) and DoubleWord (64 bits) subclasses which are possible in Spur format, but yet not exploited.

=============== Diff against Kernel-bf.1038 ===============

Item was added:
+ ----- Method: Behavior>>isDoubleWords (in category 'testing') -----
+ isDoubleWords
+ "Answer true if the receiver is made of 64-bit instance variables."
+
+ ^self instSpec = 2r1001!

Item was added:
+ ----- Method: Behavior>>isHalfWords (in category 'testing') -----
+ isHalfWords
+ "Answer true if the receiver is made of 16-bit instance variables."
+
+ ^(self instSpec bitAnd: 2r11100) = 2r1100!

Item was changed:
  ----- Method: Behavior>>isWords (in category 'testing') -----
  isWords
  "Answer true if the receiver is made of 32-bit instance variables."
 
+ ^(self instSpec bitAnd: 2r11110) = 2r1010!
- ^self isBytes not!

Item was added:
+ ----- Method: Class>>variableDoubleWordSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category: (in category 'subclass creation') -----
+ variableDoubleWordSubclass: t instanceVariableNames: f
+ classVariableNames: d poolDictionaries: s category: cat
+ "This is the standard initialization message for creating a new class as a
+ subclass of an existing class (the receiver) in which the subclass is to
+ have indexable double-word-sized nonpointer variables."
+ ^(ClassBuilder new)
+ superclass: self
+ variableDoubleWordSubclass: t
+ instanceVariableNames: f
+ classVariableNames: d
+ poolDictionaries: s
+ category: cat
+ !

Item was added:
+ ----- Method: Class>>variableDoubleWordSubclass:uses:instanceVariableNames:classVariableNames:poolDictionaries:category: (in category 'subclass creation') -----
+ variableDoubleWordSubclass: t uses: aTraitCompositionOrArray instanceVariableNames: f
+ classVariableNames: d poolDictionaries: s category: cat
+ "This is the standard initialization message for creating a new class as a
+ subclass of an existing class (the receiver) in which the subclass is to
+ have indexable double-word-sized nonpointer variables."
+
+ | newClass copyOfOldClass |
+ copyOfOldClass := self copy.
+ newClass := self
+ variableDoubleWordSubclass: t
+ instanceVariableNames: f
+ classVariableNames: d
+ poolDictionaries: s
+ category: cat.
+
+ newClass setTraitComposition: aTraitCompositionOrArray asTraitComposition.
+ SystemChangeNotifier uniqueInstance
+ classDefinitionChangedFrom: copyOfOldClass to: newClass.
+ ^newClass
+ !

Item was added:
+ ----- Method: Class>>variableHalfWordSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category: (in category 'subclass creation') -----
+ variableHalfWordSubclass: t instanceVariableNames: f
+ classVariableNames: d poolDictionaries: s category: cat
+ "This is the standard initialization message for creating a new class as a
+ subclass of an existing class (the receiver) in which the subclass is to
+ have indexable half-word-sized nonpointer variables."
+ ^(ClassBuilder new)
+ superclass: self
+ variableHalfWordSubclass: t
+ instanceVariableNames: f
+ classVariableNames: d
+ poolDictionaries: s
+ category: cat
+ !

Item was added:
+ ----- Method: Class>>variableHalfWordSubclass:uses:instanceVariableNames:classVariableNames:poolDictionaries:category: (in category 'subclass creation') -----
+ variableHalfWordSubclass: t uses: aTraitCompositionOrArray instanceVariableNames: f
+ classVariableNames: d poolDictionaries: s category: cat
+ "This is the standard initialization message for creating a new class as a
+ subclass of an existing class (the receiver) in which the subclass is to
+ have indexable half-word-sized nonpointer variables."
+
+ | newClass copyOfOldClass |
+ copyOfOldClass := self copy.
+ newClass := self
+ variableHalfWordSubclass: t
+ instanceVariableNames: f
+ classVariableNames: d
+ poolDictionaries: s
+ category: cat.
+
+ newClass setTraitComposition: aTraitCompositionOrArray asTraitComposition.
+ SystemChangeNotifier uniqueInstance
+ classDefinitionChangedFrom: copyOfOldClass to: newClass.
+ ^newClass!

Item was changed:
  ----- Method: ClassBuilder>>superclass:variableByteSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category: (in category 'public') -----
  superclass: aClass
  variableByteSubclass: t instanceVariableNames: f
  classVariableNames: d poolDictionaries: s category: cat
  "This is the standard initialization message for creating a new class as a
  subclass of an existing class in which the subclass is to
  have indexable byte-sized nonpointer variables."
  | oldClassOrNil actualType env |
  (aClass instSize > 0)
  ifTrue: [^self error: 'cannot make a byte subclass of a class with named fields'].
  (aClass isVariable and: [aClass isWords])
  ifTrue: [^self error: 'cannot make a byte subclass of a class with word fields'].
+ (aClass isVariable and: [aClass isHalfWords])
+ ifTrue: [^self error: 'cannot make a byte subclass of a class with half word fields'].
+ (aClass isVariable and: [aClass isDoubleWords])
+ ifTrue: [^self error: 'cannot make a byte subclass of a class with double word fields'].
  (aClass isVariable and: [aClass isPointers])
  ifTrue: [^self error: 'cannot make a byte subclass of a class with pointer fields'].
  oldClassOrNil := aClass environment at: t ifAbsent:[nil].
  actualType := (oldClassOrNil notNil
    and: [oldClassOrNil typeOfClass == #compiledMethod])
  ifTrue: [#compiledMethod]
  ifFalse: [#bytes].
  env := CurrentEnvironment signal ifNil: [aClass environment].
  ^self
  name: t
  inEnvironment: env
  subclassOf: aClass
  type: actualType
  instanceVariableNames: f
  classVariableNames: d
  poolDictionaries: s
  category: cat!

Item was added:
+ ----- Method: ClassBuilder>>superclass:variableDoubleWordSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category: (in category 'public') -----
+ superclass: aClass
+ variableDoubleWordSubclass: t instanceVariableNames: f
+ classVariableNames: d poolDictionaries: s category: cat
+ "This is the standard initialization message for creating a new class as a
+ subclass of an existing class in which the subclass is to
+ have indexable double-word-sized nonpointer variables."
+ | env |
+ (aClass instSize > 0)
+ ifTrue: [^self error: 'cannot make a double word subclass of a class with named fields'].
+ (aClass isVariable and: [aClass isBytes])
+ ifTrue: [^self error: 'cannot make a double word subclass of a class with byte fields'].
+ (aClass isVariable and: [aClass isHalfWords])
+ ifTrue: [^self error: 'cannot make a double word subclass of a class with half word fields'].
+ (aClass isVariable and: [aClass isWords])
+ ifTrue: [^self error: 'cannot make a double word subclass of a class with word fields'].
+ (aClass isVariable and: [aClass isPointers])
+ ifTrue: [^self error: 'cannot make a double word subclass of a class with pointer fields'].
+ env := CurrentEnvironment signal ifNil: [aClass environment].
+ ^self
+ name: t
+ inEnvironment: env
+ subclassOf: aClass
+ type: #longs
+ instanceVariableNames: f
+ classVariableNames: d
+ poolDictionaries: s
+ category: cat!

Item was added:
+ ----- Method: ClassBuilder>>superclass:variableHalfWordSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category: (in category 'public') -----
+ superclass: aClass
+ variableHalfWordSubclass: t instanceVariableNames: f
+ classVariableNames: d poolDictionaries: s category: cat
+ "This is the standard initialization message for creating a new class as a
+ subclass of an existing class in which the subclass is to
+ have indexable half-word-sized nonpointer variables."
+ | env |
+ (aClass instSize > 0)
+ ifTrue: [^self error: 'cannot make a half word subclass of a class with named fields'].
+ (aClass isVariable and: [aClass isBytes])
+ ifTrue: [^self error: 'cannot make a half word subclass of a class with byte fields'].
+ (aClass isVariable and: [aClass isWords])
+ ifTrue: [^self error: 'cannot make a half word subclass of a class with word fields'].
+ (aClass isVariable and: [aClass isDoubleWords])
+ ifTrue: [^self error: 'cannot make a half word subclass of a class with double word fields'].
+ (aClass isVariable and: [aClass isPointers])
+ ifTrue: [^self error: 'cannot make a half word subclass of a class with pointer fields'].
+ env := CurrentEnvironment signal ifNil: [aClass environment].
+ ^self
+ name: t
+ inEnvironment: env
+ subclassOf: aClass
+ type: #shorts
+ instanceVariableNames: f
+ classVariableNames: d
+ poolDictionaries: s
+ category: cat!

Item was changed:
  ----- Method: ClassBuilder>>superclass:variableWordSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category: (in category 'public') -----
  superclass: aClass
  variableWordSubclass: t instanceVariableNames: f
  classVariableNames: d poolDictionaries: s category: cat
  "This is the standard initialization message for creating a new class as a
  subclass of an existing class in which the subclass is to
  have indexable word-sized nonpointer variables."
  | env |
  (aClass instSize > 0)
  ifTrue: [^self error: 'cannot make a word subclass of a class with named fields'].
  (aClass isVariable and: [aClass isBytes])
  ifTrue: [^self error: 'cannot make a word subclass of a class with byte fields'].
+ (aClass isVariable and: [aClass isHalfWords])
+ ifTrue: [^self error: 'cannot make a word subclass of a class with half word fields'].
+ (aClass isVariable and: [aClass isDoubleWords])
+ ifTrue: [^self error: 'cannot make a word subclass of a class with double word fields'].
  (aClass isVariable and: [aClass isPointers])
  ifTrue: [^self error: 'cannot make a word subclass of a class with pointer fields'].
  env := CurrentEnvironment signal ifNil: [aClass environment].
  ^self
  name: t
  inEnvironment: env
  subclassOf: aClass
  type: #words
  instanceVariableNames: f
  classVariableNames: d
  poolDictionaries: s
  category: cat!


Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Kernel-nice.1039.mcz

Chris Muller-3
Cool.  So we already have variableWord subclasses which provide a
32-bit integral per slot.  This adds variableHalfWord and
variableDoubleWord for 16 and 64-bit slots sizes, respectively.  May I
assume these new class formats will work fine in both 32 and 64-bit
spur images?

Applications should be careful about assuming (#isWords =false) =
(#isBytes = true) in this broader context.

On Tue, Sep 20, 2016 at 4:00 PM,  <[hidden email]> wrote:

> Nicolas Cellier uploaded a new version of Kernel to project The Inbox:
> http://source.squeak.org/inbox/Kernel-nice.1039.mcz
>
> ==================== Summary ====================
>
> Name: Kernel-nice.1039
> Author: nice
> Time: 20 September 2016, 11:00:27.302558 pm
> UUID: b0aeabf6-f73d-44c4-be8b-d2c66a73486f
> Ancestors: Kernel-bf.1038
>
> Introduce HalfWord (16 bits) and DoubleWord (64 bits) subclasses which are possible in Spur format, but yet not exploited.
>
> =============== Diff against Kernel-bf.1038 ===============
>
> Item was added:
> + ----- Method: Behavior>>isDoubleWords (in category 'testing') -----
> + isDoubleWords
> +       "Answer true if the receiver is made of 64-bit instance variables."
> +
> +       ^self instSpec = 2r1001!
>
> Item was added:
> + ----- Method: Behavior>>isHalfWords (in category 'testing') -----
> + isHalfWords
> +       "Answer true if the receiver is made of 16-bit instance variables."
> +
> +       ^(self instSpec bitAnd: 2r11100) = 2r1100!
>
> Item was changed:
>   ----- Method: Behavior>>isWords (in category 'testing') -----
>   isWords
>         "Answer true if the receiver is made of 32-bit instance variables."
>
> +       ^(self instSpec bitAnd: 2r11110) = 2r1010!
> -       ^self isBytes not!
>
> Item was added:
> + ----- Method: Class>>variableDoubleWordSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category: (in category 'subclass creation') -----
> + variableDoubleWordSubclass: t instanceVariableNames: f
> +       classVariableNames: d poolDictionaries: s category: cat
> +       "This is the standard initialization message for creating a new class as a
> +       subclass of an existing class (the receiver) in which the subclass is to
> +       have indexable double-word-sized nonpointer variables."
> +       ^(ClassBuilder new)
> +               superclass: self
> +               variableDoubleWordSubclass: t
> +               instanceVariableNames: f
> +               classVariableNames: d
> +               poolDictionaries: s
> +               category: cat
> + !
>
> Item was added:
> + ----- Method: Class>>variableDoubleWordSubclass:uses:instanceVariableNames:classVariableNames:poolDictionaries:category: (in category 'subclass creation') -----
> + variableDoubleWordSubclass: t uses: aTraitCompositionOrArray instanceVariableNames: f
> +       classVariableNames: d poolDictionaries: s category: cat
> +       "This is the standard initialization message for creating a new class as a
> +       subclass of an existing class (the receiver) in which the subclass is to
> +       have indexable double-word-sized nonpointer variables."
> +
> +       | newClass copyOfOldClass |
> +       copyOfOldClass := self copy.
> +       newClass := self
> +               variableDoubleWordSubclass: t
> +               instanceVariableNames: f
> +               classVariableNames: d
> +               poolDictionaries: s
> +               category: cat.
> +
> +       newClass setTraitComposition: aTraitCompositionOrArray asTraitComposition.
> +       SystemChangeNotifier uniqueInstance
> +               classDefinitionChangedFrom: copyOfOldClass to: newClass.
> +       ^newClass
> + !
>
> Item was added:
> + ----- Method: Class>>variableHalfWordSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category: (in category 'subclass creation') -----
> + variableHalfWordSubclass: t instanceVariableNames: f
> +       classVariableNames: d poolDictionaries: s category: cat
> +       "This is the standard initialization message for creating a new class as a
> +       subclass of an existing class (the receiver) in which the subclass is to
> +       have indexable half-word-sized nonpointer variables."
> +       ^(ClassBuilder new)
> +               superclass: self
> +               variableHalfWordSubclass: t
> +               instanceVariableNames: f
> +               classVariableNames: d
> +               poolDictionaries: s
> +               category: cat
> + !
>
> Item was added:
> + ----- Method: Class>>variableHalfWordSubclass:uses:instanceVariableNames:classVariableNames:poolDictionaries:category: (in category 'subclass creation') -----
> + variableHalfWordSubclass: t uses: aTraitCompositionOrArray instanceVariableNames: f
> +       classVariableNames: d poolDictionaries: s category: cat
> +       "This is the standard initialization message for creating a new class as a
> +       subclass of an existing class (the receiver) in which the subclass is to
> +       have indexable half-word-sized nonpointer variables."
> +
> +       | newClass copyOfOldClass |
> +       copyOfOldClass := self copy.
> +       newClass := self
> +               variableHalfWordSubclass: t
> +               instanceVariableNames: f
> +               classVariableNames: d
> +               poolDictionaries: s
> +               category: cat.
> +
> +       newClass setTraitComposition: aTraitCompositionOrArray asTraitComposition.
> +       SystemChangeNotifier uniqueInstance
> +               classDefinitionChangedFrom: copyOfOldClass to: newClass.
> +       ^newClass!
>
> Item was changed:
>   ----- Method: ClassBuilder>>superclass:variableByteSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category: (in category 'public') -----
>   superclass: aClass
>         variableByteSubclass: t instanceVariableNames: f
>         classVariableNames: d poolDictionaries: s category: cat
>         "This is the standard initialization message for creating a new class as a
>         subclass of an existing class in which the subclass is to
>         have indexable byte-sized nonpointer variables."
>         | oldClassOrNil actualType env |
>         (aClass instSize > 0)
>                 ifTrue: [^self error: 'cannot make a byte subclass of a class with named fields'].
>         (aClass isVariable and: [aClass isWords])
>                 ifTrue: [^self error: 'cannot make a byte subclass of a class with word fields'].
> +       (aClass isVariable and: [aClass isHalfWords])
> +               ifTrue: [^self error: 'cannot make a byte subclass of a class with half word fields'].
> +       (aClass isVariable and: [aClass isDoubleWords])
> +               ifTrue: [^self error: 'cannot make a byte subclass of a class with double word fields'].
>         (aClass isVariable and: [aClass isPointers])
>                 ifTrue: [^self error: 'cannot make a byte subclass of a class with pointer fields'].
>         oldClassOrNil := aClass environment at: t ifAbsent:[nil].
>         actualType := (oldClassOrNil notNil
>                                    and: [oldClassOrNil typeOfClass == #compiledMethod])
>                                         ifTrue: [#compiledMethod]
>                                         ifFalse: [#bytes].
>         env := CurrentEnvironment signal ifNil: [aClass environment].
>         ^self
>                 name: t
>                 inEnvironment: env
>                 subclassOf: aClass
>                 type: actualType
>                 instanceVariableNames: f
>                 classVariableNames: d
>                 poolDictionaries: s
>                 category: cat!
>
> Item was added:
> + ----- Method: ClassBuilder>>superclass:variableDoubleWordSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category: (in category 'public') -----
> + superclass: aClass
> +       variableDoubleWordSubclass: t instanceVariableNames: f
> +       classVariableNames: d poolDictionaries: s category: cat
> +       "This is the standard initialization message for creating a new class as a
> +       subclass of an existing class in which the subclass is to
> +       have indexable double-word-sized nonpointer variables."
> +       | env |
> +       (aClass instSize > 0)
> +               ifTrue: [^self error: 'cannot make a double word subclass of a class with named fields'].
> +       (aClass isVariable and: [aClass isBytes])
> +               ifTrue: [^self error: 'cannot make a double word subclass of a class with byte fields'].
> +       (aClass isVariable and: [aClass isHalfWords])
> +               ifTrue: [^self error: 'cannot make a double word subclass of a class with half word fields'].
> +       (aClass isVariable and: [aClass isWords])
> +               ifTrue: [^self error: 'cannot make a double word subclass of a class with word fields'].
> +       (aClass isVariable and: [aClass isPointers])
> +               ifTrue: [^self error: 'cannot make a double word subclass of a class with pointer fields'].
> +       env := CurrentEnvironment signal ifNil: [aClass environment].
> +       ^self
> +               name: t
> +               inEnvironment: env
> +               subclassOf: aClass
> +               type: #longs
> +               instanceVariableNames: f
> +               classVariableNames: d
> +               poolDictionaries: s
> +               category: cat!
>
> Item was added:
> + ----- Method: ClassBuilder>>superclass:variableHalfWordSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category: (in category 'public') -----
> + superclass: aClass
> +       variableHalfWordSubclass: t instanceVariableNames: f
> +       classVariableNames: d poolDictionaries: s category: cat
> +       "This is the standard initialization message for creating a new class as a
> +       subclass of an existing class in which the subclass is to
> +       have indexable half-word-sized nonpointer variables."
> +       | env |
> +       (aClass instSize > 0)
> +               ifTrue: [^self error: 'cannot make a half word subclass of a class with named fields'].
> +       (aClass isVariable and: [aClass isBytes])
> +               ifTrue: [^self error: 'cannot make a half word subclass of a class with byte fields'].
> +       (aClass isVariable and: [aClass isWords])
> +               ifTrue: [^self error: 'cannot make a half word subclass of a class with word fields'].
> +       (aClass isVariable and: [aClass isDoubleWords])
> +               ifTrue: [^self error: 'cannot make a half word subclass of a class with double word fields'].
> +       (aClass isVariable and: [aClass isPointers])
> +               ifTrue: [^self error: 'cannot make a half word subclass of a class with pointer fields'].
> +       env := CurrentEnvironment signal ifNil: [aClass environment].
> +       ^self
> +               name: t
> +               inEnvironment: env
> +               subclassOf: aClass
> +               type: #shorts
> +               instanceVariableNames: f
> +               classVariableNames: d
> +               poolDictionaries: s
> +               category: cat!
>
> Item was changed:
>   ----- Method: ClassBuilder>>superclass:variableWordSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category: (in category 'public') -----
>   superclass: aClass
>         variableWordSubclass: t instanceVariableNames: f
>         classVariableNames: d poolDictionaries: s category: cat
>         "This is the standard initialization message for creating a new class as a
>         subclass of an existing class in which the subclass is to
>         have indexable word-sized nonpointer variables."
>         | env |
>         (aClass instSize > 0)
>                 ifTrue: [^self error: 'cannot make a word subclass of a class with named fields'].
>         (aClass isVariable and: [aClass isBytes])
>                 ifTrue: [^self error: 'cannot make a word subclass of a class with byte fields'].
> +       (aClass isVariable and: [aClass isHalfWords])
> +               ifTrue: [^self error: 'cannot make a word subclass of a class with half word fields'].
> +       (aClass isVariable and: [aClass isDoubleWords])
> +               ifTrue: [^self error: 'cannot make a word subclass of a class with double word fields'].
>         (aClass isVariable and: [aClass isPointers])
>                 ifTrue: [^self error: 'cannot make a word subclass of a class with pointer fields'].
>         env := CurrentEnvironment signal ifNil: [aClass environment].
>         ^self
>                 name: t
>                 inEnvironment: env
>                 subclassOf: aClass
>                 type: #words
>                 instanceVariableNames: f
>                 classVariableNames: d
>                 poolDictionaries: s
>                 category: cat!
>
>

Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Kernel-nice.1039.mcz

Nicolas Cellier


2016-09-20 23:42 GMT+02:00 Chris Muller <[hidden email]>:
Cool.  So we already have variableWord subclasses which provide a
32-bit integral per slot.  This adds variableHalfWord and
variableDoubleWord for 16 and 64-bit slots sizes, respectively.  May I
assume these new class formats will work fine in both 32 and 64-bit
spur images?

yes, but there's currently problems with JIT at least for x64...
 
Applications should be careful about assuming (#isWords =false) =
(#isBytes = true) in this broader context.

yes
 
On Tue, Sep 20, 2016 at 4:00 PM,  <[hidden email]> wrote:
> Nicolas Cellier uploaded a new version of Kernel to project The Inbox:
> http://source.squeak.org/inbox/Kernel-nice.1039.mcz
>
> ==================== Summary ====================
>
> Name: Kernel-nice.1039
> Author: nice
> Time: 20 September 2016, 11:00:27.302558 pm
> UUID: b0aeabf6-f73d-44c4-be8b-d2c66a73486f
> Ancestors: Kernel-bf.1038
>
> Introduce HalfWord (16 bits) and DoubleWord (64 bits) subclasses which are possible in Spur format, but yet not exploited.
>
> =============== Diff against Kernel-bf.1038 ===============
>
> Item was added:
> + ----- Method: Behavior>>isDoubleWords (in category 'testing') -----
> + isDoubleWords
> +       "Answer true if the receiver is made of 64-bit instance variables."
> +
> +       ^self instSpec = 2r1001!
>
> Item was added:
> + ----- Method: Behavior>>isHalfWords (in category 'testing') -----
> + isHalfWords
> +       "Answer true if the receiver is made of 16-bit instance variables."
> +
> +       ^(self instSpec bitAnd: 2r11100) = 2r1100!
>
> Item was changed:
>   ----- Method: Behavior>>isWords (in category 'testing') -----
>   isWords
>         "Answer true if the receiver is made of 32-bit instance variables."
>
> +       ^(self instSpec bitAnd: 2r11110) = 2r1010!
> -       ^self isBytes not!
>
> Item was added:
> + ----- Method: Class>>variableDoubleWordSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category: (in category 'subclass creation') -----
> + variableDoubleWordSubclass: t instanceVariableNames: f
> +       classVariableNames: d poolDictionaries: s category: cat
> +       "This is the standard initialization message for creating a new class as a
> +       subclass of an existing class (the receiver) in which the subclass is to
> +       have indexable double-word-sized nonpointer variables."
> +       ^(ClassBuilder new)
> +               superclass: self
> +               variableDoubleWordSubclass: t
> +               instanceVariableNames: f
> +               classVariableNames: d
> +               poolDictionaries: s
> +               category: cat
> + !
>
> Item was added:
> + ----- Method: Class>>variableDoubleWordSubclass:uses:instanceVariableNames:classVariableNames:poolDictionaries:category: (in category 'subclass creation') -----
> + variableDoubleWordSubclass: t uses: aTraitCompositionOrArray instanceVariableNames: f
> +       classVariableNames: d poolDictionaries: s category: cat
> +       "This is the standard initialization message for creating a new class as a
> +       subclass of an existing class (the receiver) in which the subclass is to
> +       have indexable double-word-sized nonpointer variables."
> +
> +       | newClass copyOfOldClass |
> +       copyOfOldClass := self copy.
> +       newClass := self
> +               variableDoubleWordSubclass: t
> +               instanceVariableNames: f
> +               classVariableNames: d
> +               poolDictionaries: s
> +               category: cat.
> +
> +       newClass setTraitComposition: aTraitCompositionOrArray asTraitComposition.
> +       SystemChangeNotifier uniqueInstance
> +               classDefinitionChangedFrom: copyOfOldClass to: newClass.
> +       ^newClass
> + !
>
> Item was added:
> + ----- Method: Class>>variableHalfWordSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category: (in category 'subclass creation') -----
> + variableHalfWordSubclass: t instanceVariableNames: f
> +       classVariableNames: d poolDictionaries: s category: cat
> +       "This is the standard initialization message for creating a new class as a
> +       subclass of an existing class (the receiver) in which the subclass is to
> +       have indexable half-word-sized nonpointer variables."
> +       ^(ClassBuilder new)
> +               superclass: self
> +               variableHalfWordSubclass: t
> +               instanceVariableNames: f
> +               classVariableNames: d
> +               poolDictionaries: s
> +               category: cat
> + !
>
> Item was added:
> + ----- Method: Class>>variableHalfWordSubclass:uses:instanceVariableNames:classVariableNames:poolDictionaries:category: (in category 'subclass creation') -----
> + variableHalfWordSubclass: t uses: aTraitCompositionOrArray instanceVariableNames: f
> +       classVariableNames: d poolDictionaries: s category: cat
> +       "This is the standard initialization message for creating a new class as a
> +       subclass of an existing class (the receiver) in which the subclass is to
> +       have indexable half-word-sized nonpointer variables."
> +
> +       | newClass copyOfOldClass |
> +       copyOfOldClass := self copy.
> +       newClass := self
> +               variableHalfWordSubclass: t
> +               instanceVariableNames: f
> +               classVariableNames: d
> +               poolDictionaries: s
> +               category: cat.
> +
> +       newClass setTraitComposition: aTraitCompositionOrArray asTraitComposition.
> +       SystemChangeNotifier uniqueInstance
> +               classDefinitionChangedFrom: copyOfOldClass to: newClass.
> +       ^newClass!
>
> Item was changed:
>   ----- Method: ClassBuilder>>superclass:variableByteSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category: (in category 'public') -----
>   superclass: aClass
>         variableByteSubclass: t instanceVariableNames: f
>         classVariableNames: d poolDictionaries: s category: cat
>         "This is the standard initialization message for creating a new class as a
>         subclass of an existing class in which the subclass is to
>         have indexable byte-sized nonpointer variables."
>         | oldClassOrNil actualType env |
>         (aClass instSize > 0)
>                 ifTrue: [^self error: 'cannot make a byte subclass of a class with named fields'].
>         (aClass isVariable and: [aClass isWords])
>                 ifTrue: [^self error: 'cannot make a byte subclass of a class with word fields'].
> +       (aClass isVariable and: [aClass isHalfWords])
> +               ifTrue: [^self error: 'cannot make a byte subclass of a class with half word fields'].
> +       (aClass isVariable and: [aClass isDoubleWords])
> +               ifTrue: [^self error: 'cannot make a byte subclass of a class with double word fields'].
>         (aClass isVariable and: [aClass isPointers])
>                 ifTrue: [^self error: 'cannot make a byte subclass of a class with pointer fields'].
>         oldClassOrNil := aClass environment at: t ifAbsent:[nil].
>         actualType := (oldClassOrNil notNil
>                                    and: [oldClassOrNil typeOfClass == #compiledMethod])
>                                         ifTrue: [#compiledMethod]
>                                         ifFalse: [#bytes].
>         env := CurrentEnvironment signal ifNil: [aClass environment].
>         ^self
>                 name: t
>                 inEnvironment: env
>                 subclassOf: aClass
>                 type: actualType
>                 instanceVariableNames: f
>                 classVariableNames: d
>                 poolDictionaries: s
>                 category: cat!
>
> Item was added:
> + ----- Method: ClassBuilder>>superclass:variableDoubleWordSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category: (in category 'public') -----
> + superclass: aClass
> +       variableDoubleWordSubclass: t instanceVariableNames: f
> +       classVariableNames: d poolDictionaries: s category: cat
> +       "This is the standard initialization message for creating a new class as a
> +       subclass of an existing class in which the subclass is to
> +       have indexable double-word-sized nonpointer variables."
> +       | env |
> +       (aClass instSize > 0)
> +               ifTrue: [^self error: 'cannot make a double word subclass of a class with named fields'].
> +       (aClass isVariable and: [aClass isBytes])
> +               ifTrue: [^self error: 'cannot make a double word subclass of a class with byte fields'].
> +       (aClass isVariable and: [aClass isHalfWords])
> +               ifTrue: [^self error: 'cannot make a double word subclass of a class with half word fields'].
> +       (aClass isVariable and: [aClass isWords])
> +               ifTrue: [^self error: 'cannot make a double word subclass of a class with word fields'].
> +       (aClass isVariable and: [aClass isPointers])
> +               ifTrue: [^self error: 'cannot make a double word subclass of a class with pointer fields'].
> +       env := CurrentEnvironment signal ifNil: [aClass environment].
> +       ^self
> +               name: t
> +               inEnvironment: env
> +               subclassOf: aClass
> +               type: #longs
> +               instanceVariableNames: f
> +               classVariableNames: d
> +               poolDictionaries: s
> +               category: cat!
>
> Item was added:
> + ----- Method: ClassBuilder>>superclass:variableHalfWordSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category: (in category 'public') -----
> + superclass: aClass
> +       variableHalfWordSubclass: t instanceVariableNames: f
> +       classVariableNames: d poolDictionaries: s category: cat
> +       "This is the standard initialization message for creating a new class as a
> +       subclass of an existing class in which the subclass is to
> +       have indexable half-word-sized nonpointer variables."
> +       | env |
> +       (aClass instSize > 0)
> +               ifTrue: [^self error: 'cannot make a half word subclass of a class with named fields'].
> +       (aClass isVariable and: [aClass isBytes])
> +               ifTrue: [^self error: 'cannot make a half word subclass of a class with byte fields'].
> +       (aClass isVariable and: [aClass isWords])
> +               ifTrue: [^self error: 'cannot make a half word subclass of a class with word fields'].
> +       (aClass isVariable and: [aClass isDoubleWords])
> +               ifTrue: [^self error: 'cannot make a half word subclass of a class with double word fields'].
> +       (aClass isVariable and: [aClass isPointers])
> +               ifTrue: [^self error: 'cannot make a half word subclass of a class with pointer fields'].
> +       env := CurrentEnvironment signal ifNil: [aClass environment].
> +       ^self
> +               name: t
> +               inEnvironment: env
> +               subclassOf: aClass
> +               type: #shorts
> +               instanceVariableNames: f
> +               classVariableNames: d
> +               poolDictionaries: s
> +               category: cat!
>
> Item was changed:
>   ----- Method: ClassBuilder>>superclass:variableWordSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category: (in category 'public') -----
>   superclass: aClass
>         variableWordSubclass: t instanceVariableNames: f
>         classVariableNames: d poolDictionaries: s category: cat
>         "This is the standard initialization message for creating a new class as a
>         subclass of an existing class in which the subclass is to
>         have indexable word-sized nonpointer variables."
>         | env |
>         (aClass instSize > 0)
>                 ifTrue: [^self error: 'cannot make a word subclass of a class with named fields'].
>         (aClass isVariable and: [aClass isBytes])
>                 ifTrue: [^self error: 'cannot make a word subclass of a class with byte fields'].
> +       (aClass isVariable and: [aClass isHalfWords])
> +               ifTrue: [^self error: 'cannot make a word subclass of a class with half word fields'].
> +       (aClass isVariable and: [aClass isDoubleWords])
> +               ifTrue: [^self error: 'cannot make a word subclass of a class with double word fields'].
>         (aClass isVariable and: [aClass isPointers])
>                 ifTrue: [^self error: 'cannot make a word subclass of a class with pointer fields'].
>         env := CurrentEnvironment signal ifNil: [aClass environment].
>         ^self
>                 name: t
>                 inEnvironment: env
>                 subclassOf: aClass
>                 type: #words
>                 instanceVariableNames: f
>                 classVariableNames: d
>                 poolDictionaries: s
>                 category: cat!
>
>




Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Kernel-nice.1039.mcz

Bert Freudenberg
In reply to this post by commits-2
On Tue, Sep 20, 2016 at 11:00 PM, <[hidden email]> wrote:
Item was added:
+ ----- Method: Behavior>>isDoubleWords (in category 'testing') -----
+ isDoubleWords
+       "Answer true if the receiver is made of 64-bit instance variables."
+
+       ^self instSpec = 2r1001!

Item was added:
+ ----- Method: Behavior>>isHalfWords (in category 'testing') -----
+ isHalfWords
+       "Answer true if the receiver is made of 16-bit instance variables."
+
+       ^(self instSpec bitAnd: 2r11100) = 2r1100!

Item was changed:
  ----- Method: Behavior>>isWords (in category 'testing') -----
  isWords
        "Answer true if the receiver is made of 32-bit instance variables."

+       ^(self instSpec bitAnd: 2r11110) = 2r1010!
-       ^self isBytes not!


In an instSpec, the lower bits are always 0, so no need to bitAnd:. Equality test would be fine:

"Formats 11, 13-15, 17-23 & 25-31 are unused in classes but used in instances to define the number of elements missing up to the slot size."

The test in isBytes needs to cover both ByteArrays and CompiledMethods, that's why it does not use equality.

- Bert -