| 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/code_patcher.h" |
| 9 | |
| 10 | #include "vm/instructions_kbc.h" |
| 11 | #include "vm/native_entry.h" |
| 12 | |
| 13 | namespace dart { |
| 14 | |
| 15 | void KBCPatcher::PatchNativeCallAt(uword return_address, |
| 16 | const Bytecode& bytecode, |
| 17 | NativeFunction function, |
| 18 | NativeFunctionWrapper trampoline) { |
| 19 | ASSERT(bytecode.ContainsInstructionAt(return_address)); |
| 20 | NativeEntryData native_entry_data(TypedData::Handle( |
| 21 | KBCNativeCallPattern::GetNativeEntryDataAt(return_address, bytecode))); |
| 22 | native_entry_data.set_trampoline(trampoline); |
| 23 | native_entry_data.set_native_function(function); |
| 24 | } |
| 25 | |
| 26 | NativeFunctionWrapper KBCPatcher::GetNativeCallAt(uword return_address, |
| 27 | const Bytecode& bytecode, |
| 28 | NativeFunction* function) { |
| 29 | ASSERT(bytecode.ContainsInstructionAt(return_address)); |
| 30 | NativeEntryData native_entry_data(TypedData::Handle( |
| 31 | KBCNativeCallPattern::GetNativeEntryDataAt(return_address, bytecode))); |
| 32 | *function = native_entry_data.native_function(); |
| 33 | return native_entry_data.trampoline(); |
| 34 | } |
| 35 | |
| 36 | } // namespace dart |
| 37 | |
| 38 | #endif // !defined(DART_PRECOMPILED_RUNTIME) |
| 39 |