Subj : Re: Spidermonkey JIT To : netscape.public.mozilla.jseng From : Peter Paulus Date : Thu Apr 21 2005 12:17 pm Michael Ten-Pow wrote: > Has there been any recent effort to write a JIT compiler for > Spidermonkey? If not, do people agree that this is worthwhile? It > seems as though more and more applications are now built solely upon JS. > Like Mr. Eich has said, the Parrot JIT interface is a possibility, as > is libjit. Licensing issues do exist though. A general remarks about our QuarkXPress plugin that allows you to javascript QuarkXPress (about 45 host objects, C++), is that is running too slow. I've been doing some profiling to determine bottlenecks. Most of the time spent is in the QuarkXPress API. So I've been optimizing around that code. But I've been wondering what the effect of javascript JIT would be for our plugin. I've been playing with the idea to build this myself, but it is way too far from our core business (I'm not granted the time for it). To gain some insights though, I started developing a bytecode disassembler based on a vistor design pattern. But after about 2 days work was abondoned, because of other more pressing matters. The visitor could be used as a start for a jit-compiler. This has resulted in a (far from complete) disassembler. I could not find, in the short timespan I worked on it, e.g. how to get the value for the string opcode. Function bodies are not disassembled yet. It would be nice to interleave source lines as comments with the bytecode disassembly. Here is a exemplary input: // Peter Paulus. Neroc'Mediaware Solutions b.v. // 20040423 load(libPath + "lib/structure/Catalog.js"); load(libPath + "lib/structure/Spread.js"); load(libPath + "lib/structure/Article.js"); load(libPath + "lib/structure/Color.js"); load(libPath + "lib/structure/PriceBlock.js"); load(libPath + "lib/structure/PriceRow.js"); load(libPath + "lib/structure/PricePanel.js"); load(libPath + "lib/structure/Discount.js"); load(libPath + "lib/structure/Stopper.js"); load(libPath + "lib/structure/Logo.js"); load(libPath + "lib/structure/Acp.js"); load(libPath + "lib/structure/AcpPriceRow.js"); load(libPath + "lib/structure/SpreadText.js"); XmlCatalogBuilder = function( source ) { this.source = source; this.document = null; this.catalog = null; this.cursor = null; } XmlCatalogBuilder.prototype = new Object(); XmlCatalogBuilder.superclass = Object.prototype; XmlCatalogBuilder.prototype.constructor = XmlCatalogBuilder; XmlCatalogBuilder.prototype.version = "1.0"; XmlCatalogBuilder.prototype.build = function() { info("Open XML document: "+this.source+" ..."); if (os·File.exists(this.source)) { var parser = w3cDOM·DOMImplementationLS.createLSParser(w3cDOM·DOMImplementationLS.MODE_SYNCHRONOUS, "http://www.w3.org/2001/XMLSchema"); this.document = parser.parseURI(this.source); if (this.document && this.document.documentElement) { this.cursor = this.document.createTreeWalker(this.document.documentElement, w3cDOM·NodeFilter.SHOW_ELEMENT, null, false); this.catalog = this.buildCatalog( this.document.documentElement ); } else { dialog.showError("Unable to parse XML document " + this.source +"!"); } } else { dialog.showError("XML document " + this.source + " does not exist!"); } return(this.catalog); } // rest of the javascript source is omitted Here is the output: # /Users/Shared/Scripts/lib/Builders/XmlCatalogBuilder.jsa # PC OPCODE ARGUMENTS 0 name 'load' 3 pushobj 4 name 'libPath' 7 string 10 add 11 call 1 14 popv 15 name 'load' 18 pushobj 19 name 'libPath' 22 string 25 add 26 call 1 29 popv 30 name 'load' 33 pushobj 34 name 'libPath' 37 string 40 add 41 call 1 44 popv 45 name 'load' 48 pushobj 49 name 'libPath' 52 string 55 add 56 call 1 59 popv 60 name 'load' 63 pushobj 64 name 'libPath' 67 string 70 add 71 call 1 74 popv 75 name 'load' 78 pushobj 79 name 'libPath' 82 string 85 add 86 call 1 89 popv 90 name 'load' 93 pushobj 94 name 'libPath' 97 string 100 add 101 call 1 104 popv 105 name 'load' 108 pushobj 109 name 'libPath' 112 string 115 add 116 call 1 119 popv 120 name 'load' 123 pushobj 124 name 'libPath' 127 string 130 add 131 call 1 134 popv 135 name 'load' 138 pushobj 139 name 'libPath' 142 string 145 add 146 call 1 149 popv 150 name 'load' 153 pushobj 154 name 'libPath' 157 string 160 add 161 call 1 164 popv 165 name 'load' 168 pushobj 169 name 'libPath' 172 string 175 add 176 call 1 179 popv 180 name 'load' 183 pushobj 184 name 'libPath' 187 string 190 add 191 call 1 194 popv 195 bindname 'XmlCatalogBuilder' 198 anonfunobj '' 201 setname 'XmlCatalogBuilder' 204 popv 205 name 'XmlCatalogBuilder' 208 name 'Object' 211 pushobj 212 new 215 setprop 'prototype' 218 popv 219 name 'XmlCatalogBuilder' 222 name 'Object' 225 getprop 'prototype' 228 setprop 'superclass' 231 popv 232 name 'XmlCatalogBuilder' 235 getprop 'prototype' 238 name 'XmlCatalogBuilder' 241 setprop 'constructor' 244 popv 245 name 'XmlCatalogBuilder' 248 getprop 'prototype' 251 string 254 setprop 'version' 257 popv 258 name 'XmlCatalogBuilder' 261 getprop 'prototype' 264 anonfunobj '' 267 setprop 'build' 270 popv // rest of the disassembly omitted I'd be willing to publish the source for this: BytecodeVisitor.hpp BytecodeVisitor.cpp Disassembler.hpp Disassembler.cpp If, at all, interesting, please let me know. I'd surely be interested in JIT, but I won't be granted any time for it and possibly am not skilled enough to build such a product. With kind regards, Peter Paulus .