Permalink
Browse files

Latest from HipHop trunk

  • Loading branch information...
joelpob authored and Blank Ubuntu 64 bit committed Jun 22, 2012
1 parent a4fbb08 commit 7623d660a872e19f2f16de93a5d08cb73490755c
Showing 467 changed files with 92,639 additions and 83,349 deletions.
View
@@ -39,6 +39,8 @@ hphp.log
/src/tools/shmw/shmw
+/tools/tc-print/tc-print
+
/src/ffi/java/classes
/src/ffi/java/hphp_ffi_java.h
View
@@ -36,10 +36,10 @@ CMAKE_COMMAND = /usr/bin/cmake
RM = /usr/bin/cmake -E remove -f
# The top-level source directory on which CMake was run.
-CMAKE_SOURCE_DIR = /home/joelp/dev/hiphop-php
+CMAKE_SOURCE_DIR = /home/joelp/dev2/hiphop-php
# The top-level build directory on which CMake was run.
-CMAKE_BINARY_DIR = /home/joelp/dev/hiphop-php
+CMAKE_BINARY_DIR = /home/joelp/dev2/hiphop-php
#=============================================================================
# Targets provided globally by CMake.
@@ -107,9 +107,9 @@ rebuild_cache/fast: rebuild_cache
# The main all target
all: cmake_check_build_system
- $(CMAKE_COMMAND) -E cmake_progress_start /home/joelp/dev/hiphop-php/CMakeFiles /home/joelp/dev/hiphop-php/CMakeFiles/progress.marks
+ $(CMAKE_COMMAND) -E cmake_progress_start /home/joelp/dev2/hiphop-php/CMakeFiles /home/joelp/dev2/hiphop-php/CMakeFiles/progress.marks
$(MAKE) -f CMakeFiles/Makefile2 all
- $(CMAKE_COMMAND) -E cmake_progress_start /home/joelp/dev/hiphop-php/CMakeFiles 0
+ $(CMAKE_COMMAND) -E cmake_progress_start /home/joelp/dev2/hiphop-php/CMakeFiles 0
.PHONY : all
# The main clean target
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -36,3 +36,23 @@ Set a break point at line 55 of main.no.cpp, then "r", you will get this,
Magically, gdb is able to switch to main thread, attaching to it, then it will
be able to debug it, even if it forks afterwards.
+
+<h2> Getting PHP symbols in the JIT under gdb </h2>
+
+The VM periodically emits DWARF files containing function address
+information for the JIT code it generates. These DWARF files are synced with gdb
+asynchronously (by default every ~128 tracelets). This means that the backtrace
+you see under gdb may contain some unresolved PHP symbols that show up as ??s,
+for symbols that have not been synced.
+
+There are three ways to resolve this:
+
+1. pass -v Eval.GdbSyncChunks=1 in the command line. This forces the VM to sync
+debug info synchronously with gdb.
+
+2. call HPHP::g_context.m_node.m_p->syncGdbState() from the gdb CLI. This
+forces a manual sync of all outstanding symbols to gdb.
+
+3. if the program has hit a seg fault (or another signal), press continue on
+the CLI. The HHVM signal handler will sync outstanding DWARF symbols to gdb,
+and a subsequent 'bt' should show all symbols.
View
@@ -61,7 +61,8 @@ can be used to control repo behavior:
* Repo.Central.Path (overrides HHVM_REPO_CENTRAL_PATH)
There is always a central read-write repo. Non-eval units prefer to be written
in the local repo, but are written in the central repo if the local repo isn't
- writable.
+ writable. If unsepcified, or unusable, will fall back first to
+ $HHVM_REPO_CENTRAL_PATH, and then to ~user/.hhvm.hhbc
* Repo.Eval.Mode: local, central, or readonly(*)
local: Write eval units to the local repo if it is writable; otherwise write
to the central repo.
View
3,249 src/Makefile

Large diffs are not rendered by default.

Oops, something went wrong.
View

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -4419,9 +4419,11 @@ void AnalysisResult::outputCPPClassMap(CodeGenerator &cg) {
ASSERT(!func->isUserFunction());
func->outputCPPClassMap(cg, ar);
}
+
cg_printf("NULL,\n"); // methods
cg_printf("NULL,\n"); // properties
- // system constants
+
+ // constants
int len;
string output = SymbolTable::getEscapedText(false, len);
cg_printf("\"false\", (const char *)%d, \"%s\",\n",
@@ -4432,9 +4434,10 @@ void AnalysisResult::outputCPPClassMap(CodeGenerator &cg) {
output = SymbolTable::getEscapedText(null, len);
cg_printf("\"null\", (const char *)%d, \"%s\",\n",
len, output.c_str());
-
m_constants->outputCPPClassMap(cg, ar);
+ cg_printf("NULL,\n"); // attributes
+
// user functions
cg_printf("(const char *)ClassInfo::IsNothing, NULL, \"\","
" \"\", NULL, NULL,\n");
@@ -4467,6 +4470,8 @@ void AnalysisResult::outputCPPClassMap(CodeGenerator &cg) {
ConstantTablePtr constants = m_fileScopes[i]->getConstants();
constants->outputCPPClassMap(cg, ar, (i == (int)m_fileScopes.size() - 1));
}
+
+ cg_printf("NULL,\n"); // attributes
// system classes
for (StringToClassScopePtrMap::const_iterator iter = m_systemClasses.begin();
@@ -220,7 +220,7 @@ class BlockScope : private boost::noncopyable,
virtual void outputPHP(CodeGenerator &cg, AnalysisResultPtr ar);
virtual void outputCPP(CodeGenerator &cg, AnalysisResultPtr ar);
- virtual bool inPseudoMain() {
+ virtual bool inPseudoMain() const {
return false;
}
@@ -396,35 +396,23 @@ MethodStatementPtr
ClassScope::importTraitMethod(const TraitMethod& traitMethod,
AnalysisResultPtr ar,
string methName,
- GeneratorRenameMap& genRenameMap) {
+ GeneratorRenameMap& genRenameMap,
+ const std::map<string, MethodStatementPtr>&
+ importedTraitMethods) {
MethodStatementPtr meth = traitMethod.m_method;
string origMethName = traitMethod.m_originalName;
ModifierExpressionPtr modifiers = traitMethod.m_modifiers;
- // For abstract methods, simply return if method already exists in the class
- if ((modifiers && modifiers->isAbstract()) ||
- (!modifiers && meth->getModifiers()->isAbstract())) {
- if (findFunction(ar, methName, true)) {
- return MethodStatementPtr();
- }
- }
-
if (meth->getOrigGeneratorFunc()) {
const string &name = meth->getOrigGeneratorFunc()->getName();
- if (m_importMethToTraitMap.find(name) == m_importMethToTraitMap.end()) {
+ if (!importedTraitMethods.count(name)) {
// Dont import the generator, if the origGenerator wasnt imported
// this happens when a generator in the trait is hidden by a non-generator
// method in the importing class.
return MethodStatementPtr();
}
}
- // Check for errors before cloning
- if (modifiers && modifiers->isStatic()) {
- Compiler::Error(Compiler::InvalidAccessModifier, traitMethod.m_ruleStmt);
- return MethodStatementPtr();
- }
-
MethodStatementPtr cloneMeth = dynamic_pointer_cast<MethodStatement>(
dynamic_pointer_cast<ClassStatement>(m_stmt)->addClone(meth));
cloneMeth->setName(methName);
@@ -459,11 +447,6 @@ ClassScope::importTraitMethod(const TraitMethod& traitMethod,
ar->recordFunctionSource(cloneMeth->getFullName(), meth->getLocation(),
meth->getFileScope()->getName());
- // OrigGenerator methods need to have their hphp_create_continuation calls
- // patched to the new generator name.
- if (cloneMeth->getGeneratorFunc()) {
- renameCreateContinuationCalls(ar, cloneMeth, genRenameMap);
- }
return cloneMeth;
}
@@ -730,8 +713,8 @@ void ClassScope::removeSpareTraitAbstractMethods(AnalysisResultPtr ar) {
}
}
-const string& ClassScope::getNewGeneratorName(FunctionScopePtr genFuncScope,
- GeneratorRenameMap& genRenameMap) {
+const string& ClassScope::getNewGeneratorName(
+ FunctionScopePtr genFuncScope, GeneratorRenameMap &genRenameMap) {
ASSERT(genFuncScope->isGenerator());
const string& oldName = genFuncScope->getName();
GeneratorRenameMap::iterator mapIt = genRenameMap.find(oldName);
@@ -745,25 +728,27 @@ const string& ClassScope::getNewGeneratorName(FunctionScopePtr genFuncScope,
}
void
-ClassScope::renameCreateContinuationCalls(AnalysisResultPtr ar,
- ConstructPtr c,
- GeneratorRenameMap& genRenameMap) {
+ClassScope::renameCreateContinuationCalls(AnalysisResultPtr ar,
+ ConstructPtr c,
+ ImportedMethodMap &importedMethods) {
if (!c) return;
SimpleFunctionCallPtr funcCall = dynamic_pointer_cast<SimpleFunctionCall>(c);
if (funcCall && funcCall->getName() == "hphp_create_continuation") {
ExpressionListPtr params = funcCall->getParams();
ASSERT(params->getCount() >= 2);
- const string& oldClassName =
+ const string &oldClassName =
dynamic_pointer_cast<ScalarExpression>((*params)[0])->getString();
ClassScopePtr oldClassScope = ar->findClass(oldClassName);
if (!oldClassScope || !oldClassScope->isTrait()) return;
- const string& oldGenName =
+ const string &oldGenName =
dynamic_pointer_cast<ScalarExpression>((*params)[1])->getString();
- FunctionScopePtr oldGenScope = oldClassScope->findFunction(ar, oldGenName,
- false);
- const string& newGenName = getNewGeneratorName(oldGenScope, genRenameMap);
+
+ MethodStatementPtr origGenStmt = importedMethods[oldGenName];
+ ASSERT(origGenStmt);
+
+ const string &newGenName = origGenStmt->getOriginalName();
ExpressionPtr newGenExpr = funcCall->makeScalarExpression(ar, newGenName);
ExpressionPtr newClsExpr = funcCall->makeScalarExpression(ar, getName());
(*params)[0] = newClsExpr;
@@ -772,30 +757,37 @@ ClassScope::renameCreateContinuationCalls(AnalysisResultPtr ar,
return;
}
for (int i=0; i < c->getKidCount(); i++) {
- renameCreateContinuationCalls(ar, c->getNthKid(i), genRenameMap);
+ renameCreateContinuationCalls(ar, c->getNthKid(i), importedMethods);
}
}
-void ClassScope::relinkGeneratorMethods(AnalysisResultPtr ar,
- const std::list<MethodStatementPtr>& importedMethods) {
- for (std::list<MethodStatementPtr>::const_iterator methIt =
+void ClassScope::relinkGeneratorMethods(
+ AnalysisResultPtr ar,
+ ImportedMethodMap &importedMethods) {
+ for (ImportedMethodMap::const_iterator methIt =
importedMethods.begin(); methIt != importedMethods.end(); methIt++) {
- MethodStatementPtr newMeth = *methIt;
+ MethodStatementPtr newMeth = methIt->second;
// Skip non-generator methods
- if (!newMeth->getOrigGeneratorFunc()) continue;
+ if (!newMeth) continue;
+
+ if (newMeth->getOrigGeneratorFunc()) {
+ // Get corresponding original generator method in the current class
+ const string& origGenName = newMeth->getOrigGeneratorFunc()->getName();
+ MethodStatementPtr origGenStmt = importedMethods[origGenName];
+ ASSERT(origGenStmt);
+ // It must be an orig gen func already, we're just updating to point
+ // to the corresponding method cloned from the trait
+ ASSERT(origGenStmt->getGeneratorFunc());
+ newMeth->setOrigGeneratorFunc(origGenStmt);
+ origGenStmt->setGeneratorFunc(newMeth);
+ }
- // Get corresponding original generator method in the current class
- const string& origGenName = newMeth->getOrigGeneratorFunc()->getName();
- FunctionScopePtr origGenScope = findFunction(ar, origGenName, false);
- ASSERT(origGenScope);
- MethodStatementPtr origGenStmt =
- dynamic_pointer_cast<MethodStatement>(origGenScope->getStmt());
- // It must be an orig gen func already, we're just updating to point
- // to the corresponding method cloned from the trait
- ASSERT(origGenStmt->getGeneratorFunc());
- newMeth->setOrigGeneratorFunc(origGenStmt);
- origGenStmt->setGeneratorFunc(newMeth);
+ // OrigGenerator methods need to have their hphp_create_continuation calls
+ // patched to the new generator name.
+ if (newMeth->getGeneratorFunc()) {
+ renameCreateContinuationCalls(ar, newMeth, importedMethods);
+ }
}
}
@@ -841,7 +833,9 @@ void ClassScope::importUsedTraits(AnalysisResultPtr ar) {
}
}
- std::list<MethodStatementPtr> importedTraitMethods;
+ std::map<string, MethodStatementPtr> importedTraitMethods;
+ std::vector<std::pair<string,const TraitMethod*> > importedTraitsWithOrigName;
+
GeneratorRenameMap genRenameMap;
// Actually import the methods
@@ -859,11 +853,38 @@ void ClassScope::importUsedTraits(AnalysisResultPtr ar) {
Compiler::Error(Compiler::MethodInMultipleTraits, getStmt());
} else {
TraitMethodList::const_iterator traitMethIter = iter->second.begin();
- MethodStatementPtr newMeth = importTraitMethod(*traitMethIter, ar,
- iter->first, genRenameMap);
- if (newMeth) {
- importedTraitMethods.push_back(newMeth);
+ if ((traitMethIter->m_modifiers ? traitMethIter->m_modifiers :
+ traitMethIter->m_method->getModifiers())->isAbstract()) {
+ // Skip abstract methods, if method already exists in the class
+ if (findFunction(ar, iter->first, true) ||
+ importedTraitMethods.count(iter->first)) {
+ continue;
+ }
}
+ if (traitMethIter->m_modifiers &&
+ traitMethIter->m_modifiers->isStatic()) {
+ Compiler::Error(Compiler::InvalidAccessModifier,
+ traitMethIter->m_modifiers);
+ continue;
+ }
+
+ string sourceName = traitMethIter->m_ruleStmt ?
+ Util::toLower(((TraitAliasStatement*)traitMethIter->m_ruleStmt.get())->
+ getMethodName()) : iter->first;
+ importedTraitMethods[sourceName] = MethodStatementPtr();
+ importedTraitsWithOrigName.push_back(
+ make_pair(sourceName, &*traitMethIter));
+ }
+ }
+
+ for (unsigned i = 0; i < importedTraitsWithOrigName.size(); i++) {
+ const string &sourceName = importedTraitsWithOrigName[i].first;
+ const TraitMethod *traitMethod = importedTraitsWithOrigName[i].second;
+ MethodStatementPtr newMeth = importTraitMethod(
+ *traitMethod, ar, Util::toLower(traitMethod->m_originalName),
+ genRenameMap, importedTraitMethods);
+ if (newMeth) {
+ importedTraitMethods[sourceName] = newMeth;
}
}
@@ -1168,9 +1189,26 @@ void ClassScope::outputCPPClassMap(CodeGenerator &cg, AnalysisResultPtr ar) {
}
cg_printf("NULL,\n");
- // properties && constants
+ // properties
m_variables->outputCPPClassMap(cg, ar);
+
+ // constants
m_constants->outputCPPClassMap(cg, ar);
+
+ // user attributes
+ UserAttributeMap::const_iterator it = m_userAttributes.begin();
+ for (; it != m_userAttributes.end(); ++it) {
+ ExpressionPtr expr = it->second;
+ Variant v;
+ bool isScalar UNUSED = expr->getScalarValue(v);
+ ASSERT(isScalar);
+ int valueLen = 0;
+ string valueText = SymbolTable::getEscapedText(v, valueLen);
+ cg_printf("\"%s\", (const char *)%d, \"%s\",\n",
+ CodeGenerator::EscapeLabel(it->first).c_str(),
+ valueLen, valueText.c_str());
+ }
+ cg_printf("NULL,\n");
}
bool ClassScope::hasConst(const string &name) const {
@@ -2243,7 +2281,6 @@ void ClassScope::outputCPPGetClassPropTableImpl(
case KindOfBoolean:
if (cflags & ConstFalse) needsInit = false;
goto check_plain;
- case KindOfInt32:
case KindOfInt64:
if (cflags & ConstZero) needsInit = false;
goto check_plain;
@@ -585,6 +585,7 @@ class ClassScope : public BlockScope, public FunctionContainer,
typedef std::map<std::string, TraitMethodList> MethodToTraitListMap;
typedef std::map<std::string, std::string> GeneratorRenameMap;
MethodToTraitListMap m_importMethToTraitMap;
+ typedef std::map<std::string, MethodStatementPtr> ImportedMethodMap;
mutable int m_attribute;
int m_redeclaring; // multiple definition of the same class
@@ -618,12 +619,14 @@ class ClassScope : public BlockScope, public FunctionContainer,
MethodStatementPtr importTraitMethod(const TraitMethod& traitMethod,
AnalysisResultPtr ar,
std::string methName,
- GeneratorRenameMap& genRenameMap);
+ GeneratorRenameMap& genRenameMap,
+ const ImportedMethodMap &
+ importedTraitMethods);
void importTraitProperties(AnalysisResultPtr ar);
void relinkGeneratorMethods(AnalysisResultPtr ar,
- const std::list<MethodStatementPtr>& importedMethods);
+ ImportedMethodMap& importedMethods);
void findTraitMethodsToImport(AnalysisResultPtr ar, ClassScopePtr trait);
@@ -651,7 +654,7 @@ class ClassScope : public BlockScope, public FunctionContainer,
GeneratorRenameMap& genRenameMap);
void renameCreateContinuationCalls(AnalysisResultPtr ar, ConstructPtr c,
- GeneratorRenameMap& genRenameMap);
+ ImportedMethodMap &importedMethods);
std::string getBaseHeaderFilename();
@@ -180,7 +180,9 @@ TypePtr ConstantTable::check(BlockScopeRawPtr context,
if (defScope) return actualType;
}
}
- Compiler::Error(Compiler::UseUndeclaredConstant, construct);
+ if (!isClassScope || !((ClassScope*)&m_blockScope)->isTrait()) {
+ Compiler::Error(Compiler::UseUndeclaredConstant, construct);
+ }
actualType = isClassScope || !Option::WholeProgram ?
Type::Variant : Type::String;
}
Oops, something went wrong.

0 comments on commit 7623d66

Please sign in to comment.