summaryrefslogtreecommitdiff
path: root/src/testdir/test_vim9_disassemble.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-02-26 21:24:23 +0100
committerBram Moolenaar <Bram@vim.org>2020-02-26 21:24:23 +0100
commit7eeefd4a395fe3d7c7a2a0879467cf7ed4c29fe6 (patch)
treea7d77697ae53255e35510b686f3ba2584803eb3a /src/testdir/test_vim9_disassemble.vim
parentb35efa5ed040162f5c988c71dfc1159045e47585 (diff)
downloadvim-git-7eeefd4a395fe3d7c7a2a0879467cf7ed4c29fe6.tar.gz
patch 8.2.0323: Vim9: calling a function that is defined later is slowv8.2.0323
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.
Diffstat (limited to 'src/testdir/test_vim9_disassemble.vim')
-rw-r--r--src/testdir/test_vim9_disassemble.vim32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/testdir/test_vim9_disassemble.vim b/src/testdir/test_vim9_disassemble.vim
index 375869717..9196184a6 100644
--- 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