816 // Klass objects contain references to c++ vtables in the JVM library. |
816 // Klass objects contain references to c++ vtables in the JVM library. |
817 // Fix them to point to our constructed vtables. However, don't iterate |
817 // Fix them to point to our constructed vtables. However, don't iterate |
818 // across the space while doing this, as that causes the vtables to be |
818 // across the space while doing this, as that causes the vtables to be |
819 // patched, undoing our useful work. Instead, iterate to make a list, |
819 // patched, undoing our useful work. Instead, iterate to make a list, |
820 // then use the list to do the fixing. |
820 // then use the list to do the fixing. |
|
821 // |
|
822 // Our constructed vtables: |
|
823 // Dump time: |
|
824 // 1. init_self_patching_vtbl_list: table of pointers to current virtual method addrs |
|
825 // 2. generate_vtable_methods: create jump table, appended to above vtbl_list |
|
826 // 3. PatchKlassVtables: for Klass list, patch the vtable entry to point to jump table |
|
827 // rather than to current vtbl |
|
828 // Table layout: NOTE FIXED SIZE |
|
829 // 1. vtbl pointers |
|
830 // 2. #Klass X #virtual methods per Klass |
|
831 // 1 entry for each, in the order: |
|
832 // Klass1:method1 entry, Klass1:method2 entry, ... Klass1:method<num_virtuals> entry |
|
833 // Klass2:method1 entry, Klass2:method2 entry, ... Klass2:method<num_virtuals> entry |
|
834 // ... |
|
835 // Klass<vtbl_list_size>:method1 entry, Klass<vtbl_list_size>:method2 entry, |
|
836 // ... Klass<vtbl_list_size>:method<num_virtuals> entry |
|
837 // Sample entry: (Sparc): |
|
838 // save(sp, -256, sp) |
|
839 // ba,pt common_code |
|
840 // mov XXX, %L0 %L0 gets: Klass index <<8 + method index (note: max method index 255) |
|
841 // |
|
842 // Restore time: |
|
843 // 1. initialize_oops: reserve space for table |
|
844 // 2. init_self_patching_vtbl_list: update pointers to NEW virtual method addrs in text |
|
845 // |
|
846 // Execution time: |
|
847 // First virtual method call for any object of these Klass types: |
|
848 // 1. object->klass->klass_part |
|
849 // 2. vtable entry for that klass_part points to the jump table entries |
|
850 // 3. branches to common_code with %O0/klass_part, %L0: Klass index <<8 + method index |
|
851 // 4. common_code: |
|
852 // Get address of new vtbl pointer for this Klass from updated table |
|
853 // Update new vtbl pointer in the Klass: future virtual calls go direct |
|
854 // Jump to method, using new vtbl pointer and method index |
821 |
855 |
822 class PatchKlassVtables: public ObjectClosure { |
856 class PatchKlassVtables: public ObjectClosure { |
823 private: |
857 private: |
824 void* _vtbl_ptr; |
858 void* _vtbl_ptr; |
825 VirtualSpace* _md_vs; |
859 VirtualSpace* _md_vs; |