33import php .runtime .Memory ;
44import php .runtime .common .Messages ;
55import php .runtime .common .Modifier ;
6+ import php .runtime .env .CallStack ;
7+ import php .runtime .env .CallStackItem ;
68import php .runtime .env .Environment ;
79import php .runtime .env .TraceInfo ;
10+ import php .runtime .env .TraceInfoCallCache ;
811import php .runtime .exceptions .CriticalException ;
912import php .runtime .exceptions .support .ErrorType ;
1013import php .runtime .invoke .cache .ConstantCallCache ;
@@ -143,6 +146,22 @@ public static Memory invokeMethod(Memory object, String methodName, String metho
143146 method = clazz .methodMagicInvoke ;
144147 } else {
145148 method = clazz .findMethod (methodLowerName );
149+ /*TraceInfoCallCache callCache = trace == null ? null : trace.getCallCache();
150+
151+ if (callCache != null && callCache.self == clazz && callCache.callEntity != null) {
152+ method = (MethodEntity) callCache.callEntity;
153+ } else {
154+ method = clazz.findMethod(methodLowerName);
155+ if (trace != null && !trace.isUnknown()) {
156+ if (callCache == null) {
157+ callCache = new TraceInfoCallCache();
158+ }
159+
160+ callCache.self = clazz;
161+ callCache.callEntity = method;
162+ trace.setCallCache(callCache);
163+ }
164+ }*/
146165
147166 if (method != null && method .isContextDepends ()) {
148167 ClassEntity context = env .getLastClassOnStack ();
@@ -195,25 +214,31 @@ public static Memory invokeMethod(Memory object, String methodName, String metho
195214 return result ;
196215 }
197216
217+ CallStack callStack = (trace == null || !method .isUsesStackTrace ()) ? null : env .getCallStack ();
218+
198219 try {
199- if (trace != null ) {
220+ if (callStack != null ) {
200221 String staticClass = className ;
201222
202223 if (iObject instanceof Closure ) {
203224 staticClass = ((Closure ) iObject ).getScope ();
204225 }
205226
206227 if (clazz .isHiddenInCallStack ()) {
207- env .pushCall (trace , iObject , args , methodName , staticClass , staticClass );
228+ callStack .push (trace , iObject , args , methodName , staticClass , staticClass );
229+ //env.pushCall(trace, iObject, args, methodName, staticClass, staticClass);
208230
209231 if (doublePop ) {
210- env .pushCall (trace , iObject , passed , method .getName (), staticClass , staticClass );
232+ callStack .push (trace , iObject , passed , method .getName (), staticClass , staticClass );
233+ //env.pushCall(trace, iObject, passed, method.getName(), staticClass, staticClass);
211234 }
212235 } else {
213- env .pushCallEx (trace , iObject , args , methodName , method .getClazz (), staticClass );
236+ callStack .push (trace , iObject , args , methodName , method .getClazz (), staticClass );
237+ //env.pushCallEx(trace, iObject, args, methodName, method.getClazz(), staticClass);
214238
215239 if (doublePop ) {
216- env .pushCallEx (trace , iObject , passed , method .getName (), method .getClazz (), staticClass );
240+ callStack .push (trace , iObject , passed , method .getName (), method .getClazz (), staticClass );
241+ //env.pushCallEx(trace, iObject, passed, method.getName(), method.getClazz(), staticClass);
217242 }
218243 }
219244 }
@@ -222,11 +247,13 @@ public static Memory invokeMethod(Memory object, String methodName, String metho
222247 } catch (NoClassDefFoundError e ) {
223248 throw new CriticalException ("Unable to call method " + className + "::" + methodName + "(), " + e .getMessage ());
224249 } finally {
225- if (trace != null ) {
226- env .popCall ();
250+ if (callStack != null ) {
251+ callStack .pop ();
252+ //env.popCall();
227253
228254 if (doublePop ) {
229- env .popCall ();
255+ callStack .pop ();
256+ //env.popCall();
230257 }
231258 }
232259 }
0 commit comments