[r7647]: sandbox / jlf / internals / notes / routine_vs_method_call.txt  Maximize  Restore  History

Download this file

244 lines (189 with data), 9.9 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
Notes taken while investigating the performance problem of routine call under window
Rick's fix :
Now the test is fast : just testing a boolean variable externalTraceEnabled.
This boolean variable is initialized then the interpreter instance is created.
activity->getInstance()->setupProgram(this);
InterpreterInstance::setupProgram
SysInterpreterInstance::setupProgram
if (externalTraceEnabled) activation->enableExternalTrace();
RexxActivation.cpp
//SystemInterpreter::setupProgram(this); /* do any system specific setup */
activity->getInstance()->setupProgram(this); /* do any system specific setup */ JLF : getInstance returns the interpreter instance
InterpreterInstance.hpp
class InterpreterInstance : public RexxInternalObject
inline void setupProgram(RexxActivation *activation)
{
sysInstance.setupProgram(activation);
}
...
SysInterpreterInstance sysInstance; // our platform specific helper
Windows
SysInterpreterInstance.hpp
class SysInterpreterInstance
void setupProgram(RexxActivation *activation);
protected:
bool externalTraceEnabled; // are we started with external trace on
Windows
SysInterpreterInstance.cpp
void SysInterpreterInstance::initialize(InterpreterInstance *i, RexxOption *options)
{
externalTraceEnabled = false; // off by default
TCHAR rxTraceBuf[8];
/* scan current environment, */
if (GetEnvironmentVariable("RXTRACE", rxTraceBuf, 8))
{
if (!Utilities::strCaselessCompare(rxTraceBuf, "ON")) /* request to turn on? */
{
externalTraceEnabled = true; // turn on tracing of top-level activations for this instance
}
}
Windows
SysInterpreterInstance.cpp
void SysInterpreterInstance::setupProgram(RexxActivation *activation)
{
// trace this activation if turned on externally when the instance was started
if (externalTraceEnabled)
{
activation->enableExternalTrace();
}
}
Windows
SystemInterpreter.hpp
remove declaration of :
static void setupProgram(RexxActivation *activation);
Windows
MiscSystem.cpp
remove implementation of :
void SystemInterpreter::setupProgram(RexxActivation *activation)
Unix
SysInterpreterInstance.hpp
class SysInterpreterInstance
void setupProgram(RexxActivation *activation);
bool externalTraceEnabled; // are we started with external trace on
Unix
SysInterpreterInstance.cpp
externalTraceEnabled = false; // off by default
/* scan current environment, */
const char *rxTraceBuf = getenv("RXTRACE");
if (rxTraceBuf != NULL)
{
if (!Utilities::strCaselessCompare(rxTraceBuf, "ON")) /* request to turn on? */
{
externalTraceEnabled = true; // turn on tracing of top-level activations for this instance
}
}
Unix
SystemInterpreter.hpp
remove declaration of :
static void setupProgram(RexxActivation *activation);
Unix
MiscSystem.cpp
remove implementation of :
void SystemInterpreter::setupProgram(RexxActivation *activation)
=================================================================
Activation.cpp
RexxActivation::RexxActivation()
RexxActivation::RexxActivation(RexxActivity* _activity, RexxMethod * _method, RexxCode *_code)
this->activation_context = METHODCALL; // the context is a method call
RexxActivation::RexxActivation(RexxActivity *_activity, RexxActivation *_parent, RexxCode *_code, int context)
this->activation_context = context; /* save the context */
RexxActivation::RexxActivation(RexxActivity *_activity, RoutineClass *_routine, RexxCode *_code, RexxString *calltype, RexxString *env, int context)
this->activation_context = context; /* save the context */
=================================================================
Entry point
message name = <none>
type of context = PROGRAMCALL (passed when creating the activation)
void RoutineClass::runProgram(
code->call(activity, this, OREF_NONE, arguments, argCount, calltype, environment, PROGRAMCALL, result);
RexxCode.cpp
void RexxCode::call(
=================================================================
Method call
MessageInstruction.cpp
void RexxInstructionMessage::execute (
stack->send(this->name, argcount, result);
ObjectClass.cpp
void RexxObject::messageSend(
method_save->run(ActivityManager::currentActivity, this, msgname, arguments, count, result);
MethodClass.cpp
void RexxMethod::run(
code->run(activity, this, receiver, msgname, argPtr, count, result);
RexxCode.cpp
void RexxCode::run(
newacta->run(receiver, msgname, argPtr, argcount, OREF_NULL, result);
RexxActivation.cpp
RexxObject * RexxActivation::run(RexxObject *_receiver, RexxString *msgname, RexxObject **_arglist, size_t _argcount, RexxInstruction * start, ProtectedObject &resultObj)
if (this->isTopLevelCall()) --> yes
if (this->isProgramLevelCall()) --> no (unlike routine call) --> the performance problem is here (read RXTRACE environment variable)
=================================================================
Routine call
CallInstruction.cpp
void RexxInstructionCall::execute(
case call_external: /* need to call externally */
/* go process the external call */
context->externalCall(_name, argcount, stack, OREF_ROUTINENAME, result);
RexxActivation.cpp
RexxObject *RexxActivation::externalCall(RexxString *target, size_t _argcount, RexxExpressionStack *_stack, RexxString *calltype, ProtectedObject &resultObj)
routine->call(this->activity, target, _arguments, _argcount, calltype, OREF_NULL, EXTERNALCALL, resultObj);
RoutineClass.cpp
void RoutineClass::call(...
code->call(activity, this, msgname, argPtr, argcount, calltype, environment, context, result);
RexxCode.cpp
void RexxCode::call(...
newacta->run(OREF_NULL, msgname, argPtr, argcount, OREF_NULL, result);
RexActivation.cpp
RexxObject * RexxActivation::run(RexxObject *_receiver, RexxString *msgname, RexxObject **_arglist, size_t _argcount, RexxInstruction * start, ProtectedObject &resultObj)
===================================================================
How a routine is found
RexxActivation.cpp
RexxActivation::externalCall
// Step 1: Check the global functions directory
// this is actually considered part of the built-in functions, but these are
// written in ooRexx. The names are also case sensitive
RoutineClass *routine = (RoutineClass *)TheFunctionsDirectory->get(target);
...
// Step 2: Check for a ::ROUTINE definition in the local context
routine = this->settings.parent_code->findRoutine(target);
RoutineClass *RexxSource::findRoutine(RexxString *routineName)
RoutineClass *routineObject = findLocalRoutine(upperName);
RoutineClass *RexxSource::findLocalRoutine(RexxString *name)
search in this->routines JLF : contains the routines defined in current source
...
// now try for one pulled in from ::REQUIRES objects
return findPublicRoutine(upperName);
// Step 2a: See if the function call exit fields this one
if (!activity->callObjectFunctionExit(this, target, calltype, resultObj, _arguments, _argcount)) return(RexxObject *)resultObj;
// Step 2b: See if the function call exit fields this one
if (!activity->callFunctionExit(this, target, calltype, resultObj, _arguments, _argcount)) return(RexxObject *)resultObj;
// Step 3: Perform all platform-specific searches
if (SystemInterpreter::invokeExternalFunction(this, this->activity, target, _arguments, _argcount, calltype, resultObj)) return(RexxObject *)resultObj;
// Step 4: Check scripting exit, which is after most of the checks
if (!activity->callScriptingExit(this, target, calltype, resultObj, _arguments, _argcount)) return(RexxObject *)resultObj;
// if it's made it through all of these steps without finding anything, we
// finally have a routine non found situation
reportException(Error_Routine_not_found_name, target);
=======================================================================
TheFunctionsDirectory : seems not filled, but a search is made inside
RexxActivation.cpp
RexxObject *RexxActivation::externalCall(RexxString *target, size_t _argcount, RexxExpressionStack *_stack,
RexxString *calltype, ProtectedObject &resultObj)
{
// Step 1: Check the global functions directory
// this is actually considered part of the built-in functions, but these are
// written in ooRexx. The names are also case sensitive
RoutineClass *routine = (RoutineClass *)TheFunctionsDirectory->get(target);
RexxMemory.cpp
RexxDirectory *RexxMemory::functionsDir = OREF_NULL; // statically defined requires
RexxMemory.cpp
void RexxMemory::restoreImage()
TheFunctionsDirectory = (RexxDirectory *)saveArray->get(saveArray_FUNCTIONS);
RexxMemory.cpp
void RexxMemory::saveImage(void)
saveArray->put((RexxObject *)TheFunctionsDirectory, saveArray_FUNCTIONS);
Setup.cpp
void RexxMemory::createImage()
TheFunctionsDirectory = new_directory();
...
kernel_public(CHAR_FUNCTIONS ,TheFunctionsDirectory ,TheKernel);
RexxCore.h
#define TheFunctionsDirectory RexxMemory::functionsDir

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks