<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<br>
<div class="moz-cite-prefix">Am 2015-07-19 um 10:23 schrieb Jay K:<br>
</div>
<blockquote cite="mid:COL130-W395EC5C192FDA371DC5C78E6860@phx.gbl"
type="cite">
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style>
<div dir="ltr">
<div>alloca is very portable even if it is not in ANSI C or even
Posix.</div>
<div><br>
</div>
<div><br>
</div>
<div> gcc has builtin support for it.</div>
<div><span style="font-size: 12pt; "> Win32 provides it, where
it is called _alloca.</span></div>
<div><span style="font-size: 12pt; ">The NT/amd64 ABI
specifically accounts for it -- functions that call</span></div>
<div><span style="font-size: 12pt; ">alloca must have a fixed
"frame pointer" in a register other than rsp,</span></div>
<div><span style="font-size: 12pt; ">so that rsp can be changed
by calling alloca.</span></div>
<div><span style="font-size: 12pt; "><br>
</span></div>
<div><span style="font-size: 12pt; "> clang/LLVM presumably
provide it.</span></div>
<div><span style="font-size: 12pt; "> A lot of code depends on
it and it is generally easy to provide.</span></div>
<div><span style="font-size: 12pt; "><br>
</span></div>
<div><span style="font-size: 12pt; ">OpenVMS apparently calls it
__ALLOCA.</span></div>
<div><br>
</div>
</div>
</blockquote>
Basically if you plan to build jumpbuf support into m3cg you could<br>
easily use a few assembly statements as well in order to achieve <br>
what alloca does (independently from the operating system):<br>
<br>
mov %[e/r]sp, PTR VAR<br>
sub %[e/r]sp, JUMPBUF_SIZE <br>
<br>
I am sure that similar workarounds would exist for any arch other<br>
than x86 and AMD64.<br>
<br>
<br>
<blockquote cite="mid:COL130-W395EC5C192FDA371DC5C78E6860@phx.gbl"
type="cite">
<div dir="ltr">
<div><br>
</div>
<div>For more complete portability to the C backend we could</div>
<div>add an m3cg operation to allocate an array of jmpbufs</div>
<div>with a constant count.</div>
</div>
</blockquote>
Why allocate an array or external buffer of jump bufs?<br>
We used to have a linked list interleaved on the stack.<br>
This is fully sufficient and faster than an independent <br>
memory area.<br>
<br>
<blockquote cite="mid:COL130-W395EC5C192FDA371DC5C78E6860@phx.gbl"
type="cite">
<div dir="ltr">
<div><br>
</div>
<div><br>
</div>
<div>It is certainly more portable than C99, and C99 VLAs are
kind of more general than I need.</div>
<div>That is, I might pass a "variable" to alloca, but it is
kind of a constant.</div>
</div>
</blockquote>
<br>
If we have arrived at using something similar as alloca in m3cg why
shouldn`t we provide<br>
this functionality to the user? i.e. let programmers call such a
function from high level M3 <br>
code in order to alloc variable length bufffers, arrays, etc.<br>
<br>
VAR localvar := NEWA(MyType);<br>
<br>
This is a functionality which I believe that is really missing in
M3!!<br>
When we implemented the algorithm of Strassen (saving some
multiplications for matrix<br>
mults.) we had to notice that everything goes much slower just
because of the need for<br>
garbage collection ...<br>
<br>
<br>
- Elmar<br>
<br>
</body>
</html>