dart-archive / sdk

The Dartino project was an experiment seeking to improve productivity when writing application code for embedded devices.
https://dartino.org
Other
332 stars 36 forks source link

Functionality for allocating 'x' bytes with repeated GC. #569

Open sigurdm opened 8 years ago

sigurdm commented 8 years ago

In src/vm/process.cc we have

LargeInteger* Process::NewIntegerWithGC(int64 value) {
  Object* result = NewInteger(value);
  if (result->IsRetryAfterGCFailure()) {
    program()->CollectGarbage();
    result = NewInteger(value);
    if (result->IsRetryAfterGCFailure()) {
      program()->CollectGarbage();
      result = NewInteger(value);
    }
  }
  return LargeInteger::cast(result);
}

It seems fragile to rely on the behaviour of trying GC'ing twice. Better it would be to ask the gc to free at least x bytes, and let it do as many collections as necessary.

@DmitryOlshansky-google