Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 6 Jan 2019 09:50:32 -0800
From:      Brian Neal <brian@aceshardware.com>
To:        freebsd-hackers@freebsd.org
Subject:   Re: Speculative: Rust for base system components
Message-ID:  <e94efcba-3fd3-7d23-cc4a-bcc0af5a8851@aceshardware.com>
In-Reply-To: <CAOtMX2jOeAZfpyH1S1N1euAQQZe00nA9JQNjY2qnRB%2BczS9O2g@mail.gmail.com>
References:  <ca76e5f7-6e59-bd67-144a-90ad66f0252e@metricspace.net> <7d7bc47d-04cf-2f9b-00a3-e3d9d92b3623@aceshardware.com> <72922F2C-9D27-47AA-BB1C-2DA8589CF008@rpi.edu> <92bd5362-d898-aa12-8f3d-9fbe23f38e0c@aceshardware.com> <CAOtMX2gPrpO2O70pnwpU80bXMXo6LB9PCkU3bYw2ToMMnhf%2Bww@mail.gmail.com> <26325c0b-4960-7739-72aa-c31c4e0638d3@aceshardware.com> <CAOtMX2jOeAZfpyH1S1N1euAQQZe00nA9JQNjY2qnRB%2BczS9O2g@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Of course.  But I'm counting like for like.  So labels are counted for 
all languages.  And I definitely don't rely on LTO when comparing the 
efficacy of compiler, especially since the linker can spend lots of time 
eliminating dead-code (usually single-threaded), which means longer 
build times.

On 1/6/2019 9:17 AM, Alan Somers wrote:
> Those 21 lines aren't 21 instructions; you're counting labels.  Also,
> the first three instructions aren't actually part of the function.
> They're dead code, and should be eliminate by LTO.  However, Rust
> doesn't do LTO when compiling libraries; only when linking
> executables.  The unwrap logic, etc is also not part of the function.
> So in this example, Rust produces only a few more instructions than C.
> Also, FYI the Rust expression "0..num" is exclusive on the right.
> It's equivalent to C's "for (int i = 0; i < num; i++)", though that
> doesn't change the instruction count.
> 
> -Alan



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?e94efcba-3fd3-7d23-cc4a-bcc0af5a8851>