Remove ReqSrc and ReqMod

They can no longer be generated. Also remove all the associated
code from the emitter.
Esse commit está contido em:
mwilliams
2013-03-12 08:53:30 -07:00
commit de Sara Golemon
commit 4514a79c60
18 arquivos alterados com 37 adições e 307 exclusões
+2 -8
Ver Arquivo
@@ -532,11 +532,7 @@ int AliasManager::testAccesses(ExpressionPtr e1, ExpressionPtr e2,
goto def;
}
case Expression::KindOfIncludeExpression: {
IncludeExpressionPtr inc(spc(IncludeExpression, e2));
if (!inc->isPrivateScope()) {
return InterfAccess;
}
goto def;
return InterfAccess;
}
case Expression::KindOfStaticMemberExpression:
case Expression::KindOfObjectPropertyExpression:
@@ -2311,9 +2307,7 @@ int AliasManager::collectAliasInfoRecur(ConstructPtr cs, bool unused) {
case Expression::KindOfIncludeExpression:
{
IncludeExpressionPtr inc(spc(IncludeExpression, e));
if (!inc->isPrivateScope()) {
m_variables->setAttribute(VariableTable::ContainsLDynamicVariable);
}
m_variables->setAttribute(VariableTable::ContainsLDynamicVariable);
}
break;
case Expression::KindOfArrayElementExpression:
+3 -14
Ver Arquivo
@@ -1697,10 +1697,7 @@ void EmitterVisitor::visit(FileScopePtr file) {
FunctionScopeRawPtr ps DEBUG_ONLY =
sl->getFunctionScope();
assert(ps && ps->inPseudoMain());
UnitMergeKind kind = inc->isPrivateScope() ?
(inc->isDocumentRoot() ?
UnitMergeKindReqMod : UnitMergeKindReqSrc) :
UnitMergeKindReqDoc;
UnitMergeKind kind = UnitMergeKindReqDoc;
m_ue.pushMergeableInclude(
kind,
StringData::GetStaticString(inc->includePath()));
@@ -3248,17 +3245,9 @@ bool EmitterVisitor::visitImpl(ConstructPtr node) {
break;
case T_REQUIRE_ONCE:
if (ie->isDocumentRoot()) {
if (ie->isPrivateScope()) {
e.ReqMod();
} else {
e.ReqDoc();
}
e.ReqDoc();
} else {
if (ie->isPrivateScope()) {
e.ReqSrc();
} else {
e.ReqOnce();
}
e.ReqOnce();
}
break;
}
+9 -29
Ver Arquivo
@@ -39,9 +39,7 @@ IncludeExpression::IncludeExpression
: UnaryOpExpression(
EXPRESSION_CONSTRUCTOR_PARAMETER_VALUES(IncludeExpression),
exp, op, true),
m_documentRoot(false), m_privateScope(false),
m_privateInclude(false), m_module(false),
m_depsSet(false) {
m_documentRoot(false), m_depsSet(false) {
}
ExpressionPtr IncludeExpression::clone() {
@@ -180,8 +178,7 @@ string IncludeExpression::CheckInclude(ConstructPtr includeExp,
void IncludeExpression::onParse(AnalysisResultConstPtr ar, FileScopePtr scope) {
/* m_documentRoot is a bitfield */
bool dr = m_documentRoot;
m_include = CheckInclude(shared_from_this(), m_exp,
dr, m_privateScope && !dr);
m_include = CheckInclude(shared_from_this(), m_exp, dr, false);
m_documentRoot = dr;
if (!m_include.empty()) ar->parseOnDemand(m_include);
}
@@ -196,20 +193,12 @@ FileScopeRawPtr IncludeExpression::getIncludedFile(
}
std::string IncludeExpression::includePath() const {
if (m_documentRoot || !m_privateScope) return m_include;
Variant v;
if (m_exp && m_exp->getScalarValue(v) &&
v.isString()) {
return v.toString()->data();
}
return "";
return m_include;
}
bool IncludeExpression::isReqLit() const {
return !m_include.empty() &&
m_op == T_REQUIRE_ONCE &&
(isDocumentRoot() || isPrivateScope());
m_op == T_REQUIRE_ONCE && isDocumentRoot();
}
bool IncludeExpression::analyzeInclude(AnalysisResultConstPtr ar,
@@ -220,13 +209,6 @@ bool IncludeExpression::analyzeInclude(AnalysisResultConstPtr ar,
Compiler::Error(Compiler::PHPIncludeFileNotFound, self);
return false;
}
if (m_module || m_privateInclude) {
Lock l(BlockScope::s_constMutex);
if (m_module) file->setModule();
if (m_privateInclude) {
file->setPrivateInclude();
}
}
FunctionScopePtr func = getFunctionScope();
if (func && file->getPseudoMain()) {
@@ -246,11 +228,10 @@ void IncludeExpression::analyzeProgram(AnalysisResultPtr ar) {
}
}
}
if (!m_privateScope) {
VariableTablePtr var = getScope()->getVariables();
var->setAttribute(VariableTable::ContainsLDynamicVariable);
var->forceVariants(ar, VariableTable::AnyVars);
}
VariableTablePtr var = getScope()->getVariables();
var->setAttribute(VariableTable::ContainsLDynamicVariable);
var->forceVariants(ar, VariableTable::AnyVars);
UnaryOpExpression::analyzeProgram(ar);
}
@@ -259,8 +240,7 @@ ExpressionPtr IncludeExpression::preOptimize(AnalysisResultConstPtr ar) {
if (ar->getPhase() >= AnalysisResult::FirstPreOptimize) {
if (m_include.empty()) {
bool dr = m_documentRoot;
m_include = CheckInclude(shared_from_this(), m_exp,
dr, m_privateScope && !dr);
m_include = CheckInclude(shared_from_this(), m_exp, dr, false);
m_documentRoot = dr;
m_depsSet = false;
}
@@ -44,12 +44,6 @@ public:
bool isReqLit() const;
void setDocumentRoot() { m_documentRoot = true;}
bool isDocumentRoot() const { return m_documentRoot;}
void setPrivateScope() { m_privateScope = true; }
bool isPrivateScope() const { return m_privateScope; }
void setPrivateInclude() { m_privateInclude = true; }
bool isPrivateInclude() const { return m_privateInclude; }
void setModule() { m_module = 1; }
bool isModule() const { return m_module; }
std::string includePath() const;
FileScopeRawPtr getIncludedFile(AnalysisResultConstPtr) const;
private:
@@ -64,9 +58,6 @@ private:
* privateInclude means this is the *only* reference to the included file
*/
unsigned m_documentRoot : 1;
unsigned m_privateScope : 1;
unsigned m_privateInclude : 1;
unsigned m_module : 1;
unsigned m_depsSet : 1;
std::string m_include;
-10
Ver Arquivo
@@ -3470,16 +3470,6 @@ ReqDoc [C] -> [C]
As ReqOnce except the string is always taken to be relative to the document
root (ie SourceRoot).
ReqMod [C] -> [C]
As ReqDoc except the pseudo-main function inherits an empty variable
environment.
ReqSrc [C] -> [C]
As ReqMod except the path is always taken to be relative to the including
file.
Eval [C] -> [C]
Eval. Executes the source code in (string)$1. This instruction eagerly marks
-8
Ver Arquivo
@@ -6591,14 +6591,6 @@ inline void OPTBLD_INLINE VMExecutionContext::iopReqDoc(PC& pc) {
inclOp(this, pc, InclOpFatal | InclOpOnce | InclOpDocRoot);
}
inline void OPTBLD_INLINE VMExecutionContext::iopReqMod(PC& pc) {
inclOp(this, pc, InclOpFatal | InclOpOnce | InclOpDocRoot | InclOpLocal);
}
inline void OPTBLD_INLINE VMExecutionContext::iopReqSrc(PC& pc) {
inclOp(this, pc, InclOpFatal | InclOpOnce | InclOpRelative | InclOpLocal);
}
inline void OPTBLD_INLINE VMExecutionContext::iopEval(PC& pc) {
NEXT();
Cell* c1 = m_stack.topC();
-2
Ver Arquivo
@@ -532,8 +532,6 @@ enum SetOpOp {
O(Req, NA, ONE(CV), ONE(CV), CF) \
O(ReqOnce, NA, ONE(CV), ONE(CV), CF) \
O(ReqDoc, NA, ONE(CV), ONE(CV), CF) \
O(ReqMod, NA, ONE(CV), ONE(CV), CF) \
O(ReqSrc, NA, ONE(CV), ONE(CV), CF) \
O(Eval, NA, ONE(CV), ONE(CV), CF) \
O(DefFunc, ONE(IVA), NOV, NOV, NF) \
O(DefCls, ONE(IVA), NOV, NOV, NF) \
@@ -596,16 +596,6 @@ void HhbcTranslator::emitReqDoc(const StringData* name) {
// emitInterpOne(Type::Cell);
}
void HhbcTranslator::emitReqMod(const StringData* name) {
// PUNT(ReqMod);
emitReqDoc(name);
}
void HhbcTranslator::emitReqSrc(const StringData* name) {
// PUNT(ReqSrc);
emitReqDoc(name);
}
template<class Lambda>
SSATmp* HhbcTranslator::emitIterInitCommon(int offset, Lambda genFunc) {
SSATmp* src = popC();
@@ -320,8 +320,6 @@ struct HhbcTranslator {
void emitStaticLocInit(uint32_t varId, uint32_t listStrId);
void emitReqDoc(const StringData* name);
void emitReqMod(const StringData* name);
void emitReqSrc(const StringData* name);
// iterators
void emitIterInit(uint32_t iterId, int targetOffset, uint32_t valLocalId);
@@ -1072,20 +1072,6 @@ TranslatorX64::irTranslateReqDoc(const Tracelet& t,
HHIR_EMIT(ReqDoc, name);
}
void
TranslatorX64::irTranslateReqMod(const Tracelet& t,
const NormalizedInstruction& i) {
const StringData* name = i.inputs[0]->rtt.valueStringOrNull();
HHIR_EMIT(ReqMod, name);
}
void
TranslatorX64::irTranslateReqSrc(const Tracelet& t,
const NormalizedInstruction& i) {
const StringData* name = i.inputs[0]->rtt.valueStringOrNull();
HHIR_EMIT(ReqSrc, name);
}
void TranslatorX64::irTranslateDefCls(const Tracelet& t,
const NormalizedInstruction& i) {
int cid = i.imm[0].u_IVA;
+1 -23
Ver Arquivo
@@ -8528,16 +8528,6 @@ TranslatorX64::analyzeReqDoc(Tracelet& t, NormalizedInstruction& i) {
analyzeReqLit(t, i, InclOpDocRoot);
}
void
TranslatorX64::analyzeReqMod(Tracelet& t, NormalizedInstruction& i) {
analyzeReqLit(t, i, InclOpDocRoot | InclOpLocal);
}
void
TranslatorX64::analyzeReqSrc(Tracelet& t, NormalizedInstruction& i) {
analyzeReqLit(t, i, InclOpRelative | InclOpLocal);
}
void
TranslatorX64::translateReqLit(const Tracelet& t,
const NormalizedInstruction& i,
@@ -8624,18 +8614,6 @@ TranslatorX64::translateReqDoc(const Tracelet& t,
translateReqLit(t, i, InclOpDocRoot);
}
void
TranslatorX64::translateReqMod(const Tracelet& t,
const NormalizedInstruction& i) {
translateReqLit(t, i, InclOpDocRoot | InclOpLocal);
}
void
TranslatorX64::translateReqSrc(const Tracelet& t,
const NormalizedInstruction& i) {
translateReqLit(t, i, InclOpRelative | InclOpLocal);
}
TCA
TranslatorX64::emitNativeTrampoline(TCA helperAddr) {
auto& a = atrampolines;
@@ -11475,7 +11453,7 @@ TranslatorX64::translateTracelet(SrcKey sk, bool considerHHIR/*=true*/,
// SrcRec::newTranslation() makes this code reachable. Do this last;
// otherwise there's some chance of hitting in the reader threads whose
// metadata is not yet visible.
TRACE(1, "newTranslation: %p sk: (func %d, bcOff %d)\n",
TRACE(1, "newTranslation: %p sk: (func %d, bcOff %d)\n",
start, sk.getFuncId(), sk.m_offset);
srcRec.newTranslation(a, astubs, start);
TRACE(1, "tx64: %zd-byte tracelet\n", a.code.frontier - start);
@@ -579,8 +579,6 @@ MINSTRS
CASE(IterNext) \
CASE(IterNextK) \
CASE(ReqDoc) \
CASE(ReqMod) \
CASE(ReqSrc) \
CASE(DefCls) \
CASE(DefFunc) \
CASE(Self) \
-6
Ver Arquivo
@@ -1162,8 +1162,6 @@ static const struct {
{ OpReq, {Stack1, Stack1, OutUnknown, 0 }},
{ OpReqOnce, {Stack1, Stack1, OutUnknown, 0 }},
{ OpReqDoc, {Stack1, Stack1, OutUnknown, 0 }},
{ OpReqMod, {Stack1, Stack1, OutUnknown, 0 }},
{ OpReqSrc, {Stack1, Stack1, OutUnknown, 0 }},
{ OpEval, {Stack1, Stack1, OutUnknown, 0 }},
{ OpDefFunc, {None, None, OutNone, 0 }},
{ OpDefCls, {None, None, OutNone, 0 }},
@@ -1465,8 +1463,6 @@ void Translator::analyzeSecondPass(Tracelet& t) {
if (prevOp == OpString &&
(ni->m_txFlags & Supported)) {
switch (op) {
case OpReqMod:
case OpReqSrc:
case OpReqDoc:
/* Dont waste a register on the string */
prev->outStack = nullptr;
@@ -1495,8 +1491,6 @@ void Translator::analyzeSecondPass(Tracelet& t) {
NormalizedInstruction* ppp = prev->prev->prev;
if (ppp && (ppp->m_txFlags & Supported)) {
switch (ppp->op()) {
case OpReqMod:
case OpReqSrc:
case OpReqDoc:
/*
We have a require+pop followed by a require or a scalar ret,
-2
Ver Arquivo
@@ -1065,8 +1065,6 @@ opcodeControlFlowInfo(const Opcode instr) {
case OpReq:
case OpReqOnce:
case OpReqDoc:
case OpReqMod:
case OpReqSrc:
return ControlFlowChangesPC;
default:
return ControlFlowNone;
+19 -56
Ver Arquivo
@@ -648,7 +648,6 @@ void Unit::initialMerge() {
end = m_mergeInfo->m_mergeablesSize;
while (ix < end) {
void *obj = m_mergeInfo->mergeableObj(ix);
InclOpFlags flags = InclOpDefault;
UnitMergeKind k = UnitMergeKind(uintptr_t(obj) & 7);
switch (k) {
case UnitMergeKindUniqueDefinedClass:
@@ -659,25 +658,16 @@ void Unit::initialMerge() {
allClassesUnique = ((PreClass*)obj)->attrs() & AttrUnique;
}
break;
case UnitMergeKindReqMod:
flags = InclOpDocRoot | InclOpLocal;
goto inc;
case UnitMergeKindReqSrc:
flags = InclOpRelative | InclOpLocal;
goto inc;
case UnitMergeKindReqDoc:
flags = InclOpDocRoot;
goto inc;
inc: {
StringData* s = (StringData*)((char*)obj - (int)k);
HPHP::Eval::PhpFile* efile =
g_vmContext->lookupIncludeRoot(s, flags, nullptr, this);
assert(efile);
Unit* unit = efile->unit();
unit->initialMerge();
m_mergeInfo->mergeableObj(ix) = (void*)((char*)unit + (int)k);
}
case UnitMergeKindReqDoc: {
StringData* s = (StringData*)((char*)obj - (int)k);
HPHP::Eval::PhpFile* efile =
g_vmContext->lookupIncludeRoot(s, InclOpDocRoot, nullptr, this);
assert(efile);
Unit* unit = efile->unit();
unit->initialMerge();
m_mergeInfo->mergeableObj(ix) = (void*)((char*)unit + (int)k);
break;
}
case UnitMergeKindDefine: {
StringData* s = (StringData*)((char*)obj - (int)k);
auto* v = (TypedValueAux*) m_mergeInfo->mergeableData(ix + 1);
@@ -828,8 +818,6 @@ size_t compactUnitMergeInfo(UnitMergeInfo* in, UnitMergeInfo* out) {
ix += sizeof(TypedValueAux) / sizeof(void*);
break;
case UnitMergeKindReqMod:
case UnitMergeKindReqSrc:
case UnitMergeKindReqDoc: {
Unit *unit = (Unit*)((char*)obj - (int)k);
void *rep = unit->replaceUnit();
@@ -839,19 +827,6 @@ size_t compactUnitMergeInfo(UnitMergeInfo* in, UnitMergeInfo* out) {
if (rep == unit) {
out->mergeableObj(oix++) = obj;
} else {
UnitMergeKind k1 = UnitMergeKind(uintptr_t(rep) & 7);
switch (k1) {
case UnitMergeKindReqMod:
case UnitMergeKindReqSrc:
break;
case UnitMergeKindReqDoc:
if (k != UnitMergeKindReqDoc) {
rep = obj;
}
break;
default:
break;
}
out->mergeableObj(oix++) = rep;
}
}
@@ -1037,8 +1012,6 @@ void Unit::mergeImpl(void* tcbase, UnitMergeInfo* mi) {
} while (k == UnitMergeKindGlobal);
continue;
case UnitMergeKindReqMod:
case UnitMergeKindReqSrc:
case UnitMergeKindReqDoc:
do {
Stats::inc(Stats::UnitMerge_mergeable);
@@ -1053,18 +1026,16 @@ void Unit::mergeImpl(void* tcbase, UnitMergeInfo* mi) {
Stats::inc(Stats::PseudoMain_Reentered);
TypedValue ret;
VarEnv* ve = nullptr;
if (k == UnitMergeKindReqDoc) {
ActRec* fp = g_vmContext->m_fp;
if (!fp) {
ve = g_vmContext->m_globalVarEnv;
ActRec* fp = g_vmContext->m_fp;
if (!fp) {
ve = g_vmContext->m_globalVarEnv;
} else {
if (fp->hasVarEnv()) {
ve = fp->m_varEnv;
} else {
if (fp->hasVarEnv()) {
ve = fp->m_varEnv;
} else {
// Nothing to do. If there is no varEnv, the enclosing
// file was called by fb_autoload_map, ReqSrc or ReqMod
// All those cases wanted a local scope.
}
// Nothing to do. If there is no varEnv, the enclosing
// file was called by fb_autoload_map, which wants a
// local scope.
}
}
g_vmContext->invokeFunc(&ret, unit->getMain(), Array(),
@@ -1728,9 +1699,7 @@ void UnitRepoProxy::InsertUnitMergeableStmt
kind == UnitMergeKindGlobal);
query.bindTypedValue("@mergeableValue", *value);
} else {
assert(kind == UnitMergeKindReqMod ||
kind == UnitMergeKindReqSrc ||
kind == UnitMergeKindReqDoc);
assert(kind == UnitMergeKindReqDoc);
query.bindNull("@mergeableValue");
}
query.exec();
@@ -1767,8 +1736,6 @@ void UnitRepoProxy::GetUnitMergeablesStmt
int mergeableKind; /**/ query.getInt(1, mergeableKind);
Id mergeableId; /**/ query.getInt(2, mergeableId);
switch (mergeableKind) {
case UnitMergeKindReqMod:
case UnitMergeKindReqSrc:
case UnitMergeKindReqDoc:
ue.insertMergeableInclude(mergeableIx,
(UnitMergeKind)mergeableKind, mergeableId);
@@ -2246,8 +2213,6 @@ bool UnitEmitter::insert(UnitOrigin unitOrigin, RepoTxn& txn) {
case UnitMergeKindUniqueDefinedClass:
not_reached();
case UnitMergeKindClass: break;
case UnitMergeKindReqMod:
case UnitMergeKindReqSrc:
case UnitMergeKindReqDoc: {
urp.insertUnitMergeable(repoId).insert(
txn, usn, i,
@@ -2392,8 +2357,6 @@ Unit* UnitEmitter::create() {
case UnitMergeKindClass:
mi->mergeableObj(ix++) = u->m_preClasses[it->second].get();
break;
case UnitMergeKindReqMod:
case UnitMergeKindReqSrc:
case UnitMergeKindReqDoc: {
assert(RuntimeOption::RepoAuthoritative);
void* name = u->lookupLitstrId(it->second);
+3 -5
Ver Arquivo
@@ -53,9 +53,8 @@ enum UnitMergeKind {
UnitMergeKindUniqueDefinedClass = 1,
UnitMergeKindDefine = 2,
UnitMergeKindGlobal = 3,
UnitMergeKindReqMod = 4, // used by isMergeKindReq
UnitMergeKindReqSrc = 5, // "
UnitMergeKindReqDoc = 6, // "
// 4 and 5 are available
UnitMergeKindReqDoc = 6,
UnitMergeKindDone = 7,
// We cannot add more kinds here; this has to fit in 3 bits.
};
@@ -71,8 +70,7 @@ enum UnitMergeState {
};
inline bool ALWAYS_INLINE isMergeKindReq(UnitMergeKind k) {
return unsigned(k - UnitMergeKindReqMod) <=
unsigned(UnitMergeKindReqDoc - UnitMergeKindReqMod);
return k == UnitMergeKindReqDoc;
}
struct UnitMergeInfo {
-99
Ver Arquivo
@@ -1,99 +0,0 @@
# This should be essentially the same as reqonce.php,
# except using the ReqMod opcode instead.
.main {
FPushCtorD 0 "TestClass"
FCall 0
PopR
FPushObjMethodD 0 "testwithctx"
FCall 0
PopR
FPushFuncD 0 "testnoctx"
FCall 0
PopR
Int 1
RetC
}
.function testnoctx {
String "testing from anonymous context\n"
Print
PopC
String "testvar set before Req? "
Print
PopC
IssetL $testvar
Print
PopC
String "\n"
Print
PopC
String "reqtests/mod.php"
Req
PopC
String "testvar set after Req? "
Print
PopC
IssetL $testvar
Print
PopC
String "\n"
Print
PopC
Null
RetC
}
.class TestClass {
.property [public] var = """s:5:"hello";""";
.method [public] 86ctor {
Null
RetC
}
.method [public] testwithctx {
String "value of var before ReqMod: "
This
CGetM <C PT:"var">
Concat
String "\n"
Concat
Print
PopC
# ReqMod and ReqDoc don't look in the current dir
String "test/vm/reqtests/mod.php"
ReqMod
PopC
String "value of var after ReqMod: "
This
CGetM <C PT:"var">
Concat
String "\n"
Concat
Print
PopC
String "testvar set after ReqMod? "
Print
PopC
IssetL $testvar
Print
PopC
String "\n"
Print
PopC
Null
RetC
}
}
-8
Ver Arquivo
@@ -1,8 +0,0 @@
value of var before ReqMod: hello
in mod.php
value of var after ReqMod: hello
testvar set after ReqMod?
testing from anonymous context
testvar set before Req?
in mod.php
testvar set after Req? 1