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#include "vm/dispatch_table.h"
6
7#include "platform/assert.h"
8
9namespace dart {
10
11intptr_t DispatchTable::OriginElement() {
12#if defined(TARGET_ARCH_X64)
13 // Max negative byte offset / 8
14 return 16;
15#elif defined(TARGET_ARCH_ARM)
16 // Max negative load offset / 4
17 return 1023;
18#elif defined(TARGET_ARCH_ARM64)
19 // Max consecutive sub immediate value
20 return 4096;
21#else
22 // No AOT on IA32
23 UNREACHABLE();
24 return 0;
25#endif
26}
27
28intptr_t DispatchTable::LargestSmallOffset() {
29#if defined(TARGET_ARCH_X64)
30 // Origin + Max positive byte offset / 8
31 return 31;
32#elif defined(TARGET_ARCH_ARM)
33 // Origin + Max positive load offset / 4
34 return 2046;
35#elif defined(TARGET_ARCH_ARM64)
36 // Origin + Max consecutive add immediate value
37 return 8192;
38#else
39 // No AOT on IA32
40 UNREACHABLE();
41 return 0;
42#endif
43}
44
45const uword* DispatchTable::ArrayOrigin() const {
46 return &array_.get()[OriginElement()];
47}
48
49} // namespace dart
50