2459046c1d
The "Address" type is V8's general-purpose type for manipulating memory addresses. Per the C++ spec, pointer arithmetic and pointer comparisons are undefined behavior except within the same array; since we generally don't operate within a C++ array, our general-purpose type shouldn't be a pointer type. Bug: v8:3770 Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng;master.tryserver.blink:linux_trusty_blink_rel Change-Id: Ib96016c24a0f18bcdba916dabd83e3f24a1b5779 Reviewed-on: https://chromium-review.googlesource.com/988657 Commit-Queue: Jakob Kummerow <jkummerow@chromium.org> Reviewed-by: Leszek Swirski <leszeks@chromium.org> Cr-Commit-Position: refs/heads/master@{#52601}
63 lines
1.5 KiB
C++
63 lines
1.5 KiB
C++
// Copyright 2014 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#ifndef V8_CCTEST_COMPILER_CALL_TESTER_H_
|
|
#define V8_CCTEST_COMPILER_CALL_TESTER_H_
|
|
|
|
#include "src/handles.h"
|
|
#include "src/objects/code.h"
|
|
#include "src/simulator.h"
|
|
#include "test/cctest/compiler/c-signature.h"
|
|
|
|
namespace v8 {
|
|
namespace internal {
|
|
namespace compiler {
|
|
|
|
template <typename R>
|
|
class CallHelper {
|
|
public:
|
|
explicit CallHelper(Isolate* isolate, MachineSignature* csig)
|
|
: csig_(csig), isolate_(isolate) {
|
|
USE(isolate_);
|
|
}
|
|
virtual ~CallHelper() {}
|
|
|
|
template <typename... Params>
|
|
R Call(Params... args) {
|
|
CSignature::VerifyParams<Params...>(csig_);
|
|
Address entry = Generate();
|
|
auto fn = GeneratedCode<R, Params...>::FromAddress(isolate_, entry);
|
|
return fn.Call(args...);
|
|
}
|
|
|
|
protected:
|
|
MachineSignature* csig_;
|
|
|
|
virtual Address Generate() = 0;
|
|
|
|
private:
|
|
Isolate* isolate_;
|
|
};
|
|
|
|
// A call helper that calls the given code object assuming C calling convention.
|
|
template <typename T>
|
|
class CodeRunner : public CallHelper<T> {
|
|
public:
|
|
CodeRunner(Isolate* isolate, Handle<Code> code, MachineSignature* csig)
|
|
: CallHelper<T>(isolate, csig), code_(code) {}
|
|
virtual ~CodeRunner() {}
|
|
|
|
Address Generate() override { return code_->entry(); }
|
|
|
|
private:
|
|
Handle<Code> code_;
|
|
};
|
|
|
|
|
|
} // namespace compiler
|
|
} // namespace internal
|
|
} // namespace v8
|
|
|
|
#endif // V8_CCTEST_COMPILER_CALL_TESTER_H_
|