Func* FuncEmitter::create(Unit& unit, PreClass* preClass /* = NULL */) const { Func* f = (m_pce == NULL) ? m_ue.newFunc(this, unit, m_id, m_line1, m_line2, m_base, m_past, m_name, m_attrs, m_top, m_docComment, m_params.size()) : m_ue.newFunc(this, unit, preClass, m_line1, m_line2, m_base, m_past, m_name, m_attrs, m_top, m_docComment, m_params.size()); f->shared()->m_info = m_info; for (unsigned i = 0; i < m_params.size(); ++i) { Func::ParamInfo pi; pi.setFuncletOff(m_params[i].funcletOff()); pi.setDefaultValue(m_params[i].defaultValue()); pi.setPhpCode(m_params[i].phpCode()); pi.setTypeConstraint(m_params[i].typeConstraint()); pi.setUserAttributes(m_params[i].userAttributes()); f->appendParam(m_params[i].ref(), pi); } f->shared()->m_localNames.create(m_localNames); f->shared()->m_numLocals = m_numLocals; f->shared()->m_numIterators = m_numIterators; f->m_maxStackCells = m_maxStackCells; ASSERT(m_maxStackCells > 0 && "You probably didn't set m_maxStackCells"); f->shared()->m_staticVars = m_staticVars; f->shared()->m_ehtab = m_ehtab; f->shared()->m_fpitab = m_fpitab; f->shared()->m_isClosureBody = m_isClosureBody; f->shared()->m_isGenerator = m_isGenerator; f->shared()->m_isGeneratorFromClosure = m_isGeneratorFromClosure; f->shared()->m_userAttributes = m_userAttributes; f->shared()->m_builtinFuncPtr = m_builtinFuncPtr; return f; }
Func* FuncEmitter::create(Unit& unit, PreClass* preClass /* = NULL */) const { Attr attrs = m_attrs; if (attrs & AttrPersistent && (RuntimeOption::EvalJitEnableRenameFunction || (!RuntimeOption::RepoAuthoritative && SystemLib::s_inited))) { attrs = Attr(attrs & ~AttrPersistent); } Func* f = (m_pce == NULL) ? m_ue.newFunc(this, unit, m_id, m_line1, m_line2, m_base, m_past, m_name, attrs, m_top, m_docComment, m_params.size()) : m_ue.newFunc(this, unit, preClass, m_line1, m_line2, m_base, m_past, m_name, attrs, m_top, m_docComment, m_params.size()); f->shared()->m_info = m_info; f->shared()->m_returnType = m_returnType; std::vector<Func::ParamInfo> pBuilder; for (unsigned i = 0; i < m_params.size(); ++i) { Func::ParamInfo pi; pi.setFuncletOff(m_params[i].funcletOff()); pi.setDefaultValue(m_params[i].defaultValue()); pi.setPhpCode(m_params[i].phpCode()); pi.setTypeConstraint(m_params[i].typeConstraint()); pi.setUserAttributes(m_params[i].userAttributes()); pi.setBuiltinType(m_params[i].builtinType()); f->appendParam(m_params[i].ref(), pi, pBuilder); } f->shared()->m_params = pBuilder; f->shared()->m_localNames.create(m_localNames); f->shared()->m_numLocals = m_numLocals; f->shared()->m_numIterators = m_numIterators; f->m_maxStackCells = m_maxStackCells; ASSERT(m_maxStackCells > 0 && "You probably didn't set m_maxStackCells"); f->shared()->m_staticVars = m_staticVars; f->shared()->m_ehtab = m_ehtab; f->shared()->m_fpitab = m_fpitab; f->shared()->m_isClosureBody = m_isClosureBody; f->shared()->m_isGenerator = m_isGenerator; f->shared()->m_isGeneratorFromClosure = m_isGeneratorFromClosure; f->shared()->m_userAttributes = m_userAttributes; f->shared()->m_builtinFuncPtr = m_builtinFuncPtr; f->shared()->m_nativeFuncPtr = m_nativeFuncPtr; return f; }
Func* FuncEmitter::create(Unit& unit, PreClass* preClass /* = NULL */) const { bool isGenerated = isdigit(m_name->data()[0]) || ParserBase::IsClosureName(m_name->toCPPString()) || m_isGenerator; Attr attrs = m_attrs; if (attrs & AttrPersistent && ((RuntimeOption::EvalJitEnableRenameFunction && !isGenerated) || (!RuntimeOption::RepoAuthoritative && SystemLib::s_inited))) { attrs = Attr(attrs & ~AttrPersistent); } if (RuntimeOption::EvalJitEnableRenameFunction && !m_name->empty() && !Func::isSpecial(m_name) && !m_isClosureBody && !m_isGenerator) { // intercepted functions need to pass all args through // to the interceptee attrs = attrs | AttrMayUseVV; } if (!m_containsCalls) attrs = Attr(attrs | AttrPhpLeafFn); Func* f = (m_pce == nullptr) ? m_ue.newFunc(this, unit, m_id, m_line1, m_line2, m_base, m_past, m_name, attrs, m_top, m_docComment, m_params.size(), m_isClosureBody | m_isGeneratorFromClosure, m_isGenerator) : m_ue.newFunc(this, unit, preClass, m_line1, m_line2, m_base, m_past, m_name, attrs, m_top, m_docComment, m_params.size(), m_isClosureBody | m_isGeneratorFromClosure, m_isGenerator); f->shared()->m_info = m_info; f->shared()->m_returnType = m_returnType; std::vector<Func::ParamInfo> pBuilder; for (unsigned i = 0; i < m_params.size(); ++i) { Func::ParamInfo pi; pi.setFuncletOff(m_params[i].funcletOff()); pi.setDefaultValue(m_params[i].defaultValue()); pi.setPhpCode(m_params[i].phpCode()); pi.setTypeConstraint(m_params[i].typeConstraint()); pi.setUserAttributes(m_params[i].userAttributes()); pi.setBuiltinType(m_params[i].builtinType()); pi.setUserType(m_params[i].userType()); f->appendParam(m_params[i].ref(), pi, pBuilder); } if (!m_params.size()) { assert(!f->m_refBitVal && !f->shared()->m_refBitPtr); f->m_refBitVal = attrs & AttrVariadicByRef ? -1uLL : 0uLL; } f->shared()->m_params = pBuilder; f->shared()->m_localNames.create(m_localNames); f->shared()->m_numLocals = m_numLocals; f->shared()->m_numIterators = m_numIterators; f->m_maxStackCells = m_maxStackCells; f->shared()->m_staticVars = m_staticVars; f->shared()->m_ehtab = m_ehtab; f->shared()->m_fpitab = m_fpitab; f->shared()->m_isClosureBody = m_isClosureBody; f->shared()->m_isGenerator = m_isGenerator; f->shared()->m_isGeneratorFromClosure = m_isGeneratorFromClosure; f->shared()->m_isPairGenerator = m_isPairGenerator; f->shared()->m_hasGeneratorAsBody = m_hasGeneratorAsBody; f->shared()->m_userAttributes = m_userAttributes; f->shared()->m_builtinFuncPtr = m_builtinFuncPtr; f->shared()->m_nativeFuncPtr = m_nativeFuncPtr; f->shared()->m_retTypeConstraint = m_retTypeConstraint; f->shared()->m_originalFilename = m_originalFilename; f->shared()->m_isGenerated = isGenerated; return f; }