mirror of
https://github.com/dart-lang/sdk
synced 2024-10-05 05:17:31 +00:00
700ba716cd
To avoid a O(n) traversal of isolates in order to find pending deopts, we'll move the pending deopt state to the Thread. It's really a property of a thread: when the thread's stack gets unwound - via return or exceptional flow - we remove pending deopts. This CL also encapsulates the pending deopt logic into a [PendingDeopts] class - thereby avoiding logic around manipulating this array being spread around. It simplifies the already very big [Isolate] class. TEST=Refactoring of existing code. Issue https://github.com/dart-lang/sdk/issues/36097 Closes https://github.com/dart-lang/sdk/issues/45168 Change-Id: I5a9b18c577f21a0f2a88332b1bc26641ec39d2af Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/188521 Commit-Queue: Martin Kustermann <kustermann@google.com> Reviewed-by: Alexander Aprelev <aam@google.com>
52 lines
1.3 KiB
C++
52 lines
1.3 KiB
C++
// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
#ifndef RUNTIME_VM_PENDING_DEOPTS_H_
|
|
#define RUNTIME_VM_PENDING_DEOPTS_H_
|
|
|
|
#if defined(SHOULD_NOT_INCLUDE_RUNTIME)
|
|
#error "Should not include runtime"
|
|
#endif
|
|
|
|
#include "vm/growable_array.h"
|
|
|
|
namespace dart {
|
|
|
|
class PendingLazyDeopt {
|
|
public:
|
|
PendingLazyDeopt(uword fp, uword pc) : fp_(fp), pc_(pc) {}
|
|
uword fp() { return fp_; }
|
|
uword pc() { return pc_; }
|
|
void set_pc(uword pc) { pc_ = pc; }
|
|
|
|
private:
|
|
uword fp_;
|
|
uword pc_;
|
|
};
|
|
|
|
class PendingDeopts {
|
|
public:
|
|
enum ClearReason {
|
|
kClearDueToThrow,
|
|
kClearDueToDeopt,
|
|
};
|
|
PendingDeopts();
|
|
~PendingDeopts();
|
|
|
|
bool HasPendingDeopts() { return pending_deopts_->length() > 0; }
|
|
|
|
void AddPendingDeopt(uword fp, uword pc);
|
|
uword FindPendingDeopt(uword fp);
|
|
void ClearPendingDeoptsBelow(uword fp, ClearReason reason);
|
|
void ClearPendingDeoptsAtOrBelow(uword fp, ClearReason reason);
|
|
uword RemapExceptionPCForDeopt(uword program_counter, uword frame_pointer);
|
|
|
|
private:
|
|
MallocGrowableArray<PendingLazyDeopt>* pending_deopts_;
|
|
};
|
|
|
|
} // namespace dart
|
|
|
|
#endif // RUNTIME_VM_PENDING_DEOPTS_H_
|