Skip to content

Commit 4a3527a

Browse files
committed
Add logger to invoke opcode
1 parent 2e5b21b commit 4a3527a

File tree

7 files changed

+59
-1
lines changed

7 files changed

+59
-1
lines changed

src/Core/JVM/Invoker/Extended/JavaMethodCallable.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,9 @@ function ($argument) {
231231
$stacks,
232232
$pointer,
233233
$dependencyInjectionProvider
234+
)
235+
->setDebugTool(
236+
$this->debugTool
234237
);
235238

236239
$executor->beforeExecute();

src/Kernel/Mnemonics/AbstractOperationCode.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ abstract class AbstractOperationCode implements OperationCodeInterface
88
{
99
use \PHPJava\Kernel\Core\Accumulator;
1010
use \PHPJava\Kernel\Core\ConstantPool;
11+
use \PHPJava\Kernel\Core\DebugTool;
1112

1213
/**
1314
* @var null|Operands

src/Kernel/Mnemonics/_invokedynamic.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,27 @@ public function execute(): void
135135
false
136136
);
137137
$annotations = $this->getAnnotateInjections(
138-
$invokerClass->getInvoker()->getStatic()->getMethods()->getAnnotations($methodHandledName)
138+
$invokerClass
139+
->getInvoker()
140+
->getStatic()
141+
->getMethods()
142+
->getAnnotations($methodHandledName)
139143
);
140144

141145
if (!empty($annotations)) {
142146
array_unshift($arguments, ...$annotations);
143147
}
144148

149+
$this->getDebugTool()->getLogger()->debug(
150+
vsprintf(
151+
'Call a method: %s, parameters: %d',
152+
[
153+
$methodHandledName,
154+
count($arguments),
155+
]
156+
)
157+
);
158+
145159
$result = $invokerClass
146160
->getInvoker()
147161
->getStatic()

src/Kernel/Mnemonics/_invokeinterface.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@ public function execute(): void
5454
*/
5555
$objectref = $this->popFromOperandStack();
5656

57+
$this->getDebugTool()->getLogger()->debug(
58+
vsprintf(
59+
'Call a method: %s, parameters: %d',
60+
[
61+
$name,
62+
count($arguments),
63+
]
64+
)
65+
);
66+
5767
if ($objectref instanceof Lambda) {
5868
$result = $objectref($name, ...$arguments);
5969
} else {

src/Kernel/Mnemonics/_invokespecial.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ public function execute(): void
5858
);
5959
}
6060

61+
$this->getDebugTool()->getLogger()->debug(
62+
vsprintf(
63+
'Call a method: %s, parameters: %d',
64+
[
65+
$methodName,
66+
count($arguments),
67+
]
68+
)
69+
);
70+
6171
/**
6272
* @var JavaClassInterface $newObject
6373
*/

src/Kernel/Mnemonics/_invokestatic.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ public function execute(): void
5858
array_unshift($arguments, ...$annotations);
5959
}
6060

61+
$this->getDebugTool()->getLogger()->debug(
62+
vsprintf(
63+
'Call a method: %s, parameters: %d',
64+
[
65+
$methodName,
66+
count($arguments),
67+
]
68+
)
69+
);
70+
6171
$result = $classObject
6272
->getInvoker()
6373
->getStatic()

src/Kernel/Mnemonics/_invokevirtual.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,16 @@ public function execute(): void
8888
array_unshift($arguments, ...$annotations);
8989
}
9090

91+
$this->getDebugTool()->getLogger()->debug(
92+
vsprintf(
93+
'Call a method: %s, parameters: %d',
94+
[
95+
$methodName,
96+
count($arguments),
97+
]
98+
)
99+
);
100+
91101
$result = $invokerClass
92102
->getInvoker()
93103
->getDynamic()

0 commit comments

Comments
 (0)