[vm] Allow for long jumps during reusable handle scopes.

Such long jumps may occur due to Out Of Memory exceptions.

TEST=run test harness with low heap limit
Change-Id: Ifc8d062d4325ea3cdb4ea1f1ad1877f2dc83229e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213534
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
Ryan Macnak 2021-09-16 19:40:05 +00:00 committed by commit-bot@chromium.org
parent a2d1fa1a33
commit d30a43d464
2 changed files with 4 additions and 16 deletions

View file

@ -36,13 +36,6 @@ void LongJumpScope::Jump(int value) {
Thread* thread = Thread::Current();
DEBUG_ASSERT(thread->TopErrorHandlerIsSetJump());
#if defined(DEBUG)
#define CHECK_REUSABLE_HANDLE(name) \
ASSERT(!thread->reusable_##name##_handle_scope_active());
REUSABLE_HANDLE_LIST(CHECK_REUSABLE_HANDLE)
#undef CHECK_REUSABLE_HANDLE
#endif // defined(DEBUG)
// Destruct all the active StackResource objects.
StackResource::UnwindAbove(thread, top_);
longjmp(environment_, value);

View file

@ -32,16 +32,13 @@ namespace dart {
#if defined(DEBUG)
#define REUSABLE_SCOPE(name) \
class Reusable##name##HandleScope : public ValueObject { \
class Reusable##name##HandleScope : public StackResource { \
public: \
explicit Reusable##name##HandleScope(Thread* thread) : thread_(thread) { \
explicit Reusable##name##HandleScope(Thread* thread = Thread::Current()) \
: StackResource(thread), thread_(thread) { \
ASSERT(!thread->reusable_##name##_handle_scope_active()); \
thread->set_reusable_##name##_handle_scope_active(true); \
} \
Reusable##name##HandleScope() : thread_(Thread::Current()) { \
ASSERT(!thread_->reusable_##name##_handle_scope_active()); \
thread_->set_reusable_##name##_handle_scope_active(true); \
} \
~Reusable##name##HandleScope() { \
ASSERT(thread_->reusable_##name##_handle_scope_active()); \
thread_->set_reusable_##name##_handle_scope_active(false); \
@ -60,10 +57,8 @@ namespace dart {
#define REUSABLE_SCOPE(name) \
class Reusable##name##HandleScope : public ValueObject { \
public: \
explicit Reusable##name##HandleScope(Thread* thread) \
explicit Reusable##name##HandleScope(Thread* thread = Thread::Current()) \
: handle_(thread->name##_handle_) {} \
Reusable##name##HandleScope() \
: handle_(Thread::Current()->name##_handle_) {} \
~Reusable##name##HandleScope() { handle_->ptr_ = name::null(); } \
name& Handle() const { \
ASSERT(handle_ != NULL); \