String count limit exceeded


Compiling huge PHP script (600k lines of code) results in error:
error PHP2007: Internal error!
Please, report this bug via http://www.codeplex.com/WorkItem/List.aspx?ProjectName=Phalanger.
Additional information:
No logical space left to create more user strings. (Exception from HRESULT: 0x80131198)
   at System.Reflection.Emit.ModuleBuilder.GetStringConstant(RuntimeModule module, String str, Int32 length)
   at System.Reflection.Emit.ILGenerator.Emit(OpCode opcode, String str)
   at PHP.Core.Emit.ILEmitter.LoadLiteral(Object value, Boolean box)
   at PHP.Core.AST.Literal.Emit(CodeGenerator codeGenerator)
   at PHP.Core.AST.ActualParam.Emit(CodeGenerator codeGenerator)
   at PHP.Core.Compiler.CodeGenerator.CallSitesBuilder.EmitMethodCallParameters(CodeGenerator cg, CallSignature callSignature)
   at PHP.Core.Compiler.CodeGenerator.CallSitesBuilder.EmitMethodCall(CodeGenerator cg, Type returnType, Expression targetExpr, DType targetType, String methodFullName, Expression methodNameExpr, CallSignature callSignature
   at PHP.Core.AST.DirectFcnCall.Emit(CodeGenerator codeGenerator)
   at PHP.Core.AST.ValueAssignEx.EmitSourceValRead(CodeGenerator codeGenerator)
   at PHP.Core.AST.ValueAssignEx.Emit(CodeGenerator codeGenerator)
   at PHP.Core.AST.ExpressionStmt.Emit(CodeGenerator codeGenerator)
   at PHP.Core.CodeGenerator.EmitArgfullOverloadBody(PhpRoutine routine, List`1 body, Position entirePosition, ShortPosition declarationBodyPosition)
   at PHP.Core.AST.MethodDecl.Emit(CodeGenerator codeGenerator)
   at PHP.Core.AST.TypeDecl.EmitDefinition(CodeGenerator codeGenerator)
   at PHP.Core.AST.GlobalCode.Emit(CodeGenerator codeGenerator)
   at PHP.Core.Reflection.SourceUnit.Emit(CodeGenerator codeGen)
   at PHP.Core.Reflection.ScriptCompilationUnit.Emit(CodeGenerator codeGenerator)
   at PHP.Core.Reflection.InclusionGraphBuilder.EmitAllUnits(CodeGenerator codeGenerator)
   at PHP.Core.Emit.ScriptAssemblyBuilder.CompileScripts(IEnumerable`1 sourceFiles, CompilationContext context)
   at PHP.Core.ApplicationCompiler.Compile(ApplicationContext applicationContext, CompilerConfiguration config, ErrorSink errorSink, CompilationParameters ps)
And, of course, my disk isn't full :)


achlubek wrote Feb 11, 2014 at 9:07 AM

I know about string embedding limit and need to switch to resources, but if PHP supports it nativelu - you sould consider generating resources on fly too.
Also refactoring 600k loc project is pure pain

wrote Aug 7, 2014 at 5:08 PM

thermous wrote Aug 7, 2014 at 5:08 PM

I am hitting this as well trying to use MediaWiki 1.23

I see that the phalanger wiki is running on MediaWiki, so is this a regression?

jakub wrote Aug 8, 2014 at 12:32 PM

wiki.php-compiler.net runs older mediawiki (1.6.10) so I assume there are not as many string literals as it is in newer version.

This is common issue, currently the only workaround is to compile the project into several assemblies separately.