Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | 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. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
4c9222f75bfac47f5422fff86b2d69a6 |
User & Date: | drh 2016-02-01 17:20:08.707 |
Context
2016-02-01
| ||
20:12 | Improve performance of fts5 queries. (check-in: 2334e88244 user: dan tags: trunk) | |
17:20 | 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. (check-in: 4c9222f75b user: drh tags: trunk) | |
16:36 | Update walcrash.test to ensure that, during a particular test, enough data is written to cause SQLite to sync the wal file 14 times. (check-in: 5d7c092869 user: dan tags: trunk) | |
Changes
Changes to src/vdbeaux.c.
︙ | ︙ | |||
167 168 169 170 171 172 173 | } int sqlite3VdbeAddOp3(Vdbe *p, int op, int p1, int p2, int p3){ int i; VdbeOp *pOp; i = p->nOp; assert( p->magic==VDBE_MAGIC_INIT ); | | | 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | } int sqlite3VdbeAddOp3(Vdbe *p, int op, int p1, int p2, int p3){ int i; VdbeOp *pOp; i = p->nOp; assert( p->magic==VDBE_MAGIC_INIT ); assert( op>=0 && op<0xff ); if( p->pParse->nOpAlloc<=i ){ return growOp3(p, op, p1, p2, p3); } p->nOp++; pOp = &p->aOp[i]; pOp->opcode = (u8)op; pOp->p5 = 0; |
︙ | ︙ |
Changes to tool/mkopcodec.tcl.
︙ | ︙ | |||
15 16 17 18 19 20 21 | puts " || defined(SQLITE_DEBUG)" puts "#if defined(SQLITE_ENABLE_EXPLAIN_COMMENTS) || defined(SQLITE_DEBUG)" puts "# define OpHelp(X) \"\\0\" X" puts "#else" puts "# define OpHelp(X)" puts "#endif" puts "const char *sqlite3OpcodeName(int i)\173" | | | | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | puts " || defined(SQLITE_DEBUG)" puts "#if defined(SQLITE_ENABLE_EXPLAIN_COMMENTS) || defined(SQLITE_DEBUG)" puts "# define OpHelp(X) \"\\0\" X" puts "#else" puts "# define OpHelp(X)" puts "#endif" puts "const char *sqlite3OpcodeName(int i)\173" puts " static const char *const azName\[\] = \173" set mx 0 set in [open [lindex $argv 0] rb] while {![eof $in]} { set line [gets $in] if {[regexp {^#define OP_} $line]} { set name [lindex $line 1] regsub {^OP_} $name {} name set i [lindex $line 2] set label($i) $name if {$mx<$i} {set mx $i} if {[regexp {synopsis: (.*) \*/} $line all x]} { set synopsis($i) [string trim $x] } else { set synopsis($i) {} } } } close $in for {set i 0} {$i<=$mx} {incr i} { puts [format " /* %3d */ %-18s OpHelp(\"%s\")," \ $i \"$label($i)\" $synopsis($i)] } puts " \175;" puts " return azName\[i\];" puts "\175" puts "#endif" |
Changes to tool/mkopcodeh.tcl.
︙ | ︙ | |||
77 78 79 80 81 82 83 | set line [split $line] set name [string trim [lindex $line 1] :] set op($name) -1 set jump($name) 0 set in1($name) 0 set in2($name) 0 set in3($name) 0 | | | | 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | set line [split $line] set name [string trim [lindex $line 1] :] set op($name) -1 set jump($name) 0 set in1($name) 0 set in2($name) 0 set in3($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 { incr i if {[lindex $line $i]=="as"} { incr i set sym [string trim [lindex $line $i] ,] |
︙ | ︙ | |||
108 109 110 111 112 113 114 | set order($nOp) $name incr nOp } } # Assign numbers to all opcodes and output the result. # | < < | > | | > > > | | | > | 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | set order($nOp) $name incr nOp } } # Assign numbers to all opcodes and output the result. # puts "/* Automatically generated. Do not edit */" puts "/* See the tool/mkopcodeh.tcl script for details */" 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() # set rp2v_ops { OP_Transaction OP_AutoCommit OP_Savepoint |
︙ | ︙ | |||
140 141 142 143 144 145 146 | OP_Prev OP_PrevIfOpen } # Assign small values to opcodes that are processed by resolveP2Values() # to make code generation for the switch() statement smaller and faster. # | | | 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | OP_Prev OP_PrevIfOpen } # Assign small values to opcodes that are processed by resolveP2Values() # to make code generation for the switch() statement smaller and faster. # set cnt -1 for {set i 0} {$i<$nOp} {incr i} { set name $order($i) if {[lsearch $rp2v_ops $name]>=0} { incr cnt while {[info exists used($cnt)]} {incr cnt} set op($name) $cnt set used($cnt) 1 |
︙ | ︙ | |||
165 166 167 168 169 170 171 | while {[info exists used($cnt)]} {incr cnt} set op($name) $cnt set used($cnt) 1 set def($cnt) $name } } set max $cnt | | | 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | while {[info exists used($cnt)]} {incr cnt} set op($name) $cnt set used($cnt) 1 set def($cnt) $name } } set max $cnt for {set i 0} {$i<$nOp} {incr i} { if {![info exists used($i)]} { set def($i) "OP_NotUsed_$i" } set name $def($i) puts -nonewline [format {#define %-16s %3d} $name $i] set com {} if {[info exists sameas($i)]} { |
︙ | ︙ | |||
192 193 194 195 196 197 198 | } puts "" } # Generate the bitvectors: # set bv(0) 0 | | > | | | | | | | | | | | | | | 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | } puts "" } # Generate the bitvectors: # set bv(0) 0 for {set i 0} {$i<=$max} {incr i} { set name $def($i) 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 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} { puts -nonewline [format "/* %3d */" $i] } puts -nonewline [format " 0x%02x," $bv($i)] if {$i%8==7} { puts "\\" } } puts "\175" |