Commit 52bd944d authored by Sigurd Schneider's avatar Sigurd Schneider Committed by Commit Bot

[wasm,test] Pass correct code kind in Wasm tests

Change-Id: I8fd0ce9ac2dc37e2daa0728b5d4c119a2bd1f340
Bug: v8:6666
Reviewed-on: https://chromium-review.googlesource.com/1256865
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56338}
parent 1e255248
......@@ -39,6 +39,24 @@ class RawMachineAssemblerTester : public HandleAndZoneScope,
InstructionSelector::SupportedMachineOperatorFlags(),
InstructionSelector::AlignmentRequirements()) {}
template <typename... ParamMachTypes>
RawMachineAssemblerTester(Code::Kind kind, ParamMachTypes... p)
: HandleAndZoneScope(),
CallHelper<ReturnType>(
main_isolate(),
CSignature::New(main_zone(), MachineTypeForC<ReturnType>(), p...)),
RawMachineAssembler(
main_isolate(), new (main_zone()) Graph(main_zone()),
Linkage::GetSimplifiedCDescriptor(
main_zone(),
CSignature::New(main_zone(), MachineTypeForC<ReturnType>(),
p...),
true),
MachineType::PointerRepresentation(),
InstructionSelector::SupportedMachineOperatorFlags(),
InstructionSelector::AlignmentRequirements()),
kind_(kind) {}
~RawMachineAssemblerTester() override = default;
void CheckNumber(double expected, Object* number) {
......@@ -64,8 +82,7 @@ class RawMachineAssemblerTester : public HandleAndZoneScope,
Schedule* schedule = this->Export();
auto call_descriptor = this->call_descriptor();
Graph* graph = this->graph();
OptimizedCompilationInfo info(ArrayVector("testing"), main_zone(),
Code::STUB);
OptimizedCompilationInfo info(ArrayVector("testing"), main_zone(), kind_);
code_ = Pipeline::GenerateCodeForTesting(
&info, main_isolate(), call_descriptor, graph,
AssemblerOptions::Default(main_isolate()), schedule);
......@@ -74,6 +91,7 @@ class RawMachineAssemblerTester : public HandleAndZoneScope,
}
private:
Code::Kind kind_ = Code::Kind::STUB;
MaybeHandle<Code> code_;
};
......
......@@ -193,7 +193,7 @@ void TestReturnMultipleValues(MachineType type) {
byte* code_start =
module->AddCodeForTesting(code)->instructions().start();
RawMachineAssemblerTester<int32_t> mt;
RawMachineAssemblerTester<int32_t> mt(Code::Kind::JS_TO_WASM_FUNCTION);
const int input_count = 2 + param_count;
Node* call_inputs[2 + kMaxParamCount];
call_inputs[0] = mt.PointerConstant(code_start);
......
......@@ -83,21 +83,6 @@ MachineType RandomType(InputProvider* input) {
return kTypes[input->NextInt8(kNumTypes)];
}
int num_registers(MachineType type) {
const RegisterConfiguration* config = RegisterConfiguration::Default();
switch (type.representation()) {
case MachineRepresentation::kWord32:
case MachineRepresentation::kWord64:
return config->num_allocatable_general_registers();
case MachineRepresentation::kFloat32:
return config->num_allocatable_float_registers();
case MachineRepresentation::kFloat64:
return config->num_allocatable_double_registers();
default:
UNREACHABLE();
}
}
int index(MachineType type) { return static_cast<int>(type.representation()); }
Node* Constant(RawMachineAssembler& m, MachineType type, int value) {
......@@ -256,7 +241,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
}
callee.Return(static_cast<int>(desc->ReturnCount()), returns.get());
OptimizedCompilationInfo info(ArrayVector("testing"), &zone, Code::STUB);
OptimizedCompilationInfo info(ArrayVector("testing"), &zone,
Code::WASM_FUNCTION);
Handle<Code> code = Pipeline::GenerateCodeForTesting(
&info, i_isolate, desc, callee.graph(),
AssemblerOptions::Default(i_isolate), callee.Export())
......@@ -300,7 +286,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
// Call the wrapper.
OptimizedCompilationInfo wrapper_info(ArrayVector("wrapper"), &zone,
Code::STUB);
Code::JS_TO_WASM_FUNCTION);
Handle<Code> wrapper_code =
Pipeline::GenerateCodeForTesting(
&wrapper_info, i_isolate, wrapper_desc, caller.graph(),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment