https://issues.dlang.org/show_bug.cgi?id=14571

--- Comment #16 from Walter Bright <bugzi...@digitalmars.com> ---
(In reply to Vladimir Panteleev from comment #15)
> DLLs are relocated at load time (and usually are linked with a base unlikely
> to conflict, so relocations are often not done). The hypothetical ptr[5]
> would be relocated as well.

It goes through a relocation thunk. So does TLS.

> Not on Win32

Win32 is dead. Even phones are 64 bit processors, aren't they?

> I would need to run some benchmarks to test this. But a quick test shows
> that 64-bit code has dedicated CPU instructions for relative addressing of
> globals, but indexing arrays on the heap still requires two instructions
> (mov rax, arr + mov dword ptr [arr+idx*4], value).

64 bit code indexes static data with the Program Counter.

Furthermore, if you're accessing large arrays, the cost of getting a pointer to
the start of it is utterly swamped by accessing the data itself. Like I said, I
bet if you do some benchmarking, you'd be hard pressed to find ANY improvement
of static large arrays over allocated ones.

--

Reply via email to