1414use PHPJava \Exceptions \RuntimeException ;
1515use PHPJava \Exceptions \UndefinedMethodException ;
1616use PHPJava \Exceptions \UndefinedOpCodeException ;
17+ use PHPJava \Kernel \Provider \DependencyInjectionProvider ;
1718use PHPJava \Packages \java \lang \NoSuchMethodException ;
1819use PHPJava \Kernel \Attributes \AttributeInfo ;
1920use PHPJava \Kernel \Attributes \AttributeInterface ;
@@ -149,7 +150,11 @@ function () use ($name, $arguments) {
149150 $ executionTime = microtime (true );
150151 $ maxExecutionTime = ($ this ->options ['max_execution_time ' ] ?? GlobalOptions::get ('max_execution_time ' ) ?? Runtime::MAX_EXECUTION_TIME );
151152
152- $ methodBeautified = Formatter::beatifyMethodFromConstantPool ($ method , $ currentConstantPool );
153+ $ methodBeautified = Formatter::beatifyMethodFromConstantPool (
154+ $ method ,
155+ $ currentConstantPool
156+ );
157+
153158 $ this ->debugTool ->getLogger ()->info ('Start operations: ' . $ methodBeautified );
154159
155160 $ localStorage = array_map (
@@ -159,17 +164,33 @@ function ($item) {
159164 $ localStorage
160165 );
161166
162- $ this ->debugTool ->getLogger ()->debug (
163- vsprintf (
164- 'Used Memory: %s, Used Memory Peak: %s ' ,
165- [
166- Metric::bytes (memory_get_usage ())->format (),
167- Metric::bytes (memory_get_peak_usage ())->format (),
168- ]
167+ $ dependencyInjectionProvider = (new DependencyInjectionProvider ())
168+ ->add (
169+ 'ConstantPool ' ,
170+ $ currentConstantPool
169171 )
170- );
172+ ->add (
173+ 'JavaClass ' ,
174+ $ this ->javaClassInvoker ->getJavaClass ()
175+ )
176+ ->add (
177+ 'JavaClassInvoker ' ,
178+ $ this ->javaClassInvoker
179+ )
180+ ->add (
181+ 'Attributes ' ,
182+ $ method ->getAttributes ()
183+ )
184+ ->add (
185+ 'Options ' ,
186+ $ this ->options
187+ );
171188
172189 while ($ reader ->getOffset () < $ codeAttribute ->getOpCodeLength ()) {
190+ $ dependencyInjectionProvider
191+ ->add ('OperandStacks ' , $ stacks )
192+ ->add ('LocalStorages ' , $ localStorage );
193+
173194 if (++$ executedCounter > ($ this ->options ['max_stack_exceeded ' ] ?? GlobalOptions::get ('max_stack_exceeded ' ) ?? Runtime::MAX_STACK_EXCEEDED )) {
174195 throw new RuntimeException (
175196 'Max stack exceeded. PHPJava has been stopped by safety guard. ' .
@@ -201,22 +222,14 @@ function ($item) {
201222
202223 $ this ->debugTool ->getLogger ()->debug (
203224 vsprintf (
204- 'Used Memory: %s, Used Memory Peak: %s ' ,
205- [
206- Metric::bytes (memory_get_usage ())->format (),
207- Metric::bytes (memory_get_peak_usage ())->format (),
208- ]
209- )
210- );
211-
212- $ this ->debugTool ->getLogger ()->debug (
213- vsprintf (
214- 'OpCode: 0x%02X, Mnemonic: %s, Stacks: %d, PC: %d ' ,
225+ 'OpCode: 0x%02X %-15.15s Stacks: %-4.4s PC: %-8.8s Used Memory: %-8.8s Used Memory Peak: %-8.8s ' ,
215226 [
216227 $ opcode ,
217- $ mnemonic ,
228+ str_replace ( ' _ ' , '' , $ mnemonic) ,
218229 count ($ stacks ),
219230 $ pointer ,
231+ Metric::bytes (memory_get_usage ())->format (),
232+ Metric::bytes (memory_get_peak_usage ())->format (),
220233 ]
221234 )
222235 );
@@ -249,7 +262,8 @@ function () use ($fullName) {
249262 $ reader ,
250263 $ localStorage ,
251264 $ stacks ,
252- $ pointer
265+ $ pointer ,
266+ $ dependencyInjectionProvider
253267 )
254268 ->execute ();
255269
0 commit comments