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_DISPATCH_TABLE_H_ |
6 | #define RUNTIME_VM_DISPATCH_TABLE_H_ |
7 | |
8 | #include <memory> |
9 | |
10 | #include "vm/globals.h" |
11 | |
12 | namespace dart { |
13 | |
14 | class DispatchTable { |
15 | public: |
16 | explicit DispatchTable(intptr_t length) |
17 | : length_(length), array_(new uword[length]()) {} |
18 | |
19 | intptr_t length() const { return length_; } |
20 | |
21 | // The element of the dispatch table array to which the dispatch table |
22 | // register points. |
23 | static intptr_t OriginElement(); |
24 | static intptr_t LargestSmallOffset(); |
25 | // Dispatch table array pointer to put into the dispatch table register. |
26 | const uword* ArrayOrigin() const; |
27 | |
28 | private: |
29 | uword* array() { return array_.get(); } |
30 | |
31 | intptr_t length_; |
32 | std::unique_ptr<uword[]> array_; |
33 | |
34 | friend class Deserializer; // For non-const array(). |
35 | DISALLOW_COPY_AND_ASSIGN(DispatchTable); |
36 | }; |
37 | |
38 | } // namespace dart |
39 | |
40 | #endif // RUNTIME_VM_DISPATCH_TABLE_H_ |
41 | |