[ruby-core:64893] Re: [ruby-trunk - Feature #10187] minor iseq memory reductions

From: Eric Wong <normalperson@...>
Date: 2014-09-09 09:55:25 UTC
List: ruby-core #64893
ko1@atdot.net wrote:
> 
> > +                if (newsize > INT_MAX) rb_memerror();
> 
> memerror?

I took the hint from compile_data_alloc:

    if (size >= INT_MAX) rb_memerror();
    if (storage->pos + size > storage->size) {
	unsigned int alloc_size = storage->size;

	while (alloc_size < size) {
	    if (alloc_size >= INT_MAX / 2) rb_memerror();
	    alloc_size *= 2;

Nobody hits the limit, so reusing rb_memerror keeps code size down.

In This Thread

Prev Next