This is an automated email from the ASF dual-hosted git repository.

tqchen pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm-ffi.git


The following commit(s) were added to refs/heads/main by this push:
     new 469d71f5 [FFI][PERF] Force-inline ObjectPtr::reset and 
WeakObjectPtr::reset (#764)
469d71f5 is described below

commit 469d71f50c280f707bd4079af93f64f8dd9dfce8
Author: Tianqi Chen <[email protected]>
AuthorDate: Mon Sep 7 21:05:26 2026 -0400

    [FFI][PERF] Force-inline ObjectPtr::reset and WeakObjectPtr::reset (#764)
    
    `~ObjectPtr()` is `TVM_FFI_INLINE` and delegates to `reset()`, which was
    a plain function, so in a large hook every `ObjectPtr` destruction still
    compiled to an out-of-line `call ObjectPtr<Object>::reset` Mark both
    `reset()` methods the same way as the special members in #761. No
    behaviour change.
---
 include/tvm/ffi/object.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/include/tvm/ffi/object.h b/include/tvm/ffi/object.h
index 5c7832d3..722dce3a 100644
--- a/include/tvm/ffi/object.h
+++ b/include/tvm/ffi/object.h
@@ -504,7 +504,9 @@ class ObjectPtr {
    */
   explicit operator bool() const { return get() != nullptr; }
   /*! \brief reset the content of ptr to be nullptr */
-  void reset() {
+  // Explicitly inlined: the inlined destructor delegates here, so an 
out-of-line
+  // reset would turn every destruction back into a call.
+  TVM_FFI_INLINE void reset() {
     if (data_ != nullptr) {
       data_->DecRef();
       data_ = nullptr;
@@ -764,7 +766,9 @@ class WeakObjectPtr {
   }
 
   /*! \brief reset the content of ptr to be nullptr */
-  void reset() {
+  // Explicitly inlined: the inlined destructor delegates here, so an 
out-of-line
+  // reset would turn every destruction back into a call.
+  TVM_FFI_INLINE void reset() {
     if (data_ != nullptr) {
       data_->DecWeakRef();
       data_ = nullptr;

Reply via email to