Add the vdbe-compress.tcl script which automatically refactors the
sqlite3VdbeExec() routine to use less stack space. Use this script when constructing the amalgamation. (CVS 6704) FossilOrigin-Name: 7f43391831b03e53d967acee6ae02089740aaedb
This commit is contained in:
parent
6ee700c32c
commit
856c10375d
@ -488,6 +488,8 @@ sqlite3$(TEXE): $(TOP)/src/shell.c libsqlite3.la sqlite3.h
|
||||
mkdir -p tsrc
|
||||
cp $(SRC) tsrc
|
||||
rm tsrc/sqlite.h.in tsrc/parse.y
|
||||
$(TCLSH_CMD) $(TOP)/tool/vdbe-compress.tcl <tsrc/vdbe.c >vdbe.new
|
||||
mv vdbe.new tsrc/vdbe.c
|
||||
touch .target_source
|
||||
|
||||
sqlite3.c: .target_source $(TOP)/tool/mksqlite3c.tcl
|
||||
|
4
main.mk
4
main.mk
@ -323,11 +323,13 @@ objects: $(LIBOBJ_ORIG)
|
||||
# files are automatically generated. This target takes care of
|
||||
# all that automatic generation.
|
||||
#
|
||||
target_source: $(SRC)
|
||||
target_source: $(SRC) $(TOP)/tool/vdbe-compress.tcl
|
||||
rm -rf tsrc
|
||||
mkdir tsrc
|
||||
cp -f $(SRC) tsrc
|
||||
rm tsrc/sqlite.h.in tsrc/parse.y
|
||||
tclsh $(TOP)/tool/vdbe-compress.tcl <tsrc/vdbe.c >vdbe.new
|
||||
mv vdbe.new tsrc/vdbe.c
|
||||
touch target_source
|
||||
|
||||
sqlite3.c: target_source $(TOP)/tool/mksqlite3c.tcl
|
||||
|
17
manifest
17
manifest
@ -1,7 +1,7 @@
|
||||
C Avoid\sallocating\slarge\sobjects\son\sthe\sstack\sin\sthe\sincremental\sBLOB\sI/O\ninterface.\s(CVS\s6703)
|
||||
D 2009-06-01T19:53:31
|
||||
C Add\sthe\svdbe-compress.tcl\sscript\swhich\sautomatically\srefactors\sthe\nsqlite3VdbeExec()\sroutine\sto\suse\sless\sstack\sspace.\s\sUse\sthis\sscript\nwhen\sconstructing\sthe\samalgamation.\s(CVS\s6704)
|
||||
D 2009-06-02T15:21:42
|
||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||
F Makefile.in 583e87706abc3026960ed759aff6371faf84c211
|
||||
F Makefile.in 8b8fb7823264331210cddf103831816c286ba446
|
||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||
F Makefile.vxworks 51698ac39a2d114c1586b7694838f2f321c43f64
|
||||
F README b974cdc3f9f12b87e851b04e75996d720ebf81ac
|
||||
@ -86,7 +86,7 @@ F ext/rtree/tkt3363.test 6662237ea75bb431cd5d262dfc9535e1023315fc
|
||||
F ext/rtree/viewrtree.tcl 09526398dae87a5a87c5aac2b3854dbaf8376869
|
||||
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895
|
||||
F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8
|
||||
F main.mk 8388687358db061fa98f062f8b417b986d8ff3fe
|
||||
F main.mk 4a9e8f062833f7ef6fc926f2701f3ce1c83a3373
|
||||
F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a
|
||||
F mkextu.sh 416f9b7089d80e5590a29692c9d9280a10dbad9f
|
||||
F mkextw.sh 4123480947681d9b434a5e7b1ee08135abe409ac
|
||||
@ -203,7 +203,7 @@ F src/update.c 6ae6c26adff8dc34532d578f66e6cfde04b5d177
|
||||
F src/utf.c 9541d28f40441812c0b40f00334372a0542c00ff
|
||||
F src/util.c a9719d309f6c65b3b79fa3ca8512fa8e3947a391
|
||||
F src/vacuum.c 981686c910b2ff9fe3db814e01da31cf9dbd48c7
|
||||
F src/vdbe.c b859cb274024e5755aa03625251ff859e3e95158
|
||||
F src/vdbe.c 2f2c4b5a1b92cdbae31f5c5d5a380c697fa3dcc4
|
||||
F src/vdbe.h 35a648bc3279a120da24f34d9a25213ec15daf8a
|
||||
F src/vdbeInt.h 43183a2a18654fa570219ab65e53a608057c48ae
|
||||
F src/vdbeapi.c 86aa27a5f3493aaffb8ac051782aa3b22670d7ed
|
||||
@ -731,7 +731,8 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
|
||||
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||
P c7c0c58e472cd8277b2ad58bb60834190bace4fa
|
||||
R 01d40d71e1b5c8cea7b1b21c881c4bd8
|
||||
F tool/vdbe-compress.tcl 383f4be3ceb8cec24f31f27480232fbb866fd83a
|
||||
P ea7dfde700fb57ed0ecb5000a55abbf45aa1e09d
|
||||
R f304b4ea19d83f978fafc25600629030
|
||||
U drh
|
||||
Z f0ffd7a898768d77c536a218a2488cbe
|
||||
Z 613f8e55a41fae0a6bf73d1968f3449f
|
||||
|
@ -1 +1 @@
|
||||
ea7dfde700fb57ed0ecb5000a55abbf45aa1e09d
|
||||
7f43391831b03e53d967acee6ae02089740aaedb
|
545
src/vdbe.c
545
src/vdbe.c
File diff suppressed because it is too large
Load Diff
124
tool/vdbe-compress.tcl
Normal file
124
tool/vdbe-compress.tcl
Normal file
@ -0,0 +1,124 @@
|
||||
#!/usr/bin/tcl
|
||||
#
|
||||
# This script makes modifications to the vdbe.c source file which reduce
|
||||
# the amount of stack space required by the sqlite3VdbeExec() routine.
|
||||
#
|
||||
# The modifications performed by this script are optional. The vdbe.c
|
||||
# source file will compile correctly with and without the modifications
|
||||
# performed by this script. And all routines within vdbe.c will compute
|
||||
# the same result. The modifications made by this script merely help
|
||||
# the C compiler to generate code for sqlite3VdbeExec() that uses less
|
||||
# stack space.
|
||||
#
|
||||
# Script usage:
|
||||
#
|
||||
# mv vdbe.c vdbe.c.template
|
||||
# tclsh vdbe-compress.tcl <vdbe.c.template >vdbe.c
|
||||
#
|
||||
# Modifications made:
|
||||
#
|
||||
# All modifications are within the sqlite3VdbeExec() function. The
|
||||
# modifications seek to reduce the amount of stack space allocated by
|
||||
# this routine by moving local variable declarations out of individual
|
||||
# opcode implementations and into a single large union. The union contains
|
||||
# a separate structure for each opcode and that structure contains the
|
||||
# local variables used by that opcode. In this way, the total amount
|
||||
# of stack space required by sqlite3VdbeExec() is reduced from the
|
||||
# sum of all local variables to the maximum of the local variable space
|
||||
# required for any single opcode.
|
||||
#
|
||||
# In order to be recognized by this script, local variables must appear
|
||||
# on the first line after the open curly-brace that begins a new opcode
|
||||
# implementation. Local variables must not have initializers, though they
|
||||
# may be commented.
|
||||
#
|
||||
# The union definition is inserted in place of a special marker comment
|
||||
# in the preamble to the sqlite3VdbeExec() implementation.
|
||||
#
|
||||
#############################################################################
|
||||
#
|
||||
set beforeUnion {} ;# C code before union
|
||||
set unionDef {} ;# C code of the union
|
||||
set afterUnion {} ;# C code after the union
|
||||
set sCtr 0 ;# Context counter
|
||||
|
||||
# Read program text up to the spot where the union should be
|
||||
# inserted.
|
||||
#
|
||||
while {![eof stdin]} {
|
||||
set line [gets stdin]
|
||||
if {[regexp {INSERT STACK UNION HERE} $line]} break
|
||||
append beforeUnion $line\n
|
||||
}
|
||||
|
||||
# Process the remaining text. Build up the union definition as we go.
|
||||
#
|
||||
set vlist {}
|
||||
set seenDecl 0
|
||||
set namechars {abcdefghijklmnopqrstuvwxyz}
|
||||
set nnc [string length $namechars]
|
||||
while {![eof stdin]} {
|
||||
set line [gets stdin]
|
||||
if {[regexp "^case (OP_\\w+): \173" $line all operator]} {
|
||||
append afterUnion $line\n
|
||||
set vlist {}
|
||||
while {![eof stdin]} {
|
||||
set line [gets stdin]
|
||||
if {[regexp {^ +(const )?\w+ \*?(\w+)(\[.*\])?;} $line \
|
||||
all constKeyword vname notused1]} {
|
||||
if {!$seenDecl} {
|
||||
set sname {}
|
||||
append sname [string index $namechars [expr {$sCtr/$nnc}]]
|
||||
append sname [string index $namechars [expr {$sCtr%$nnc}]]
|
||||
incr sCtr
|
||||
append unionDef " struct ${operator}_stack_vars \173\n"
|
||||
append afterUnion \
|
||||
"#if 0 /* local variables moved into u.$sname */\n"
|
||||
set seenDecl 1
|
||||
}
|
||||
append unionDef " $line\n"
|
||||
append afterUnion $line\n
|
||||
lappend vlist $vname
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
if {$seenDecl} {
|
||||
append unionDef " \175 $sname;\n"
|
||||
append afterUnion "#endif /* local variables moved into u.$sname */\n"
|
||||
}
|
||||
set seenDecl 0
|
||||
}
|
||||
if {[regexp "^\175" $line]} {
|
||||
append afterUnion $line\n
|
||||
set vlist {}
|
||||
} elseif {[llength $vlist]>0} {
|
||||
append line " "
|
||||
foreach v $vlist {
|
||||
regsub -all "(\[^a-zA-Z0-9>.\])${v}(\\W)" $line "\\1u.$sname.$v\\2" line
|
||||
}
|
||||
append afterUnion [string trimright $line]\n
|
||||
} elseif {$line=="" && [eof stdin]} {
|
||||
# no-op
|
||||
} else {
|
||||
append afterUnion $line\n
|
||||
}
|
||||
}
|
||||
|
||||
# Output the resulting text.
|
||||
#
|
||||
puts -nonewline $beforeUnion
|
||||
puts " /********************************************************************"
|
||||
puts " ** Automatically generated code"
|
||||
puts " **"
|
||||
puts " ** The following union is automatically generated by the"
|
||||
puts " ** vdbe-compress.tcl script. The purpose of this union is to"
|
||||
puts " ** reduce the amount of stack space required by this function."
|
||||
puts " ** See comments in the vdbe-compress.tcl script for details."
|
||||
puts " */"
|
||||
puts " union vdbeExecUnion \173"
|
||||
puts -nonewline $unionDef
|
||||
puts " \175 u;"
|
||||
puts " /* End automatically generated code"
|
||||
puts " ********************************************************************/"
|
||||
puts -nonewline $afterUnion
|
Loading…
Reference in New Issue
Block a user