Erlang Development Environment

Erik.Johansson Erik.Johansson@REDACTED
Tue Mar 6 16:19:03 CET 2001


> I agree.  If constant data had it's own non-GCed memory pool, that would be
> great.  But that's a big change to the runtime, I expect.  Oh, but it would
> really open up possibilities, IMO.

Well, the change is not that big, it is a bit problematic with the current GC, but it is doable.
In fact, when you compile a function to native code with HiPE all constant data structures are stored in such a memory pool. (This feature might be added to BEAM at some point...)

/Erik
HiPE -- Comming soon to an OTP implementation near you.

Ex:
const() ->
  {a,somewhat,big,"constant"}.
loop(0) ->
  const();
loop(N) ->
  const(),
  loop(N-1).
test() ->
  loop(1000).

> timer:tc(jt,test,[]).
{1557,{a,somewhat,big,"constant"}}
> hipe:c(jt,[o2]).      
> timer:tc(jt,test,[]).
{152,{a,somewhat,big,"constant"}}



> hipe:compile({jt,const,0},[o2,pp_rtl]).  
{jt,const,0}() ->
;; Info: []
.DataSegment
.DL0: {a,somewhat,big,[99,111,110,115,116,97,110,116]}
.CodeSegment
L9:
    r39 <- %l6 add 208
    if (r39 lt %l7) then L1 (0.99) else L7
L7:
    ;; save_frame
    [%l6+0] <- %o7
    %l6 <- %l6 add 4
    jsr inc_stack_0 [c] () then L8
L8:
    ;; restore_frame
    %o7 <- [%l6+-4]
    ;; pop_frame
    %l6 <- %l6 sub 4
    goto L1
L1:
    %l5 <- %l5 sub 1 if lt then L3 (0.01) else L2
L2:
    v38 <- DL0
    v37 <- v38 add 2
    goto L5
L5:
    %o0 <= v37
    jmp %o7+8 (%o0)
L3:
    ;; save_frame
    [%l6+0] <- %o7
    %l6 <- %l6 add 4
    jsr suspend_0 [c] () then L6
L6:
    ;; restore_frame
    %o7 <- [%l6+-4]
    ;; pop_frame
    %l6 <- %l6 sub 4
    goto L2






More information about the erlang-questions mailing list