<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<p>Hi all,</p>
<p><br>
</p>
<p>this a question regarding the Compiler's implementation. I spent some time on it but could not yet find a satisfying explanation. Maybe someone of you can help me?<br>
</p>
<p><br>
</p>
<p>Let's look into MessageNode >> #<span>emitCodeForCase:encoder:value:, which contains the following passage:</span></p>
<p><span></span></p>
<div><br>
</div>
<p></p>
<blockquote style="margin:0 0 0 40px; border:none; padding:0px">
<p><span></span></p>
<div>(isLast and: [allReturn]) ifTrue:</div>
<p></p>
<p><span></span></p>
<div><span style="white-space:pre"></span>    [self emitCodeForJump: elseSize encoder: encoder]</div>
<p></p>
</blockquote>
<p><span></span></p>
<div></div>
<p></p>
<p><span><br>
</span></p>
<p><span>Btw, the equivalent in #sizeCodeForCase:value: is:</span></p>
<p><span><br>
</span></p>
<blockquote style="margin:0 0 0 40px; border:none; padding:0px">
<p><span><span>(isLast and: [allReturn]) ifTrue: [thenSize := thenSize + (self sizeCode: encoder forJump: elseSize)].</span></span></p>
</blockquote>
<p><span><span><br>
</span></span></p>
<p><span><span>In the bytecode of a method, this will look like this:</span></span></p>
<p><span><span><br>
</span></span></p>
<blockquote style="margin:0 0 0 40px; border:none; padding:0px">
<p><span><span></span></span></p>
<div>89 <23> pushConstant: 2</div>
<p></p>
<p><span><span></span></span></p>
<div>90 <88> dup</div>
<p></p>
<p><span><span></span></span></p>
<div>91 <76> pushConstant: 1</div>
<p></p>
<p><span><span></span></span></p>
<div>92 <B6> send: =</div>
<p></p>
<p><span><span></span></span></p>
<div>93 <9A> jumpFalse: 97</div>
<p></p>
<p><span><span></span></span></p>
<div>94 <87> pop</div>
<p></p>
<p><span><span></span></span></p>
<div>95 <22> pushConstant: #one</div>
<p></p>
<p><span><span></span></span></p>
<div>96 <7C> returnTop</div>
<p></p>
<p><span><span></span></span></p>
<div>97 <77> pushConstant: 2</div>
<p></p>
<p><span><span></span></span></p>
<div>98 <B6> send: =</div>
<p></p>
<p><span><span></span></span></p>
<div>99 <9A> jumpFalse: 103</div>
<p></p>
<p><span><span></span></span></p>
<div>100 <21> pushConstant: #two</div>
<p></p>
<p><span><span></span></span></p>
<div>101 <7C> returnTop</div>
<p></p>
<p><span><span></span></span></p>
<div><b><span style="background-color:rgb(255,255,0)">102 <90> jumpTo: 104 "here!"</span></b></div>
<p></p>
<p><span><span></span></span></p>
<div>103 <20> pushConstant: 42</div>
<p></p>
<p><span><span></span></span></p>
<div>104 <87> pop</div>
<p></p>
</blockquote>
<p><span><span><br>
</span></span></p>
<p><span><span>I cannot see when this jump would be ever reached.</span></span></p>
<p><span style="font-size:12pt"><b>Case 1:</b> Any </span><span style="font-size:12pt">case is selected, and because allReturn is true, its inlined value block is guaranteed to #returnTop and thus not to reach the last jump (in the above example, this happens
 in </span><span style="font-size:12pt">pc101).</span><br>
</p>
<p><span><span><b>Case 2:</b> No case is selected, so the execution will jump straightly to the inlined otherwiseBlock (this is pc99 in the example).</span></span></p>
<p><span style="font-size: 12pt;">For what purpose do we need this jump (ex: pc102)? Should we maybe remove it?</span><br>
</p>
<p><span><span><br>
</span></span></p>
<p><span><span>Are there any special situations in which #returns is true but there is any code path that does *not* return? Some weird exception handling trick, for example?</span></span></p>
<p><span><span>Or was the dubious jump just designed as a fallback to catch any hypothetic failures in any other component of the compiler system?</span></span></p>
<p><span><span><br>
</span></span></p>
<p><span><span>I removed the generation of this jump for testing and could not investigate any anomalies so far. All compiler tests are passing - except of a number of Decompiler tests, which probably would need to be updated as well.</span></span></p>
<p><span style="font-size: 12pt;">Please find a minimum changeset in the attachment that demonstrates my question.</span><br>
</p>
<p><span style="font-size: 12pt;"><br>
</span></p>
<p><span><span>I am looking forward to your replies!</span></span></p>
<p><span><span><br>
</span></span></p>
<p><span><span>Best,</span></span></p>
<p><span><span>Christoph</span></span></p>
<div id="Signature">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<div name="divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
<div><font size="2" color="#808080"></font></div>
</div>
</div>
</div>
</div>
</body>
</html>