Skip to main content

exception in CVMinvokeCompiledHelper

2 replies [Last post]
gyu
Offline
Joined: 2007-06-03

Hello,

I have a question about the following code in jit_common.c

CVMCompiledResultCode
CVMinvokeCompiledHelper(CVMExecEnv *ee, CVMFrame *frame,
CVMMethodBlock **mb_p)
{
...
check_mb:

if (mb == NULL) {

/* Make sure there isn't an exception thrown first: */
if (CVMexceptionOccurred(ee)) {
return CVM_COMPILED_EXCEPTION;
}
...
}

I think " if (CVMexceptionOccurred(ee)) " is unreachable code.
Because I think all the exception might be handled before there.

If there are cases that execute above code, could you explain the scenario?

One more question,

If remote exception occurrs after all other exception checking point and before the " if (CVMexceptoinOccurred(ee)) ", the VM does not work propery. For example, monitorexit is executed twice.

The following is the flow I think. (twice monitorexit)

1st monitorexit is in javac-generated block.
2nd monitorexit is executed in the following sequence.

return_to_compiled:
DECACHE_TOS();
resCode = CVMreturnToCompiledHelper(ee, frame, &mb, NULL); goto compiled_code_result_code;
-->
compiled_code_result_code:
switch (resCode) {
...
case CVM_COMPILED_EXCEPTION:
CACHE_FRAME();
goto handle_exception;
}
-->
handle_exception:
-->
handle_exception_tos_already_reset:
-->
if (CVMframeIsCompiled(frame)) {
goto return_to_compiled_with_exception;
}
-->
return_to_compiled_with_exception:
/* return to the compiled method handling the exception */
topOfStack--;
DECACHE_TOS();
resCode =
CVMreturnToCompiledHelper(ee, frame, &mb, STACK_OBJECT(0));

Is there any solution to handle this situation ?

I tried ignoring remote exception by modifying following code.

if (mb == NULL) {

/* Make sure there isn't an exception thrown first: */
if (CVMexceptionOccurred(ee)) {
return CVM_COMPILED_EXCEPTION;
}

But it gives me assertion failure in CVMassert(frameSanity(frame,topOfStack));
or strange behavior.

Sanggyu

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
cjplummer
Offline
Joined: 2006-10-16

The "return CVM_COMPILED_EXCEPTION" line is executed. If you want to see it in action, do a CVM_DEBUG=true build, run gdb, set a breakpoint on it, and then do the following:

run -cp ../testclasses.zip -Xjit:compile=all Test

I believe all exceptions thrown by compiled code are handled by exiting to the interpreter, so all exceptions in compiled code will end up using this path, although I forget why sometimes mb == NULL. Possibly sometimes when there is an exception, mb != NULL.

As for remote exceptions, they are not supported in the OSS code. If you enable them, expect lots of problems. The CVM engineering team never enables them, and any code you see supporting them is probably 7 years old and has not been enabled since.

Chris

gyu
Offline
Joined: 2007-06-03

Thank you very much for your prompt and helpful answer.

Sanggyu