1 | // Copyright (c) 2018, 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/globals.h" |
6 | #if !defined(DART_PRECOMPILED_RUNTIME) |
7 | |
8 | #include "vm/instructions.h" |
9 | #include "vm/instructions_kbc.h" |
10 | |
11 | #include "vm/constants_kbc.h" |
12 | #include "vm/native_entry.h" |
13 | |
14 | namespace dart { |
15 | |
16 | TypedDataPtr KBCNativeCallPattern::GetNativeEntryDataAt( |
17 | uword pc, |
18 | const Bytecode& bytecode) { |
19 | ASSERT(bytecode.ContainsInstructionAt(pc)); |
20 | |
21 | const KBCInstr* return_addr = reinterpret_cast<const KBCInstr*>(pc); |
22 | const KBCInstr* instr = |
23 | reinterpret_cast<const KBCInstr*>(bytecode.PayloadStart()); |
24 | ASSERT(instr < return_addr); |
25 | while (!KernelBytecode::IsNativeCallOpcode(instr)) { |
26 | instr = KernelBytecode::Next(instr); |
27 | if (instr >= return_addr) { |
28 | FATAL1( |
29 | "Unable to find NativeCall bytecode instruction" |
30 | " corresponding to PC %"Px, |
31 | pc); |
32 | } |
33 | } |
34 | |
35 | intptr_t native_entry_data_pool_index = KernelBytecode::DecodeD(instr); |
36 | const ObjectPool& obj_pool = ObjectPool::Handle(bytecode.object_pool()); |
37 | TypedData& native_entry_data = TypedData::Handle(); |
38 | native_entry_data ^= obj_pool.ObjectAt(native_entry_data_pool_index); |
39 | // Native calls to recognized functions should never be patched. |
40 | ASSERT(NativeEntryData(native_entry_data).kind() == |
41 | MethodRecognizer::kUnknown); |
42 | return native_entry_data.raw(); |
43 | } |
44 | |
45 | } // namespace dart |
46 | |
47 | #endif // !defined(DART_PRECOMPILED_RUNTIME) |
48 |