diff src/testdir/test_vim9_disassemble.vim @ 19532:b8f778dda1a1 v8.2.0323

patch 8.2.0323: Vim9: calling a function that is defined later is slow Commit: https://github.com/vim/vim/commit/7eeefd4a395fe3d7c7a2a0879467cf7ed4c29fe6 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Feb 26 21:24:23 2020 +0100 patch 8.2.0323: Vim9: calling a function that is defined later is slow Problem: Vim9: calling a function that is defined later is slow. Solution: Once the function is found update the instruction so it can be called directly.
author Bram Moolenaar <Bram@vim.org>
date Wed, 26 Feb 2020 21:30:04 +0100
parents 3b026343f398
children 6b6e97d0185e
line wrap: on
line diff
--- a/src/testdir/test_vim9_disassemble.vim
+++ b/src/testdir/test_vim9_disassemble.vim
@@ -222,6 +222,38 @@ def Test_disassemble_call()
 enddef
 
 
+def FuncWithForwardCall(): string
+  return DefinedLater("yes")
+enddef
+
+def DefinedLater(arg: string): string
+  return arg
+enddef
+
+def Test_disassemble_update_instr()
+  let res = execute('disass FuncWithForwardCall')
+  assert_match('FuncWithForwardCall.*'
+        \ .. 'return DefinedLater("yes").*'
+        \ .. '\d PUSHS "yes".*'
+        \ .. '\d UCALL DefinedLater(argc 1).*'
+        \ .. '\d CHECKTYPE string stack\[-1].*'
+        \ .. '\d RETURN.*'
+        \, res)
+
+  " Calling the function will change UCALL into the faster DCALL
+  assert_equal('yes', FuncWithForwardCall())
+
+  res = execute('disass FuncWithForwardCall')
+  assert_match('FuncWithForwardCall.*'
+        \ .. 'return DefinedLater("yes").*'
+        \ .. '\d PUSHS "yes".*'
+        \ .. '\d DCALL DefinedLater(argc 1).*'
+        \ .. '\d CHECKTYPE string stack\[-1].*'
+        \ .. '\d RETURN.*'
+        \, res)
+enddef
+
+
 def FuncWithDefault(arg: string = 'default'): string
   return arg
 enddef