LiangliangSui commented on issue #1482:
URL: 
https://github.com/apache/incubator-fury/issues/1482#issuecomment-2053657741

   I extracted a piece of logic that is not executed frequently into a function 
to reduce the bytecode size of the register method. The extracted function is 
as follows:
   
   ```java
     public void register(Class<?> cls, int classId) {
       ......
   
       short id = (short) classId;
       if (id < registeredId2ClassInfo.length && registeredId2ClassInfo[id] != 
null) {
         throw new IllegalArgumentException(
             String.format(
                 "Class %s with id %s has been registered, registering class %s 
with same id are not allowed.",
                 registeredId2ClassInfo[id].getCls(), id, cls.getName()));
       }
       extRegistry.registeredClassIdMap.put(cls, id);
       if (registeredId2ClassInfo.length <= id) {
         ensure(id);
       }
       ......
     }
   
     private void ensure(short id) {
       ClassInfo[] tmp = new ClassInfo[(id + 1) * 2];
       System.arraycopy(registeredId2ClassInfo, 0, tmp, 0, 
registeredId2ClassInfo.length);
       registeredId2ClassInfo = tmp;
     }
   
   ```
   
   Then the `register` function bytecode is reduced from 341 to 314, which is 
lower than `-XX:+FreqInlineSize(325)`, and is successfully inlined.
   
   
![image](https://github.com/apache/incubator-fury/assets/116876207/02e2c438-90bb-4b7c-a523-76a83b944727)
   
   I will upload a PR later to do this.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to