<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<br>
<div class="moz-cite-prefix">On 05/02/2014 01:00 PM, Andrew Trick
wrote:<br>
</div>
<blockquote
cite="mid:853DE6C3-4142-4BD0-B88E-98EC9354D6B3@apple.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<br>
<div>
<div>On May 2, 2014, at 12:54 PM, Eric Christopher <<a
moz-do-not-send="true" href="mailto:echristo@gmail.com">echristo@gmail.com</a>>
wrote:</div>
<br class="Apple-interchange-newline">
<blockquote type="cite">
<blockquote type="cite" style="font-family: Helvetica;
font-size: 12px; font-style: normal; font-variant: normal;
font-weight: normal; letter-spacing: normal; line-height:
normal; orphans: auto; text-align: start; text-indent: 0px;
text-transform: none; white-space: normal; widows: auto;
word-spacing: 0px; -webkit-text-stroke-width: 0px;">I do not
like the idea of doing this for safe.div at all, but we
could<br>
certainly add more useful semantics to patchpoint without
affecting WebKit.<br>
<br>
</blockquote>
<br style="font-family: Helvetica; font-size: 12px;
font-style: normal; font-variant: normal; font-weight:
normal; letter-spacing: normal; line-height: normal;
orphans: auto; text-align: start; text-indent: 0px;
text-transform: none; white-space: normal; widows: auto;
word-spacing: 0px; -webkit-text-stroke-width: 0px;">
<span style="font-family: Helvetica; font-size: 12px;
font-style: normal; font-variant: normal; font-weight:
normal; letter-spacing: normal; line-height: normal;
orphans: auto; text-align: start; text-indent: 0px;
text-transform: none; white-space: normal; widows: auto;
word-spacing: 0px; -webkit-text-stroke-width: 0px; float:
none; display: inline !important;">I'm curious about this
though, what do you have in mind here about sdiv?</span></blockquote>
</div>
<br>
<div>
<div>division + patchpoints just work the way you would expect</div>
<div><br>
</div>
<div>(1) if (division would fail) { call @patchpoint(all of my
state) } else { result = a / b }</div>
<div><br>
</div>
<div>Good, this is exactly how patchpoints should be used in
general. If you're not going to use the div0/overflow result,
say because you deoptimize here, you would also have an
unreachable on the cold path.</div>
<div><br>
</div>
<div>(2) call @safe.div; if (division-failed) { call
@patchpoint(my state); unreachable }</div>
<div><br>
</div>
<div>Great! In this case, the operation we're checking already
gives us the condition we need to check and it's easier to
pattern match. Note that this use case alone is not a
compelling reason for @safe.div. The good thing about
@safe.div is that it can be used for such a wide variety of
use cases and in some situations will lead to much better
codegen (yes we could get performance data--I don't have it on
hand).</div>
</div>
<div><br>
</div>
<div>-Andy</div>
</blockquote>
I've come around to the idea that this can be used to cleanly
express either explicit deopt-with-branch or trapping loads. I
still don't think this is necessarily the best representation, but I
can work with it. <br>
<br>
By having a pattern match which combines both the structural pattern
Andy specified above, *and* profiling metadata on the branch, I can
get either implementation.<br>
<br>
I'm still not happy with hiding the explicit control flow, but I can
achieve the same effect as:<br>
if( div by zero ) throw<br>
(r, o, d) = safe.div(a,b);<br>
if( o ) {<br>
r = a;<br>
}<br>
<br>
i.e. emit a separate guard branch for the interesting condition and
not utilize the value from the safe div. <br>
<br>
Assuming the codegen patterns are right, this should give me options
for expressing all of the patterns I might like to explore. <br>
<br>
Given that, I am okay with the proposed safe.div intrinsics being
submitted. It's worth continuing the "patchable call" discussion,
but that is entirely separate from the original proposal. <br>
<br>
Philip<br>
<br>
<br>
<br>
</body>
</html>