Minor tweaks to StateVector @override-unit-failures
- Move to state_vector.h - Use smart::vector instead of std::vector - Make factoryId and count helpers private - Add const_iterator support - Make grow() use resize() instead of looping push_back(). - Use assign() in reset().
Esse commit está contido em:
@@ -21,7 +21,8 @@
|
||||
#include "runtime/vm/translator/hopt/ir.h"
|
||||
#include "runtime/vm/translator/hopt/irfactory.h"
|
||||
#include "runtime/vm/translator/targetcache.h"
|
||||
#include <runtime/vm/translator/translator-x64.h>
|
||||
#include "runtime/vm/translator/translator-x64.h"
|
||||
#include "runtime/vm/translator/hopt/state_vector.h"
|
||||
|
||||
namespace HPHP {
|
||||
namespace VM {
|
||||
|
||||
@@ -14,12 +14,14 @@
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#include <boost/range/adaptors.hpp>
|
||||
|
||||
#include "util/trace.h"
|
||||
#include "runtime/vm/translator/hopt/ir.h"
|
||||
#include "runtime/vm/translator/hopt/opt.h"
|
||||
#include "runtime/vm/translator/hopt/irfactory.h"
|
||||
#include "runtime/vm/translator/hopt/simplifier.h"
|
||||
#include <boost/range/adaptors.hpp>
|
||||
#include "runtime/vm/translator/hopt/state_vector.h"
|
||||
|
||||
namespace HPHP {
|
||||
namespace VM {
|
||||
|
||||
@@ -264,72 +264,6 @@ private:
|
||||
Arena m_arena;
|
||||
};
|
||||
|
||||
/*
|
||||
* Utility to keep a vector of state about each key, indexed by
|
||||
* factoryId(key), where key can be an IRInstruction, Block, or SSATmp.
|
||||
*/
|
||||
template<class Key, class Info>
|
||||
struct StateVector {
|
||||
typedef std::vector<Info> InfoVector;
|
||||
typedef typename InfoVector::iterator iterator;
|
||||
typedef typename InfoVector::reference reference;
|
||||
typedef typename InfoVector::const_reference const_reference;
|
||||
|
||||
static unsigned factoryId(const IRInstruction* inst) {
|
||||
return inst->getIId();
|
||||
}
|
||||
static unsigned factoryId(const Block* block) { return block->getId(); }
|
||||
static unsigned factoryId(const SSATmp* tmp) { return tmp->getId(); }
|
||||
static unsigned count(const IRFactory* factory, IRInstruction*) {
|
||||
return factory->numInsts();
|
||||
}
|
||||
static unsigned count(const IRFactory* factory, SSATmp*) {
|
||||
return factory->numTmps();
|
||||
}
|
||||
static unsigned count(const IRFactory* factory, Block*) {
|
||||
return factory->numBlocks();
|
||||
}
|
||||
StateVector(const IRFactory* factory, Info init)
|
||||
: m_factory(factory)
|
||||
, m_info(count(factory, (Key*)nullptr), init)
|
||||
, m_init(init) {
|
||||
}
|
||||
reference operator[](const Key& k) { return (*this)[&k]; }
|
||||
reference operator[](const Key* k) {
|
||||
auto id = factoryId(k);
|
||||
if (id >= m_info.size()) grow();
|
||||
assert(id < m_info.size());
|
||||
return m_info[id];
|
||||
}
|
||||
const_reference operator[](const Key& k) const { return (*this)[&k]; }
|
||||
const_reference operator[](const Key* k) const {
|
||||
assert(factoryId(k) < m_info.size());
|
||||
return m_info[factoryId(k)];
|
||||
}
|
||||
void reset() {
|
||||
for (size_t i = 0, n = m_info.size(); i < n; ++i) {
|
||||
m_info[i] = m_init;
|
||||
}
|
||||
grow();
|
||||
}
|
||||
|
||||
iterator begin() { return m_info.begin(); }
|
||||
iterator end() { return m_info.end(); }
|
||||
|
||||
private:
|
||||
void grow() {
|
||||
for (size_t i = m_info.size(), n = count(m_factory, (Key*)nullptr);
|
||||
i < n; ++i) {
|
||||
m_info.push_back(m_init);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
const IRFactory* m_factory;
|
||||
InfoVector m_info;
|
||||
Info m_init;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
}}}
|
||||
|
||||
@@ -608,6 +608,7 @@ void LinearScan::insertAllocFreeSpillAux(Trace* trace,
|
||||
void LinearScan::collectInfo(BlockList::iterator it, Trace* trace) {
|
||||
m_natives.clear();
|
||||
m_jmps.reset();
|
||||
|
||||
for (auto* block : m_blocks) {
|
||||
for (auto& inst : *block) {
|
||||
for (auto& dst : inst.getDsts()) {
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "runtime/vm/translator/hopt/ir.h"
|
||||
#include "runtime/vm/translator/hopt/tracebuilder.h"
|
||||
#include "runtime/vm/translator/hopt/codegen.h"
|
||||
#include "runtime/vm/translator/hopt/state_vector.h"
|
||||
|
||||
namespace HPHP { namespace VM { namespace JIT {
|
||||
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| HipHop for PHP |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 2010- Facebook, Inc. (http://www.facebook.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.01 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_01.txt |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#ifndef incl_HPHP_JIT_STATE_VECTOR_H_
|
||||
#define incl_HPHP_JIT_STATE_VECTOR_H_
|
||||
|
||||
#include "runtime/base/memory/memory_manager.h"
|
||||
|
||||
#include "runtime/vm/translator/hopt/irfactory.h"
|
||||
|
||||
namespace HPHP { namespace VM { namespace JIT {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
* Utility to keep a vector of state about each key, indexed by
|
||||
* factoryId(key), where key can be an IRInstruction, Block, or SSATmp.
|
||||
*
|
||||
* Takes an `init' element, which everything is defaulted to. Calls
|
||||
* to reset() restore all entries to this state.
|
||||
*/
|
||||
template<class Key, class Info>
|
||||
struct StateVector {
|
||||
typedef smart::vector<Info> InfoVector;
|
||||
typedef typename InfoVector::iterator iterator;
|
||||
typedef typename InfoVector::const_iterator const_iterator;
|
||||
typedef typename InfoVector::reference reference;
|
||||
typedef typename InfoVector::const_reference const_reference;
|
||||
|
||||
StateVector(const IRFactory* factory, Info init)
|
||||
: m_factory(factory)
|
||||
, m_info(count(factory, (Key*)nullptr), init)
|
||||
, m_init(init) {
|
||||
}
|
||||
|
||||
void reset() {
|
||||
m_info.assign(m_info.size(), m_init);
|
||||
grow();
|
||||
}
|
||||
|
||||
reference operator[](const Key& k) { return (*this)[&k]; }
|
||||
reference operator[](const Key* k) {
|
||||
auto id = factoryId(k);
|
||||
if (id >= m_info.size()) grow();
|
||||
assert(id < m_info.size());
|
||||
return m_info[id];
|
||||
}
|
||||
|
||||
const_reference operator[](const Key& k) const { return (*this)[&k]; }
|
||||
const_reference operator[](const Key* k) const {
|
||||
assert(factoryId(k) < m_info.size());
|
||||
return m_info[factoryId(k)];
|
||||
}
|
||||
|
||||
iterator begin() { return m_info.begin(); }
|
||||
iterator end() { return m_info.end(); }
|
||||
const_iterator begin() const { return m_info.begin(); }
|
||||
const_iterator end() const { return m_info.end(); }
|
||||
const_iterator cbegin() const { return m_info.cbegin(); }
|
||||
const_iterator cend() const { return m_info.cend(); }
|
||||
|
||||
private:
|
||||
static unsigned factoryId(const IRInstruction* inst) {
|
||||
return inst->getIId();
|
||||
}
|
||||
static unsigned factoryId(const Block* block) { return block->getId(); }
|
||||
static unsigned factoryId(const SSATmp* tmp) { return tmp->getId(); }
|
||||
|
||||
static unsigned count(const IRFactory* factory, IRInstruction*) {
|
||||
return factory->numInsts();
|
||||
}
|
||||
static unsigned count(const IRFactory* factory, SSATmp*) {
|
||||
return factory->numTmps();
|
||||
}
|
||||
static unsigned count(const IRFactory* factory, Block*) {
|
||||
return factory->numBlocks();
|
||||
}
|
||||
|
||||
private:
|
||||
void grow() {
|
||||
m_info.resize(count(m_factory, static_cast<Key*>(nullptr)),
|
||||
m_init);
|
||||
}
|
||||
|
||||
private:
|
||||
const IRFactory* m_factory;
|
||||
InfoVector m_info;
|
||||
Info m_init;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
}}}
|
||||
|
||||
#endif
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "runtime/vm/translator/hopt/irfactory.h"
|
||||
#include "runtime/vm/translator/hopt/cse.h"
|
||||
#include "runtime/vm/translator/hopt/simplifier.h"
|
||||
#include "runtime/vm/translator/hopt/state_vector.h"
|
||||
|
||||
#include "folly/ScopeGuard.h"
|
||||
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário