From: drh Date: Mon, 1 Feb 2016 17:20:08 +0000 (+0000) Subject: Number VDBE opcodes starting with 0 instead of 1, as this obviates the X-Git-Tag: version-3.11.0~69 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ed94af5eb9b75dc1ad6f3d462a14271b5386396b;p=thirdparty%2Fsqlite.git Number VDBE opcodes starting with 0 instead of 1, as this obviates the lower-bound test on "switch(opcode){...}", making the code smaller and faster. FossilOrigin-Name: 4c9222f75bfac47f5422fff86b2d69a61933b3a2 --- diff --git a/manifest b/manifest index 115a4bbaf2..5ae7fd9d24 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\swalcrash.test\sto\sensure\sthat,\sduring\sa\sparticular\stest,\senough\sdata\sis\swritten\sto\scause\sSQLite\sto\ssync\sthe\swal\sfile\s14\stimes. -D 2016-02-01T16:36:47.969 +C Number\sVDBE\sopcodes\sstarting\swith\s0\sinstead\sof\s1,\sas\sthis\sobviates\sthe\nlower-bound\stest\son\s"switch(opcode){...}",\smaking\sthe\scode\ssmaller\sand\sfaster. +D 2016-02-01T17:20:08.707 F Makefile.in 027c1603f255390c43a426671055a31c0a65fdb4 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 72b7858f02017611c3ac1ddc965251017fed0845 @@ -416,7 +416,7 @@ F src/vdbe.c 755b1e2117214549b768efb6e552fcd12a9d859b F src/vdbe.h 7a733ea8aac1b77305a67698e784fa3484ee3337 F src/vdbeInt.h 4b69d5451bcadd473e745af53ef1e8abfdce0a79 F src/vdbeapi.c 9d640d5efd9a140a6bda8da53b220aa258167993 -F src/vdbeaux.c b8ba8e6d48732fb7a735a23e3040a01f4848498e +F src/vdbeaux.c f0e7cfa04f7ac44d69866868531dbaf20659d0a2 F src/vdbeblob.c 37c3d11a753e403698c69e17383d282e1ae73e75 F src/vdbemem.c b9181e77eca2a095929d46250daf85c8d2621fc0 F src/vdbesort.c ef3c6d1f1a7d44cf67bb2bee59ea3d1fe5bad174 @@ -1381,8 +1381,8 @@ F tool/logest.c eef612f8adf4d0993dafed0416064cf50d5d33c6 F tool/mkautoconfamal.sh a29b14d54302b33fd892958f6895582ea90e4a45 F tool/mkkeywordhash.c 06ec0b78bd4fa68c12d90ef2bdfe76b039133ff8 F tool/mkmsvcmin.tcl d57e6efc9428605f5418d0b235721ddf7b5d9c0b -F tool/mkopcodec.tcl edde8adc42621b5e598127f8cdc6d52cfe21f52b -F tool/mkopcodeh.tcl e04177031532b7aa9379ded50e820231ac4abd6e +F tool/mkopcodec.tcl d1b6362bd3aa80d5520d4d6f3765badf01f6c43c +F tool/mkopcodeh.tcl 385c62d78c38b2d92146dcb5abd319dbbc33506d F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e F tool/mkpragmatab.tcl f0d5bb266d1d388cf86fce5ba01a891e95d72d41 F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 @@ -1422,7 +1422,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P a17712bf8d98dd485560f434a5350e6381cf1411 -R 9c14b59494afeacd043f7754f1a985e1 -U dan -Z ecc144871fca92cc0fc68693a6e08d49 +P 5d7c092869137a0ba69f93324fe4ed56a05b5985 +R c689c18fc524ba4b0a7bb357f3467ad8 +U drh +Z 4a66c8beaa1a93ec6bbf8e1c0f940158 diff --git a/manifest.uuid b/manifest.uuid index af8a34f793..cc32153f40 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5d7c092869137a0ba69f93324fe4ed56a05b5985 \ No newline at end of file +4c9222f75bfac47f5422fff86b2d69a61933b3a2 \ No newline at end of file diff --git a/src/vdbeaux.c b/src/vdbeaux.c index d6cf451af4..13aef0d7fd 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -171,7 +171,7 @@ int sqlite3VdbeAddOp3(Vdbe *p, int op, int p1, int p2, int p3){ i = p->nOp; assert( p->magic==VDBE_MAGIC_INIT ); - assert( op>0 && op<0xff ); + assert( op>=0 && op<0xff ); if( p->pParse->nOpAlloc<=i ){ return growOp3(p, op, p1, p2, p3); } diff --git a/tool/mkopcodec.tcl b/tool/mkopcodec.tcl index 55d828b14d..abdeaaeb32 100644 --- a/tool/mkopcodec.tcl +++ b/tool/mkopcodec.tcl @@ -19,7 +19,7 @@ puts "#else" puts "# define OpHelp(X)" puts "#endif" puts "const char *sqlite3OpcodeName(int i)\173" -puts " static const char *const azName\[\] = \173 \"?\"," +puts " static const char *const azName\[\] = \173" set mx 0 set in [open [lindex $argv 0] rb] @@ -40,7 +40,7 @@ while {![eof $in]} { } close $in -for {set i 1} {$i<=$mx} {incr i} { +for {set i 0} {$i<=$mx} {incr i} { puts [format " /* %3d */ %-18s OpHelp(\"%s\")," \ $i \"$label($i)\" $synopsis($i)] } diff --git a/tool/mkopcodeh.tcl b/tool/mkopcodeh.tcl index 4c36f24ba4..053c7f8984 100644 --- a/tool/mkopcodeh.tcl +++ b/tool/mkopcodeh.tcl @@ -81,8 +81,8 @@ while {![eof $in]} { set in1($name) 0 set in2($name) 0 set in3($name) 0 - set out1($name) 0 set out2($name) 0 + set out3($name) 0 for {set i 3} {$i<[llength $line]-1} {incr i} { switch [string trim [lindex $line $i] ,] { same { @@ -112,16 +112,19 @@ while {![eof $in]} { # Assign numbers to all opcodes and output the result. # -set cnt 0 -set max 0 puts "/* Automatically generated. Do not edit */" puts "/* See the tool/mkopcodeh.tcl script for details */" -set op(OP_Noop) -1 -set order($nOp) OP_Noop -incr nOp -set op(OP_Explain) -1 -set order($nOp) OP_Explain -incr nOp +foreach name {OP_Noop OP_Explain} { + set jump($name) 0 + set in1($name) 0 + set in2($name) 0 + set in3($name) 0 + set out2($name) 0 + set out3($name) 0 + set op($name) -1 + set order($nOp) $name + incr nOp +} # The following are the opcodes that are processed by resolveP2Values() # @@ -144,7 +147,7 @@ set rp2v_ops { # Assign small values to opcodes that are processed by resolveP2Values() # to make code generation for the switch() statement smaller and faster. # -set cnt 0 +set cnt -1 for {set i 0} {$i<$nOp} {incr i} { set name $order($i) if {[lsearch $rp2v_ops $name]>=0} { @@ -169,7 +172,7 @@ for {set i 0} {$i<$nOp} {incr i} { } } set max $cnt -for {set i 1} {$i<=$nOp} {incr i} { +for {set i 0} {$i<$nOp} {incr i} { if {![info exists used($i)]} { set def($i) "OP_NotUsed_$i" } @@ -196,27 +199,28 @@ for {set i 1} {$i<=$nOp} {incr i} { # Generate the bitvectors: # set bv(0) 0 -for {set i 1} {$i<=$max} {incr i} { +for {set i 0} {$i<=$max} {incr i} { set name $def($i) - if {[info exists jump($name)] && $jump($name)} {set a0 1} {set a0 0} - if {[info exists in1($name)] && $in1($name)} {set a1 2} {set a1 0} - if {[info exists in2($name)] && $in2($name)} {set a2 4} {set a2 0} - if {[info exists in3($name)] && $in3($name)} {set a3 8} {set a3 0} - if {[info exists out2($name)] && $out2($name)} {set a4 16} {set a4 0} - if {[info exists out3($name)] && $out3($name)} {set a5 32} {set a5 0} - set bv($i) [expr {$a0+$a1+$a2+$a3+$a4+$a5}] + set x 0 + if {$jump($name)} {incr x 1} + if {$in1($name)} {incr x 2} + if {$in2($name)} {incr x 4} + if {$in3($name)} {incr x 8} + if {$out2($name)} {incr x 16} + if {$out3($name)} {incr x 32} + set bv($i) $x } puts "" puts "/* Properties such as \"out2\" or \"jump\" that are specified in" puts "** comments following the \"case\" for each opcode in the vdbe.c" puts "** are encoded into bitvectors as follows:" puts "*/" -puts "#define OPFLG_JUMP 0x0001 /* jump: P2 holds jmp target */" -puts "#define OPFLG_IN1 0x0002 /* in1: P1 is an input */" -puts "#define OPFLG_IN2 0x0004 /* in2: P2 is an input */" -puts "#define OPFLG_IN3 0x0008 /* in3: P3 is an input */" -puts "#define OPFLG_OUT2 0x0010 /* out2: P2 is an output */" -puts "#define OPFLG_OUT3 0x0020 /* out3: P3 is an output */" +puts "#define OPFLG_JUMP 0x01 /* jump: P2 holds jmp target */" +puts "#define OPFLG_IN1 0x02 /* in1: P1 is an input */" +puts "#define OPFLG_IN2 0x04 /* in2: P2 is an input */" +puts "#define OPFLG_IN3 0x08 /* in3: P3 is an input */" +puts "#define OPFLG_OUT2 0x10 /* out2: P2 is an output */" +puts "#define OPFLG_OUT3 0x20 /* out3: P3 is an output */" puts "#define OPFLG_INITIALIZER \173\\" for {set i 0} {$i<=$max} {incr i} { if {$i%8==0} {