【正文】
nsistent with the newresults presented here. Holkner and Harland have conducted a study of the use of dynamic features (addition and deletion of fields and methods) in the Python programming language. Their study focused on a smaller set of programs and concluded that there is a clear phase distinction. In their corpus dynamic features occur mostly in the initialization phase of programs and less so during the main putation. Our results suggest that JavaScript is more dynamic than Python in practice. There are many studies of the runtime use of selected features of objectoriented languages. For example, Garret et al. reported on the dynamism of message sends in Self , Calder et al. characterized the difference of between C and C++ programs in , and Temporo et al. studied the usage of inheritance in Java in . These previous papers study in great detail one particular aspect of each language. In this particular work, we strive for an overview of JavaScript, and leave detailed analysis for future work. Finally, we were inspired by the work of Dufour et al. and their rigorous framework for discussing runtime metrics for Java. 3. Tracing and Analysis Infrastructure The tracing infrastructure developed for this paper is based on an instrumented version of the WebKit web browser engine integrated into Apple’s Safari browser. While there are standalone interpreters available, they would not be able to deal with the mixture of DOM and AJAX that is monplace in most JavaScriptenabled sites. For flexibility, analysis is performed offline. Our instrumented browser records a trace containing most operations performed by the interpreter (reads, writes,deletes, calls,defines,etc.)as well as events for garbage collection and source file loads. Invocations to eval trigger an event similar to the one for source file loads, and the 中原工學(xué)院信息商務(wù)學(xué)院畢業(yè)設(shè)計(jì)(論文)譯文專用紙 第 12頁 evaluated string is saved and traced like any other part of the program’s execution. Complete traces are pressed and stored to disk. While it does have some performance overhead, our instrumentation does not cause a noticeable slowdown in interactive applications, and none of our users plained about performance. Traces are analyzed offline and the results are stored in a database which is then mined for data. The offline trace analysis ponent is essentially an abstract interpreter for the event stream. It is able to replay any trace creating an abstract representation of the heap state of the corresponding JavaScript program. The trace analyzer maintains rich and customizable historical information about the program’s behavior, such as access histories of each object, call sites and allocation sites, and so on. Finally, several static analyses (eval classification, code size metrics) are performed on the recovered source files using the parsing framework from the Rhino JavaScript piler. 4. Conclusion This paper has provided the first largescale study of the runtime behavior of JavaScript programs. We have identified a set of representative realworld programs ranging in size from hundreds of kilobytes to megabytes, using an instrumented interpreter we have recorded multiple traces per site, and then with an offline analysis tool we have extracted behavioral information from the traces. We use this information to evaluate a list of nine monly made assumptions about JavaScript programs.