dart-sdk/runtime/vm/code_patcher_kbc.cc
Régis Crelier f721d52163 [VM runtime] Introduce a new VM class Bytecode.
Allow pc_marker slot to hold a Code object or a new Bytecode object.

Change-Id: If11c1df6dafc5b1cfcce6f0322c36d1d68e86df9
Reviewed-on: https://dart-review.googlesource.com/c/82526
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-11-14 02:48:03 +00:00

39 lines
1.5 KiB
C++

// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#include "vm/globals.h"
#if !defined(DART_PRECOMPILED_RUNTIME)
#include "vm/code_patcher.h"
#include "vm/instructions_kbc.h"
#include "vm/native_entry.h"
namespace dart {
void KBCPatcher::PatchNativeCallAt(uword return_address,
const Bytecode& bytecode,
NativeFunction function,
NativeFunctionWrapper trampoline) {
ASSERT(bytecode.ContainsInstructionAt(return_address));
NativeEntryData native_entry_data(TypedData::Handle(
KBCNativeCallPattern::GetNativeEntryDataAt(return_address, bytecode)));
native_entry_data.set_trampoline(trampoline);
native_entry_data.set_native_function(function);
}
NativeFunctionWrapper KBCPatcher::GetNativeCallAt(uword return_address,
const Bytecode& bytecode,
NativeFunction* function) {
ASSERT(bytecode.ContainsInstructionAt(return_address));
NativeEntryData native_entry_data(TypedData::Handle(
KBCNativeCallPattern::GetNativeEntryDataAt(return_address, bytecode)));
*function = native_entry_data.native_function();
return native_entry_data.trampoline();
}
} // namespace dart
#endif // !defined(DART_PRECOMPILED_RUNTIME)