1. A computer-implemented method comprising steps of: detecting that a particular event, which is generated when an original native function is going to be called, has been generated; in response to detecting that the particular event has been generated: generating an object that indicates (a) a name of the original native function and (b) a list of types of arguments of the original native function; populating the object with information that is specified by the particular event; generating a native thunk; and instructing a virtual machine to replace (a) a binding to the original native function with (b) a binding to the native thunk; wherein replacement of the binding to the original native function with the binding to the native thunk causes the virtual machine to call the native thunk instead of calling the original native function whenever the original native function otherwise would be called; wherein said steps are performed by one or more computing devices.