[Issue 4298] New: Constant array translated to unnecessary array literal creation

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jun 8 17:57:54 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4298

           Summary: Constant array translated to unnecessary array literal
                    creation
           Product: D
           Version: 2.041
          Platform: x86
        OS/Version: All
            Status: NEW
          Keywords: performance
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: rsinfu at gmail.com


--- Comment #0 from Shin Fujishiro <rsinfu at gmail.com> 2010-06-08 17:57:52 PDT ---
Using constant (const or immutable) dynamic array causes unnecessary
array literal creation if the constant array has an initializer.

This behavior degrades performance, and also causes the bug 4297.

Test code and the disassembled output:
--------------------
immutable int[] TABLE = [ 1, 2, 3 ];
void foo()
{
    const(int)[] tab = TABLE;
}
--------------------
_D4test3fooFZv:
        push    EBP
        mov    EBP,ESP
        push    EBX
        push    3
        push    2
        push    1
        push    3
        mov    EAX,offset FLAT:_D12TypeInfo_Axi6__initZ at SYM32
        push    EAX
        call      _d_arrayliteralT at PC32
        mov    ECX,EAX
        mov    EBX,3
        add    ESP,014h
        pop    EBX
        pop    EBP
        ret
--------------------

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list