Commit d0bacc61 authored by titzer's avatar titzer Committed by Commit bot

[turbofan] Fix stack->stack double moves for pushing on ia32 and x64.

R=mstarzinger@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1299023002

Cr-Commit-Position: refs/heads/master@{#30235}
parent e1ad0237
......@@ -857,10 +857,15 @@ void InstructionSelector::VisitCall(Node* node, BasicBlock* handler) {
for (Node* input : base::Reversed(buffer.pushed_nodes)) {
// Skip any alignment holes in pushed nodes.
if (input == nullptr) continue;
// TODO(titzer): IA32Push cannot handle stack->stack double moves
// because there is no way to encode fixed double slots.
InstructionOperand value =
g.CanBeImmediate(input)
? g.UseImmediate(input)
: IsSupported(ATOM) ? g.UseRegister(input) : g.Use(input);
: IsSupported(ATOM) ||
sequence()->IsFloat(GetVirtualRegister(input))
? g.UseRegister(input)
: g.Use(input);
Emit(kIA32Push, g.NoOutput(), value);
}
}
......
......@@ -1023,7 +1023,6 @@ struct PrintableInstructionSequence;
// Represents architecture-specific generated code before, during, and after
// register allocation.
// TODO(titzer): s/IsDouble/IsFloat64/
class InstructionSequence final : public ZoneObject {
public:
static InstructionBlocks* InstructionBlocksFor(Zone* zone,
......
......@@ -1054,7 +1054,7 @@ void InstructionSelector::VisitCall(Node* node, BasicBlock* handler) {
// Poke any stack arguments.
for (size_t n = 0; n < buffer.pushed_nodes.size(); ++n) {
if (Node* input = buffer.pushed_nodes[n]) {
int const slot = static_cast<int>(n);
int slot = static_cast<int>(n);
InstructionOperand value = g.CanBeImmediate(input)
? g.UseImmediate(input)
: g.UseRegister(input);
......@@ -1064,11 +1064,15 @@ void InstructionSelector::VisitCall(Node* node, BasicBlock* handler) {
} else {
// Push any stack arguments.
for (Node* input : base::Reversed(buffer.pushed_nodes)) {
// TODO(titzer): handle pushing double parameters.
// TODO(titzer): X64Push cannot handle stack->stack double moves
// because there is no way to encode fixed double slots.
InstructionOperand value =
g.CanBeImmediate(input)
? g.UseImmediate(input)
: IsSupported(ATOM) ? g.UseRegister(input) : g.Use(input);
: IsSupported(ATOM) ||
sequence()->IsFloat(GetVirtualRegister(input))
? g.UseRegister(input)
: g.Use(input);
Emit(kX64Push, g.NoOutput(), value);
}
}
......
......@@ -447,7 +447,7 @@ class Computer {
Unique<HeapObject> unique =
Unique<HeapObject>::CreateUninitialized(inner);
Node* target = raw.HeapConstant(unique);
Node** args = zone.NewArray<Node*>(kMaxParamCount);
Node** args = zone.NewArray<Node*>(num_params);
for (int i = 0; i < num_params; i++) {
args[i] = io.MakeConstant(raw, io.input[i]);
}
......@@ -930,3 +930,56 @@ TEST(Float64Select_stack_params_return_reg) {
RunSelect<float64, 5>(desc);
}
}
template <typename CType, int which>
static void Build_Select_With_Call(CallDescriptor* desc,
RawMachineAssembler& raw) {
Handle<Code> inner = Handle<Code>::null();
int num_params = ParamCount(desc);
CHECK_LE(num_params, kMaxParamCount);
{
Isolate* isolate = CcTest::InitIsolateOnce();
// Build the actual select.
Zone zone;
Graph graph(&zone);
RawMachineAssembler raw(isolate, &graph, desc);
raw.Return(raw.Parameter(which));
inner = CompileGraph("Select-indirection", desc, &graph, raw.Export());
CHECK(!inner.is_null());
CHECK(inner->IsCode());
}
{
// Build a call to the function that does the select.
Unique<HeapObject> unique = Unique<HeapObject>::CreateUninitialized(inner);
Node* target = raw.HeapConstant(unique);
Node** args = raw.zone()->NewArray<Node*>(num_params);
for (int i = 0; i < num_params; i++) {
args[i] = raw.Parameter(i);
}
Node* call = raw.CallN(desc, target, args);
raw.Return(call);
}
}
TEST(Float64StackParamsToStackParams) {
if (DISABLE_NATIVE_STACK_PARAMS) return;
int rarray[] = {0};
Allocator params(nullptr, 0, nullptr, 0);
Allocator rets(nullptr, 0, rarray, 1);
Zone zone;
ArgsBuffer<float64>::Sig sig(2);
RegisterConfig config(params, rets);
CallDescriptor* desc = config.Create(&zone, &sig);
Run_Computation<float64>(desc, Build_Select_With_Call<float64, 0>,
Compute_Select<float64, 0>, 1098);
Run_Computation<float64>(desc, Build_Select_With_Call<float64, 1>,
Compute_Select<float64, 1>, 1099);
}
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