Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
dispatch_table.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_DISPATCH_TABLE_H_
6#define RUNTIME_VM_DISPATCH_TABLE_H_
7
8#include <memory>
9
10#include "vm/globals.h"
11
12namespace dart {
13
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#if defined(TARGET_ARCH_X64)
24 // Max negative byte offset / 8
25 static constexpr intptr_t kOriginElement = 16;
26#elif defined(TARGET_ARCH_ARM)
27 // Max negative load offset / 4
28 static constexpr intptr_t kOriginElement = 1023;
29#elif defined(TARGET_ARCH_ARM64)
30 // Max consecutive sub immediate value
31 static constexpr intptr_t kOriginElement = 4096;
32#elif defined(TARGET_ARCH_RISCV32)
33 // Max consecutive sub immediate value
34 static constexpr intptr_t kOriginElement = 2048 / 4;
35#elif defined(TARGET_ARCH_RISCV64)
36 // Max consecutive sub immediate value
37 static constexpr intptr_t kOriginElement = 2048 / 8;
38#else
39 static constexpr intptr_t kOriginElement = 0;
40#endif
41
42#if defined(TARGET_ARCH_X64)
43 // Origin + Max positive byte offset / 8
44 static constexpr intptr_t kLargestSmallOffset = 31;
45#elif defined(TARGET_ARCH_ARM)
46 // Origin + Max positive load offset / 4
47 static constexpr intptr_t kLargestSmallOffset = 2046;
48#elif defined(TARGET_ARCH_ARM64)
49 // Origin + Max consecutive add immediate value
50 static constexpr intptr_t kLargestSmallOffset = 8192;
51#elif defined(TARGET_ARCH_RISCV32)
52 // Origin + Max consecutive add immediate value
53 static constexpr intptr_t kLargestSmallOffset = 4096 / 4;
54#elif defined(TARGET_ARCH_RISCV64)
55 // Origin + Max consecutive add immediate value
56 static constexpr intptr_t kLargestSmallOffset = 4096 / 8;
57#else
58 // No AOT on IA32
59 static constexpr intptr_t kLargestSmallOffset = 0;
60#endif
61
62 // Dispatch table array pointer to put into the dispatch table register.
63 const uword* ArrayOrigin() const;
64
65 private:
66 uword* array() { return array_.get(); }
67
68 intptr_t length_;
69 std::unique_ptr<uword[]> array_;
70
71 friend class Deserializer; // For non-const array().
73};
74
75} // namespace dart
76
77#endif // RUNTIME_VM_DISPATCH_TABLE_H_
static constexpr intptr_t kOriginElement
const uword * ArrayOrigin() const
DispatchTable(intptr_t length)
static constexpr intptr_t kLargestSmallOffset
intptr_t length() const
uintptr_t uword
Definition globals.h:501
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition globals.h:581