[ https://issues.apache.org/jira/browse/HARMONY-4714?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Aleksey Shipilev updated HARMONY-4714: -------------------------------------- Description: During JNI transition the exception flags are checked twice. 1. One check is generated in JNI lil stub (vm/vmcore/src/jit/compile.cpp:675) //***** Part 11: Rethrow exception cs = lil_parse_onto_end(cs, "l0=ts;" "ld l2,[l0+%0i:ref];" "jc l2!=0,_exn_raised;" "ld l2,[l0+%1i:ref];" "jc l2=0,_no_exn;" ":_exn_raised;" "m2n_save_all;" "out platform::void;" "call.noret %2i;" ":_no_exn;", eoo, eco, exn_rethrow); assert(cs); 2. Second check is done during pop_m2n frame generation: (ex.: vm/port/src/lil/ia32/pim/m2n_ia32.cpp:259) static void m2n_free_local_handles() { assert(!hythread_is_suspend_enabled()); // AGAIN! if (exn_raised()) { exn_rethrow(); } M2nFrame * m2n = m2n_get_last_frame(); free_local_object_handles3(m2n->local_object_handles); } So, we might throw away the exception handling from JNI lil stub, as far push_m2n is made always during JNI transition. Much more effective is to throw away blocks from m2n_free_local_handles and m2n_pop_local_handles, but that could affect compatibility across the m2n calls. Simple JNI test (executing several millions of JNI transitions) shows: $ ../../Builds/Harmony-clean/bin/java -cp . -Xmx128m -Xms128m nalog.nalog iteration: 0 millis:8763 iteration: 1 millis:8722 iteration: 2 millis:8833 $ ../../Builds/Harmony-noEXP/bin/java -cp . -Xmx128m -Xms128m nalog.nalog iteration: 0 millis:7824 iteration: 1 millis:7845 iteration: 2 millis:7836 $ ../../Builds/Harmony-noEXP-clean/bin/java -cp . -Xmx128m -Xms128m nalog.nalog iteration: 0 millis:8241 iteration: 1 millis:8255 iteration: 2 millis:8214 was: During JNI transition the exception flags are checked twice. 1. One check is generated in JNI lil stub (vm/vmcore/src/jit/compile.cpp:675) //***** Part 11: Rethrow exception cs = lil_parse_onto_end(cs, "l0=ts;" "ld l2,[l0+%0i:ref];" "jc l2!=0,_exn_raised;" "ld l2,[l0+%1i:ref];" "jc l2=0,_no_exn;" ":_exn_raised;" "m2n_save_all;" "out platform::void;" "call.noret %2i;" ":_no_exn;", eoo, eco, exn_rethrow); assert(cs); 2. Second check is done during pop_m2n frame generation: (ex.: vm/port/src/lil/ia32/pim/m2n_ia32.cpp:259) static void m2n_free_local_handles() { assert(!hythread_is_suspend_enabled()); // AGAIN! if (exn_raised()) { exn_rethrow(); } M2nFrame * m2n = m2n_get_last_frame(); free_local_object_handles3(m2n->local_object_handles); } So, we might throw away the exception handling from JNI lil stub, as far push_m2n is made always during JNI transition. Much more effective is to throw away blocks from m2n_free_local_handles and m2n_pop_local_handles, but that could affect compatibility across the m2n calls. > [drlvm][jni] JNI transition check exceptions twice > -------------------------------------------------- > > Key: HARMONY-4714 > URL: https://issues.apache.org/jira/browse/HARMONY-4714 > Project: Harmony > Issue Type: Improvement > Reporter: Aleksey Shipilev > Attachments: HARMONY-4714-dirty.patch, HARMONY-4714.patch > > > During JNI transition the exception flags are checked twice. > 1. One check is generated in JNI lil stub (vm/vmcore/src/jit/compile.cpp:675) > //***** Part 11: Rethrow exception > cs = lil_parse_onto_end(cs, > "l0=ts;" > "ld l2,[l0+%0i:ref];" > "jc l2!=0,_exn_raised;" > "ld l2,[l0+%1i:ref];" > "jc l2=0,_no_exn;" > ":_exn_raised;" > "m2n_save_all;" > "out platform::void;" > "call.noret %2i;" > ":_no_exn;", > eoo, eco, exn_rethrow); > assert(cs); > 2. Second check is done during pop_m2n frame generation: (ex.: vm/port/src/lil/ia32/pim/m2n_ia32.cpp:259) > static void m2n_free_local_handles() { > assert(!hythread_is_suspend_enabled()); > // AGAIN! > if (exn_raised()) { > exn_rethrow(); > } > M2nFrame * m2n = m2n_get_last_frame(); > free_local_object_handles3(m2n->local_object_handles); > } > So, we might throw away the exception handling from JNI lil stub, as far push_m2n is made always during JNI transition. Much more effective is to throw away blocks from m2n_free_local_handles and m2n_pop_local_handles, but that could affect compatibility across the m2n calls. > Simple JNI test (executing several millions of JNI transitions) shows: > $ ../../Builds/Harmony-clean/bin/java -cp . -Xmx128m -Xms128m nalog.nalog > iteration: 0 millis:8763 > iteration: 1 millis:8722 > iteration: 2 millis:8833 > $ ../../Builds/Harmony-noEXP/bin/java -cp . -Xmx128m -Xms128m nalog.nalog > iteration: 0 millis:7824 > iteration: 1 millis:7845 > iteration: 2 millis:7836 > $ ../../Builds/Harmony-noEXP-clean/bin/java -cp . -Xmx128m -Xms128m nalog.nalog > iteration: 0 millis:8241 > iteration: 1 millis:8255 > iteration: 2 millis:8214 -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.