[M3commit] [modula3/cm3] ced183: Aligned_procedures always FALSE -- reduce target v...
Jay K
jay.krell at cornell.edu
Mon Sep 21 05:05:03 CEST 2015
ps: in the "read 4 byte proposal", there'd still be an entire integer there, we just wouldn't bother checking the entire thing. That way, we'd only require 4 alignment, which is how instructions/functions are always aligned on everything but arm32 and x86 and amd64. This seems fairly elegant, but maybe a new target would break it.i.e. it is clear that the ideal design has a fixed size instruction, of probably 4 bytes.
Almost every architecture looks like that -- mips, alpha, powerpc, sparc, arm64, I think happier.But there is the unfortunate x86 design with anything from 1 to 15 byte instruction, and the unfortunate arm32 design with 2 or 4 byte instructions, 2 byte instructions being indicated by having an odd address.
- Jay
From: jay.krell at cornell.edu
To: hosking at purdue.edu
Date: Mon, 21 Sep 2015 02:57:21 +0000
CC: m3commit at elegosoft.com
Subject: Re: [M3commit] [modula3/cm3] ced183: Aligned_procedures always FALSE -- reduce target v...
I didn't change the alignment of anything.
At a level we do not control, the alignment on NT/amd64 I believe is 4 when optimizing for space, 16 when optimizing for speed. Any alignment works, but this is what you will see in practice.I don't believe you will see 8-alignment, except typically half of the size-aligned functions that are 4-aligned.Probably all amd64 targets are like this but I'd have to check.
But we don't control this and I didn't change it.
The alignment on NT of heap allocation is two pointers.The alignment of closures in Modula-3 is presumably at least pointer.
What this does is affect the alignment check of a closure.On x86/amd64, we can safely read 4 or 8 bytes from any pointer, and compare for -1.No alignment check is needed.On other architectures, the reads need to be aligned.
What the code does, optionally, is check the alignment, and if it isn't integer-aligned,it is assumed to be code, not a closure, and the check for -1 is skipped.
What the change does is add the alignment check for all architectures.Previously it was only present for 64 bit architectures, except amd64.
Another proposal is to always clear the lower 2 bits and check for a 4 byte -1.The conditional branch would be gone.The clearing of the lower 2 bits is only to accommodate ARM32.On everything but ARM32, either alignment doesn't matter (x86/amd64) or all instructions/functionsare at least 4-aligned. Doing an 8-byte check is redundant, and risks an alignment fault.
- Jay
Subject: Re: [M3commit] [modula3/cm3] ced183: Aligned_procedures always FALSE -- reduce target v...
From: hosking at purdue.edu
Date: Mon, 21 Sep 2015 12:48:09 +1000
CC: m3commit at elegosoft.com
To: jay.krell at cornell.edu
It's my understanding that 8-byte procedure alignment performs better on x86-64.
Sent from my iPhone
On Sep 21, 2015, at 12:21 PM, Jay K <jay.krell at cornell.edu> wrote:
I don't think so. Calls through function pointers will incur like two extra instructions, an and and a conditional branch. All 32bit targets in fact will pay that cost, and only arm32 needs it.
I have another propose a week or so go, roughly, for all targets: mask off lower two bits only read 4 bytes
That would avoid the conditional branch.It should work for all targets also.The masking is only needed for ARM32.All other targets have either 4-byte aligned instructions, or don't care about alignment faults.
- Jay
> Subject: Re: [M3commit] [modula3/cm3] ced183: Aligned_procedures always FALSE -- reduce target v...
> From: hosking at purdue.edu
> Date: Mon, 21 Sep 2015 10:47:05 +1000
> CC: m3commit at elegosoft.com
> To: jay.krell at cornell.edu
>
> This will break some targets I believe. X86/x86-64 no?
>
> Sent from my iPhone
>
> > On Sep 21, 2015, at 2:43 AM, jaykrell <jay.krell at cornell.edu> wrote:
> >
> > Branch: refs/heads/master
> > Home: https://github.com/modula3/cm3
> > Commit: ced183d086a829001f44ea5f8f791df2e3952d4f
> > https://github.com/modula3/cm3/commit/ced183d086a829001f44ea5f8f791df2e3952d4f
> > Author: jaykrell <jay.krell at cornell.edu>
> > Date: 2015-09-20 (Sun, 20 Sep 2015)
> >
> > Changed paths:
> > M m3-sys/m3middle/src/Target.m3
> >
> > Log Message:
> > -----------
> > Aligned_procedures always FALSE -- reduce target variation
> >
> >
> > _______________________________________________
> > M3commit mailing list
> > M3commit at elegosoft.com
> > https://mail.elegosoft.com/cgi-bin/mailman/listinfo/m3commit
_______________________________________________
M3commit mailing list
M3commit at elegosoft.com
https://mail.elegosoft.com/cgi-bin/mailman/listinfo/m3commit
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3commit/attachments/20150921/b487e4fd/attachment-0002.html>
More information about the M3commit
mailing list