[wasm] Replace the BufferedRawMachineAssemblerTester in the WasmRunner.
The BufferedRawMachineAssemblerTester caused problems for the Int64Lowering. Instead we construct a TF graph now which is compiled by Pipeline::GenerateCodeForTesting. R=titzer@chromium.org Review URL: https://codereview.chromium.org/1702023002 Cr-Commit-Position: refs/heads/master@{#34107}
This commit is contained in:
parent
7a9ebb5846
commit
f8e068e926
src/profiler
test/cctest
@ -24,7 +24,7 @@ namespace internal {
|
||||
// next_sample = (- ln u) / λ
|
||||
intptr_t SamplingAllocationObserver::GetNextSampleInterval(uint64_t rate) {
|
||||
if (FLAG_sampling_heap_profiler_suppress_randomness) {
|
||||
return rate;
|
||||
return static_cast<intptr_t>(rate);
|
||||
}
|
||||
double u = random_->NextDouble();
|
||||
double next = (-std::log(u)) * rate;
|
||||
@ -38,9 +38,11 @@ SamplingHeapProfiler::SamplingHeapProfiler(Heap* heap, StringsStorage* names,
|
||||
: isolate_(heap->isolate()),
|
||||
heap_(heap),
|
||||
new_space_observer_(new SamplingAllocationObserver(
|
||||
heap_, rate, rate, this, heap->isolate()->random_number_generator())),
|
||||
heap_, static_cast<intptr_t>(rate), rate, this,
|
||||
heap->isolate()->random_number_generator())),
|
||||
other_spaces_observer_(new SamplingAllocationObserver(
|
||||
heap_, rate, rate, this, heap->isolate()->random_number_generator())),
|
||||
heap_, static_cast<intptr_t>(rate), rate, this,
|
||||
heap->isolate()->random_number_generator())),
|
||||
names_(names),
|
||||
samples_(),
|
||||
stack_depth_(stack_depth) {
|
||||
|
@ -53,16 +53,16 @@ class CSignature : public MachineSignature {
|
||||
public:
|
||||
template <typename P1 = void, typename P2 = void, typename P3 = void,
|
||||
typename P4 = void, typename P5 = void>
|
||||
void VerifyParams() {
|
||||
static void VerifyParams(MachineSignature* sig) {
|
||||
// Verifies the C signature against the machine types. Maximum {5} params.
|
||||
CHECK_LT(parameter_count(), 6u);
|
||||
CHECK_LT(sig->parameter_count(), 6u);
|
||||
const int kMax = 5;
|
||||
MachineType params[] = {MachineTypeForC<P1>(), MachineTypeForC<P2>(),
|
||||
MachineTypeForC<P3>(), MachineTypeForC<P4>(),
|
||||
MachineTypeForC<P5>()};
|
||||
for (int p = kMax - 1; p >= 0; p--) {
|
||||
if (p < static_cast<int>(parameter_count())) {
|
||||
CHECK_EQ(GetParam(p), params[p]);
|
||||
if (p < static_cast<int>(sig->parameter_count())) {
|
||||
CHECK_EQ(sig->GetParam(p), params[p]);
|
||||
} else {
|
||||
CHECK_EQ(MachineType::None(), params[p]);
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ struct ParameterTraits<uint32_t> {
|
||||
template <typename R>
|
||||
class CallHelper {
|
||||
public:
|
||||
explicit CallHelper(Isolate* isolate, CSignature* csig)
|
||||
explicit CallHelper(Isolate* isolate, MachineSignature* csig)
|
||||
: csig_(csig), isolate_(isolate) {
|
||||
USE(isolate_);
|
||||
}
|
||||
@ -127,47 +127,47 @@ class CallHelper {
|
||||
|
||||
R Call() {
|
||||
typedef R V8_CDECL FType();
|
||||
csig_->VerifyParams();
|
||||
CSignature::VerifyParams(csig_);
|
||||
return DoCall(FUNCTION_CAST<FType*>(Generate()));
|
||||
}
|
||||
|
||||
template <typename P1>
|
||||
R Call(P1 p1) {
|
||||
typedef R V8_CDECL FType(P1);
|
||||
csig_->VerifyParams<P1>();
|
||||
CSignature::VerifyParams<P1>(csig_);
|
||||
return DoCall(FUNCTION_CAST<FType*>(Generate()), p1);
|
||||
}
|
||||
|
||||
template <typename P1, typename P2>
|
||||
R Call(P1 p1, P2 p2) {
|
||||
typedef R V8_CDECL FType(P1, P2);
|
||||
csig_->VerifyParams<P1, P2>();
|
||||
CSignature::VerifyParams<P1, P2>(csig_);
|
||||
return DoCall(FUNCTION_CAST<FType*>(Generate()), p1, p2);
|
||||
}
|
||||
|
||||
template <typename P1, typename P2, typename P3>
|
||||
R Call(P1 p1, P2 p2, P3 p3) {
|
||||
typedef R V8_CDECL FType(P1, P2, P3);
|
||||
csig_->VerifyParams<P1, P2, P3>();
|
||||
CSignature::VerifyParams<P1, P2, P3>(csig_);
|
||||
return DoCall(FUNCTION_CAST<FType*>(Generate()), p1, p2, p3);
|
||||
}
|
||||
|
||||
template <typename P1, typename P2, typename P3, typename P4>
|
||||
R Call(P1 p1, P2 p2, P3 p3, P4 p4) {
|
||||
typedef R V8_CDECL FType(P1, P2, P3, P4);
|
||||
csig_->VerifyParams<P1, P2, P3, P4>();
|
||||
CSignature::VerifyParams<P1, P2, P3, P4>(csig_);
|
||||
return DoCall(FUNCTION_CAST<FType*>(Generate()), p1, p2, p3, p4);
|
||||
}
|
||||
|
||||
template <typename P1, typename P2, typename P3, typename P4, typename P5>
|
||||
R Call(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) {
|
||||
typedef R V8_CDECL FType(P1, P2, P3, P4, P5);
|
||||
csig_->VerifyParams<P1, P2, P3, P4, P5>();
|
||||
CSignature::VerifyParams<P1, P2, P3, P4, P5>(csig_);
|
||||
return DoCall(FUNCTION_CAST<FType*>(Generate()), p1, p2, p3, p4, p5);
|
||||
}
|
||||
|
||||
protected:
|
||||
CSignature* csig_;
|
||||
MachineSignature* csig_;
|
||||
|
||||
virtual byte* Generate() = 0;
|
||||
|
||||
@ -342,7 +342,7 @@ class CallHelper {
|
||||
template <typename T>
|
||||
class CodeRunner : public CallHelper<T> {
|
||||
public:
|
||||
CodeRunner(Isolate* isolate, Handle<Code> code, CSignature* csig)
|
||||
CodeRunner(Isolate* isolate, Handle<Code> code, MachineSignature* csig)
|
||||
: CallHelper<T>(isolate, csig), code_(code) {}
|
||||
virtual ~CodeRunner() {}
|
||||
|
||||
|
@ -113,7 +113,7 @@ class BufferedRawMachineAssemblerTester
|
||||
|
||||
ReturnType Call() {
|
||||
ReturnType return_value;
|
||||
test_graph_signature_->VerifyParams();
|
||||
CSignature::VerifyParams(test_graph_signature_);
|
||||
CallHelper<int32_t>::Call(reinterpret_cast<void*>(&return_value));
|
||||
return return_value;
|
||||
}
|
||||
@ -121,7 +121,7 @@ class BufferedRawMachineAssemblerTester
|
||||
template <typename P0>
|
||||
ReturnType Call(P0 p0) {
|
||||
ReturnType return_value;
|
||||
test_graph_signature_->VerifyParams<P0>();
|
||||
CSignature::VerifyParams<P0>(test_graph_signature_);
|
||||
CallHelper<int32_t>::Call(reinterpret_cast<void*>(&p0),
|
||||
reinterpret_cast<void*>(&return_value));
|
||||
return return_value;
|
||||
@ -130,7 +130,7 @@ class BufferedRawMachineAssemblerTester
|
||||
template <typename P0, typename P1>
|
||||
ReturnType Call(P0 p0, P1 p1) {
|
||||
ReturnType return_value;
|
||||
test_graph_signature_->VerifyParams<P0, P1>();
|
||||
CSignature::VerifyParams<P0, P1>(test_graph_signature_);
|
||||
CallHelper<int32_t>::Call(reinterpret_cast<void*>(&p0),
|
||||
reinterpret_cast<void*>(&p1),
|
||||
reinterpret_cast<void*>(&return_value));
|
||||
@ -140,7 +140,7 @@ class BufferedRawMachineAssemblerTester
|
||||
template <typename P0, typename P1, typename P2>
|
||||
ReturnType Call(P0 p0, P1 p1, P2 p2) {
|
||||
ReturnType return_value;
|
||||
test_graph_signature_->VerifyParams<P0, P1, P2>();
|
||||
CSignature::VerifyParams<P0, P1, P2>(test_graph_signature_);
|
||||
CallHelper<int32_t>::Call(
|
||||
reinterpret_cast<void*>(&p0), reinterpret_cast<void*>(&p1),
|
||||
reinterpret_cast<void*>(&p2), reinterpret_cast<void*>(&return_value));
|
||||
@ -150,7 +150,7 @@ class BufferedRawMachineAssemblerTester
|
||||
template <typename P0, typename P1, typename P2, typename P3>
|
||||
ReturnType Call(P0 p0, P1 p1, P2 p2, P3 p3) {
|
||||
ReturnType return_value;
|
||||
test_graph_signature_->VerifyParams<P0, P1, P2, P3>();
|
||||
CSignature::VerifyParams<P0, P1, P2, P3>(test_graph_signature_);
|
||||
CallHelper<int32_t>::Call(
|
||||
reinterpret_cast<void*>(&p0), reinterpret_cast<void*>(&p1),
|
||||
reinterpret_cast<void*>(&p2), reinterpret_cast<void*>(&p3),
|
||||
@ -262,26 +262,26 @@ class BufferedRawMachineAssemblerTester<void>
|
||||
|
||||
|
||||
void Call() {
|
||||
test_graph_signature_->VerifyParams();
|
||||
CSignature::VerifyParams(test_graph_signature_);
|
||||
CallHelper<void>::Call();
|
||||
}
|
||||
|
||||
template <typename P0>
|
||||
void Call(P0 p0) {
|
||||
test_graph_signature_->VerifyParams<P0>();
|
||||
CSignature::VerifyParams<P0>(test_graph_signature_);
|
||||
CallHelper<void>::Call(reinterpret_cast<void*>(&p0));
|
||||
}
|
||||
|
||||
template <typename P0, typename P1>
|
||||
void Call(P0 p0, P1 p1) {
|
||||
test_graph_signature_->VerifyParams<P0, P1>();
|
||||
CSignature::VerifyParams<P0, P1>(test_graph_signature_);
|
||||
CallHelper<void>::Call(reinterpret_cast<void*>(&p0),
|
||||
reinterpret_cast<void*>(&p1));
|
||||
}
|
||||
|
||||
template <typename P0, typename P1, typename P2>
|
||||
void Call(P0 p0, P1 p1, P2 p2) {
|
||||
test_graph_signature_->VerifyParams<P0, P1, P2>();
|
||||
CSignature::VerifyParams<P0, P1, P2>(test_graph_signature_);
|
||||
CallHelper<void>::Call(reinterpret_cast<void*>(&p0),
|
||||
reinterpret_cast<void*>(&p1),
|
||||
reinterpret_cast<void*>(&p2));
|
||||
@ -289,7 +289,7 @@ class BufferedRawMachineAssemblerTester<void>
|
||||
|
||||
template <typename P0, typename P1, typename P2, typename P3>
|
||||
void Call(P0 p0, P1 p1, P2 p2, P3 p3) {
|
||||
test_graph_signature_->VerifyParams<P0, P1, P2, P3>();
|
||||
CSignature::VerifyParams<P0, P1, P2, P3>(test_graph_signature_);
|
||||
CallHelper<void>::Call(
|
||||
reinterpret_cast<void*>(&p0), reinterpret_cast<void*>(&p1),
|
||||
reinterpret_cast<void*>(&p2), reinterpret_cast<void*>(&p3));
|
||||
@ -540,24 +540,6 @@ class Int32BinopInputShapeTester {
|
||||
void RunLeft(RawMachineAssemblerTester<int32_t>* m);
|
||||
void RunRight(RawMachineAssemblerTester<int32_t>* m);
|
||||
};
|
||||
|
||||
// TODO(bmeurer): Drop this crap once we switch to GTest/Gmock.
|
||||
static inline void CheckFloatEq(volatile float x, volatile float y) {
|
||||
if (std::isnan(x)) {
|
||||
CHECK(std::isnan(y));
|
||||
} else {
|
||||
CHECK_EQ(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void CheckDoubleEq(volatile double x, volatile double y) {
|
||||
if (std::isnan(x)) {
|
||||
CHECK(std::isnan(y));
|
||||
} else {
|
||||
CHECK_EQ(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace compiler
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
@ -312,6 +312,23 @@ class ValueHelper {
|
||||
|
||||
#define FOR_UINT32_SHIFTS(var) for (uint32_t var = 0; var < 32; var++)
|
||||
|
||||
// TODO(bmeurer): Drop this crap once we switch to GTest/Gmock.
|
||||
static inline void CheckFloatEq(volatile float x, volatile float y) {
|
||||
if (std::isnan(x)) {
|
||||
CHECK(std::isnan(y));
|
||||
} else {
|
||||
CHECK_EQ(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void CheckDoubleEq(volatile double x, volatile double y) {
|
||||
if (std::isnan(x)) {
|
||||
CHECK(std::isnan(y));
|
||||
} else {
|
||||
CHECK_EQ(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace compiler
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "src/wasm/wasm-macro-gen.h"
|
||||
|
||||
#include "test/cctest/cctest.h"
|
||||
#include "test/cctest/compiler/value-helper.h"
|
||||
#include "test/cctest/wasm/test-signatures.h"
|
||||
#include "test/cctest/wasm/wasm-run-utils.h"
|
||||
|
||||
|
@ -1276,16 +1276,43 @@ TEST(Run_Wasm_ReturnStore) {
|
||||
|
||||
|
||||
TEST(Run_Wasm_VoidReturn1) {
|
||||
WasmRunner<void> r;
|
||||
BUILD(r, kExprNop);
|
||||
r.Call();
|
||||
// We use a wrapper function because WasmRunner<void> does not exist.
|
||||
|
||||
// Build the test function.
|
||||
TestSignatures sigs;
|
||||
TestingModule module;
|
||||
WasmFunctionCompiler t(sigs.v_v());
|
||||
BUILD(t, kExprNop);
|
||||
uint32_t index = t.CompileAndAdd(&module);
|
||||
|
||||
const int32_t kExpected = -414444;
|
||||
// Build the calling function.
|
||||
WasmRunner<int32_t> r;
|
||||
r.env()->module = &module;
|
||||
BUILD(r, WASM_BLOCK(2, WASM_CALL_FUNCTION0(index), WASM_I32(kExpected)));
|
||||
|
||||
int32_t result = r.Call();
|
||||
CHECK_EQ(kExpected, result);
|
||||
}
|
||||
|
||||
|
||||
TEST(Run_Wasm_VoidReturn2) {
|
||||
WasmRunner<void> r;
|
||||
BUILD(r, WASM_RETURN0);
|
||||
r.Call();
|
||||
// We use a wrapper function because WasmRunner<void> does not exist.
|
||||
// Build the test function.
|
||||
TestSignatures sigs;
|
||||
TestingModule module;
|
||||
WasmFunctionCompiler t(sigs.v_v());
|
||||
BUILD(t, WASM_RETURN0);
|
||||
uint32_t index = t.CompileAndAdd(&module);
|
||||
|
||||
const int32_t kExpected = -414444;
|
||||
// Build the calling function.
|
||||
WasmRunner<int32_t> r;
|
||||
r.env()->module = &module;
|
||||
BUILD(r, WASM_BLOCK(2, WASM_CALL_FUNCTION0(index), WASM_I32(kExpected)));
|
||||
|
||||
int32_t result = r.Call();
|
||||
CHECK_EQ(kExpected, result);
|
||||
}
|
||||
|
||||
|
||||
|
@ -14,6 +14,8 @@
|
||||
#include "src/compiler/graph-visualizer.h"
|
||||
#include "src/compiler/int64-lowering.h"
|
||||
#include "src/compiler/js-graph.h"
|
||||
#include "src/compiler/node.h"
|
||||
#include "src/compiler/pipeline.h"
|
||||
#include "src/compiler/wasm-compiler.h"
|
||||
|
||||
#include "src/wasm/ast-decoder.h"
|
||||
@ -21,8 +23,10 @@
|
||||
#include "src/wasm/wasm-module.h"
|
||||
#include "src/wasm/wasm-opcodes.h"
|
||||
|
||||
#include "src/zone.h"
|
||||
|
||||
#include "test/cctest/cctest.h"
|
||||
#include "test/cctest/compiler/codegen-tester.h"
|
||||
#include "test/cctest/compiler/call-tester.h"
|
||||
#include "test/cctest/compiler/graph-builder-tester.h"
|
||||
|
||||
// TODO(titzer): pull WASM_64 up to a common header.
|
||||
@ -42,6 +46,8 @@
|
||||
CHECK_EQ(0xdeadbeefdeadbeef, (bit_cast<uint64_t>(x)) & 0xFFFFFFFFFFFFFFFF)
|
||||
#define CHECK_TRAP(x) CHECK_TRAP32(x)
|
||||
|
||||
#define WASM_WRAPPER_RETURN_VALUE 8754
|
||||
|
||||
namespace {
|
||||
using namespace v8::base;
|
||||
using namespace v8::internal;
|
||||
@ -246,6 +252,127 @@ inline void TestBuildingGraph(Zone* zone, JSGraph* jsgraph, FunctionEnv* env,
|
||||
}
|
||||
}
|
||||
|
||||
template <typename ReturnType>
|
||||
class WasmFunctionWrapper : public HandleAndZoneScope,
|
||||
private GraphAndBuilders {
|
||||
public:
|
||||
WasmFunctionWrapper()
|
||||
: GraphAndBuilders(main_zone()),
|
||||
inner_code_node_(nullptr),
|
||||
signature_(nullptr) {
|
||||
Signature<MachineType>::Builder sig_builder(zone(), 1, 5);
|
||||
|
||||
sig_builder.AddReturn(MachineType::Int32());
|
||||
for (int i = 0; i < 5; i++) {
|
||||
sig_builder.AddParam(MachineType::Pointer());
|
||||
}
|
||||
signature_ = sig_builder.Build();
|
||||
}
|
||||
|
||||
void Init(CallDescriptor* descriptor, MachineType p0 = MachineType::None(),
|
||||
MachineType p1 = MachineType::None(),
|
||||
MachineType p2 = MachineType::None(),
|
||||
MachineType p3 = MachineType::None()) {
|
||||
// Create the TF graph for the wrapper. The wrapper always takes four
|
||||
// pointers as parameters, but may not pass the values of all pointers to
|
||||
// the actual test function.
|
||||
|
||||
// Function, effect, and control.
|
||||
Node** parameters = zone()->template NewArray<Node*>(4 + 3);
|
||||
graph()->SetStart(graph()->NewNode(common()->Start(6)));
|
||||
Node* effect = graph()->start();
|
||||
int parameter_count = 0;
|
||||
|
||||
// Dummy node which gets replaced in SetInnerCode.
|
||||
inner_code_node_ = graph()->NewNode(common()->Int32Constant(0));
|
||||
parameters[parameter_count++] = inner_code_node_;
|
||||
|
||||
if (p0 != MachineType::None()) {
|
||||
parameters[parameter_count] = graph()->NewNode(
|
||||
machine()->Load(p0),
|
||||
graph()->NewNode(common()->Parameter(0), graph()->start()),
|
||||
graph()->NewNode(common()->Int32Constant(0)), effect,
|
||||
graph()->start());
|
||||
effect = parameters[parameter_count++];
|
||||
}
|
||||
if (p1 != MachineType::None()) {
|
||||
parameters[parameter_count] = graph()->NewNode(
|
||||
machine()->Load(p0),
|
||||
graph()->NewNode(common()->Parameter(1), graph()->start()),
|
||||
graph()->NewNode(common()->Int32Constant(0)), effect,
|
||||
graph()->start());
|
||||
effect = parameters[parameter_count++];
|
||||
}
|
||||
if (p2 != MachineType::None()) {
|
||||
parameters[parameter_count] = graph()->NewNode(
|
||||
machine()->Load(p0),
|
||||
graph()->NewNode(common()->Parameter(2), graph()->start()),
|
||||
graph()->NewNode(common()->Int32Constant(0)), effect,
|
||||
graph()->start());
|
||||
effect = parameters[parameter_count++];
|
||||
}
|
||||
if (p3 != MachineType::None()) {
|
||||
parameters[parameter_count] = graph()->NewNode(
|
||||
machine()->Load(p0),
|
||||
graph()->NewNode(common()->Parameter(3), graph()->start()),
|
||||
graph()->NewNode(common()->Int32Constant(0)), effect,
|
||||
graph()->start());
|
||||
effect = parameters[parameter_count++];
|
||||
}
|
||||
|
||||
parameters[parameter_count++] = effect;
|
||||
parameters[parameter_count++] = graph()->start();
|
||||
Node* call = graph()->NewNode(common()->Call(descriptor), parameter_count,
|
||||
parameters);
|
||||
|
||||
effect = graph()->NewNode(
|
||||
machine()->Store(
|
||||
StoreRepresentation(MachineTypeForC<ReturnType>().representation(),
|
||||
WriteBarrierKind::kNoWriteBarrier)),
|
||||
graph()->NewNode(common()->Parameter(4), graph()->start()),
|
||||
graph()->NewNode(common()->Int32Constant(0)), call, effect,
|
||||
graph()->start());
|
||||
Node* r = graph()->NewNode(
|
||||
common()->Return(),
|
||||
graph()->NewNode(common()->Int32Constant(WASM_WRAPPER_RETURN_VALUE)),
|
||||
effect, graph()->start());
|
||||
graph()->SetEnd(graph()->NewNode(common()->End(2), r, graph()->start()));
|
||||
}
|
||||
|
||||
void SetInnerCode(Handle<Code> code_handle) {
|
||||
NodeProperties::ChangeOp(inner_code_node_,
|
||||
common()->HeapConstant(code_handle));
|
||||
}
|
||||
|
||||
Handle<Code> GetWrapperCode() {
|
||||
if (code_.is_null()) {
|
||||
Isolate* isolate = CcTest::InitIsolateOnce();
|
||||
|
||||
CallDescriptor* descriptor =
|
||||
Linkage::GetSimplifiedCDescriptor(zone(), signature_, true);
|
||||
|
||||
CompilationInfo info("testing", isolate, graph()->zone());
|
||||
code_ =
|
||||
Pipeline::GenerateCodeForTesting(&info, descriptor, graph(), nullptr);
|
||||
CHECK(!code_.is_null());
|
||||
#ifdef ENABLE_DISASSEMBLER
|
||||
if (FLAG_print_opt_code) {
|
||||
OFStream os(stdout);
|
||||
code_->Disassemble("wasm wrapper", os);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return code_;
|
||||
}
|
||||
|
||||
Signature<MachineType>* signature() const { return signature_; }
|
||||
|
||||
private:
|
||||
Node* inner_code_node_;
|
||||
Handle<Code> code_;
|
||||
Signature<MachineType>* signature_;
|
||||
};
|
||||
|
||||
// A helper for compiling functions that are only internally callable WASM code.
|
||||
class WasmFunctionCompiler : public HandleAndZoneScope,
|
||||
@ -270,6 +397,11 @@ class WasmFunctionCompiler : public HandleAndZoneScope,
|
||||
Zone* zone() const { return graph()->zone(); }
|
||||
CommonOperatorBuilder* common() { return &main_common_; }
|
||||
MachineOperatorBuilder* machine() { return &main_machine_; }
|
||||
void InitializeDescriptor() {
|
||||
if (descriptor_ == nullptr) {
|
||||
descriptor_ = env.module->GetWasmCallDescriptor(main_zone(), env.sig);
|
||||
}
|
||||
}
|
||||
CallDescriptor* descriptor() { return descriptor_; }
|
||||
|
||||
void Build(const byte* start, const byte* end) {
|
||||
@ -285,7 +417,7 @@ class WasmFunctionCompiler : public HandleAndZoneScope,
|
||||
}
|
||||
|
||||
Handle<Code> Compile(ModuleEnv* module) {
|
||||
descriptor_ = module->GetWasmCallDescriptor(this->zone(), env.sig);
|
||||
InitializeDescriptor();
|
||||
CompilationInfo info("wasm compile", this->isolate(), this->zone());
|
||||
Handle<Code> result =
|
||||
Pipeline::GenerateCodeForTesting(&info, descriptor_, this->graph());
|
||||
@ -323,7 +455,6 @@ class WasmRunner {
|
||||
: signature_(MachineTypeForC<ReturnType>() == MachineType::None() ? 0 : 1,
|
||||
GetParameterCount(p0, p1, p2, p3), storage_),
|
||||
compiler_(&signature_),
|
||||
call_wrapper_(p0, p1, p2, p3),
|
||||
compilation_done_(false) {
|
||||
int index = 0;
|
||||
MachineType ret = MachineTypeForC<ReturnType>();
|
||||
@ -338,6 +469,9 @@ class WasmRunner {
|
||||
storage_[index++] = WasmOpcodes::LocalTypeFor(p2);
|
||||
if (p3 != MachineType::None())
|
||||
storage_[index++] = WasmOpcodes::LocalTypeFor(p3);
|
||||
|
||||
compiler_.InitializeDescriptor();
|
||||
wrapper_.Init(compiler_.descriptor(), p0, p1, p2, p3);
|
||||
}
|
||||
|
||||
|
||||
@ -355,39 +489,35 @@ class WasmRunner {
|
||||
// Generate code.
|
||||
Handle<Code> code = compiler_.Compile(env()->module);
|
||||
|
||||
// Construct the call wrapper.
|
||||
Node* inputs[5];
|
||||
int input_count = 0;
|
||||
inputs[input_count++] = call_wrapper_.HeapConstant(code);
|
||||
for (size_t i = 0; i < signature_.parameter_count(); i++) {
|
||||
inputs[input_count++] = call_wrapper_.Parameter(i);
|
||||
}
|
||||
|
||||
call_wrapper_.Return(call_wrapper_.AddNode(
|
||||
call_wrapper_.common()->Call(compiler_.descriptor()), input_count,
|
||||
inputs));
|
||||
wrapper_.SetInnerCode(code);
|
||||
}
|
||||
|
||||
ReturnType Call() { return call_wrapper_.Call(); }
|
||||
ReturnType Call() { return Call(nullptr, nullptr, nullptr, nullptr); }
|
||||
|
||||
template <typename P0>
|
||||
ReturnType Call(P0 p0) {
|
||||
return call_wrapper_.Call(p0);
|
||||
return Call(p0, nullptr, nullptr, nullptr);
|
||||
}
|
||||
|
||||
template <typename P0, typename P1>
|
||||
ReturnType Call(P0 p0, P1 p1) {
|
||||
return call_wrapper_.Call(p0, p1);
|
||||
return Call(p0, p1, nullptr, nullptr);
|
||||
}
|
||||
|
||||
template <typename P0, typename P1, typename P2>
|
||||
ReturnType Call(P0 p0, P1 p1, P2 p2) {
|
||||
return call_wrapper_.Call(p0, p1, p2);
|
||||
return Call(p0, p1, p2, nullptr);
|
||||
}
|
||||
|
||||
template <typename P0, typename P1, typename P2, typename P3>
|
||||
ReturnType Call(P0 p0, P1 p1, P2 p2, P3 p3) {
|
||||
return call_wrapper_.Call(p0, p1, p2, p3);
|
||||
CodeRunner<int32_t> runner(CcTest::InitIsolateOnce(),
|
||||
wrapper_.GetWrapperCode(), wrapper_.signature());
|
||||
ReturnType return_value;
|
||||
int32_t result = runner.Call<void*, void*, void*, void*, void*>(
|
||||
&p0, &p1, &p2, &p3, &return_value);
|
||||
CHECK_EQ(WASM_WRAPPER_RETURN_VALUE, result);
|
||||
return return_value;
|
||||
}
|
||||
|
||||
byte AllocateLocal(LocalType type) {
|
||||
@ -402,7 +532,7 @@ class WasmRunner {
|
||||
LocalType storage_[5];
|
||||
FunctionSig signature_;
|
||||
WasmFunctionCompiler compiler_;
|
||||
BufferedRawMachineAssemblerTester<ReturnType> call_wrapper_;
|
||||
WasmFunctionWrapper<ReturnType> wrapper_;
|
||||
bool compilation_done_;
|
||||
|
||||
static size_t GetParameterCount(MachineType p0, MachineType p1,
|
||||
|
Loading…
Reference in New Issue
Block a user