mirror of
https://github.com/dart-lang/sdk
synced 2024-11-05 18:22:09 +00:00
[vm, bytecode] Fix memory leak in calls from compiled code to interpreted code.
Change-Id: If82d371fc49892508dd33cd837e6b06b40325a48 Reviewed-on: https://dart-review.googlesource.com/c/87264 Reviewed-by: Régis Crelier <regis@google.com> Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
parent
80a6f4b5dd
commit
a33cb92c4f
1 changed files with 10 additions and 5 deletions
|
@ -2650,16 +2650,21 @@ RawObject* RuntimeEntry::InterpretCall(RawFunction* function,
|
|||
ASSERT(Function::HasBytecode(function));
|
||||
ASSERT(interpreter != NULL);
|
||||
#endif
|
||||
const Object& result = Object::Handle(
|
||||
thread->zone(), interpreter->Call(function, argdesc, argc, argv, thread));
|
||||
RawObject* result = interpreter->Call(function, argdesc, argc, argv, thread);
|
||||
DEBUG_ASSERT(thread->top_exit_frame_info() == exit_fp);
|
||||
if (result.IsError()) {
|
||||
if (RawObject::IsErrorClassId(result->GetClassIdMayBeSmi())) {
|
||||
// Must not allocate handles in the caller's zone.
|
||||
StackZone stack_zone(thread);
|
||||
// Protect the result in a handle before transitioning, which may trigger
|
||||
// GC.
|
||||
const Error& error =
|
||||
Error::Handle(stack_zone.GetZone(), static_cast<RawError*>(result));
|
||||
// Propagating an error may cause allocation. Check if we need to block for
|
||||
// a safepoint by switching to "in VM" execution state.
|
||||
TransitionGeneratedToVM transition(thread);
|
||||
Exceptions::PropagateError(Error::Cast(result));
|
||||
Exceptions::PropagateError(error);
|
||||
}
|
||||
return result.raw();
|
||||
return result;
|
||||
#endif // defined(DART_PRECOMPILED_RUNTIME)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue