Commit 1dd0988a authored by Seth Brenith's avatar Seth Brenith Committed by Commit Bot

[interpreter] Rename AccumulatorUse so it can be expanded for short star

In https://chromium-review.googlesource.com/c/v8/v8/+/2641180 , we are
discussing renaming AccumulatorUse. To avoid polluting that change with
a large mechanical find&replace, I've created a separate change for the
renaming.

Change-Id: Ibc7e438f9e719571c9237e7e08ba86562a3c679f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2684923Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Commit-Queue: Seth Brenith <seth.brenith@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#72679}
parent 34ea1904
...@@ -327,7 +327,7 @@ class OperandHelper<OperandType::kRegOutTriple> { ...@@ -327,7 +327,7 @@ class OperandHelper<OperandType::kRegOutTriple> {
} // namespace } // namespace
template <Bytecode bytecode, AccumulatorUse accumulator_use, template <Bytecode bytecode, ImplicitRegisterUse implicit_register_use,
OperandType... operand_types> OperandType... operand_types>
class BytecodeNodeBuilder { class BytecodeNodeBuilder {
public: public:
...@@ -336,7 +336,7 @@ class BytecodeNodeBuilder { ...@@ -336,7 +336,7 @@ class BytecodeNodeBuilder {
Operands... operands) { Operands... operands) {
static_assert(sizeof...(Operands) <= Bytecodes::kMaxOperands, static_assert(sizeof...(Operands) <= Bytecodes::kMaxOperands,
"too many operands for bytecode"); "too many operands for bytecode");
builder->PrepareToOutputBytecode<bytecode, accumulator_use>(); builder->PrepareToOutputBytecode<bytecode, implicit_register_use>();
// The "OperandHelper<operand_types>::Convert(builder, operands)..." will // The "OperandHelper<operand_types>::Convert(builder, operands)..." will
// expand both the OperandType... and Operands... parameter packs e.g. for: // expand both the OperandType... and Operands... parameter packs e.g. for:
// BytecodeNodeBuilder<OperandType::kReg, OperandType::kImm>::Make< // BytecodeNodeBuilder<OperandType::kReg, OperandType::kImm>::Make<
...@@ -344,7 +344,8 @@ class BytecodeNodeBuilder { ...@@ -344,7 +344,8 @@ class BytecodeNodeBuilder {
// the code will expand into: // the code will expand into:
// OperandHelper<OperandType::kReg>::Convert(builder, reg), // OperandHelper<OperandType::kReg>::Convert(builder, reg),
// OperandHelper<OperandType::kImm>::Convert(builder, immediate), // OperandHelper<OperandType::kImm>::Convert(builder, immediate),
return BytecodeNode::Create<bytecode, accumulator_use, operand_types...>( return BytecodeNode::Create<bytecode, implicit_register_use,
operand_types...>(
builder->CurrentSourcePosition(bytecode), builder->CurrentSourcePosition(bytecode),
OperandHelper<operand_types>::Convert(builder, operands)...); OperandHelper<operand_types>::Convert(builder, operands)...);
} }
...@@ -1598,10 +1599,10 @@ bool BytecodeArrayBuilder::RegisterListIsValid(RegisterList reg_list) const { ...@@ -1598,10 +1599,10 @@ bool BytecodeArrayBuilder::RegisterListIsValid(RegisterList reg_list) const {
} }
} }
template <Bytecode bytecode, AccumulatorUse accumulator_use> template <Bytecode bytecode, ImplicitRegisterUse implicit_register_use>
void BytecodeArrayBuilder::PrepareToOutputBytecode() { void BytecodeArrayBuilder::PrepareToOutputBytecode() {
if (register_optimizer_) if (register_optimizer_)
register_optimizer_->PrepareForBytecode<bytecode, accumulator_use>(); register_optimizer_->PrepareForBytecode<bytecode, implicit_register_use>();
} }
uint32_t BytecodeArrayBuilder::GetInputRegisterOperand(Register reg) { uint32_t BytecodeArrayBuilder::GetInputRegisterOperand(Register reg) {
......
...@@ -567,7 +567,7 @@ class V8_EXPORT_PRIVATE BytecodeArrayBuilder final { ...@@ -567,7 +567,7 @@ class V8_EXPORT_PRIVATE BytecodeArrayBuilder final {
private: private:
friend class BytecodeRegisterAllocator; friend class BytecodeRegisterAllocator;
template <Bytecode bytecode, AccumulatorUse accumulator_use, template <Bytecode bytecode, ImplicitRegisterUse implicit_register_use,
OperandType... operand_types> OperandType... operand_types>
friend class BytecodeNodeBuilder; friend class BytecodeNodeBuilder;
...@@ -613,7 +613,7 @@ class V8_EXPORT_PRIVATE BytecodeArrayBuilder final { ...@@ -613,7 +613,7 @@ class V8_EXPORT_PRIVATE BytecodeArrayBuilder final {
// during bytecode generation. // during bytecode generation.
BytecodeArrayBuilder& Illegal(); BytecodeArrayBuilder& Illegal();
template <Bytecode bytecode, AccumulatorUse accumulator_use> template <Bytecode bytecode, ImplicitRegisterUse implicit_register_use>
void PrepareToOutputBytecode(); void PrepareToOutputBytecode();
BytecodeArrayWriter* bytecode_array_writer() { BytecodeArrayWriter* bytecode_array_writer() {
......
...@@ -253,7 +253,8 @@ void BytecodeArrayWriter::MaybeElideLastBytecode(Bytecode next_bytecode, ...@@ -253,7 +253,8 @@ void BytecodeArrayWriter::MaybeElideLastBytecode(Bytecode next_bytecode,
// and the next bytecode clobbers this load without reading the accumulator, // and the next bytecode clobbers this load without reading the accumulator,
// then the previous bytecode can be elided as it has no effect. // then the previous bytecode can be elided as it has no effect.
if (Bytecodes::IsAccumulatorLoadWithoutEffects(last_bytecode_) && if (Bytecodes::IsAccumulatorLoadWithoutEffects(last_bytecode_) &&
Bytecodes::GetAccumulatorUse(next_bytecode) == AccumulatorUse::kWrite && Bytecodes::GetImplicitRegisterUse(next_bytecode) ==
ImplicitRegisterUse::kWriteAccumulator &&
(!last_bytecode_had_source_info_ || !has_source_info)) { (!last_bytecode_had_source_info_ || !has_source_info)) {
DCHECK_GT(bytecodes()->size(), last_bytecode_offset_); DCHECK_GT(bytecodes()->size(), last_bytecode_offset_);
bytecodes()->resize(last_bytecode_offset_); bytecodes()->resize(last_bytecode_offset_);
......
...@@ -127,7 +127,7 @@ class V8_EXPORT_PRIVATE BytecodeNode final { ...@@ -127,7 +127,7 @@ class V8_EXPORT_PRIVATE BytecodeNode final {
bool operator!=(const BytecodeNode& other) const { return !(*this == other); } bool operator!=(const BytecodeNode& other) const { return !(*this == other); }
private: private:
template <Bytecode bytecode, AccumulatorUse accumulator_use, template <Bytecode bytecode, ImplicitRegisterUse implicit_register_use,
OperandType... operand_types> OperandType... operand_types>
friend class BytecodeNodeBuilder; friend class BytecodeNodeBuilder;
...@@ -148,12 +148,12 @@ class V8_EXPORT_PRIVATE BytecodeNode final { ...@@ -148,12 +148,12 @@ class V8_EXPORT_PRIVATE BytecodeNode final {
operands_[4] = operand4; operands_[4] = operand4;
} }
template <Bytecode bytecode, AccumulatorUse accum_use> template <Bytecode bytecode, ImplicitRegisterUse accum_use>
V8_INLINE static BytecodeNode Create(BytecodeSourceInfo source_info) { V8_INLINE static BytecodeNode Create(BytecodeSourceInfo source_info) {
return BytecodeNode(bytecode, 0, OperandScale::kSingle, source_info); return BytecodeNode(bytecode, 0, OperandScale::kSingle, source_info);
} }
template <Bytecode bytecode, AccumulatorUse accum_use, template <Bytecode bytecode, ImplicitRegisterUse accum_use,
OperandType operand0_type> OperandType operand0_type>
V8_INLINE static BytecodeNode Create(BytecodeSourceInfo source_info, V8_INLINE static BytecodeNode Create(BytecodeSourceInfo source_info,
uint32_t operand0) { uint32_t operand0) {
...@@ -163,7 +163,7 @@ class V8_EXPORT_PRIVATE BytecodeNode final { ...@@ -163,7 +163,7 @@ class V8_EXPORT_PRIVATE BytecodeNode final {
return BytecodeNode(bytecode, 1, scale, source_info, operand0); return BytecodeNode(bytecode, 1, scale, source_info, operand0);
} }
template <Bytecode bytecode, AccumulatorUse accum_use, template <Bytecode bytecode, ImplicitRegisterUse accum_use,
OperandType operand0_type, OperandType operand1_type> OperandType operand0_type, OperandType operand1_type>
V8_INLINE static BytecodeNode Create(BytecodeSourceInfo source_info, V8_INLINE static BytecodeNode Create(BytecodeSourceInfo source_info,
uint32_t operand0, uint32_t operand1) { uint32_t operand0, uint32_t operand1) {
...@@ -175,7 +175,7 @@ class V8_EXPORT_PRIVATE BytecodeNode final { ...@@ -175,7 +175,7 @@ class V8_EXPORT_PRIVATE BytecodeNode final {
return BytecodeNode(bytecode, 2, scale, source_info, operand0, operand1); return BytecodeNode(bytecode, 2, scale, source_info, operand0, operand1);
} }
template <Bytecode bytecode, AccumulatorUse accum_use, template <Bytecode bytecode, ImplicitRegisterUse accum_use,
OperandType operand0_type, OperandType operand1_type, OperandType operand0_type, OperandType operand1_type,
OperandType operand2_type> OperandType operand2_type>
V8_INLINE static BytecodeNode Create(BytecodeSourceInfo source_info, V8_INLINE static BytecodeNode Create(BytecodeSourceInfo source_info,
...@@ -192,7 +192,7 @@ class V8_EXPORT_PRIVATE BytecodeNode final { ...@@ -192,7 +192,7 @@ class V8_EXPORT_PRIVATE BytecodeNode final {
operand2); operand2);
} }
template <Bytecode bytecode, AccumulatorUse accum_use, template <Bytecode bytecode, ImplicitRegisterUse accum_use,
OperandType operand0_type, OperandType operand1_type, OperandType operand0_type, OperandType operand1_type,
OperandType operand2_type, OperandType operand3_type> OperandType operand2_type, OperandType operand3_type>
V8_INLINE static BytecodeNode Create(BytecodeSourceInfo source_info, V8_INLINE static BytecodeNode Create(BytecodeSourceInfo source_info,
...@@ -211,7 +211,7 @@ class V8_EXPORT_PRIVATE BytecodeNode final { ...@@ -211,7 +211,7 @@ class V8_EXPORT_PRIVATE BytecodeNode final {
operand2, operand3); operand2, operand3);
} }
template <Bytecode bytecode, AccumulatorUse accum_use, template <Bytecode bytecode, ImplicitRegisterUse accum_use,
OperandType operand0_type, OperandType operand1_type, OperandType operand0_type, OperandType operand1_type,
OperandType operand2_type, OperandType operand3_type, OperandType operand2_type, OperandType operand3_type,
OperandType operand4_type> OperandType operand4_type>
......
...@@ -12,15 +12,16 @@ namespace interpreter { ...@@ -12,15 +12,16 @@ namespace interpreter {
namespace { namespace {
const char* AccumulatorUseToString(AccumulatorUse accumulator_use) { const char* ImplicitRegisterUseToString(
switch (accumulator_use) { ImplicitRegisterUse implicit_register_use) {
case AccumulatorUse::kNone: switch (implicit_register_use) {
case ImplicitRegisterUse::kNone:
return "None"; return "None";
case AccumulatorUse::kRead: case ImplicitRegisterUse::kReadAccumulator:
return "Read"; return "Read";
case AccumulatorUse::kWrite: case ImplicitRegisterUse::kWriteAccumulator:
return "Write"; return "Write";
case AccumulatorUse::kReadWrite: case ImplicitRegisterUse::kReadWriteAccumulator:
return "ReadWrite"; return "ReadWrite";
} }
UNREACHABLE(); UNREACHABLE();
...@@ -64,8 +65,8 @@ const char* OperandSizeToString(OperandSize operand_size) { ...@@ -64,8 +65,8 @@ const char* OperandSizeToString(OperandSize operand_size) {
} // namespace } // namespace
std::ostream& operator<<(std::ostream& os, const AccumulatorUse& use) { std::ostream& operator<<(std::ostream& os, const ImplicitRegisterUse& use) {
return os << AccumulatorUseToString(use); return os << ImplicitRegisterUseToString(use);
} }
std::ostream& operator<<(std::ostream& os, const OperandSize& operand_size) { std::ostream& operator<<(std::ostream& os, const OperandSize& operand_size) {
......
...@@ -109,27 +109,27 @@ enum class OperandType : uint8_t { ...@@ -109,27 +109,27 @@ enum class OperandType : uint8_t {
#undef COUNT_OPERAND_TYPES #undef COUNT_OPERAND_TYPES
}; };
enum class AccumulatorUse : uint8_t { enum class ImplicitRegisterUse : uint8_t {
kNone = 0, kNone = 0,
kRead = 1 << 0, kReadAccumulator = 1 << 0,
kWrite = 1 << 1, kWriteAccumulator = 1 << 1,
kReadWrite = kRead | kWrite kReadWriteAccumulator = kReadAccumulator | kWriteAccumulator
}; };
constexpr inline AccumulatorUse operator&(AccumulatorUse lhs, constexpr inline ImplicitRegisterUse operator&(ImplicitRegisterUse lhs,
AccumulatorUse rhs) { ImplicitRegisterUse rhs) {
return static_cast<AccumulatorUse>(static_cast<int>(lhs) & return static_cast<ImplicitRegisterUse>(static_cast<int>(lhs) &
static_cast<int>(rhs)); static_cast<int>(rhs));
} }
constexpr inline AccumulatorUse operator|(AccumulatorUse lhs, constexpr inline ImplicitRegisterUse operator|(ImplicitRegisterUse lhs,
AccumulatorUse rhs) { ImplicitRegisterUse rhs) {
return static_cast<AccumulatorUse>(static_cast<int>(lhs) | return static_cast<ImplicitRegisterUse>(static_cast<int>(lhs) |
static_cast<int>(rhs)); static_cast<int>(rhs));
} }
V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
const AccumulatorUse& use); const ImplicitRegisterUse& use);
V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
const OperandScale& operand_scale); const OperandScale& operand_scale);
V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
...@@ -170,14 +170,20 @@ class BytecodeOperands : public AllStatic { ...@@ -170,14 +170,20 @@ class BytecodeOperands : public AllStatic {
return static_cast<int>(operand_scale) >> 1; return static_cast<int>(operand_scale) >> 1;
} }
// Returns true if |accumulator_use| reads the accumulator. // Returns true if |implicit_register_use| reads the
static constexpr bool ReadsAccumulator(AccumulatorUse accumulator_use) { // accumulator.
return (accumulator_use & AccumulatorUse::kRead) == AccumulatorUse::kRead; static constexpr bool ReadsAccumulator(
ImplicitRegisterUse implicit_register_use) {
return (implicit_register_use & ImplicitRegisterUse::kReadAccumulator) ==
ImplicitRegisterUse::kReadAccumulator;
} }
// Returns true if |accumulator_use| writes the accumulator. // Returns true if |implicit_register_use| writes the
static constexpr bool WritesAccumulator(AccumulatorUse accumulator_use) { // accumulator.
return (accumulator_use & AccumulatorUse::kWrite) == AccumulatorUse::kWrite; static constexpr bool WritesAccumulator(
ImplicitRegisterUse implicit_register_use) {
return (implicit_register_use & ImplicitRegisterUse::kWriteAccumulator) ==
ImplicitRegisterUse::kWriteAccumulator;
} }
// Returns true if |operand_type| is a scalable signed byte. // Returns true if |operand_type| is a scalable signed byte.
......
...@@ -65,7 +65,7 @@ class V8_EXPORT_PRIVATE BytecodeRegisterOptimizer final ...@@ -65,7 +65,7 @@ class V8_EXPORT_PRIVATE BytecodeRegisterOptimizer final
bool EnsureAllRegistersAreFlushed() const; bool EnsureAllRegistersAreFlushed() const;
// Prepares for |bytecode|. // Prepares for |bytecode|.
template <Bytecode bytecode, AccumulatorUse accumulator_use> template <Bytecode bytecode, ImplicitRegisterUse implicit_register_use>
V8_INLINE void PrepareForBytecode() { V8_INLINE void PrepareForBytecode() {
if (Bytecodes::IsJump(bytecode) || Bytecodes::IsSwitch(bytecode) || if (Bytecodes::IsJump(bytecode) || Bytecodes::IsSwitch(bytecode) ||
bytecode == Bytecode::kDebugger || bytecode == Bytecode::kDebugger ||
...@@ -85,13 +85,13 @@ class V8_EXPORT_PRIVATE BytecodeRegisterOptimizer final ...@@ -85,13 +85,13 @@ class V8_EXPORT_PRIVATE BytecodeRegisterOptimizer final
// Materialize the accumulator if it is read by the bytecode. The // Materialize the accumulator if it is read by the bytecode. The
// accumulator is special and no other register can be materialized // accumulator is special and no other register can be materialized
// in it's place. // in it's place.
if (BytecodeOperands::ReadsAccumulator(accumulator_use)) { if (BytecodeOperands::ReadsAccumulator(implicit_register_use)) {
Materialize(accumulator_info_); Materialize(accumulator_info_);
} }
// Materialize an equivalent to the accumulator if it will be // Materialize an equivalent to the accumulator if it will be
// clobbered when the bytecode is dispatched. // clobbered when the bytecode is dispatched.
if (BytecodeOperands::WritesAccumulator(accumulator_use)) { if (BytecodeOperands::WritesAccumulator(implicit_register_use)) {
PrepareOutputRegister(accumulator_); PrepareOutputRegister(accumulator_);
} }
} }
......
...@@ -76,7 +76,7 @@ struct SumHelper<value, values...> { ...@@ -76,7 +76,7 @@ struct SumHelper<value, values...> {
static const int kValue = value + SumHelper<values...>::kValue; static const int kValue = value + SumHelper<values...>::kValue;
}; };
template <AccumulatorUse accumulator_use, OperandType... operands> template <ImplicitRegisterUse implicit_register_use, OperandType... operands>
struct BytecodeTraits { struct BytecodeTraits {
static const OperandType kOperandTypes[]; static const OperandType kOperandTypes[];
static const OperandTypeInfo kOperandTypeInfos[]; static const OperandTypeInfo kOperandTypeInfos[];
...@@ -89,33 +89,33 @@ struct BytecodeTraits { ...@@ -89,33 +89,33 @@ struct BytecodeTraits {
1, OperandScaler<operands, OperandScale::kDouble>::kSize...>::kValue; 1, OperandScaler<operands, OperandScale::kDouble>::kSize...>::kValue;
static const int kQuadrupleScaleSize = SumHelper< static const int kQuadrupleScaleSize = SumHelper<
1, OperandScaler<operands, OperandScale::kQuadruple>::kSize...>::kValue; 1, OperandScaler<operands, OperandScale::kQuadruple>::kSize...>::kValue;
static const AccumulatorUse kAccumulatorUse = accumulator_use; static const ImplicitRegisterUse kImplicitRegisterUse = implicit_register_use;
static const int kOperandCount = sizeof...(operands); static const int kOperandCount = sizeof...(operands);
}; };
template <AccumulatorUse accumulator_use, OperandType... operands> template <ImplicitRegisterUse implicit_register_use, OperandType... operands>
STATIC_CONST_MEMBER_DEFINITION const OperandType STATIC_CONST_MEMBER_DEFINITION const OperandType
BytecodeTraits<accumulator_use, operands...>::kOperandTypes[] = { BytecodeTraits<implicit_register_use, operands...>::kOperandTypes[] = {
operands...}; operands...};
template <AccumulatorUse accumulator_use, OperandType... operands> template <ImplicitRegisterUse implicit_register_use, OperandType... operands>
STATIC_CONST_MEMBER_DEFINITION const OperandTypeInfo STATIC_CONST_MEMBER_DEFINITION const OperandTypeInfo
BytecodeTraits<accumulator_use, operands...>::kOperandTypeInfos[] = { BytecodeTraits<implicit_register_use, operands...>::kOperandTypeInfos[] = {
OperandTraits<operands>::kOperandTypeInfo...}; OperandTraits<operands>::kOperandTypeInfo...};
template <AccumulatorUse accumulator_use, OperandType... operands> template <ImplicitRegisterUse implicit_register_use, OperandType... operands>
STATIC_CONST_MEMBER_DEFINITION const OperandSize STATIC_CONST_MEMBER_DEFINITION const OperandSize BytecodeTraits<
BytecodeTraits<accumulator_use, operands...>::kSingleScaleOperandSizes[] = { implicit_register_use, operands...>::kSingleScaleOperandSizes[] = {
OperandScaler<operands, OperandScale::kSingle>::kOperandSize...}; OperandScaler<operands, OperandScale::kSingle>::kOperandSize...};
template <AccumulatorUse accumulator_use, OperandType... operands> template <ImplicitRegisterUse implicit_register_use, OperandType... operands>
STATIC_CONST_MEMBER_DEFINITION const OperandSize STATIC_CONST_MEMBER_DEFINITION const OperandSize BytecodeTraits<
BytecodeTraits<accumulator_use, operands...>::kDoubleScaleOperandSizes[] = { implicit_register_use, operands...>::kDoubleScaleOperandSizes[] = {
OperandScaler<operands, OperandScale::kDouble>::kOperandSize...}; OperandScaler<operands, OperandScale::kDouble>::kOperandSize...};
template <AccumulatorUse accumulator_use, OperandType... operands> template <ImplicitRegisterUse implicit_register_use, OperandType... operands>
STATIC_CONST_MEMBER_DEFINITION const OperandSize BytecodeTraits< STATIC_CONST_MEMBER_DEFINITION const OperandSize BytecodeTraits<
accumulator_use, operands...>::kQuadrupleScaleOperandSizes[] = { implicit_register_use, operands...>::kQuadrupleScaleOperandSizes[] = {
OperandScaler<operands, OperandScale::kQuadruple>::kOperandSize...}; OperandScaler<operands, OperandScale::kQuadruple>::kOperandSize...};
template <AccumulatorUse accumulator_use> template <ImplicitRegisterUse implicit_register_use>
struct BytecodeTraits<accumulator_use> { struct BytecodeTraits<implicit_register_use> {
static const OperandType kOperandTypes[]; static const OperandType kOperandTypes[];
static const OperandTypeInfo kOperandTypeInfos[]; static const OperandTypeInfo kOperandTypeInfos[];
static const OperandSize kSingleScaleOperandSizes[]; static const OperandSize kSingleScaleOperandSizes[];
...@@ -124,28 +124,29 @@ struct BytecodeTraits<accumulator_use> { ...@@ -124,28 +124,29 @@ struct BytecodeTraits<accumulator_use> {
static const int kSingleScaleSize = 1; static const int kSingleScaleSize = 1;
static const int kDoubleScaleSize = 1; static const int kDoubleScaleSize = 1;
static const int kQuadrupleScaleSize = 1; static const int kQuadrupleScaleSize = 1;
static const AccumulatorUse kAccumulatorUse = accumulator_use; static const ImplicitRegisterUse kImplicitRegisterUse = implicit_register_use;
static const int kOperandCount = 0; static const int kOperandCount = 0;
}; };
template <AccumulatorUse accumulator_use> template <ImplicitRegisterUse implicit_register_use>
STATIC_CONST_MEMBER_DEFINITION const OperandType STATIC_CONST_MEMBER_DEFINITION const OperandType
BytecodeTraits<accumulator_use>::kOperandTypes[] = {OperandType::kNone}; BytecodeTraits<implicit_register_use>::kOperandTypes[] = {
template <AccumulatorUse accumulator_use> OperandType::kNone};
template <ImplicitRegisterUse implicit_register_use>
STATIC_CONST_MEMBER_DEFINITION const OperandTypeInfo STATIC_CONST_MEMBER_DEFINITION const OperandTypeInfo
BytecodeTraits<accumulator_use>::kOperandTypeInfos[] = { BytecodeTraits<implicit_register_use>::kOperandTypeInfos[] = {
OperandTypeInfo::kNone}; OperandTypeInfo::kNone};
template <AccumulatorUse accumulator_use> template <ImplicitRegisterUse implicit_register_use>
STATIC_CONST_MEMBER_DEFINITION const OperandSize STATIC_CONST_MEMBER_DEFINITION const OperandSize
BytecodeTraits<accumulator_use>::kSingleScaleOperandSizes[] = { BytecodeTraits<implicit_register_use>::kSingleScaleOperandSizes[] = {
OperandSize::kNone}; OperandSize::kNone};
template <AccumulatorUse accumulator_use> template <ImplicitRegisterUse implicit_register_use>
STATIC_CONST_MEMBER_DEFINITION const OperandSize STATIC_CONST_MEMBER_DEFINITION const OperandSize
BytecodeTraits<accumulator_use>::kDoubleScaleOperandSizes[] = { BytecodeTraits<implicit_register_use>::kDoubleScaleOperandSizes[] = {
OperandSize::kNone}; OperandSize::kNone};
template <AccumulatorUse accumulator_use> template <ImplicitRegisterUse implicit_register_use>
STATIC_CONST_MEMBER_DEFINITION const OperandSize STATIC_CONST_MEMBER_DEFINITION const OperandSize
BytecodeTraits<accumulator_use>::kQuadrupleScaleOperandSizes[] = { BytecodeTraits<implicit_register_use>::kQuadrupleScaleOperandSizes[] = {
OperandSize::kNone}; OperandSize::kNone};
} // namespace interpreter } // namespace interpreter
......
...@@ -32,8 +32,8 @@ const int Bytecodes::kOperandCount[] = { ...@@ -32,8 +32,8 @@ const int Bytecodes::kOperandCount[] = {
#undef ENTRY #undef ENTRY
}; };
const AccumulatorUse Bytecodes::kAccumulatorUse[] = { const ImplicitRegisterUse Bytecodes::kImplicitRegisterUse[] = {
#define ENTRY(Name, ...) BytecodeTraits<__VA_ARGS__>::kAccumulatorUse, #define ENTRY(Name, ...) BytecodeTraits<__VA_ARGS__>::kImplicitRegisterUse,
BYTECODE_LIST(ENTRY) BYTECODE_LIST(ENTRY)
#undef ENTRY #undef ENTRY
}; };
......
This diff is collapsed.
...@@ -42,7 +42,7 @@ InterpreterAssembler::InterpreterAssembler(CodeAssemblerState* state, ...@@ -42,7 +42,7 @@ InterpreterAssembler::InterpreterAssembler(CodeAssemblerState* state,
TVARIABLE_CONSTRUCTOR( TVARIABLE_CONSTRUCTOR(
accumulator_, accumulator_,
Parameter<Object>(InterpreterDispatchDescriptor::kAccumulator)), Parameter<Object>(InterpreterDispatchDescriptor::kAccumulator)),
accumulator_use_(AccumulatorUse::kNone), implicit_register_use_(ImplicitRegisterUse::kNone),
made_call_(false), made_call_(false),
reloaded_frame_ptr_(false), reloaded_frame_ptr_(false),
bytecode_array_valid_(true) { bytecode_array_valid_(true) {
...@@ -64,7 +64,8 @@ InterpreterAssembler::~InterpreterAssembler() { ...@@ -64,7 +64,8 @@ InterpreterAssembler::~InterpreterAssembler() {
// If the following check fails the handler does not use the // If the following check fails the handler does not use the
// accumulator in the way described in the bytecode definitions in // accumulator in the way described in the bytecode definitions in
// bytecodes.h. // bytecodes.h.
DCHECK_EQ(accumulator_use_, Bytecodes::GetAccumulatorUse(bytecode_)); DCHECK_EQ(implicit_register_use_,
Bytecodes::GetImplicitRegisterUse(bytecode_));
UnregisterCallGenerationCallbacks(); UnregisterCallGenerationCallbacks();
} }
...@@ -154,13 +155,15 @@ TNode<Object> InterpreterAssembler::GetAccumulatorUnchecked() { ...@@ -154,13 +155,15 @@ TNode<Object> InterpreterAssembler::GetAccumulatorUnchecked() {
TNode<Object> InterpreterAssembler::GetAccumulator() { TNode<Object> InterpreterAssembler::GetAccumulator() {
DCHECK(Bytecodes::ReadsAccumulator(bytecode_)); DCHECK(Bytecodes::ReadsAccumulator(bytecode_));
accumulator_use_ = accumulator_use_ | AccumulatorUse::kRead; implicit_register_use_ =
implicit_register_use_ | ImplicitRegisterUse::kReadAccumulator;
return TaggedPoisonOnSpeculation(GetAccumulatorUnchecked()); return TaggedPoisonOnSpeculation(GetAccumulatorUnchecked());
} }
void InterpreterAssembler::SetAccumulator(TNode<Object> value) { void InterpreterAssembler::SetAccumulator(TNode<Object> value) {
DCHECK(Bytecodes::WritesAccumulator(bytecode_)); DCHECK(Bytecodes::WritesAccumulator(bytecode_));
accumulator_use_ = accumulator_use_ | AccumulatorUse::kWrite; implicit_register_use_ =
implicit_register_use_ | ImplicitRegisterUse::kWriteAccumulator;
accumulator_ = value; accumulator_ = value;
} }
...@@ -754,7 +757,8 @@ void InterpreterAssembler::CallJSAndDispatch( ...@@ -754,7 +757,8 @@ void InterpreterAssembler::CallJSAndDispatch(
args_count, args.base_reg_location(), args_count, args.base_reg_location(),
function); function);
// TailCallStubThenDispatch updates accumulator with result. // TailCallStubThenDispatch updates accumulator with result.
accumulator_use_ = accumulator_use_ | AccumulatorUse::kWrite; implicit_register_use_ =
implicit_register_use_ | ImplicitRegisterUse::kWriteAccumulator;
} }
template <class... TArgs> template <class... TArgs>
...@@ -780,7 +784,8 @@ void InterpreterAssembler::CallJSAndDispatch(TNode<Object> function, ...@@ -780,7 +784,8 @@ void InterpreterAssembler::CallJSAndDispatch(TNode<Object> function,
context, function, arg_count, args...); context, function, arg_count, args...);
} }
// TailCallStubThenDispatch updates accumulator with result. // TailCallStubThenDispatch updates accumulator with result.
accumulator_use_ = accumulator_use_ | AccumulatorUse::kWrite; implicit_register_use_ =
implicit_register_use_ | ImplicitRegisterUse::kWriteAccumulator;
} }
// Instantiate CallJSAndDispatch() for argument counts used by interpreter // Instantiate CallJSAndDispatch() for argument counts used by interpreter
...@@ -817,7 +822,8 @@ void InterpreterAssembler::CallJSWithSpreadAndDispatch( ...@@ -817,7 +822,8 @@ void InterpreterAssembler::CallJSWithSpreadAndDispatch(
args_count, args.base_reg_location(), args_count, args.base_reg_location(),
function); function);
// TailCallStubThenDispatch updates accumulator with result. // TailCallStubThenDispatch updates accumulator with result.
accumulator_use_ = accumulator_use_ | AccumulatorUse::kWrite; implicit_register_use_ =
implicit_register_use_ | ImplicitRegisterUse::kWriteAccumulator;
} }
TNode<Object> InterpreterAssembler::Construct( TNode<Object> InterpreterAssembler::Construct(
...@@ -1158,10 +1164,10 @@ TNode<WordT> InterpreterAssembler::StarDispatchLookahead( ...@@ -1158,10 +1164,10 @@ TNode<WordT> InterpreterAssembler::StarDispatchLookahead(
void InterpreterAssembler::InlineStar() { void InterpreterAssembler::InlineStar() {
Bytecode previous_bytecode = bytecode_; Bytecode previous_bytecode = bytecode_;
AccumulatorUse previous_acc_use = accumulator_use_; ImplicitRegisterUse previous_acc_use = implicit_register_use_;
bytecode_ = Bytecode::kStar; bytecode_ = Bytecode::kStar;
accumulator_use_ = AccumulatorUse::kNone; implicit_register_use_ = ImplicitRegisterUse::kNone;
#ifdef V8_TRACE_IGNITION #ifdef V8_TRACE_IGNITION
TraceBytecode(Runtime::kInterpreterTraceBytecodeEntry); TraceBytecode(Runtime::kInterpreterTraceBytecodeEntry);
...@@ -1169,11 +1175,12 @@ void InterpreterAssembler::InlineStar() { ...@@ -1169,11 +1175,12 @@ void InterpreterAssembler::InlineStar() {
StoreRegister(GetAccumulator(), StoreRegister(GetAccumulator(),
BytecodeOperandReg(0, LoadSensitivity::kSafe)); BytecodeOperandReg(0, LoadSensitivity::kSafe));
DCHECK_EQ(accumulator_use_, Bytecodes::GetAccumulatorUse(bytecode_)); DCHECK_EQ(implicit_register_use_,
Bytecodes::GetImplicitRegisterUse(bytecode_));
Advance(); Advance();
bytecode_ = previous_bytecode; bytecode_ = previous_bytecode;
accumulator_use_ = previous_acc_use; implicit_register_use_ = previous_acc_use;
} }
void InterpreterAssembler::Dispatch() { void InterpreterAssembler::Dispatch() {
......
...@@ -398,7 +398,7 @@ class V8_EXPORT_PRIVATE InterpreterAssembler : public CodeStubAssembler { ...@@ -398,7 +398,7 @@ class V8_EXPORT_PRIVATE InterpreterAssembler : public CodeStubAssembler {
CodeStubAssembler::TVariable<IntPtrT> bytecode_offset_; CodeStubAssembler::TVariable<IntPtrT> bytecode_offset_;
CodeStubAssembler::TVariable<ExternalReference> dispatch_table_; CodeStubAssembler::TVariable<ExternalReference> dispatch_table_;
CodeStubAssembler::TVariable<Object> accumulator_; CodeStubAssembler::TVariable<Object> accumulator_;
AccumulatorUse accumulator_use_; ImplicitRegisterUse implicit_register_use_;
bool made_call_; bool made_call_;
bool reloaded_frame_ptr_; bool reloaded_frame_ptr_;
bool bytecode_array_valid_; bool bytecode_array_valid_;
......
...@@ -81,7 +81,8 @@ TEST_F(BytecodeRegisterOptimizerTest, TemporaryMaterializedForJump) { ...@@ -81,7 +81,8 @@ TEST_F(BytecodeRegisterOptimizerTest, TemporaryMaterializedForJump) {
Register temp = NewTemporary(); Register temp = NewTemporary();
optimizer()->DoStar(temp); optimizer()->DoStar(temp);
CHECK_EQ(write_count(), 0u); CHECK_EQ(write_count(), 0u);
optimizer()->PrepareForBytecode<Bytecode::kJump, AccumulatorUse::kNone>(); optimizer()
->PrepareForBytecode<Bytecode::kJump, ImplicitRegisterUse::kNone>();
CHECK_EQ(write_count(), 1u); CHECK_EQ(write_count(), 1u);
CHECK_EQ(output()->at(0).bytecode, Bytecode::kStar); CHECK_EQ(output()->at(0).bytecode, Bytecode::kStar);
CHECK_EQ(output()->at(0).output.index(), temp.index()); CHECK_EQ(output()->at(0).output.index(), temp.index());
...@@ -98,19 +99,25 @@ TEST_F(BytecodeRegisterOptimizerTest, TemporaryNotEmitted) { ...@@ -98,19 +99,25 @@ TEST_F(BytecodeRegisterOptimizerTest, TemporaryNotEmitted) {
optimizer()->DoStar(temp); optimizer()->DoStar(temp);
ReleaseTemporaries(temp); ReleaseTemporaries(temp);
CHECK_EQ(write_count(), 0u); CHECK_EQ(write_count(), 0u);
optimizer()->PrepareForBytecode<Bytecode::kReturn, AccumulatorUse::kRead>(); optimizer()
->PrepareForBytecode<Bytecode::kReturn,
ImplicitRegisterUse::kReadAccumulator>();
CHECK_EQ(output()->at(0).bytecode, Bytecode::kLdar); CHECK_EQ(output()->at(0).bytecode, Bytecode::kLdar);
CHECK_EQ(output()->at(0).input.index(), parameter.index()); CHECK_EQ(output()->at(0).input.index(), parameter.index());
} }
TEST_F(BytecodeRegisterOptimizerTest, ReleasedRegisterUsed) { TEST_F(BytecodeRegisterOptimizerTest, ReleasedRegisterUsed) {
Initialize(3, 1); Initialize(3, 1);
optimizer()->PrepareForBytecode<Bytecode::kLdaSmi, AccumulatorUse::kWrite>(); optimizer()
->PrepareForBytecode<Bytecode::kLdaSmi,
ImplicitRegisterUse::kWriteAccumulator>();
Register temp0 = NewTemporary(); Register temp0 = NewTemporary();
Register temp1 = NewTemporary(); Register temp1 = NewTemporary();
optimizer()->DoStar(temp1); optimizer()->DoStar(temp1);
CHECK_EQ(write_count(), 0u); CHECK_EQ(write_count(), 0u);
optimizer()->PrepareForBytecode<Bytecode::kLdaSmi, AccumulatorUse::kWrite>(); optimizer()
->PrepareForBytecode<Bytecode::kLdaSmi,
ImplicitRegisterUse::kWriteAccumulator>();
CHECK_EQ(write_count(), 1u); CHECK_EQ(write_count(), 1u);
CHECK_EQ(output()->at(0).bytecode, Bytecode::kStar); CHECK_EQ(output()->at(0).bytecode, Bytecode::kStar);
CHECK_EQ(output()->at(0).output.index(), temp1.index()); CHECK_EQ(output()->at(0).output.index(), temp1.index());
...@@ -120,7 +127,9 @@ TEST_F(BytecodeRegisterOptimizerTest, ReleasedRegisterUsed) { ...@@ -120,7 +127,9 @@ TEST_F(BytecodeRegisterOptimizerTest, ReleasedRegisterUsed) {
CHECK_EQ(write_count(), 1u); CHECK_EQ(write_count(), 1u);
optimizer()->DoLdar(temp0); optimizer()->DoLdar(temp0);
CHECK_EQ(write_count(), 1u); CHECK_EQ(write_count(), 1u);
optimizer()->PrepareForBytecode<Bytecode::kReturn, AccumulatorUse::kRead>(); optimizer()
->PrepareForBytecode<Bytecode::kReturn,
ImplicitRegisterUse::kReadAccumulator>();
CHECK_EQ(write_count(), 2u); CHECK_EQ(write_count(), 2u);
CHECK_EQ(output()->at(1).bytecode, Bytecode::kLdar); CHECK_EQ(output()->at(1).bytecode, Bytecode::kLdar);
CHECK_EQ(output()->at(1).input.index(), temp1.index()); CHECK_EQ(output()->at(1).input.index(), temp1.index());
...@@ -128,7 +137,9 @@ TEST_F(BytecodeRegisterOptimizerTest, ReleasedRegisterUsed) { ...@@ -128,7 +137,9 @@ TEST_F(BytecodeRegisterOptimizerTest, ReleasedRegisterUsed) {
TEST_F(BytecodeRegisterOptimizerTest, ReleasedRegisterNotFlushed) { TEST_F(BytecodeRegisterOptimizerTest, ReleasedRegisterNotFlushed) {
Initialize(3, 1); Initialize(3, 1);
optimizer()->PrepareForBytecode<Bytecode::kLdaSmi, AccumulatorUse::kWrite>(); optimizer()
->PrepareForBytecode<Bytecode::kLdaSmi,
ImplicitRegisterUse::kWriteAccumulator>();
Register temp0 = NewTemporary(); Register temp0 = NewTemporary();
Register temp1 = NewTemporary(); Register temp1 = NewTemporary();
optimizer()->DoStar(temp0); optimizer()->DoStar(temp0);
...@@ -154,7 +165,9 @@ TEST_F(BytecodeRegisterOptimizerTest, StoresToLocalsImmediate) { ...@@ -154,7 +165,9 @@ TEST_F(BytecodeRegisterOptimizerTest, StoresToLocalsImmediate) {
CHECK_EQ(output()->at(0).input.index(), parameter.index()); CHECK_EQ(output()->at(0).input.index(), parameter.index());
CHECK_EQ(output()->at(0).output.index(), local.index()); CHECK_EQ(output()->at(0).output.index(), local.index());
optimizer()->PrepareForBytecode<Bytecode::kReturn, AccumulatorUse::kRead>(); optimizer()
->PrepareForBytecode<Bytecode::kReturn,
ImplicitRegisterUse::kReadAccumulator>();
CHECK_EQ(write_count(), 2u); CHECK_EQ(write_count(), 2u);
CHECK_EQ(output()->at(1).bytecode, Bytecode::kLdar); CHECK_EQ(output()->at(1).bytecode, Bytecode::kLdar);
CHECK_EQ(output()->at(1).input.index(), local.index()); CHECK_EQ(output()->at(1).input.index(), local.index());
...@@ -183,13 +196,16 @@ TEST_F(BytecodeRegisterOptimizerTest, RangeOfTemporariesMaterializedForInput) { ...@@ -183,13 +196,16 @@ TEST_F(BytecodeRegisterOptimizerTest, RangeOfTemporariesMaterializedForInput) {
Register parameter = Register::FromParameterIndex(1, 3); Register parameter = Register::FromParameterIndex(1, 3);
Register temp0 = NewTemporary(); Register temp0 = NewTemporary();
Register temp1 = NewTemporary(); Register temp1 = NewTemporary();
optimizer()->PrepareForBytecode<Bytecode::kLdaSmi, AccumulatorUse::kWrite>(); optimizer()
->PrepareForBytecode<Bytecode::kLdaSmi,
ImplicitRegisterUse::kWriteAccumulator>();
optimizer()->DoStar(temp0); optimizer()->DoStar(temp0);
optimizer()->DoMov(parameter, temp1); optimizer()->DoMov(parameter, temp1);
CHECK_EQ(write_count(), 0u); CHECK_EQ(write_count(), 0u);
optimizer() optimizer()
->PrepareForBytecode<Bytecode::kCallJSRuntime, AccumulatorUse::kWrite>(); ->PrepareForBytecode<Bytecode::kCallJSRuntime,
ImplicitRegisterUse::kWriteAccumulator>();
RegisterList reg_list = optimizer()->GetInputRegisterList( RegisterList reg_list = optimizer()->GetInputRegisterList(
BytecodeUtils::NewRegisterList(temp0.index(), 2)); BytecodeUtils::NewRegisterList(temp0.index(), 2));
CHECK_EQ(temp0.index(), reg_list.first_register().index()); CHECK_EQ(temp0.index(), reg_list.first_register().index());
......
...@@ -333,30 +333,33 @@ TEST(OperandScale, PrefixesRequired) { ...@@ -333,30 +333,33 @@ TEST(OperandScale, PrefixesRequired) {
Bytecode::kExtraWide); Bytecode::kExtraWide);
} }
TEST(AccumulatorUse, LogicalOperators) { TEST(ImplicitRegisterUse, LogicalOperators) {
CHECK_EQ(AccumulatorUse::kNone | AccumulatorUse::kRead, CHECK_EQ(ImplicitRegisterUse::kNone | ImplicitRegisterUse::kReadAccumulator,
AccumulatorUse::kRead); ImplicitRegisterUse::kReadAccumulator);
CHECK_EQ(AccumulatorUse::kRead | AccumulatorUse::kWrite, CHECK_EQ(ImplicitRegisterUse::kReadAccumulator |
AccumulatorUse::kReadWrite); ImplicitRegisterUse::kWriteAccumulator,
CHECK_EQ(AccumulatorUse::kRead & AccumulatorUse::kReadWrite, ImplicitRegisterUse::kReadWriteAccumulator);
AccumulatorUse::kRead); CHECK_EQ(ImplicitRegisterUse::kReadAccumulator &
CHECK_EQ(AccumulatorUse::kRead & AccumulatorUse::kWrite, ImplicitRegisterUse::kReadWriteAccumulator,
AccumulatorUse::kNone); ImplicitRegisterUse::kReadAccumulator);
CHECK_EQ(ImplicitRegisterUse::kReadAccumulator &
ImplicitRegisterUse::kWriteAccumulator,
ImplicitRegisterUse::kNone);
} }
TEST(AccumulatorUse, SampleBytecodes) { TEST(ImplicitRegisterUse, SampleBytecodes) {
CHECK(Bytecodes::ReadsAccumulator(Bytecode::kStar)); CHECK(Bytecodes::ReadsAccumulator(Bytecode::kStar));
CHECK(!Bytecodes::WritesAccumulator(Bytecode::kStar)); CHECK(!Bytecodes::WritesAccumulator(Bytecode::kStar));
CHECK_EQ(Bytecodes::GetAccumulatorUse(Bytecode::kStar), CHECK_EQ(Bytecodes::GetImplicitRegisterUse(Bytecode::kStar),
AccumulatorUse::kRead); ImplicitRegisterUse::kReadAccumulator);
CHECK(!Bytecodes::ReadsAccumulator(Bytecode::kLdar)); CHECK(!Bytecodes::ReadsAccumulator(Bytecode::kLdar));
CHECK(Bytecodes::WritesAccumulator(Bytecode::kLdar)); CHECK(Bytecodes::WritesAccumulator(Bytecode::kLdar));
CHECK_EQ(Bytecodes::GetAccumulatorUse(Bytecode::kLdar), CHECK_EQ(Bytecodes::GetImplicitRegisterUse(Bytecode::kLdar),
AccumulatorUse::kWrite); ImplicitRegisterUse::kWriteAccumulator);
CHECK(Bytecodes::ReadsAccumulator(Bytecode::kAdd)); CHECK(Bytecodes::ReadsAccumulator(Bytecode::kAdd));
CHECK(Bytecodes::WritesAccumulator(Bytecode::kAdd)); CHECK(Bytecodes::WritesAccumulator(Bytecode::kAdd));
CHECK_EQ(Bytecodes::GetAccumulatorUse(Bytecode::kAdd), CHECK_EQ(Bytecodes::GetImplicitRegisterUse(Bytecode::kAdd),
AccumulatorUse::kReadWrite); ImplicitRegisterUse::kReadWriteAccumulator);
} }
} // namespace interpreter } // namespace interpreter
......
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