Commit cda8387c authored by rmcilroy's avatar rmcilroy Committed by Commit bot

[Interpreter] Remove LdaConstant+ToName peephole optimization.

This optimization required access to the heap which we can't do off-thread.
There doesn't seem to be a regression without this optmization in anycase,
so just rip it out.

BUG=v8:5203

Review-Url: https://codereview.chromium.org/2238853002
Cr-Commit-Position: refs/heads/master@{#38585}
parent d27d2938
......@@ -43,8 +43,7 @@ BytecodeArrayBuilder::BytecodeArrayBuilder(
}
if (FLAG_ignition_peephole) {
pipeline_ = new (zone)
BytecodePeepholeOptimizer(&constant_array_builder_, pipeline_);
pipeline_ = new (zone) BytecodePeepholeOptimizer(pipeline_);
}
if (FLAG_ignition_reo) {
......
......@@ -4,7 +4,6 @@
#include "src/interpreter/bytecode-peephole-optimizer.h"
#include "src/interpreter/constant-array-builder.h"
#include "src/objects-inl.h"
#include "src/objects.h"
......@@ -13,9 +12,8 @@ namespace internal {
namespace interpreter {
BytecodePeepholeOptimizer::BytecodePeepholeOptimizer(
ConstantArrayBuilder* constant_array_builder,
BytecodePipelineStage* next_stage)
: constant_array_builder_(constant_array_builder), next_stage_(next_stage) {
: next_stage_(next_stage) {
InvalidateLast();
}
......@@ -83,14 +81,6 @@ void BytecodePeepholeOptimizer::SetLast(const BytecodeNode* const node) {
last_.Clone(node);
}
Handle<Object> BytecodePeepholeOptimizer::GetConstantForIndexOperand(
const BytecodeNode* const node, int index) const {
DCHECK_LE(index, node->operand_count());
DCHECK_EQ(Bytecodes::GetOperandType(node->bytecode(), 0), OperandType::kIdx);
uint32_t index_operand = node->operand(0);
return constant_array_builder_->At(index_operand);
}
bool BytecodePeepholeOptimizer::CanElideLastBasedOnSourcePosition(
const BytecodeNode* const current) const {
//
......@@ -289,19 +279,6 @@ void BytecodePeepholeOptimizer::
}
}
void BytecodePeepholeOptimizer::TransformToStarIfLoadingNameConstantAction(
BytecodeNode* const node, const PeepholeActionAndData* action_data) {
DCHECK_EQ(last()->bytecode(), Bytecode::kLdaConstant);
DCHECK(!Bytecodes::IsJump(node->bytecode()));
// TODO(5203): Remove this temporary exception.
AllowHandleDereference allow_deref;
if (GetConstantForIndexOperand(last(), 0)->IsName()) {
node->replace_bytecode(Bytecode::kStar);
}
DefaultAction(node);
}
void BytecodePeepholeOptimizer::DefaultJumpAction(
BytecodeNode* const node, const PeepholeActionAndData* action_data) {
DCHECK(LastIsValid());
......
......@@ -12,7 +12,6 @@ namespace v8 {
namespace internal {
namespace interpreter {
class ConstantArrayBuilder;
class BytecodePeepholeActionAndData;
// An optimization stage for performing peephole optimizations on
......@@ -21,8 +20,7 @@ class BytecodePeepholeActionAndData;
class BytecodePeepholeOptimizer final : public BytecodePipelineStage,
public ZoneObject {
public:
BytecodePeepholeOptimizer(ConstantArrayBuilder* constant_array_builder,
BytecodePipelineStage* next_stage);
explicit BytecodePeepholeOptimizer(BytecodePipelineStage* next_stage);
// BytecodePipelineStage interface.
void Write(BytecodeNode* node) override;
......@@ -48,13 +46,9 @@ class BytecodePeepholeOptimizer final : public BytecodePipelineStage,
bool LastIsValid() const;
void SetLast(const BytecodeNode* const node);
Handle<Object> GetConstantForIndexOperand(const BytecodeNode* const node,
int index) const;
BytecodePipelineStage* next_stage() const { return next_stage_; }
BytecodeNode* last() { return &last_; }
ConstantArrayBuilder* constant_array_builder_;
BytecodePipelineStage* next_stage_;
BytecodeNode last_;
......
......@@ -11,18 +11,17 @@ namespace v8 {
namespace internal {
namespace interpreter {
#define PEEPHOLE_NON_JUMP_ACTION_LIST(V) \
V(DefaultAction) \
V(UpdateLastAction) \
V(UpdateLastIfSourceInfoPresentAction) \
V(ElideCurrentAction) \
V(ElideCurrentIfOperand0MatchesAction) \
V(ElideLastAction) \
V(ChangeBytecodeAction) \
V(TransformLdaStarToLdrLdarAction) \
V(TransformLdaSmiBinaryOpToBinaryOpWithSmiAction) \
V(TransformLdaZeroBinaryOpToBinaryOpWithZeroAction) \
V(TransformToStarIfLoadingNameConstantAction)
#define PEEPHOLE_NON_JUMP_ACTION_LIST(V) \
V(DefaultAction) \
V(UpdateLastAction) \
V(UpdateLastIfSourceInfoPresentAction) \
V(ElideCurrentAction) \
V(ElideCurrentIfOperand0MatchesAction) \
V(ElideLastAction) \
V(ChangeBytecodeAction) \
V(TransformLdaStarToLdrLdarAction) \
V(TransformLdaSmiBinaryOpToBinaryOpWithSmiAction) \
V(TransformLdaZeroBinaryOpToBinaryOpWithZeroAction)
#define PEEPHOLE_JUMP_ACTION_LIST(V) \
V(DefaultJumpAction) \
......
......@@ -108,13 +108,8 @@ PeepholeActionAndData PeepholeActionTableWriter::LookupActionAndData(
// ToName bytecodes can be replaced by Star with the same output register if
// the value in the accumulator is already a name.
if (current == Bytecode::kToName) {
if (last == Bytecode::kLdaConstant) {
return {PeepholeAction::kTransformToStarIfLoadingNameConstantAction,
Bytecode::kIllegal};
} else if (Bytecodes::PutsNameInAccumulator(last)) {
return {PeepholeAction::kChangeBytecodeAction, Bytecode::kStar};
}
if (current == Bytecode::kToName && Bytecodes::PutsNameInAccumulator(last)) {
return {PeepholeAction::kChangeBytecodeAction, Bytecode::kStar};
}
// Nop are placeholders for holding source position information and can be
......
......@@ -35,7 +35,7 @@ bytecodes: [
B(Star), R(3),
B(LdrNamedProperty), R(3), U8(1), U8(1), R(4),
B(LdaConstant), U8(2),
B(Star), R(6),
B(ToName), R(6),
B(CreateClosure), U8(3), U8(2),
B(Star), R(7),
B(LdaSmi), U8(2),
......@@ -88,7 +88,7 @@ bytecodes: [
B(Star), R(3),
B(LdrNamedProperty), R(3), U8(1), U8(1), R(4),
B(LdaConstant), U8(2),
B(Star), R(6),
B(ToName), R(6),
B(CreateClosure), U8(3), U8(2),
B(Star), R(7),
B(LdaSmi), U8(2),
......
......@@ -404,7 +404,7 @@ bytecodes: [
B(Mov), R(1), R(2),
B(CallRuntime), U16(Runtime::kDefineDataPropertyInLiteral), R(2), U8(5),
B(LdaConstant), U8(3),
B(Star), R(3),
B(ToName), R(3),
B(CreateClosure), U8(4), U8(2),
B(Star), R(4),
B(LdaZero),
......@@ -412,7 +412,7 @@ bytecodes: [
B(Mov), R(1), R(2),
B(CallRuntime), U16(Runtime::kDefineGetterPropertyUnchecked), R(2), U8(4),
B(LdaConstant), U8(3),
B(Star), R(3),
B(ToName), R(3),
B(CreateClosure), U8(5), U8(2),
B(Star), R(4),
B(LdaZero),
......
......@@ -7,7 +7,6 @@
#include "src/factory.h"
#include "src/interpreter/bytecode-label.h"
#include "src/interpreter/bytecode-peephole-optimizer.h"
#include "src/interpreter/constant-array-builder.h"
#include "src/objects-inl.h"
#include "src/objects.h"
#include "test/unittests/test-utils.h"
......@@ -19,9 +18,7 @@ namespace interpreter {
class BytecodePeepholeOptimizerTest : public BytecodePipelineStage,
public TestWithIsolateAndZone {
public:
BytecodePeepholeOptimizerTest()
: constant_array_builder_(isolate(), zone()),
peephole_optimizer_(&constant_array_builder_, this) {}
BytecodePeepholeOptimizerTest() : peephole_optimizer_(this) {}
~BytecodePeepholeOptimizerTest() override {}
void Reset() {
......@@ -52,13 +49,11 @@ class BytecodePeepholeOptimizerTest : public BytecodePipelineStage,
}
BytecodePeepholeOptimizer* optimizer() { return &peephole_optimizer_; }
ConstantArrayBuilder* constant_array() { return &constant_array_builder_; }
int write_count() const { return write_count_; }
const BytecodeNode& last_written() const { return last_written_; }
private:
ConstantArrayBuilder constant_array_builder_;
BytecodePeepholeOptimizer peephole_optimizer_;
int write_count_ = 0;
......@@ -266,38 +261,6 @@ TEST_F(BytecodePeepholeOptimizerTest, TypeOfToName) {
CHECK_EQ(last_written().bytecode(), Bytecode::kStar);
}
TEST_F(BytecodePeepholeOptimizerTest, LdaConstantStringToName) {
Handle<Object> word =
isolate()->factory()->NewStringFromStaticChars("optimizing");
size_t index = constant_array()->Insert(word);
BytecodeNode first(Bytecode::kLdaConstant, static_cast<uint32_t>(index));
BytecodeNode second(Bytecode::kToName, Register(0).ToOperand());
optimizer()->Write(&first);
CHECK_EQ(write_count(), 0);
optimizer()->Write(&second);
CHECK_EQ(write_count(), 1);
CHECK_EQ(last_written(), first);
Flush();
CHECK_EQ(write_count(), 2);
CHECK_EQ(last_written(), second);
CHECK_EQ(last_written().bytecode(), Bytecode::kStar);
}
TEST_F(BytecodePeepholeOptimizerTest, LdaConstantNumberToName) {
Handle<Object> word = isolate()->factory()->NewNumber(0.380);
size_t index = constant_array()->Insert(word);
BytecodeNode first(Bytecode::kLdaConstant, static_cast<uint32_t>(index));
BytecodeNode second(Bytecode::kToName, Register(0).ToOperand());
optimizer()->Write(&first);
CHECK_EQ(write_count(), 0);
optimizer()->Write(&second);
CHECK_EQ(write_count(), 1);
CHECK_EQ(last_written(), first);
Flush();
CHECK_EQ(write_count(), 2);
CHECK_EQ(last_written(), second);
}
// Tests covering BytecodePeepholeOptimizer::CanElideLast().
TEST_F(BytecodePeepholeOptimizerTest, LdaTrueLdaFalse) {
......
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