Commit 69753f26 authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

Move StackArgumentsAccessor from codegen.h to macroassembler.h on x64

Bug: v8:6921
Change-Id: Id73a9ecc476c3c3ce0718bef81684787b72e366e
Reviewed-on: https://chromium-review.googlesource.com/727202Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48733}
parent ba77137b
......@@ -2185,7 +2185,6 @@ v8_source_set("v8_base") {
"src/x64/code-stubs-x64.cc",
"src/x64/code-stubs-x64.h",
"src/x64/codegen-x64.cc",
"src/x64/codegen-x64.h",
"src/x64/cpu-x64.cc",
"src/x64/deoptimizer-x64.cc",
"src/x64/disasm-x64.cc",
......
......@@ -8,10 +8,6 @@
#include "src/code-stubs.h"
#include "src/globals.h"
#if V8_TARGET_ARCH_X64
#include "src/x64/codegen-x64.h" // NOLINT
#endif
namespace v8 {
namespace internal {
......
......@@ -1694,7 +1694,6 @@
'x64/code-stubs-x64.cc',
'x64/code-stubs-x64.h',
'x64/codegen-x64.cc',
'x64/codegen-x64.h',
'x64/cpu-x64.cc',
'x64/deoptimizer-x64.cc',
'x64/disasm-x64.cc',
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/x64/codegen-x64.h"
#if V8_TARGET_ARCH_X64
#include "src/codegen.h"
......@@ -41,27 +39,6 @@ UnaryMathFunctionWithIsolate CreateSqrtFunction(Isolate* isolate) {
#undef __
Operand StackArgumentsAccessor::GetArgumentOperand(int index) {
DCHECK_GE(index, 0);
int receiver = (receiver_mode_ == ARGUMENTS_CONTAIN_RECEIVER) ? 1 : 0;
int displacement_to_last_argument =
base_reg_ == rsp ? kPCOnStackSize : kFPOnStackSize + kPCOnStackSize;
displacement_to_last_argument += extra_displacement_to_last_argument_;
if (argument_count_reg_ == no_reg) {
// argument[0] is at base_reg_ + displacement_to_last_argument +
// (argument_count_immediate_ + receiver - 1) * kPointerSize.
DCHECK_GT(argument_count_immediate_ + receiver, 0);
return Operand(base_reg_, displacement_to_last_argument +
(argument_count_immediate_ + receiver - 1 - index) * kPointerSize);
} else {
// argument[0] is at base_reg_ + displacement_to_last_argument +
// argument_count_reg_ * times_pointer_size + (receiver - 1) * kPointerSize.
return Operand(base_reg_, argument_count_reg_, times_pointer_size,
displacement_to_last_argument + (receiver - 1 - index) * kPointerSize);
}
}
} // namespace internal
} // namespace v8
......
// Copyright 2011 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_X64_CODEGEN_X64_H_
#define V8_X64_CODEGEN_X64_H_
#include "src/macro-assembler.h"
namespace v8 {
namespace internal {
enum StackArgumentsAccessorReceiverMode {
ARGUMENTS_CONTAIN_RECEIVER,
ARGUMENTS_DONT_CONTAIN_RECEIVER
};
class StackArgumentsAccessor BASE_EMBEDDED {
public:
StackArgumentsAccessor(
Register base_reg,
int argument_count_immediate,
StackArgumentsAccessorReceiverMode receiver_mode =
ARGUMENTS_CONTAIN_RECEIVER,
int extra_displacement_to_last_argument = 0)
: base_reg_(base_reg),
argument_count_reg_(no_reg),
argument_count_immediate_(argument_count_immediate),
receiver_mode_(receiver_mode),
extra_displacement_to_last_argument_(
extra_displacement_to_last_argument) { }
StackArgumentsAccessor(
Register base_reg,
Register argument_count_reg,
StackArgumentsAccessorReceiverMode receiver_mode =
ARGUMENTS_CONTAIN_RECEIVER,
int extra_displacement_to_last_argument = 0)
: base_reg_(base_reg),
argument_count_reg_(argument_count_reg),
argument_count_immediate_(0),
receiver_mode_(receiver_mode),
extra_displacement_to_last_argument_(
extra_displacement_to_last_argument) { }
StackArgumentsAccessor(
Register base_reg,
const ParameterCount& parameter_count,
StackArgumentsAccessorReceiverMode receiver_mode =
ARGUMENTS_CONTAIN_RECEIVER,
int extra_displacement_to_last_argument = 0)
: base_reg_(base_reg),
argument_count_reg_(parameter_count.is_reg() ?
parameter_count.reg() : no_reg),
argument_count_immediate_(parameter_count.is_immediate() ?
parameter_count.immediate() : 0),
receiver_mode_(receiver_mode),
extra_displacement_to_last_argument_(
extra_displacement_to_last_argument) { }
Operand GetArgumentOperand(int index);
Operand GetReceiverOperand() {
DCHECK(receiver_mode_ == ARGUMENTS_CONTAIN_RECEIVER);
return GetArgumentOperand(0);
}
private:
const Register base_reg_;
const Register argument_count_reg_;
const int argument_count_immediate_;
const StackArgumentsAccessorReceiverMode receiver_mode_;
const int extra_displacement_to_last_argument_;
DISALLOW_IMPLICIT_CONSTRUCTORS(StackArgumentsAccessor);
};
} // namespace internal
} // namespace v8
#endif // V8_X64_CODEGEN_X64_H_
......@@ -24,6 +24,42 @@
namespace v8 {
namespace internal {
Operand StackArgumentsAccessor::GetArgumentOperand(int index) {
DCHECK_GE(index, 0);
int receiver = (receiver_mode_ == ARGUMENTS_CONTAIN_RECEIVER) ? 1 : 0;
int displacement_to_last_argument =
base_reg_ == rsp ? kPCOnStackSize : kFPOnStackSize + kPCOnStackSize;
displacement_to_last_argument += extra_displacement_to_last_argument_;
if (argument_count_reg_ == no_reg) {
// argument[0] is at base_reg_ + displacement_to_last_argument +
// (argument_count_immediate_ + receiver - 1) * kPointerSize.
DCHECK_GT(argument_count_immediate_ + receiver, 0);
return Operand(
base_reg_,
displacement_to_last_argument +
(argument_count_immediate_ + receiver - 1 - index) * kPointerSize);
} else {
// argument[0] is at base_reg_ + displacement_to_last_argument +
// argument_count_reg_ * times_pointer_size + (receiver - 1) * kPointerSize.
return Operand(
base_reg_, argument_count_reg_, times_pointer_size,
displacement_to_last_argument + (receiver - 1 - index) * kPointerSize);
}
}
StackArgumentsAccessor::StackArgumentsAccessor(
Register base_reg, const ParameterCount& parameter_count,
StackArgumentsAccessorReceiverMode receiver_mode,
int extra_displacement_to_last_argument)
: base_reg_(base_reg),
argument_count_reg_(parameter_count.is_reg() ? parameter_count.reg()
: no_reg),
argument_count_immediate_(
parameter_count.is_immediate() ? parameter_count.immediate() : 0),
receiver_mode_(receiver_mode),
extra_displacement_to_last_argument_(
extra_displacement_to_last_argument) {}
MacroAssembler::MacroAssembler(Isolate* isolate, void* buffer, int size,
CodeObjectRequired create_code_object)
: TurboAssembler(isolate, buffer, size, create_code_object) {}
......
......@@ -67,6 +67,57 @@ struct SmiIndex {
ScaleFactor scale;
};
enum StackArgumentsAccessorReceiverMode {
ARGUMENTS_CONTAIN_RECEIVER,
ARGUMENTS_DONT_CONTAIN_RECEIVER
};
class StackArgumentsAccessor BASE_EMBEDDED {
public:
StackArgumentsAccessor(Register base_reg, int argument_count_immediate,
StackArgumentsAccessorReceiverMode receiver_mode =
ARGUMENTS_CONTAIN_RECEIVER,
int extra_displacement_to_last_argument = 0)
: base_reg_(base_reg),
argument_count_reg_(no_reg),
argument_count_immediate_(argument_count_immediate),
receiver_mode_(receiver_mode),
extra_displacement_to_last_argument_(
extra_displacement_to_last_argument) {}
StackArgumentsAccessor(Register base_reg, Register argument_count_reg,
StackArgumentsAccessorReceiverMode receiver_mode =
ARGUMENTS_CONTAIN_RECEIVER,
int extra_displacement_to_last_argument = 0)
: base_reg_(base_reg),
argument_count_reg_(argument_count_reg),
argument_count_immediate_(0),
receiver_mode_(receiver_mode),
extra_displacement_to_last_argument_(
extra_displacement_to_last_argument) {}
StackArgumentsAccessor(Register base_reg,
const ParameterCount& parameter_count,
StackArgumentsAccessorReceiverMode receiver_mode =
ARGUMENTS_CONTAIN_RECEIVER,
int extra_displacement_to_last_argument = 0);
Operand GetArgumentOperand(int index);
Operand GetReceiverOperand() {
DCHECK(receiver_mode_ == ARGUMENTS_CONTAIN_RECEIVER);
return GetArgumentOperand(0);
}
private:
const Register base_reg_;
const Register argument_count_reg_;
const int argument_count_immediate_;
const StackArgumentsAccessorReceiverMode receiver_mode_;
const int extra_displacement_to_last_argument_;
DISALLOW_IMPLICIT_CONSTRUCTORS(StackArgumentsAccessor);
};
class TurboAssembler : public Assembler {
public:
TurboAssembler(Isolate* isolate, void* buffer, int buffer_size,
......
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