Upgrade V8 to version 4.9.385.28
https://chromium.googlesource.com/v8/v8/+/4.9.385.28
FPIIM-449
Change-Id: I4b2e74289d4bf3667f2f3dc8aa2e541f63e26eb4
diff --git a/test/cctest/compiler/test-gap-resolver.cc b/test/cctest/compiler/test-gap-resolver.cc
index ea6f4ee..7f85088 100644
--- a/test/cctest/compiler/test-gap-resolver.cc
+++ b/test/cctest/compiler/test-gap-resolver.cc
@@ -7,19 +7,18 @@
#include "src/base/utils/random-number-generator.h"
#include "test/cctest/cctest.h"
-using namespace v8::internal;
-using namespace v8::internal::compiler;
+namespace v8 {
+namespace internal {
+namespace compiler {
// The state of our move interpreter is the mapping of operands to values. Note
// that the actual values don't really matter, all we care about is equality.
class InterpreterState {
public:
- typedef std::vector<MoveOperands> Moves;
-
- void ExecuteInParallel(Moves moves) {
+ void ExecuteInParallel(const ParallelMove* moves) {
InterpreterState copy(*this);
- for (Moves::iterator it = moves.begin(); it != moves.end(); ++it) {
- if (!it->IsRedundant()) write(it->destination(), copy.read(it->source()));
+ for (const auto m : *moves) {
+ if (!m->IsRedundant()) write(m->destination(), copy.read(m->source()));
}
}
@@ -32,17 +31,41 @@
}
private:
+ struct Key {
+ bool is_constant;
+ bool is_float;
+ LocationOperand::LocationKind kind;
+ int index;
+
+ bool operator<(const Key& other) const {
+ if (this->is_constant != other.is_constant) {
+ return this->is_constant;
+ }
+ if (this->is_float != other.is_float) {
+ return this->is_float;
+ }
+ if (this->kind != other.kind) {
+ return this->kind < other.kind;
+ }
+ return this->index < other.index;
+ }
+
+ bool operator==(const Key& other) const {
+ return this->is_constant == other.is_constant &&
+ this->kind == other.kind && this->index == other.index;
+ }
+ };
+
// Internally, the state is a normalized permutation of (kind,index) pairs.
- typedef std::pair<InstructionOperand::Kind, int> Key;
typedef Key Value;
typedef std::map<Key, Value> OperandMap;
- Value read(const InstructionOperand* op) const {
+ Value read(const InstructionOperand& op) const {
OperandMap::const_iterator it = values_.find(KeyFor(op));
return (it == values_.end()) ? ValueFor(op) : it->second;
}
- void write(const InstructionOperand* op, Value v) {
+ void write(const InstructionOperand& op, Value v) {
if (v == ValueFor(op)) {
values_.erase(KeyFor(op));
} else {
@@ -50,12 +73,39 @@
}
}
- static Key KeyFor(const InstructionOperand* op) {
- return Key(op->kind(), op->index());
+ static Key KeyFor(const InstructionOperand& op) {
+ bool is_constant = op.IsConstant();
+ bool is_float = false;
+ LocationOperand::LocationKind kind;
+ int index;
+ if (!is_constant) {
+ if (op.IsRegister()) {
+ index = LocationOperand::cast(op).GetRegister().code();
+ } else if (op.IsDoubleRegister()) {
+ index = LocationOperand::cast(op).GetDoubleRegister().code();
+ } else {
+ index = LocationOperand::cast(op).index();
+ }
+ is_float = IsFloatingPoint(LocationOperand::cast(op).representation());
+ kind = LocationOperand::cast(op).location_kind();
+ } else {
+ index = ConstantOperand::cast(op).virtual_register();
+ kind = LocationOperand::REGISTER;
+ }
+ Key key = {is_constant, is_float, kind, index};
+ return key;
}
- static Value ValueFor(const InstructionOperand* op) {
- return Value(op->kind(), op->index());
+ static Value ValueFor(const InstructionOperand& op) { return KeyFor(op); }
+
+ static InstructionOperand FromKey(Key key) {
+ if (key.is_constant) {
+ return ConstantOperand(key.index);
+ }
+ return AllocatedOperand(
+ key.kind,
+ v8::internal::compiler::InstructionSequence::DefaultRepresentation(),
+ key.index);
}
friend std::ostream& operator<<(std::ostream& os,
@@ -63,10 +113,12 @@
for (OperandMap::const_iterator it = is.values_.begin();
it != is.values_.end(); ++it) {
if (it != is.values_.begin()) os << " ";
- InstructionOperand source(it->first.first, it->first.second);
- InstructionOperand destination(it->second.first, it->second.second);
- MoveOperands mo(&source, &destination);
- PrintableMoveOperands pmo = {RegisterConfiguration::ArchDefault(), &mo};
+ InstructionOperand source = FromKey(it->first);
+ InstructionOperand destination = FromKey(it->second);
+ MoveOperands mo(source, destination);
+ PrintableMoveOperands pmo = {
+ RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN),
+ &mo};
os << pmo;
}
return os;
@@ -79,30 +131,31 @@
// An abstract interpreter for moves, swaps and parallel moves.
class MoveInterpreter : public GapResolver::Assembler {
public:
- virtual void AssembleMove(InstructionOperand* source,
- InstructionOperand* destination) OVERRIDE {
- InterpreterState::Moves moves;
- moves.push_back(MoveOperands(source, destination));
+ explicit MoveInterpreter(Zone* zone) : zone_(zone) {}
+
+ void AssembleMove(InstructionOperand* source,
+ InstructionOperand* destination) override {
+ ParallelMove* moves = new (zone_) ParallelMove(zone_);
+ moves->AddMove(*source, *destination);
state_.ExecuteInParallel(moves);
}
- virtual void AssembleSwap(InstructionOperand* source,
- InstructionOperand* destination) OVERRIDE {
- InterpreterState::Moves moves;
- moves.push_back(MoveOperands(source, destination));
- moves.push_back(MoveOperands(destination, source));
+ void AssembleSwap(InstructionOperand* source,
+ InstructionOperand* destination) override {
+ ParallelMove* moves = new (zone_) ParallelMove(zone_);
+ moves->AddMove(*source, *destination);
+ moves->AddMove(*destination, *source);
state_.ExecuteInParallel(moves);
}
- void AssembleParallelMove(const ParallelMove* pm) {
- InterpreterState::Moves moves(pm->move_operands()->begin(),
- pm->move_operands()->end());
+ void AssembleParallelMove(const ParallelMove* moves) {
state_.ExecuteInParallel(moves);
}
InterpreterState state() const { return state_; }
private:
+ Zone* const zone_;
InterpreterState state_;
};
@@ -113,11 +166,11 @@
ParallelMove* Create(int size) {
ParallelMove* parallel_move = new (main_zone()) ParallelMove(main_zone());
- std::set<InstructionOperand*, InstructionOperandComparator> seen;
+ std::set<InstructionOperand, CompareOperandModuloType> seen;
for (int i = 0; i < size; ++i) {
- MoveOperands mo(CreateRandomOperand(), CreateRandomOperand());
+ MoveOperands mo(CreateRandomOperand(true), CreateRandomOperand(false));
if (!mo.IsRedundant() && seen.find(mo.destination()) == seen.end()) {
- parallel_move->AddMove(mo.source(), mo.destination(), main_zone());
+ parallel_move->AddMove(mo.source(), mo.destination());
seen.insert(mo.destination());
}
}
@@ -125,30 +178,57 @@
}
private:
- struct InstructionOperandComparator {
- bool operator()(const InstructionOperand* x,
- const InstructionOperand* y) const {
- return (x->kind() < y->kind()) ||
- (x->kind() == y->kind() && x->index() < y->index());
- }
- };
-
- InstructionOperand* CreateRandomOperand() {
- int index = rng_->NextInt(6);
- switch (rng_->NextInt(5)) {
+ MachineRepresentation RandomRepresentation() {
+ int index = rng_->NextInt(3);
+ switch (index) {
case 0:
- return ConstantOperand::Create(index, main_zone());
+ return MachineRepresentation::kWord32;
case 1:
- return StackSlotOperand::Create(index, main_zone());
+ return MachineRepresentation::kWord64;
case 2:
- return DoubleStackSlotOperand::Create(index, main_zone());
- case 3:
- return RegisterOperand::Create(index, main_zone());
- case 4:
- return DoubleRegisterOperand::Create(index, main_zone());
+ return MachineRepresentation::kTagged;
}
UNREACHABLE();
- return NULL;
+ return MachineRepresentation::kNone;
+ }
+
+ MachineRepresentation RandomDoubleRepresentation() {
+ int index = rng_->NextInt(2);
+ if (index == 0) return MachineRepresentation::kFloat64;
+ return MachineRepresentation::kFloat32;
+ }
+
+ InstructionOperand CreateRandomOperand(bool is_source) {
+ int index = rng_->NextInt(7);
+ // destination can't be Constant.
+ switch (rng_->NextInt(is_source ? 7 : 6)) {
+ case 0:
+ return AllocatedOperand(LocationOperand::STACK_SLOT,
+ RandomRepresentation(), index);
+ case 1:
+ return AllocatedOperand(LocationOperand::STACK_SLOT,
+ RandomDoubleRepresentation(), index);
+ case 2:
+ return AllocatedOperand(LocationOperand::REGISTER,
+ RandomRepresentation(), index);
+ case 3:
+ return AllocatedOperand(LocationOperand::REGISTER,
+ RandomDoubleRepresentation(), index);
+ case 4:
+ return ExplicitOperand(
+ LocationOperand::REGISTER, RandomRepresentation(),
+ RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN)
+ ->GetAllocatableGeneralCode(1));
+ case 5:
+ return ExplicitOperand(
+ LocationOperand::STACK_SLOT, RandomRepresentation(),
+ RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN)
+ ->GetAllocatableGeneralCode(index));
+ case 6:
+ return ConstantOperand(index);
+ }
+ UNREACHABLE();
+ return InstructionOperand();
}
private:
@@ -163,10 +243,10 @@
ParallelMove* pm = pmc.Create(size);
// Note: The gap resolver modifies the ParallelMove, so interpret first.
- MoveInterpreter mi1;
+ MoveInterpreter mi1(pmc.main_zone());
mi1.AssembleParallelMove(pm);
- MoveInterpreter mi2;
+ MoveInterpreter mi2(pmc.main_zone());
GapResolver resolver(&mi2);
resolver.Resolve(pm);
@@ -174,3 +254,7 @@
}
}
}
+
+} // namespace compiler
+} // namespace internal
+} // namespace v8