Class: YTLJit::Runtime::Arena

Inherits:
Object
  • Object
show all
Defined in:
lib/ytljit/arena.rb,
lib/ytljit/marshal.rb,
ext/ytljit.c

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeArena

Returns a new instance of Arena.



4
5
6
# File 'lib/ytljit/arena.rb', line 4

def initialize
  @using = 0
end

Instance Attribute Details

#usingObject

Returns the value of attribute using.



8
9
10
# File 'lib/ytljit/arena.rb', line 8

def using
  @using
end

Instance Method Details

#[](offset) ⇒ Object



152
153
154
155
156
157
158
159
160
161
162
# File 'ext/memory.c', line 152

VALUE
ytl_arena_ref(VALUE self, VALUE offset)
{
  struct ArenaHeader *arenah;
  int raw_offset;

  Data_Get_Struct(self, struct ArenaHeader, arenah);
  raw_offset = (arenah->body->size / sizeof(VALUE)) - FIX2INT(offset);

  return ULONG2NUM(arenah->body->body[raw_offset]);
}

#[]=(offset, src) ⇒ Object



164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'ext/memory.c', line 164

VALUE
ytl_arena_emit(VALUE self, VALUE offset, VALUE src)
{
  struct ArenaHeader *arenah;

  int raw_offset;
  VALUE *newlastptr;

  Data_Get_Struct(self, struct ArenaHeader, arenah);
  raw_offset = (arenah->body->size / sizeof(VALUE)) - NUM2ULONG(offset);

  arenah->body->body[raw_offset] = FIX2INT(src);
  newlastptr = arenah->body->body + raw_offset;
  if (newlastptr < arenah->lastptr) {
    arenah->lastptr = newlastptr;
  }

  return src;
}

#_dump_dataObject



136
137
138
# File 'lib/ytljit/marshal.rb', line 136

def _dump_data
  []
end

#_load_data(obj) ⇒ Object



140
141
# File 'lib/ytljit/marshal.rb', line 140

def _load_data(obj)
end

#body_addressObject



201
202
203
204
205
206
207
208
209
# File 'ext/memory.c', line 201

VALUE
ytl_arena_address(VALUE self)
{
  struct ArenaHeader *arenah;

  Data_Get_Struct(self, struct ArenaHeader, arenah);

  return ULONG2NUM((uintptr_t)arenah->body->body);
}

#raw_addressObject



211
212
213
214
215
216
217
218
219
# File 'ext/memory.c', line 211

VALUE
ytl_arena_raw_address(VALUE self)
{
  struct ArenaHeader *arenah;

  Data_Get_Struct(self, struct ArenaHeader, arenah);

  return ULONG2NUM((uintptr_t)arenah);
}

#sizeObject



184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# File 'ext/memory.c', line 184

VALUE
ytl_arena_size(VALUE self)
{
  struct ArenaHeader *arenah;
  struct ArenaBody *arenab;

  int totsize;

  Data_Get_Struct(self, struct ArenaHeader, arenah);
  totsize = 0;
  for (arenab = arenah->body; arenab; arenab = arenab->next) {
    totsize += arenab->size;
  }

  return INT2FIX(totsize);
}

#to_sObject



221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'ext/memory.c', line 221

VALUE
ytl_arena_to_s(VALUE self)
{
  struct ArenaHeader *arenah;

  Data_Get_Struct(self, struct ArenaHeader, arenah);

  return rb_sprintf("#<Arena %p size=%lu body=%p last=%p>", 
		    (void *)self, 
		    ytl_arena_size(self) / 2,
		    (void *)arenah->body->body,
		    (void *)arenah->lastptr);
}