Files
sdk/runtime/vm/compiler/ffi/frame_rebase.h
T
Daco Harkes 88de61b933 [vm/ffi] Refactor Zone arguments to first position
We pass `Zone* zone` usually as first argument to functions.
This was not the case in existing FFI code.

Addressing:
https://dart-review.googlesource.com/c/sdk/+/140290/37/runtime/vm/compiler/ffi/native_type.h#181

Change-Id: I858af575848d94381780800eda7a9c506f67eb3e
Cq-Include-Trybots: luci.dart.try:vm-precomp-ffi-qemu-linux-release-arm-try,vm-ffi-android-debug-arm64-try,vm-ffi-android-debug-arm-try,vm-kernel-linux-debug-x64-try,vm-kernel-linux-debug-ia32-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170428
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-11-05 13:57:53 +00:00

61 lines
1.8 KiB
C++

// Copyright (c) 2020, 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.
#ifndef RUNTIME_VM_COMPILER_FFI_FRAME_REBASE_H_
#define RUNTIME_VM_COMPILER_FFI_FRAME_REBASE_H_
#if defined(DART_PRECOMPILED_RUNTIME)
#error "AOT runtime should not use compiler sources (including header files)"
#endif // defined(DART_PRECOMPILED_RUNTIME)
#include "vm/compiler/backend/locations.h"
#include "vm/compiler/ffi/native_location.h"
#include "vm/compiler/ffi/native_type.h"
#include "vm/compiler/runtime_api.h"
#include "vm/thread.h"
namespace dart {
namespace compiler {
namespace ffi {
// Describes a change of stack frame where the stack or base register or stack
// offset may change. This class allows easily rebasing stack locations across
// frame manipulations.
//
// If the stack offset register matches 'old_base', it is changed to 'new_base'
// and 'stack_delta_in_bytes' (# of bytes) is applied.
//
// This class can be used to rebase both Locations and NativeLocations.
class FrameRebase : public ValueObject {
public:
FrameRebase(Zone* zone,
const Register old_base,
const Register new_base,
intptr_t stack_delta_in_bytes)
: zone_(zone),
old_base_(old_base),
new_base_(new_base),
stack_delta_in_bytes_(stack_delta_in_bytes) {}
const NativeLocation& Rebase(const NativeLocation& loc) const;
Location Rebase(const Location loc) const;
private:
Zone* zone_;
const Register old_base_;
const Register new_base_;
const intptr_t stack_delta_in_bytes_;
};
} // namespace ffi
} // namespace compiler
} // namespace dart
#endif // RUNTIME_VM_COMPILER_FFI_FRAME_REBASE_H_