<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2016-04-22 0:50 GMT+02:00 Levente Uzonyi <span dir="ltr">&lt;<a href="mailto:leves@caesar.elte.hu" target="_blank">leves@caesar.elte.hu</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
On Thu, 21 Apr 2016, <a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a> wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Nicolas Cellier uploaded a new version of VMMaker to project VM Maker:<br>
<a href="http://source.squeak.org/VMMaker/VMMaker.oscog-nice.1830.mcz" rel="noreferrer" target="_blank">http://source.squeak.org/VMMaker/VMMaker.oscog-nice.1830.mcz</a><br>
<br>
</blockquote>
<br>
snip<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ ----- Method: VMPluginCodeGenerator&gt;&gt;preDeclareMacrosForFastClassChekingOn: (in category &#39;C code generator&#39;) -----<br>
+ preDeclareMacrosForFastClassChekingOn: aStream<br>
+       &quot;These macros can be used to check for various case of Integer type.<br>
+       Since they can be defined based on existing API, this is a good trade off:<br>
+       - avoid extending the interpreterProxy API like mad<br>
+       - provide fast type checking&quot;<br>
+<br>
+       &quot;Fast-up generated code by using a macro for this well known function unconditionnally&quot;<br>
+       aStream cr; nextPutAll: &#39;#define isIntegerObject(oop) (oop &amp; 1)&#39;; cr.<br>
+<br>
+       aStream cr; nextPutAll: &#39;#if SPURVM &amp;&amp; defined(SQUEAK_BUILTIN_PLUGIN)&#39;.<br>
+<br>
+       &quot;Compact class index are hardcoded because there is no guaranty that the pool values at generation time are that of SPUR..<br>
+        Make sure they are in sync with SpurMemoryManager class&gt;&gt;initializeCompactClassIndices&quot;<br>
+       aStream cr; nextPutAll: &#39;# define LargeNegativeIntegerClassIndex 32&#39;.<br>
+       aStream cr; nextPutAll: &#39;# define LargePositiveIntegerClassIndex 33&#39;.<br>
+       aStream cr; nextPutAll: &#39;extern sqInt classIndexOf(sqInt);&#39;.<br>
+       aStream cr; nextPutAll: &#39;# define isKindOfInteger(oop) (isImmediate(oop) ? isIntegerObject(oop) : (unsigned)(classIndexOf(oop) - LargeNegativeIntegerClassIndex) &lt;= 1)&#39;.<br>
+       aStream cr; nextPutAll: &#39;# define isLargeIntegerObject(oop) (!!isImmediate(oop) &amp;&amp; (unsigned)(classIndexOf(oop) - LargeNegativeIntegerClassIndex) &lt;= 1)&#39;.<br>
+       aStream cr; nextPutAll: &#39;# define isLargeNegativeIntegerObject(oop) (!!isImmediate(oop) &amp;&amp; classIndexOf(oop) == LargeNegativeIntegerClassIndex)&#39;.<br>
+       aStream cr; nextPutAll: &#39;# define isLargePositiveIntegerObject(oop) (!!isImmediate(oop) &amp;&amp; classIndexOf(oop) == LargePositiveIntegerClassIndex)&#39;.<br>
+<br>
+       aStream cr; nextPutAll: &#39;#else /* defined(SQUEAK_BUILTIN_PLUGIN) &amp;&amp; defined(SPURVM) */&#39;.<br>
</blockquote>
<br>
These macros look pretty good. I wonder if we can have more, e.g. #classIndexOf:. IIRC that&#39;s part of the object header in Spur. If so, then we could use a macro for that as well, couldn&#39;t we?<br></blockquote><div><br></div><div>Yes, I was thinking of it.<br>Ideally I would have wanted this macro to be automatically generated from current source.<br></div><div>That means picking the right set of vm classes (the plugins are not necessarily generated from spur)<br></div><div>Then transform the method and sent methods, inline, check if it can be generated as macro (no temp vars, no side effect,...), remove return &amp; parameter type declarations, appropriately place parentheses and protect intermediate end of lines \<br><br></div><div>For sure, for just a function it&#39;s not worth, better duplicate code...<br></div><div>But this scheme would be extensible.<br><br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Btw, the comment here and below don&#39;t match the actual #if.<br></blockquote><div><br></div><div>Ah good eyes, I modified only the first and forgot the two others<br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Also, there&#39;s a &quot;c&quot; missing from the name of the method: Cheking vs Checking.<br>
<br></blockquote><div>excellent eyes, I missed it.<br><br></div><div>I&#39;ll fix it when I&#39;ll have something else to commit.<br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Levente<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+       aStream cr; nextPutAll: &#39;# define isLargeNegativeIntegerObject(oop) (fetchClassOf(oop) == classLargeNegativeInteger())&#39;.<br>
+       aStream cr; nextPutAll: &#39;# define isLargePositiveIntegerObject(oop) (fetchClassOf(oop) == classLargePositiveInteger())&#39;.<br>
+       aStream cr; nextPutAll: &#39;# define isLargeIntegerObject(oop) (isLargeNegativeIntegerObject(oop) || isLargePositiveIntegerObject(oop))&#39;.<br>
+       aStream cr; nextPutAll: &#39;# define isKindOfInteger(oop) (isIntegerObject(oop) || isLargeNegativeIntegerObject(oop) || isLargePositiveIntegerObject(oop))&#39;.<br>
+<br>
+       aStream cr; nextPutAll: &#39;#endif /* defined(SQUEAK_BUILTIN_PLUGIN) &amp;&amp; defined(SPURVM) */&#39;; cr<br>
+       !<br>
<br>
Item was added:<br>
+ ----- Method: VMPluginCodeGenerator&gt;&gt;selectorsThatAreGeneratedAsMacros (in category &#39;public&#39;) -----<br>
+ selectorsThatAreGeneratedAsMacros<br>
+       &quot;Answer a list of selectors that are generated as a C macro rather than as an interpreterProxy function call.&quot;<br>
+<br>
+       ^#(isKindOfInteger: isIntegerObject: isLargeIntegerObject: isLargeNegativeIntegerObject: isLargePositiveIntegerObject:)!<br>
<br>
<br>
</blockquote>
</blockquote></div><br></div></div>