Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
deopt_id.h
Go to the documentation of this file.
1// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
5#ifndef RUNTIME_VM_COMPILER_API_DEOPT_ID_H_
6#define RUNTIME_VM_COMPILER_API_DEOPT_ID_H_
7
9
10namespace dart {
11
12// Deoptimization Id logic.
13//
14// Deoptimization ids are used to refer to deoptimization points, at which
15// control can enter unoptimized code from the optimized version of the code.
16//
17// Note: any instruction that does a call has two deoptimization points,
18// one before the call and one after the call - so that we could deoptimize
19// to either before or after the call depending on whether the same call
20// already occurred in the optimized code (and potentially produced
21// observable side-effects) or not.
22//
23// To simplify implementation we always allocate two deopt ids (one for before
24// point and one for the after point).
25class DeoptId : public AllStatic {
26 public:
27 static constexpr intptr_t kNone = -1;
28
29 static inline intptr_t Next(intptr_t deopt_id) { return deopt_id + kStep; }
30
31 static inline intptr_t ToDeoptAfter(intptr_t deopt_id) {
32 ASSERT(IsDeoptBefore(deopt_id));
33 return deopt_id + kAfterOffset;
34 }
35
36 static inline bool IsDeoptBefore(intptr_t deopt_id) {
37 return (deopt_id % kStep) == kBeforeOffset;
38 }
39
40 static inline bool IsDeoptAfter(intptr_t deopt_id) {
41 return (deopt_id % kStep) == kAfterOffset;
42 }
43
44 private:
45 static constexpr intptr_t kStep = 2;
46 static constexpr intptr_t kBeforeOffset = 0;
47 static constexpr intptr_t kAfterOffset = 1;
48};
49
50} // namespace dart
51
52#endif // RUNTIME_VM_COMPILER_API_DEOPT_ID_H_
static bool IsDeoptAfter(intptr_t deopt_id)
Definition deopt_id.h:40
static constexpr intptr_t kNone
Definition deopt_id.h:27
static intptr_t ToDeoptAfter(intptr_t deopt_id)
Definition deopt_id.h:31
static bool IsDeoptBefore(intptr_t deopt_id)
Definition deopt_id.h:36
static intptr_t Next(intptr_t deopt_id)
Definition deopt_id.h:29
#define ASSERT(E)