Rip out preconsts
This was barely a demonstrable win in sandbox mode when I first wrote it and it's not even used in hhir. It's probably been bitrotting and is causing crashes for some people. Time to say goodbye.
Esse commit está contido em:
@@ -3192,15 +3192,7 @@ bool EmitterVisitor::visitImpl(ConstructPtr node) {
|
||||
if (p0->getScalarValue(v0) && v0.isString()) {
|
||||
const StringData* cname =
|
||||
StringData::GetStaticString(v0.toString());
|
||||
ExpressionPtr p1 = (*params)[1];
|
||||
Variant v1;
|
||||
if (p1->getScalarValue(v1) && v1.isAllowedAsConstantValue()) {
|
||||
m_ue.addPreConst(cname, *v1.getTypedAccessor());
|
||||
} else {
|
||||
m_ue.addPreConst(cname, *null_variant.getTypedAccessor());
|
||||
}
|
||||
|
||||
visit(p1);
|
||||
visit((*params)[1]);
|
||||
emitConvertToCell(e);
|
||||
e.DefCns(cname);
|
||||
return true;
|
||||
|
||||
@@ -15,33 +15,34 @@
|
||||
*/
|
||||
|
||||
#define __STDC_LIMIT_MACROS
|
||||
#include <stdint.h>
|
||||
|
||||
#include "hphp/runtime/base/execution_context.h"
|
||||
#include "hphp/runtime/base/complex_types.h"
|
||||
#include "hphp/runtime/base/type_conversions.h"
|
||||
#include "hphp/runtime/base/builtin_functions.h"
|
||||
#include "hphp/runtime/base/comparisons.h"
|
||||
#include "hphp/runtime/base/externals.h"
|
||||
#include "hphp/runtime/base/util/request_local.h"
|
||||
#include "hphp/runtime/base/resource_data.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "hphp/util/logger.h"
|
||||
#include "hphp/util/process.h"
|
||||
#include "hphp/util/text_color.h"
|
||||
#include "hphp/runtime/base/array/array_init.h"
|
||||
#include "hphp/runtime/base/array/array_iterator.h"
|
||||
#include "hphp/runtime/base/memory/memory_manager.h"
|
||||
#include "hphp/runtime/base/memory/sweepable.h"
|
||||
#include "hphp/runtime/base/runtime_option.h"
|
||||
#include "hphp/runtime/eval/debugger/debugger.h"
|
||||
#include "hphp/runtime/vm/event_hook.h"
|
||||
#include "hphp/runtime/ext/ext_string.h"
|
||||
#include "hphp/util/logger.h"
|
||||
#include "hphp/util/process.h"
|
||||
#include "hphp/util/text_color.h"
|
||||
#include "hphp/runtime/eval/runtime/file_repository.h"
|
||||
#include "hphp/runtime/vm/translator/translator.h"
|
||||
#include "hphp/runtime/vm/translator/translator-inline.h"
|
||||
#include "hphp/runtime/vm/translator/translator-deps.h"
|
||||
#include "hphp/runtime/vm/debugger_hook.h"
|
||||
#include "hphp/runtime/base/server/server_stats.h"
|
||||
#include "hphp/runtime/base/util/request_local.h"
|
||||
#include "hphp/runtime/base/builtin_functions.h"
|
||||
#include "hphp/runtime/base/comparisons.h"
|
||||
#include "hphp/runtime/base/complex_types.h"
|
||||
#include "hphp/runtime/base/externals.h"
|
||||
#include "hphp/runtime/base/resource_data.h"
|
||||
#include "hphp/runtime/base/runtime_option.h"
|
||||
#include "hphp/runtime/base/type_conversions.h"
|
||||
#include "hphp/runtime/eval/debugger/debugger.h"
|
||||
#include "hphp/runtime/eval/runtime/file_repository.h"
|
||||
#include "hphp/runtime/ext/ext_string.h"
|
||||
#include "hphp/runtime/vm/translator/translator-inline.h"
|
||||
#include "hphp/runtime/vm/translator/translator.h"
|
||||
#include "hphp/runtime/vm/debugger_hook.h"
|
||||
#include "hphp/runtime/vm/event_hook.h"
|
||||
|
||||
namespace HPHP {
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@@ -137,14 +138,6 @@ VMExecutionContext::~VMExecutionContext() {
|
||||
delete m_injTables;
|
||||
delete m_breakPointFilter;
|
||||
delete m_lastLocFilter;
|
||||
|
||||
if (UNLIKELY(!m_preConsts.empty())) {
|
||||
Transl::unmergePreConsts(m_preConsts, this);
|
||||
for (PreConstVec::iterator i = m_preConsts.begin();
|
||||
i != m_preConsts.end(); ++i) {
|
||||
decRefStr(const_cast<StringData*>(i->name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BaseExecutionContext::backupSession() {
|
||||
|
||||
@@ -753,8 +753,6 @@ public:
|
||||
const ClassInfo* findTraitInfo(CStrRef name);
|
||||
const ClassInfo::ConstantInfo* findConstantInfo(CStrRef name);
|
||||
|
||||
void newPreConst(StringData* name, const TypedValue& val);
|
||||
|
||||
// The op*() methods implement individual opcode handlers.
|
||||
#define O(name, imm, pusph, pop, flags) \
|
||||
void op##name();
|
||||
@@ -777,7 +775,6 @@ OPCODES
|
||||
void dispatchBB();
|
||||
|
||||
private:
|
||||
PreConstVec m_preConsts;
|
||||
static Mutex s_threadIdxLock;
|
||||
static hphp_hash_map<pid_t, int64_t> s_threadIdxMap;
|
||||
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include "hphp/runtime/base/shared/shared_store_stats.h"
|
||||
#include "hphp/runtime/vm/repo.h"
|
||||
#include "hphp/runtime/vm/translator/translator.h"
|
||||
#include "hphp/runtime/vm/translator/translator-deps.h"
|
||||
#include "hphp/runtime/vm/translator/translator-x64.h"
|
||||
#include "hphp/util/alloc.h"
|
||||
#include "hphp/util/timer.h"
|
||||
@@ -212,7 +211,6 @@ void AdminRequestHandler::handleRequest(Transport *transport) {
|
||||
"/vm-tcspace: show space used by translator caches\n"
|
||||
"/vm-dump-tc: dump translation cache to /tmp/tc_dump_a and\n"
|
||||
" /tmp/tc_dump_astub\n"
|
||||
"/vm-preconsts: show information about preconsts\n"
|
||||
"/vm-tcreset: throw away translations and start over\n"
|
||||
"/vm-namedentities:show size of the NamedEntityTable\n"
|
||||
;
|
||||
@@ -969,34 +967,6 @@ bool AdminRequestHandler::handleVMRequest(const std::string &cmd,
|
||||
transport->sendString(result.str());
|
||||
return true;
|
||||
}
|
||||
if (cmd == "vm-preconsts") {
|
||||
InfoMap counts;
|
||||
using namespace HPHP::Transl;
|
||||
for (PreConstDepMap::iterator i = gPreConsts.begin(); i != gPreConsts.end();
|
||||
++i) {
|
||||
PreConstDep& dep = i->second;
|
||||
PCInfo& info = counts[dep.preConsts.size()];
|
||||
info.count++;
|
||||
if (preConstVecHasUnique(dep.preConsts)) {
|
||||
info.unique++;
|
||||
}
|
||||
}
|
||||
|
||||
using std::setw;
|
||||
using std::right;
|
||||
using std::setfill;
|
||||
std::stringstream out;
|
||||
const int width = 10;
|
||||
out << setfill(' ') << right;
|
||||
out << setw(width) << "size" << setw(width) << "count"
|
||||
<< setw(width) << "unique" << endl;
|
||||
for (InfoMap::iterator i = counts.begin(); i != counts.end(); ++i) {
|
||||
out << setw(width) << i->first << setw(width) << i->second.count
|
||||
<< setw(width) << i->second.unique << endl;
|
||||
}
|
||||
transport->sendString(out.str());
|
||||
return true;
|
||||
}
|
||||
if (cmd == "vm-dump-tc") {
|
||||
if (HPHP::Transl::tc_dump()) {
|
||||
transport->sendString("Done");
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include "hphp/runtime/vm/bytecode.h"
|
||||
#include "hphp/compiler/builtin_symbols.h"
|
||||
#include "hphp/runtime/vm/event_hook.h"
|
||||
#include "hphp/runtime/vm/translator/translator-deps.h"
|
||||
#include "hphp/runtime/vm/translator/translator-x64.h"
|
||||
#include "hphp/runtime/vm/member_operations.h"
|
||||
#include "hphp/runtime/base/code_coverage.h"
|
||||
@@ -1558,14 +1557,6 @@ Array VMExecutionContext::getCallerInfo() {
|
||||
return result;
|
||||
}
|
||||
|
||||
void VMExecutionContext::newPreConst(StringData* name,
|
||||
const TypedValue& val) {
|
||||
name->incRefCount();
|
||||
PreConst pc = { val, this, name };
|
||||
m_preConsts.push_back(pc);
|
||||
Transl::mergePreConst(m_preConsts.back());
|
||||
}
|
||||
|
||||
bool VMExecutionContext::renameFunction(const StringData* oldName,
|
||||
const StringData* newName) {
|
||||
return m_renamedFuncs.rename(oldName, newName);
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#include "hphp/runtime/eval/runtime/file_repository.h"
|
||||
#include "hphp/system/lib/systemlib.h"
|
||||
#include "hphp/runtime/vm/treadmill.h"
|
||||
#include "hphp/runtime/vm/translator/translator-deps.h"
|
||||
#include "hphp/runtime/vm/translator/translator-inline.h"
|
||||
#include "hphp/runtime/vm/translator/translator-x64.h"
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#include "hphp/runtime/base/complex_types.h"
|
||||
#include "hphp/runtime/base/runtime_option.h"
|
||||
#include "hphp/runtime/vm/translator/targetcache.h"
|
||||
#include "hphp/runtime/vm/translator/translator-deps.h"
|
||||
#include "hphp/runtime/vm/translator/translator-inline.h"
|
||||
#include "hphp/runtime/vm/translator/translator-x64.h"
|
||||
#include "hphp/runtime/base/stats.h"
|
||||
|
||||
@@ -1,143 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| 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. |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#include "hphp/runtime/vm/translator/translator-x64.h"
|
||||
#include "hphp/runtime/vm/translator/translator-deps.h"
|
||||
|
||||
namespace HPHP {
|
||||
namespace Transl {
|
||||
|
||||
PreConstDepMap gPreConsts;
|
||||
|
||||
TRACE_SET_MOD(txdeps);
|
||||
|
||||
const TypedValue* preConstVecHasUnique(const PreConstPtrVec& preConsts) {
|
||||
if (preConsts.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
assert(preConsts.size() >= 1);
|
||||
const TypedValue* first = &preConsts.front()->value;
|
||||
if (first->m_type == KindOfUninit) {
|
||||
return nullptr;
|
||||
}
|
||||
for (size_t i = 1; i < preConsts.size(); ++i) {
|
||||
if (!tvSame(first, &preConsts[i]->value)) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
return first;
|
||||
}
|
||||
|
||||
static void mergePreConstImpl(const PreConst& pc,
|
||||
SrcKeySet& invalidateKeys) {
|
||||
PreConstDepMap::accessor acc;
|
||||
bool isNew = Transl::gPreConsts.insert(acc, pc.name);
|
||||
PreConstDep& dep = acc->second;
|
||||
// We're going to add a new PreConst below. Invalidate dependent
|
||||
// SrcKeys iff (there's currently a unique value AND the new value
|
||||
// is not the same) OR (there are no preConsts right now AND there
|
||||
// used to be a unique value AND the value we're adding is
|
||||
// different from the old value)
|
||||
bool invalidate = false;
|
||||
if (!isNew && !dep.srcKeys.empty()) {
|
||||
const TypedValue* uniq = preConstVecHasUnique(dep.preConsts);
|
||||
if (uniq && !tvSame(uniq, &pc.value)) {
|
||||
invalidate = true;
|
||||
} else if (dep.preConsts.empty() &&
|
||||
dep.lastUniqueVal.m_type != KindOfUninit &&
|
||||
!tvSame(&dep.lastUniqueVal, &pc.value)) {
|
||||
invalidate = true;
|
||||
}
|
||||
}
|
||||
if (invalidate) {
|
||||
TRACE(1, "%s: Invalidating %lu SrcKeys for preConst %s\n",
|
||||
__FUNCTION__, dep.srcKeys.size(), pc.name->data());
|
||||
// The invalidation is deferred to avoid a lock rank violation
|
||||
// between gPreConsts and the write lease.
|
||||
invalidateKeys.insert(dep.srcKeys.begin(), dep.srcKeys.end());
|
||||
dep.srcKeys.clear();
|
||||
}
|
||||
|
||||
TRACE(3, "%s: %lu preConst(s) for %s, adding %s\n",
|
||||
__FUNCTION__, dep.preConsts.size(), pc.name->data(),
|
||||
pc.value.pretty().c_str());
|
||||
dep.preConsts.push_back(&pc);
|
||||
if (const TypedValue* tv = preConstVecHasUnique(dep.preConsts)) {
|
||||
dep.lastUniqueVal = *tv;
|
||||
} else {
|
||||
dep.lastUniqueVal.m_type = KindOfUninit;
|
||||
}
|
||||
}
|
||||
|
||||
void mergePreConst(const PreConst& pc) {
|
||||
SrcKeySet invalidateKeys;
|
||||
mergePreConstImpl(pc, invalidateKeys);
|
||||
if (!invalidateKeys.empty()) {
|
||||
TranslatorX64::Get()->invalidateSrcKeys(invalidateKeys);
|
||||
}
|
||||
}
|
||||
|
||||
void mergePreConsts(const PreConstVec& preConsts) {
|
||||
SrcKeySet invalidateKeys;
|
||||
for (PreConstVec::const_iterator i = preConsts.begin();
|
||||
i != preConsts.end(); ++i) {
|
||||
mergePreConstImpl(*i, invalidateKeys);
|
||||
}
|
||||
if (!invalidateKeys.empty()) {
|
||||
TranslatorX64::Get()->invalidateSrcKeys(invalidateKeys);
|
||||
}
|
||||
}
|
||||
|
||||
void unmergePreConsts(const PreConstVec& preConsts, void* owner) {
|
||||
ConstStringDataSet visitedNames;
|
||||
for (PreConstVec::const_iterator mi = preConsts.begin();
|
||||
mi != preConsts.end(); ++mi) {
|
||||
assert(mi->owner == owner);
|
||||
if (visitedNames.find(mi->name) != visitedNames.end()) {
|
||||
continue;
|
||||
}
|
||||
visitedNames.insert(mi->name);
|
||||
PreConstDepMap::accessor acc;
|
||||
UNUSED bool found = gPreConsts.find(acc, mi->name);
|
||||
assert(found);
|
||||
UNUSED int erased = 0;
|
||||
PreConstPtrVec& pcPtrs = acc->second.preConsts;
|
||||
for (PreConstPtrVec::iterator vi = pcPtrs.begin(); vi != pcPtrs.end(); ) {
|
||||
if ((*vi)->owner == owner) {
|
||||
vi = pcPtrs.erase(vi);
|
||||
erased++;
|
||||
} else {
|
||||
++vi;
|
||||
}
|
||||
}
|
||||
assert(erased > 0);
|
||||
TRACE(3, "%s: Erased %d preConsts for %s\n",
|
||||
__FUNCTION__, erased, mi->name->data());
|
||||
// We erased one or more of the pcPtrs registered for this
|
||||
// name. If the value is newly unique, we should update
|
||||
// lastUniqueVal appropriately. If it's still non-unique or all
|
||||
// the preconsts are gone, lastUniqueVal already has an
|
||||
// appropriate value.
|
||||
if (const TypedValue* tv = preConstVecHasUnique(pcPtrs)) {
|
||||
TRACE(2, "%s: Constant %s %s is newly unique\n",
|
||||
__FUNCTION__, mi->name->data(), tv->pretty().c_str());
|
||||
acc->second.lastUniqueVal = *tv;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} } // HPHP::Transl
|
||||
@@ -1,86 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| 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_TRANSLATOR_DEPS_H
|
||||
#define incl_HPHP_TRANSLATOR_DEPS_H
|
||||
|
||||
#include <vector>
|
||||
#include "tbb/concurrent_hash_map.h"
|
||||
|
||||
#include "hphp/runtime/base/complex_types.h"
|
||||
#include "hphp/runtime/base/string_data.h"
|
||||
#include "hphp/runtime/vm/unit.h"
|
||||
#include "hphp/runtime/vm/translator/translator.h"
|
||||
#include "hphp/util/mutex.h"
|
||||
#include "hphp/util/trace.h"
|
||||
|
||||
// Invalidation tracking for constants
|
||||
|
||||
namespace HPHP {
|
||||
namespace Transl {
|
||||
typedef std::vector<const PreConst*> PreConstPtrVec;
|
||||
|
||||
/*
|
||||
* We create one of these structs per constant name that has ever been
|
||||
* seen. It contains a list of all PreConsts from currently live
|
||||
* Units, a set of SrcKeys that depend on there being a unique value,
|
||||
* and the most recently unique value.
|
||||
*/
|
||||
struct PreConstDep {
|
||||
PreConstDep() {
|
||||
lastUniqueVal.m_type = KindOfUninit;
|
||||
}
|
||||
SrcKeySet srcKeys;
|
||||
PreConstPtrVec preConsts;
|
||||
TypedValue lastUniqueVal; // Will be KindOfUninit if the value is
|
||||
// not currently unique, and for a short
|
||||
// moment before any preConsts are added
|
||||
// after creation
|
||||
};
|
||||
typedef RankedCHM<const StringData*, PreConstDep,
|
||||
StringDataHashCompare, RankPreConstDep> PreConstDepMap;
|
||||
extern PreConstDepMap gPreConsts;
|
||||
|
||||
const TypedValue* preConstVecHasUnique(const PreConstPtrVec& preConsts);
|
||||
|
||||
template<typename Accessor>
|
||||
const TypedValue* findUniquePreConst(Accessor& acc, const StringData* name) {
|
||||
assert(!RuntimeOption::RepoAuthoritative);
|
||||
TRACE_SET_MOD(txdeps);
|
||||
if (gPreConsts.find(acc, name)) {
|
||||
const PreConstDep& dep = acc->second;
|
||||
if (const TypedValue* tv = preConstVecHasUnique(dep.preConsts)) {
|
||||
TRACE(3, "%s: Found unique preConst value %s for %s\n",
|
||||
__FUNCTION__, tv->pretty().c_str(), name->data());
|
||||
return tv;
|
||||
}
|
||||
TRACE(2, "%s: Found %lu non-unique preConsts values for %s\n",
|
||||
__FUNCTION__, dep.preConsts.size(), name->data());
|
||||
acc.release();
|
||||
} else {
|
||||
TRACE(2, "%s: No preConsts for %s\n", __FUNCTION__, name->data());
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void mergePreConst(const PreConst& preConst);
|
||||
void mergePreConsts(const PreConstVec& preConsts);
|
||||
void unmergePreConsts(const PreConstVec& preConsts, void* owner);
|
||||
|
||||
} } // HPHP::Transl
|
||||
|
||||
#endif // TRANSLATOR_DEPS_H_
|
||||
@@ -13,7 +13,6 @@
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
#include "hphp/runtime/vm/translator/translator-deps.h"
|
||||
#include "hphp/runtime/vm/translator/translator-inline.h"
|
||||
#include "hphp/runtime/vm/translator/translator-x64.h"
|
||||
#include "hphp/runtime/vm/translator/targetcache.h"
|
||||
|
||||
@@ -75,7 +75,6 @@ typedef __sighandler_t *sighandler_t;
|
||||
#include "hphp/runtime/ext/ext_function.h"
|
||||
#include "hphp/runtime/vm/debug/debug.h"
|
||||
#include "hphp/runtime/vm/translator/targetcache.h"
|
||||
#include "hphp/runtime/vm/translator/translator-deps.h"
|
||||
#include "hphp/runtime/vm/translator/translator-inline.h"
|
||||
#include "hphp/runtime/vm/translator/srcdb.h"
|
||||
#include "hphp/runtime/vm/translator/x64-util.h"
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
#include "hphp/runtime/vm/hhbc.h"
|
||||
#include "hphp/runtime/vm/bytecode.h"
|
||||
#include "hphp/runtime/vm/translator/targetcache.h"
|
||||
#include "hphp/runtime/vm/translator/translator-deps.h"
|
||||
#include "hphp/runtime/vm/translator/translator-inline.h"
|
||||
#include "hphp/runtime/vm/translator/translator-x64.h"
|
||||
#include "hphp/runtime/vm/translator/annotation.h"
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#include "hphp/runtime/vm/repo.h"
|
||||
#include "hphp/runtime/vm/blob_helper.h"
|
||||
#include "hphp/runtime/vm/translator/targetcache.h"
|
||||
#include "hphp/runtime/vm/translator/translator-deps.h"
|
||||
#include "hphp/runtime/vm/translator/translator-inline.h"
|
||||
#include "hphp/runtime/vm/translator/translator-x64.h"
|
||||
#include "hphp/runtime/vm/verifier/check.h"
|
||||
@@ -406,11 +405,6 @@ Unit::~Unit() {
|
||||
}
|
||||
}
|
||||
|
||||
if (!RuntimeOption::RepoAuthoritative &&
|
||||
(m_mergeState & UnitMergeStateMerged)) {
|
||||
Transl::unmergePreConsts(m_preConsts, this);
|
||||
}
|
||||
|
||||
free(m_mergeInfo);
|
||||
|
||||
if (m_pseudoMainCache) {
|
||||
@@ -835,9 +829,7 @@ void Unit::initialMerge() {
|
||||
}
|
||||
}
|
||||
if (allFuncsUnique) state |= UnitMergeStateUniqueFuncs;
|
||||
if (!RuntimeOption::RepoAuthoritative && SystemLib::s_inited) {
|
||||
Transl::mergePreConsts(m_preConsts);
|
||||
} else {
|
||||
if (RuntimeOption::RepoAuthoritative || !SystemLib::s_inited) {
|
||||
/*
|
||||
* The mergeables array begins with the hoistable Func*s,
|
||||
* followed by the (potenitally) hoistable Class*s.
|
||||
@@ -1706,13 +1698,6 @@ void UnitRepoProxy::createSchema(int repoId, RepoTxn& txn) {
|
||||
" PRIMARY KEY (unitSn, arrayId));";
|
||||
txn.exec(ssCreate.str());
|
||||
}
|
||||
{
|
||||
std::stringstream ssCreate;
|
||||
ssCreate << "CREATE TABLE " << m_repo.table(repoId, "UnitPreConst")
|
||||
<< "(unitSn INTEGER, name TEXT, value BLOB, preConstId INTEGER,"
|
||||
" PRIMARY KEY (unitSn, preConstId));";
|
||||
txn.exec(ssCreate.str());
|
||||
}
|
||||
{
|
||||
std::stringstream ssCreate;
|
||||
ssCreate << "CREATE TABLE " << m_repo.table(repoId, "UnitMergeables")
|
||||
@@ -1750,7 +1735,6 @@ Unit* UnitRepoProxy::load(const std::string& name, const MD5& md5) {
|
||||
try {
|
||||
getUnitLitstrs(repoId).get(ue);
|
||||
getUnitArrays(repoId).get(ue);
|
||||
getUnitPreConsts(repoId).get(ue);
|
||||
m_repo.pcrp().getPreClasses(repoId).get(ue);
|
||||
getUnitMergeables(repoId).get(ue);
|
||||
m_repo.frp().getFuncs(repoId).get(ue);
|
||||
@@ -1926,48 +1910,6 @@ void UnitRepoProxy::GetUnitArraysStmt
|
||||
txn.commit();
|
||||
}
|
||||
|
||||
void UnitRepoProxy::InsertUnitPreConstStmt
|
||||
::insert(RepoTxn& txn, int64_t unitSn, const PreConst& pc,
|
||||
Id id) {
|
||||
if (!prepared()) {
|
||||
std::stringstream ssInsert;
|
||||
ssInsert << "INSERT INTO " << m_repo.table(m_repoId, "UnitPreConst")
|
||||
<< " VALUES(@unitSn, @name, @value, @preConstId);";
|
||||
txn.prepare(*this, ssInsert.str());
|
||||
}
|
||||
RepoTxnQuery query(txn, *this);
|
||||
query.bindInt64("@unitSn", unitSn);
|
||||
query.bindStaticString("@name", pc.name);
|
||||
query.bindTypedValue("@value", pc.value);
|
||||
query.bindId("@preConstId", id);
|
||||
query.exec();
|
||||
}
|
||||
|
||||
void UnitRepoProxy::GetUnitPreConstsStmt
|
||||
::get(UnitEmitter& ue) {
|
||||
RepoTxn txn(m_repo);
|
||||
if (!prepared()) {
|
||||
std::stringstream ssSelect;
|
||||
ssSelect << "SELECT name,value,preconstId FROM "
|
||||
<< m_repo.table(m_repoId, "UnitPreConst")
|
||||
<< " WHERE unitSn == @unitSn ORDER BY preConstId ASC;";
|
||||
txn.prepare(*this, ssSelect.str());
|
||||
}
|
||||
RepoTxnQuery query(txn, *this);
|
||||
query.bindInt64("@unitSn", ue.sn());
|
||||
do {
|
||||
query.step();
|
||||
if (query.row()) {
|
||||
StringData* name; /**/ query.getStaticString(0, name);
|
||||
TypedValue value; /**/ query.getTypedValue(1, value);
|
||||
Id id; /**/ query.getId(2, id);
|
||||
UNUSED Id addedId = ue.addPreConst(name, value);
|
||||
assert(id == addedId);
|
||||
}
|
||||
} while (!query.done());
|
||||
txn.commit();
|
||||
}
|
||||
|
||||
void UnitRepoProxy::InsertUnitMergeableStmt
|
||||
::insert(RepoTxn& txn, int64_t unitSn,
|
||||
int ix, UnitMergeKind kind, Id id,
|
||||
@@ -2281,21 +2223,6 @@ void UnitEmitter::setLines(const LineTable& lines) {
|
||||
}
|
||||
}
|
||||
|
||||
Id UnitEmitter::addPreConst(const StringData* name, const TypedValue& value) {
|
||||
assert(value.m_type != KindOfObject && value.m_type != KindOfArray);
|
||||
PreConst pc = { value, nullptr, name };
|
||||
if (pc.value.m_type == KindOfString && !pc.value.m_data.pstr->isStatic()) {
|
||||
pc.value.m_data.pstr = StringData::GetStaticString(pc.value.m_data.pstr);
|
||||
pc.value.m_type = KindOfStaticString;
|
||||
}
|
||||
assert(!IS_REFCOUNTED_TYPE(pc.value.m_type));
|
||||
|
||||
Id id = m_preConsts.size();
|
||||
m_preConsts.push_back(pc);
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
Id UnitEmitter::mergeLitstr(const StringData* litstr) {
|
||||
LitstrMap::const_iterator it = m_litstr2id.find(litstr);
|
||||
if (it == m_litstr2id.end()) {
|
||||
@@ -2515,9 +2442,6 @@ bool UnitEmitter::insert(UnitOrigin unitOrigin, RepoTxn& txn) {
|
||||
for (unsigned i = 0; i < m_arrays.size(); ++i) {
|
||||
urp.insertUnitArray(repoId).insert(txn, usn, i, m_arrays[i].serialized);
|
||||
}
|
||||
for (size_t i = 0; i < m_preConsts.size(); ++i) {
|
||||
urp.insertUnitPreConst(repoId).insert(txn, usn, m_preConsts[i], i);
|
||||
}
|
||||
for (FeVec::const_iterator it = m_fes.begin(); it != m_fes.end(); ++it) {
|
||||
(*it)->commit(txn);
|
||||
}
|
||||
@@ -2721,12 +2645,6 @@ Unit* UnitEmitter::create() {
|
||||
|
||||
m_fMap.clear();
|
||||
|
||||
u->m_preConsts = m_preConsts;
|
||||
for (PreConstVec::iterator i = u->m_preConsts.begin();
|
||||
i != u->m_preConsts.end(); ++i) {
|
||||
i->owner = u;
|
||||
}
|
||||
|
||||
if (RuntimeOption::EvalDumpBytecode) {
|
||||
// Dump human-readable bytecode.
|
||||
Trace::traceRelease(u->toString());
|
||||
|
||||
@@ -238,27 +238,6 @@ typedef std::vector<LineEntry> LineTable;
|
||||
typedef TableEntry<const Func*> FuncEntry;
|
||||
typedef std::vector<FuncEntry> FuncTable;
|
||||
|
||||
/*
|
||||
* Each Unit has one of these structs for each DefCns instruction. If
|
||||
* the value is not known at Unit emission time, the 'value' field
|
||||
* will be KindOfUninit. The 'owner' field is an opaque blob used by
|
||||
* Units and ExecutionContexes to identify which PreConsts belong to
|
||||
* them on destruction.
|
||||
*
|
||||
* If user code contains a call to define($s, ...) where $s is not a
|
||||
* string known at compile time, it will be left as a normal call to
|
||||
* the function define. If that code is ever executed, a PreConst will
|
||||
* be created by that request's g_vmContext and destroyed at the end
|
||||
* of the request.
|
||||
*/
|
||||
struct PreConst {
|
||||
TypedValue value;
|
||||
void* owner;
|
||||
const StringData* name;
|
||||
};
|
||||
|
||||
typedef std::vector<PreConst> PreConstVec;
|
||||
|
||||
/*
|
||||
* This is the runtime representation of a typedef. Typedefs are only
|
||||
* allowed when hip hop extensions are enabled.
|
||||
@@ -573,11 +552,6 @@ struct Unit {
|
||||
static bool classExists(const StringData* name, bool autoload,
|
||||
Attr typeAttrs);
|
||||
|
||||
const PreConst* lookupPreConstId(Id id) const {
|
||||
assert(id < Id(m_preConsts.size()));
|
||||
return &m_preConsts[id];
|
||||
}
|
||||
|
||||
bool compileTimeFatal(const StringData*& msg, int& line) const;
|
||||
const TypedValue *getMainReturn() const {
|
||||
return &m_mainReturn;
|
||||
@@ -706,7 +680,6 @@ private:
|
||||
bool m_mergeOnly;
|
||||
LineTable m_lineTable;
|
||||
FuncTable m_funcTable;
|
||||
PreConstVec m_preConsts;
|
||||
mutable PseudoMainCacheMap *m_pseudoMainCache;
|
||||
};
|
||||
|
||||
@@ -730,7 +703,6 @@ class UnitEmitter {
|
||||
void setMainReturn(const TypedValue* v) { m_mainReturn = *v; }
|
||||
void setMergeOnly(bool b) { m_mergeOnly = b; }
|
||||
const MD5& md5() const { return m_md5; }
|
||||
Id addPreConst(const StringData* name, const TypedValue& value);
|
||||
Id addTypedef(const Typedef& td);
|
||||
Id mergeLitstr(const StringData* litstr);
|
||||
Id mergeArray(ArrayData* a, const StringData* key=nullptr);
|
||||
@@ -878,7 +850,6 @@ class UnitEmitter {
|
||||
*/
|
||||
std::vector<std::pair<Offset,SourceLoc> > m_sourceLocTab;
|
||||
std::vector<std::pair<Offset,const FuncEmitter*> > m_feTab;
|
||||
PreConstVec m_preConsts;
|
||||
std::vector<Typedef> m_typedefs;
|
||||
};
|
||||
|
||||
@@ -900,8 +871,6 @@ class UnitRepoProxy : public RepoProxy {
|
||||
URP_GOP(UnitLitstrs) \
|
||||
URP_IOP(UnitArray) \
|
||||
URP_GOP(UnitArrays) \
|
||||
URP_IOP(UnitPreConst) \
|
||||
URP_GOP(UnitPreConsts) \
|
||||
URP_IOP(UnitMergeable) \
|
||||
URP_GOP(UnitMergeables) \
|
||||
URP_IOP(UnitSourceLoc) \
|
||||
@@ -946,17 +915,6 @@ class UnitRepoProxy : public RepoProxy {
|
||||
GetUnitArraysStmt(Repo& repo, int repoId) : Stmt(repo, repoId) {}
|
||||
void get(UnitEmitter& ue);
|
||||
};
|
||||
class InsertUnitPreConstStmt : public RepoProxy::Stmt {
|
||||
public:
|
||||
InsertUnitPreConstStmt(Repo& repo, int repoId) : Stmt(repo, repoId) {}
|
||||
void insert(RepoTxn& txn, int64_t unitSn, const PreConst& pc,
|
||||
Id id);
|
||||
};
|
||||
class GetUnitPreConstsStmt : public RepoProxy::Stmt {
|
||||
public:
|
||||
GetUnitPreConstsStmt(Repo& repo, int repoId) : Stmt(repo, repoId) {}
|
||||
void get(UnitEmitter& ue);
|
||||
};
|
||||
class InsertUnitMergeableStmt : public RepoProxy::Stmt {
|
||||
public:
|
||||
InsertUnitMergeableStmt(Repo& repo, int repoId) : Stmt(repo, repoId) {}
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Verifier {
|
||||
|
||||
/**
|
||||
* Check one whole unit, including its internal string, array, sourceLoc,
|
||||
* preConst, preClass, and func tables.
|
||||
* preClass, and func tables.
|
||||
*
|
||||
* Checked:
|
||||
* -- string table may not contain null pointers, but strings can contain
|
||||
@@ -42,7 +42,6 @@ namespace Verifier {
|
||||
*
|
||||
* Not Checked:
|
||||
* -- SourceLocs
|
||||
* -- PreConsts
|
||||
* -- PreClasses
|
||||
* -- Metadata
|
||||
*/
|
||||
|
||||
@@ -34,7 +34,6 @@ class UnitChecker {
|
||||
bool checkStrings();
|
||||
bool checkArrays();
|
||||
bool checkSourceLocs();
|
||||
bool checkPreConsts();
|
||||
bool checkPreClasses();
|
||||
bool checkFuncs();
|
||||
bool checkBytecode();
|
||||
@@ -58,7 +57,6 @@ bool checkUnit(const Unit* unit, bool verbose) {
|
||||
// 4. UnitLitStr table
|
||||
// 5. UnitArray table
|
||||
// 6. UnitSourceLoc table
|
||||
// 7. UnitPreConst table
|
||||
// 8. Classes
|
||||
// 9. Functions
|
||||
|
||||
@@ -70,7 +68,6 @@ bool UnitChecker::verify() {
|
||||
return checkStrings() &&
|
||||
checkArrays() &&
|
||||
//checkSourceLocs() &&
|
||||
//checkPreConsts() &&
|
||||
//checkPreClasses() &&
|
||||
checkBytecode() &&
|
||||
//checkMetadata() &&
|
||||
|
||||
@@ -46,8 +46,6 @@ enum Rank {
|
||||
RankEvaledUnits,
|
||||
RankWriteLease,
|
||||
|
||||
RankPreConstDep,
|
||||
|
||||
RankStatCache,
|
||||
|
||||
RankFileRepo,
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário