Class: YTLJit::Runtime::GCCopy

Inherits:
GCBase show all
Defined in:
lib/runtime/gc.rb

Instance Method Summary collapse

Constructor Details

#initializeGCCopy

Returns a new instance of GCCopy.



13
14
15
16
17
18
# File 'lib/runtime/gc.rb', line 13

def initialize
  @arena = []
  @arena[0] = Arena.new
  @arena[1] = Arena.new
  @from_arena = 0
end

Instance Method Details

#gcObject



20
21
# File 'lib/runtime/gc.rb', line 20

def gc
end

#malloc(type) {|res| ... } ⇒ Object

Yields:

  • (res)


23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/runtime/gc.rb', line 23

def malloc(type)
  siz = type.size
  siz += YTLObject.size
  fromare = @arena[@from_arena]
  if fromare.size < fromare.using + siz then
    gc
  end
  
  res = TypedDataArena.new(YTLObject, fromare, fromare.using)
  fromare.using += siz

  # Initialize object header
  yield res
  
  res.cast(type)
end