b30948e315636c7aae9c6e02a518febb396a472c
[WebKit-https.git] / JavaScriptCore / ChangeLog
1 2008-05-23  Oliver Hunt  <oliver@apple.com>
2
3        <rdar://problem/5951561> Turn on JavaScript Profiler
4
5         Reviewed by Kevin McCullough.
6
7         Flipped the switch on the profiler, rearranged how we
8         signal the the profiler is active so that calls aren't
9         needed in the general case.
10         
11         Also fixed the entry point for Machine::execute(FunctionBodyNode..)
12         to correctly indicate function exit.
13
14         Results in a 0.7-1.0% regression in SunSpider :-(
15
16         * VM/Machine.cpp:
17         (KJS::callEval):
18         (KJS::Machine::unwindCallFrame):
19         (KJS::Machine::execute):
20         (KJS::Machine::privateExecute):
21         * kjs/config.h:
22         * profiler/Profiler.cpp:
23         (KJS::Profiler::profiler):
24         (KJS::Profiler::startProfiling):
25         (KJS::Profiler::stopProfiling):
26         * profiler/Profiler.h:
27         (KJS::Profiler::enabledProfilerReference):
28
29 2008-05-23  Simon Hausmann  <hausmann@webkit.org>
30
31         Fix the Qt build by adding profiler/ to the include search path.
32
33         * JavaScriptCore.pri:
34
35 2008-05-22  Kevin McCullough  <kmccullough@apple.com>
36
37         Reviewed by Adam.
38
39         Fix a bug in the profiler where time in the current function is given to
40         (idle).
41
42         * profiler/Profile.cpp:
43         (KJS::Profile::didExecute): Set the start time and then call didExecute
44         to calculate the time spent in this function.
45         * profiler/ProfileNode.cpp: Remove confusing calculations that are no
46         longer necessary.
47         (KJS::ProfileNode::insertNode):
48         * profiler/ProfileNode.h: Expose access to the start time to allow the
49         simpler time calculations above.
50         (KJS::ProfileNode::startTime):
51         (KJS::ProfileNode::setStartTime):
52
53 2008-05-22  Adam Roben  <aroben@apple.com>
54
55         Show "(Function object)" instead of "(JSInpectorCallbackWrapper
56         object)" in profiles
57
58         Reviewed by Kevin McCullough.
59
60         * profiler/Profiler.cpp:
61         (KJS::createCallIdentifier): Use JSObject::className instead of
62         getting the class name from the ClassInfo directly. JSObject
63         subclasses can override className to provide a custom class name, and
64         it seems like we should honor that.
65
66 2008-05-22  Timothy Hatcher  <timothy@apple.com>
67
68         Added Profile::restoreAll and added ProfileNode::restoreAll
69         to the export file.
70
71         Reviewed by Adam Roben.
72
73         * JavaScriptCore.exp:
74         * profiler/Profile.h:
75
76 2008-05-22  Alp Toker  <alp@nuanti.com>
77
78         GTK+ build fix. Add JavaScriptCore/profiler to include path.
79
80         * GNUmakefile.am:
81
82 2008-05-22  Adam Roben  <aroben@apple.com>
83
84         Implement sub-millisecond profiling on Windows
85
86         Reviewed by Kevin McCullough.
87
88         * profiler/ProfileNode.cpp:
89         (KJS::getCount): Added. On Windows, we use QueryPerformanceCounter. On
90         other platforms, we use getCurrentUTCTimeWithMicroseconds.
91         (KJS::ProfileNode::endAndRecordCall): Use getCount instead of
92         getCurrentUTCTimeWithMicroseconds.
93         (KJS::ProfileNode::startTimer): Ditto.
94
95 2008-05-22  Adam Roben  <aroben@apple.com>
96
97         Fix a profiler assertion when calling a NodeList as a function
98
99         Reviewed by Kevin McCullough.
100
101         * profiler/Profiler.cpp:
102         (KJS::createCallIdentifier): Don't assert when a non-function object
103         is called as a function. Instead, build up a CallIdentifier using the
104         object's class name.
105
106 2008-05-22  Kevin McCullough  <kmccullough@apple.com>
107
108         Reviewed by Darin.
109
110         <rdar://problem/5951529> JSProfiler: Allow the profiler to "Exclude" a
111         profile node.
112         -Implement 'exclude'; where the excluded node attributes its time to its
113         parent's self time.
114
115         * JavaScriptCore.exp: Export the exclude function.
116         * profiler/Profile.h: 
117         (KJS::Profile::exclude):
118         * profiler/ProfileNode.cpp: 
119         (KJS::ProfileNode::setTreeVisible): New function that allows a change in
120         visiblitiy to be propogated to all the children of a node.
121         (KJS::ProfileNode::exclude): If the node matches the callIdentifier then
122         set the visiblity of this node and all of its children to false and
123         attribute it's total time to it's caller's self time.
124         * profiler/ProfileNode.h:
125
126 2008-05-22  Mark Rowe  <mrowe@apple.com>
127
128         Reviewed by Oliver Hunt.
129
130         Fix access to static global variables in Windows release builds.
131
132         * kjs/JSGlobalObject.h: Don't store a reference to an Identifier
133         in GlobalPropertyInfo as the Identifier is likely to be a temporary
134         and therefore may be destroyed before the GlobalPropertyInfo.
135
136 2008-05-22  Kevin McCullough  <kmccullough@apple.com>
137
138         Build fix.
139
140         * VM/Machine.cpp:
141         (KJS::callEval):
142
143 2008-05-22  Kevin McCullough  <kmccullough@apple.com>
144
145         Reviewed by Sam.
146
147         <rdar://problem/5951561> Turn on JavaScript Profiler
148         Get basic JS profiling working.
149         Even with this patch the profiler will not be compiled in because we do
150         not know the extend, if any, of the performance regression it would cause
151         when it is not in use. However with these changes, if the profiler were
152         on, it would not crash and show good profiling data.
153
154         * VM/Machine.cpp: Instrument the calls sites that are needed for profiling.
155         (KJS::callEval):
156         (KJS::Machine::unwindCallFrame):
157         (KJS::Machine::execute):
158         (KJS::Machine::privateExecute):
159         * kjs/function.cpp: Ditto.
160         (KJS::globalFuncEval):
161         * kjs/interpreter.cpp: Ditto.
162         (KJS::Interpreter::evaluate):
163         * profiler/Profile.cpp: 
164         (KJS::Profile::willExecute):
165         (KJS::Profile::didExecute): Because we do not get a good context when
166         startProfiling is called it is possible that m_currentNode will be at the
167         top of the known stack when a didExecute() is called.  What we then do is
168         create a new node that represents the function being exited and insert
169         it between the head and the currently known children, since they should
170         be children of this new node.
171         * profiler/ProfileNode.cpp:
172         (KJS::ProfileNode::ProfileNode):
173         (KJS::ProfileNode::willExecute): Rename the add function for consistency.
174         (KJS::ProfileNode::addChild): Appends the child to this node but also
175         sets the parent pointer of the children to this node.
176         (KJS::ProfileNode::insertNode): Insert a node between this node and its
177         children.  Also set the time for the new node since it is now exiting
178         and we don't really know when it started.
179         (KJS::ProfileNode::stopProfiling):
180         (KJS::ProfileNode::startTimer):
181         * profiler/ProfileNode.h:
182         (KJS::CallIdentifier::toString): Added for debugging.
183         (KJS::ProfileNode::setParent):
184         (KJS::ProfileNode::setSelfTime): Fixed an old bug where we set the
185         visibleTotalTime not the visibleSelfTime.
186         (KJS::ProfileNode::children):
187         (KJS::ProfileNode::toString): Added for debugging.
188         * profiler/Profiler.cpp: remove unecessary calls.
189         (KJS::Profiler::startProfiling):
190
191 2008-05-22  Sam Weinig  <sam@webkit.org>
192
193         Reviewed by Oliver Hunt.
194
195         Rename register arguments for op_call, op_call_eval, op_end, and op_construct 
196         to document what they are for.
197
198         * VM/CodeGenerator.cpp:
199         (KJS::CodeGenerator::emitCall):
200         (KJS::CodeGenerator::emitCallEval):
201         (KJS::CodeGenerator::emitEnd):
202         (KJS::CodeGenerator::emitConstruct):
203         * VM/CodeGenerator.h:
204         * VM/Machine.cpp:
205         (KJS::Machine::privateExecute):
206
207 2008-05-22  Oliver Hunt  <oliver@apple.com>
208
209         Reviewed by Darin.
210
211         Bug 19116: SquirrelFish shouldn't regress on variable lookups
212         <https://bugs.webkit.org/show_bug.cgi?id=19116>
213
214         Last of the multiscope look up optimisations.  This is a wash overall on SunSpider
215         but is a factor of 5-10 improvement in multiscope read/write/modify (eg. ++, --, +=,
216         ... applied to any non-local var).
217
218         * kjs/nodes.cpp:
219         (KJS::PostIncResolveNode::emitCode):
220         (KJS::PostDecResolveNode::emitCode):
221         (KJS::PreIncResolveNode::emitCode):
222         (KJS::PreDecResolveNode::emitCode):
223         (KJS::ReadModifyResolveNode::emitCode):
224
225 2008-05-22  David Kilzer  <ddkilzer@apple.com>
226
227         <rdar://problem/5954233> Add method to release free memory from FastMalloc
228
229         Patch suggested by Mark Rowe.  Rubber-stamped by Maciej.
230
231         * JavaScriptCore.exp: Export _releaseFastMallocFreeMemory.
232         * wtf/FastMalloc.cpp:
233         (WTF::TCMallocStats::): Added releaseFastMallocFreeMemory() for both
234         system malloc and FastMalloc code paths.
235         * wtf/FastMalloc.h: Define releaseFastMallocFreeMemory().
236
237 2008-05-22  Oliver Hunt  <oliver@apple.com>
238
239         RS=Maciej.
240
241         Roll out r34020 as it causes recursion tests to fail.
242
243         * kjs/object.cpp:
244         (KJS::JSObject::call):
245
246 2008-05-22  Oliver Hunt  <oliver@apple.com>
247
248         Reviewed by Mark.
249
250         Don't leak the SymbolTable when compiling eval code.
251
252         * kjs/nodes.cpp:
253         (KJS::EvalNode::generateCode):
254
255 2008-05-22  Simon Hausmann  <hausmann@webkit.org>
256
257         Reviewed by Oliver.
258
259         Qt build fix.
260
261         * JavaScriptCore.pri: Added DebuggerCallFrame to the build.
262         * VM/LabelID.h: Include limits.h for UINT_MAX.
263         * wtf/VectorTraits.h: Include memory for std::auto_ptr.
264
265 2008-05-22  Geoffrey Garen  <ggaren@apple.com>
266
267         Reviewed by Adam Roben.
268         
269         Removed the old recursion guard mechanism, since squirrelfish has its
270         own mechanism. Also removed some old JS call tracing code, since we
271         have other ways to do that, too.
272         
273         SunSpider reports no change.
274
275         * kjs/object.cpp:
276         (KJS::JSObject::call):
277
278 2008-05-22  Maciej Stachowiak  <mjs@apple.com>
279
280         Reviewed by Oliver.
281         
282         - fixed <rdar://problem/5954979> crash on celtic kane JS benchmark
283
284         * kjs/nodes.cpp:
285         (KJS::WithNode::emitCode):
286         (KJS::TryNode::emitCode):
287
288 2008-05-21  Kevin McCullough  <kmccullough@apple.com>
289
290         Reviewed by Maciej and Geoff.
291
292         <rdar://problem/5951561> Turn on JavaScript Profiler
293         -As part of the effort to turn on the profiler it would be helpful if it
294         did not need ExecStates to represent the stack location of the currently
295         executing statement.
296         -We now create each node as necessary with a reference to the current
297         node and each node knows its parent so that the tree can be made without
298         the entire stack.
299
300         * profiler/Profile.cpp:
301         (KJS::Profile::Profile): The current node starts at the head.
302         (KJS::Profile::stopProfiling): The current node is cleared when profiling
303         stops.
304         (KJS::Profile::willExecute): The current node either adds a new child or
305         starts and returns a reference to an already existing child if the call
306         ID that is requested already exists.
307         (KJS::Profile::didExecute): The current node finishes and returns its
308         parent.
309         * profiler/Profile.h: Use a single callIdentifier instead of a vector
310         since we no longer use the whole stack.
311         * profiler/ProfileNode.cpp: Now profile nodes keep a reference to their
312         parent.
313         (KJS::ProfileNode::ProfileNode): Initialize the parent.
314         (KJS::ProfileNode::didExecute): Record the time and return the parent.
315         (KJS::ProfileNode::addOrStartChild): If the given callIdentifier is
316         already a child, start it and return it, otherwise create a new one and
317         return that.
318         (KJS::ProfileNode::stopProfiling): Same logic, just use the new function.
319         * profiler/ProfileNode.h: Utilize the parent.
320         (KJS::ProfileNode::create):
321         (KJS::ProfileNode::parent):
322         * profiler/Profiler.cpp: 
323         (KJS::Profiler::startProfiling): Here is the only place where the
324         ExecState is used to figure out where in the stack the profiler is
325         currently profiling.
326         (KJS::dispatchFunctionToProfiles): Only send one CallIdentifier instead
327         of a vector of them.
328         (KJS::Profiler::willExecute): Ditto.
329         (KJS::Profiler::didExecute): Ditto.
330         (KJS::createCallIdentifier): Create only one CallIdentifier.
331         (KJS::createCallIdentifierFromFunctionImp): Ditto.
332         * profiler/Profiler.h:
333
334 2008-05-21  Darin Adler  <darin@apple.com>
335
336         Reviewed by Maciej.
337
338         - https://bugs.webkit.org/show_bug.cgi?id=19180
339           speed up the < operator for the case when both values are integers
340
341         Makes standalone SunSpider 1.022x faster.
342
343         * VM/Machine.cpp:
344         (KJS::jsLess): Add a special case for when both are numbers that fit in a JSImmediate.
345
346 2008-05-21  Maciej Stachowiak  <mjs@apple.com>
347
348         Reviewed by Oliver and Sam.
349         
350         - fixed <rdar://problem/5815631> REGRESSION (r31239): Multiscope optimisation of function calls results in incorrect this value (breaks tvtv.de)
351         
352         Track global this value in the scope chain so we can retrieve it
353         efficiently but it follows lexical scope properly.
354
355         * kjs/ExecState.h:
356         (KJS::ExecState::globalThisValue):
357         * kjs/JSGlobalObject.h:
358         (KJS::JSGlobalObject::JSGlobalObjectData::JSGlobalObjectData):
359         * kjs/function_object.cpp:
360         (KJS::FunctionObjectImp::construct):
361         * kjs/scope_chain.h:
362         (KJS::ScopeChainNode::ScopeChainNode):
363         (KJS::ScopeChainNode::globalThisObject):
364         (KJS::ScopeChainNode::push):
365         (KJS::ScopeChain::ScopeChain):
366
367 2008-05-21  Kevin McCullough  <kmccullough@apple.com>
368
369         Sadness :(
370
371         * kjs/config.h:
372
373 2008-05-21  Kevin McCullough  <kmccullough@apple.com>
374
375         Reviewed by Maciej.
376
377         <rdar://problem/5950867> JSProfiler: Allow the profiler to "Focus" a
378         profile node.
379         - This patch updatest the times of the visible nodes correctly, but to do
380         so, some of the design of the ProfileNode changed.
381
382         * JavaScriptCore.exp: export focus' symbol.
383         * profiler/Profile.cpp: ProfileNodes now take a reference to the head of
384         the profile tree to get up-to-date accurate total profile time.
385         (KJS::Profile::Profile): Pass 0 for the head node.
386         (KJS::Profile::stopProfiling): stopProfiling no longer needs the time
387         passed into it, since it can get it from the head and it does not need to
388         be told it is the head because it can figure it out on it's own.
389         (KJS::Profile::willExecute): Set the head node for each created node.
390         * profiler/Profile.h:
391         (KJS::Profile::focus): Instead of taking a CallIdentifier that the caller
392         would have to create, now focus() takes a ProfileNode that they should
393         already have a reference to and focus() can extract the CallIdentifier
394         from it.
395         * profiler/ProfileNode.cpp: Create actual and visible versions fo the
396         total and self times for focus and exclude.  Also add a head node
397         reference so that nodes can get information from their head.
398         (KJS::ProfileNode::ProfileNode):
399         (KJS::ProfileNode::stopProfiling): Rename the total and self time
400         variables and set the visual ones to the actual ones, so that without any
401         changes to the visual versions of these variables, their times will match
402         the actual times.
403         (KJS::ProfileNode::focus): Now focus() has a bool to force it's children
404         to be visible if this node is visible.  If this node does not match the
405         CallIdentifier being focused then the visibleTotalTime is only updated if
406         one or more of it's children is the CallIdentifier being focused. 
407         (KJS::ProfileNode::restoreAll): Restores all variables with respect to
408         the visible data in the ProfileNode.
409         (KJS::ProfileNode::endAndRecordCall): Name change.
410         (KJS::ProfileNode::debugPrintData): Dump the new variables.
411         (KJS::ProfileNode::debugPrintDataSampleStyle): Name change.
412         * profiler/ProfileNode.h: Use the new variables and reference to the head
413         node.
414         (KJS::ProfileNode::create):
415         (KJS::ProfileNode::totalTime):
416         (KJS::ProfileNode::setTotalTime):
417         (KJS::ProfileNode::selfTime):
418         (KJS::ProfileNode::setSelfTime):
419         (KJS::ProfileNode::totalPercent):
420         (KJS::ProfileNode::selfPercent):
421         (KJS::ProfileNode::setVisible):
422
423 2008-05-21  Alp Toker  <alp@nuanti.com>
424
425         GTK+/UNIX testkjs build fix. Include signal.h.
426
427         * kjs/testkjs.cpp:
428
429 2008-05-21  Oliver Hunt  <oliver@apple.com>
430
431         Reviewed by NOBODY (Build fix).
432
433         Yet more windows build fixes
434
435         * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
436
437 2008-05-21  Oliver Hunt  <oliver@apple.com>
438
439         Reviewed by NOBODY (Build fix).
440
441         Yet more windows build fixes
442
443         * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
444
445 2008-05-21  Alp Toker  <alp@nuanti.com>
446
447         GTK+ build fix. Add DebuggerCallFrame.cpp and take AllInOneFile.cpp
448         changes into account.
449
450         * GNUmakefile.am:
451
452 2008-05-21  Oliver Hunt  <oliver@apple.com>
453
454         Reviewed by NOBODY (Build fix).
455
456         Add DebuggerCallFrame.{h,cpp} to the project file
457
458         * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
459
460 2008-05-21  Alp Toker  <alp@nuanti.com>
461
462         GTK+ port build fixes following squirrelfish merge r33979.
463
464         * GNUmakefile.am:
465
466 2008-05-21  Maciej Stachowiak  <mjs@apple.com>
467
468         Reviewed by Darin.
469         
470         - save a hash lookup wne writing to global properties
471         0.3% speedup on SunSpider, 7% on bitops-bitwise-and
472
473         * VM/Machine.cpp:
474         (KJS::resolveBase): Check for being a the end of the scope chain
475         before hash lookup.
476
477 2008-05-21  Alp Toker  <alp@nuanti.com>
478
479         Rubber-stamped by Maciej.
480
481         Replace non-standard #pragma marks with comments to avoid compiler
482         warnings.
483
484         * profiler/ProfileNode.cpp:
485
486 2008-05-21  Geoffrey Garen  <ggaren@apple.com>
487
488         Reviewed by Mark Rowe.
489
490         Fix layout test failure in fast/dom/getter-on-window-object2 introduced in r33961.
491
492         * JavaScriptCore.exp:
493         * kjs/JSGlobalObject.cpp:
494         (KJS::JSGlobalObject::defineGetter):
495         (KJS::JSGlobalObject::defineSetter):
496         * kjs/JSGlobalObject.h:
497
498 === End merge of squirrelfish ===
499
500 2008-05-21  Geoffrey Garen  <ggaren@apple.com>
501
502         Reviewed by Tim Hatcher.
503         
504         Merged with trunk WebCore's new debugger.
505
506         * kjs/DebuggerCallFrame.cpp:
507         (KJS::DebuggerCallFrame::evaluate): Changed this function to separate
508         the exception value from the return value. The WebKit debugger treats
509         them as one, but the WebCore debugger doesn't.
510
511         * kjs/DebuggerCallFrame.h:
512         (KJS::DebuggerCallFrame::dynamicGlobalObject): Added a new accessor for
513         the dynamic global object, since the debugger doesn't want the lexical
514         global object.
515
516 2008-05-21  Oliver Hunt  <oliver@apple.com>
517
518         Reviewed by Maciej.
519
520         Bug 19116: SquirrelFish shouldn't regress on variable lookups
521         <https://bugs.webkit.org/show_bug.cgi?id=19116>
522
523         Optimise cross scope assignment, 0.4% progression in sunspider.
524
525         * VM/CodeBlock.cpp:
526         (KJS::CodeBlock::dump):
527         * VM/CodeGenerator.cpp:
528         (KJS::CodeGenerator::emitPutScopedVar):
529         * VM/CodeGenerator.h:
530         * VM/Machine.cpp:
531         (KJS::Machine::privateExecute):
532         * VM/Opcode.h:
533         * kjs/nodes.cpp:
534         (KJS::AssignResolveNode::emitCode):
535
536 2008-05-21  Maciej Stachowiak  <mjs@apple.com>
537
538         Reviewed by Oliver.
539         
540         - check property map before symbol table in JSGlobalObject::getOwnPropertySlot
541         0.5% speedup on SunSpider
542
543         * kjs/JSGlobalObject.h:
544         (KJS::JSGlobalObject::getOwnPropertySlot): Check property map before symbol table
545         because symbol table access is likely to have been optimized.
546
547 2008-05-21  Oliver Hunt  <oliver@apple.com>
548
549         Reviewed by Maciej.
550
551         Bug 19116: SquirrelFish shouldn't regress on variable lookups
552         <https://bugs.webkit.org/show_bug.cgi?id=19116>
553
554         Optimise multiscope lookup of statically resolvable function calls.
555         SunSpider reports a 1.5% improvement, including 37% on 
556         controlflow-recursive for some reason :D
557
558         * VM/CodeBlock.cpp:
559         (KJS::CodeBlock::dump):
560         * VM/CodeGenerator.cpp:
561         (KJS::CodeGenerator::emitResolve):
562         * VM/CodeGenerator.h:
563         * kjs/nodes.cpp:
564         (KJS::FunctionCallResolveNode::emitCode):
565
566 2008-05-21  Maciej Stachowiak  <mjs@apple.com>
567
568         Reviewed by Oliver.
569         
570         - give JSGlobalObject a special version of getOwnPropertySlot that tells you if the slot is directly writable
571         (WebCore change using this is a 2.6% speedup on in-browser SunSpider).
572
573         * JavaScriptCore.exp:
574         * kjs/JSGlobalObject.h:
575         (KJS::JSGlobalObject::getOwnPropertySlot):
576         * kjs/JSVariableObject.h:
577         (KJS::JSVariableObject::symbolTableGet):
578         * kjs/object.h:
579         (KJS::JSObject::getDirectLocation):
580         (KJS::JSObject::getOwnPropertySlotForWrite):
581         * kjs/property_map.cpp:
582         (KJS::PropertyMap::getLocation):
583         * kjs/property_map.h:
584         * kjs/property_slot.h:
585         (KJS::PropertySlot::putValue):
586
587 2008-05-20  Oliver Hunt  <oliver@apple.com>
588
589         Reviewed by Maciej.
590
591         Bug 19116: SquirrelFish shouldn't regress on variable lookups
592         <https://bugs.webkit.org/show_bug.cgi?id=19116>
593
594         This restores multiscope optimisation to simple resolve, producing
595         a 2.6% progression in SunSpider.  Have verified that none of the
596         sites broken by the multiscope optimisation in trunk were effected
597         by this change.
598
599         * VM/CodeBlock.cpp:
600         (KJS::CodeBlock::dump):
601         * VM/CodeBlock.h:
602         (KJS::CodeBlock::CodeBlock):
603         * VM/CodeGenerator.cpp:
604         (KJS::CodeGenerator::findScopedProperty):
605         (KJS::CodeGenerator::emitResolve):
606         * VM/CodeGenerator.h:
607         * VM/Machine.cpp:
608         (KJS::resolve_n):
609         (KJS::Machine::privateExecute):
610         * VM/Opcode.h:
611         * kjs/JSVariableObject.h:
612
613 2008-05-20  Oliver Hunt  <oliver@apple.com>
614
615         Reviewed by NOBODY (Build fix).
616
617         Fixerate the windows build.
618
619         * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
620         * VM/CodeGenerator.cpp:
621         * VM/RegisterFile.h:
622         * kjs/JSGlobalObject.h:
623         * kjs/Parser.cpp:
624         * kjs/interpreter.h:
625
626 2008-05-20  Oliver Hunt  <oliver@apple.com>
627
628         Reviewed by Geoff.
629
630         Bug 19110: SquirrelFish: Google Maps - no maps
631         <https://bugs.webkit.org/show_bug.cgi?id=19110>
632
633         Correct a comedy of errors present in my original patch to "fix"
634         exceptions occurring midway through pre and post increment. This
635         solution is cleaner than the original, doesn't need the additional
636         opcodes, and as an added benefit does not break Google Maps.
637
638         Sunspider reports a 0.4% progression.
639
640         * VM/CodeBlock.cpp:
641         (KJS::CodeBlock::dump):
642         * VM/CodeGenerator.cpp:
643         * VM/CodeGenerator.h:
644         * VM/Machine.cpp:
645         (KJS::Machine::privateExecute):
646         * VM/Opcode.h:
647         * kjs/nodes.cpp:
648         (KJS::PreIncResolveNode::emitCode):
649         (KJS::PreDecResolveNode::emitCode):
650         (KJS::PreIncBracketNode::emitCode):
651         (KJS::PreDecBracketNode::emitCode):
652         (KJS::PreIncDotNode::emitCode):
653         (KJS::PreDecDotNode::emitCode):
654
655 2008-05-20  Maciej Stachowiak  <mjs@apple.com>
656
657         Reviewed by Oliver.
658         
659         - inline JSGlobalObject::getOwnPropertySlot
660         1% improvement on in-browser SunSpider (a wash command-line)
661
662         * kjs/JSGlobalObject.cpp:
663         * kjs/JSGlobalObject.h:
664         (KJS::JSGlobalObject::getOwnPropertySlot):
665
666 2008-05-18  Oliver Hunt  <oliver@apple.com>
667
668         Reviewed by Maciej.
669
670         Bug 18752: SQUIRRELFISH: exceptions are not always handled by the vm
671         <https://bugs.webkit.org/show_bug.cgi?id=18752>
672
673         Handle exceptions thrown by toString conversion in subscript operators,
674         this should basically complete exception handling in SquirrelFish.
675
676         Sunspider reports no regression.
677
678         * VM/Machine.cpp:
679         (KJS::Machine::privateExecute):
680
681 2008-05-17  Geoffrey Garen  <ggaren@apple.com>
682
683         Reviewed by Oliver Hunt.
684
685         [Reapplying patch with previously missing files from r33553 -- Oliver]
686
687         Behold: debugging.
688         
689         SunSpider reports no change.
690
691         * JavaScriptCore.xcodeproj/project.pbxproj: Added DebuggerCallFrame.h/.cpp,
692         and created a debugger folder.
693
694         * VM/CodeGenerator.cpp:
695         (KJS::CodeGenerator::generate): If the debugger is attached, always
696         generate full scope chains for its sake.
697
698         * VM/Machine.cpp:
699         (KJS::Machine::unwindCallFrame): Notify the debugger when unwinding
700         due to an exception, so it doesn't keep stale call frames around.
701
702         (KJS::Machine::execute): Set Callee to 0 in eval frames, so the
703         debugger can distinguish them from function call frames.
704
705         (KJS::Machine::debug): Simplified this function, since the debugger
706         doesn't actually need all the information we used to provide.
707
708         (KJS::Machine::privateExecute): Treat debugging hooks like other function
709         calls, so the code we hook into (the debugger UI) can be optimized.
710
711         * kjs/debugger.cpp: Nixed these default callback implementations and
712         made the callbacks pure virtual instead, so the compiler could tell me
713         if I made a mistake in one of the subclasses.
714
715         * kjs/debugger.h: Removed a bunch of irrelevent data from the debugger
716         callbacks. Changed from passing an ExecState* to passing a
717         DebuggerCallFrame*, since an ExecState* doesn't contain sufficient
718         information anymore.
719
720         * kjs/function.cpp:
721         (KJS::globalFuncEval): Easiest bug fix evar!
722
723         [Previously missing files from r33553]
724         * kjs/DebuggerCallFrame.cpp: Copied from JavaScriptCore/profiler/FunctionCallProfile.h.
725         (KJS::DebuggerCallFrame::functionName):
726         (KJS::DebuggerCallFrame::thisObject):
727         (KJS::DebuggerCallFrame::evaluateScript):
728         * kjs/DebuggerCallFrame.h: Copied from JavaScriptCore/VM/Register.h.
729         (KJS::DebuggerCallFrame::DebuggerCallFrame):
730         (KJS::DebuggerCallFrame::scopeChain):
731         (KJS::DebuggerCallFrame::exception):
732
733 2008-05-17  Cameron Zwarich  <cwzwarich@uwaterloo.ca>
734
735         Reviewed by Oliver.
736
737         Bug 18991: SquirrelFish: Major codegen issue in a.b=expr, a[b]=expr
738         <https://bugs.webkit.org/show_bug.cgi?id=18991>
739
740         Fix the last remaining blocking cases of this bug.
741
742         * kjs/grammar.y:
743         * kjs/nodes.cpp:
744         (KJS::ReadModifyResolveNode::emitCode):
745
746 2008-05-17  Cameron Zwarich  <cwzwarich@uwaterloo.ca>
747
748         Reviewed by Oliver.
749
750         Partial fix for:
751
752         Bug 18991: SquirrelFish: Major codegen issue in a.b=expr, a[b]=expr
753         <https://bugs.webkit.org/show_bug.cgi?id=18991>
754
755         Ensure that the code generated for assignments uses temporaries whenever
756         necessary. This patch covers the vast majority of situations, but there
757         are still a few left.
758
759         This patch also adds some missing cases to CodeBlock::dump().
760
761         * VM/CodeBlock.cpp:
762         (KJS::CodeBlock::dump):
763         * VM/CodeGenerator.h:
764         (KJS::CodeGenerator::destinationForAssignResult):
765         (KJS::CodeGenerator::leftHandSideNeedsCopy):
766         (KJS::CodeGenerator::emitNodeForLeftHandSide):
767         * kjs/NodeInfo.h:
768         * kjs/grammar.y:
769         * kjs/nodes.cpp:
770         (KJS::AssignDotNode::emitCode):
771         (KJS::ReadModifyDotNode::emitCode):
772         (KJS::AssignBracketNode::emitCode):
773         (KJS::ReadModifyBracketNode::emitCode):
774         (KJS::ForInNode::ForInNode):
775         * kjs/nodes.h:
776         (KJS::ReadModifyResolveNode::):
777         (KJS::AssignResolveNode::):
778         (KJS::ReadModifyBracketNode::):
779         (KJS::AssignBracketNode::):
780         (KJS::AssignDotNode::):
781         (KJS::ReadModifyDotNode::):
782
783 2008-05-17  Oliver Hunt  <oliver@apple.com>
784
785         Reviewed by Maciej.
786
787         Bug 19106: SquirrelFish: Activation is not marked correctly
788         <https://bugs.webkit.org/show_bug.cgi?id=19106>
789
790         We can't rely on the symbol table for a count of the number of globals
791         we need to mark as that misses duplicate parameters and 'this'.  Now we
792         use the actual local register count from the codeBlock.
793
794         * kjs/JSActivation.cpp:
795         (KJS::JSActivation::mark):
796
797 2008-05-16  Oliver Hunt  <oliver@apple.com>
798
799         Reviewed by Geoff.
800
801         Bug 19076: SquirrelFish: RegisterFile can be corrupted if implictly reenter global scope with no declared vars
802         <https://bugs.webkit.org/show_bug.cgi?id=19076>
803
804         Don't delay allocation of initial global RegisterFile, as we can't guarantee we will be able
805         to allocate the global 'this' register safely at any point after initialisation of the Global
806         Object.
807
808         Unfortunately this initial allocation caused a regression of 0.2-0.3%, however this patch adds
809         support for the static slot optimisation for the global Math object which brings it to a 0.3%
810         progression.
811
812         * VM/CodeGenerator.cpp:
813         (KJS::CodeGenerator::programCodeThis):
814         (KJS::CodeGenerator::CodeGenerator):
815         (KJS::CodeGenerator::addParameter):
816         * VM/CodeGenerator.h:
817         * VM/Machine.cpp:
818         (KJS::Machine::execute):
819         * kjs/ExecState.h:
820         * kjs/JSGlobalObject.cpp:
821         (KJS::JSGlobalObject::reset):
822         * kjs/JSGlobalObject.h:
823         (KJS::JSGlobalObject::GlobalPropertyInfo::GlobalPropertyInfo):
824         (KJS::JSGlobalObject::addStaticGlobals):
825         * kjs/nodes.cpp:
826
827 2008-05-16  Cameron Zwarich  <cwzwarich@uwaterloo.ca>
828
829         Reviewed by Oliver Hunt.
830
831         Bug 19098: SquirrelFish: Ref'd temporaries can be clobbered
832         <https://bugs.webkit.org/show_bug.cgi?id=19098>
833
834         When doing code generation for a statement list, increase the reference
835         count on a register that might eventually be returned, so that it doesn't
836         get clobbered by a request for a new temporary.
837
838         * kjs/nodes.cpp:
839         (KJS::statementListEmitCode):
840
841 2008-05-16  Maciej Stachowiak  <mjs@apple.com>
842
843         Reviewed by Oliver.
844         
845         - fixed Bug 19044: SquirrelFish: Bogus values enter evaluation when closing over scope with parameter and var with same name
846         https://bugs.webkit.org/show_bug.cgi?id=19044
847
848         * kjs/JSActivation.cpp:
849         (KJS::JSActivation::copyRegisters): Use numLocals from the code
850         block rather than the size of the symbol table for the number of
851         registers to copy, to account for duplicate parameters and vars
852         with the same name as parameters (we still have potentially
853         suboptimal codegen in that we allocate a local register for the
854         var in the latter case but it is never used).
855         
856 2008-05-15  Geoffrey Garen  <ggaren@apple.com>
857
858         Not reviewed.
859         
860         We regret to inform you that your program is crashing because you were
861         stupid.
862
863         * VM/Machine.cpp:
864         (KJS::Machine::privateExecute): Math is hard.
865
866 2008-05-14  Geoffrey Garen  <ggaren@apple.com>
867
868         Reviewed by Oliver Hunt.
869
870         A little more debugger action: filled in op_debug. All debugger control
871         flow works now, but variable inspection and backtraces still don't.
872         
873         SunSpider reports no change.
874
875         * VM/CodeGenerator.cpp: Changed op_debug to accept line number parameters.
876
877         * VM/Machine.cpp:
878         (KJS::Machine::getFunctionAndArguments): Moved op_debug into a
879         NEVER_INLINE function to avoid a stunning 10% performance regression.
880         Also factored out a common function for retrieving the function and 
881         arguments from a  call frame. 
882
883         * kjs/JSActivation.cpp:
884         (KJS::JSActivation::createArgumentsObject): Use the new factored out
885         function mentioned above.
886
887         * kjs/Parser.cpp:
888         (KJS::Parser::parse): Increment m_sourceId before assigning it, so the
889         sourceId we send to the debugger matches the sourceId recorded in the
890         node.
891
892         * kjs/nodes.cpp: Emit debugging hooks.
893
894 2008-05-14  Oliver Hunt  <oliver@apple.com>
895
896         Reviewed by Maciej.
897
898         Bug 19024: SQUIRRELFISH: ASSERTION FAILED: activation->isActivationObject() in Machine::unwindCallFrame
899         <https://bugs.webkit.org/show_bug.cgi?id=19024>
900
901         This fixes a number of issues.  The most important is that we now check every register
902         file for tainting rather than just looking for function register files as that was
903         insufficient. Additionally guarded against implicit re-entry into Eval code.
904
905         Also added a few additional assertions to reduce the amout of time between something
906         going wrong and us seeing the error.
907
908         * VM/Machine.cpp:
909         (KJS::Machine::execute):
910         (KJS::Machine::privateExecute):
911         * VM/RegisterFile.cpp:
912         (KJS::RegisterFile::growBuffer):
913         (KJS::RegisterFile::addGlobalSlots):
914         * VM/RegisterFileStack.cpp:
915         (KJS::RegisterFileStack::pushGlobalRegisterFile):
916         (KJS::RegisterFileStack::pushFunctionRegisterFile):
917         * VM/RegisterFileStack.h:
918         (KJS::RegisterFileStack::inImplicitCall):
919
920 2008-05-14  Geoffrey Garen  <ggaren@apple.com>
921
922         Reviewed by Oliver Hunt.
923         
924         A little more debugger action: emit opcodes for debugger hooks. Right
925         now, the opcode implementation is just a stub.
926         
927         SunSpider reports no change.
928         
929         Some example codegen for "function f() { 1; }":
930
931             [   0] dbg         DidEnterCallFrame
932             [   2] dbg         WillExecuteStatement
933             [   4] load        tr0, 1(@k0)
934             [   7] load        tr0, undefined(@k1)
935             [  10] dbg         WillLeaveCallFrame
936             [  12] ret         tr0
937
938 2008-05-14  Oliver Hunt  <oliver@apple.com>
939
940         Reviewed by Geoff.
941
942         Bug 19025: SQUIRRELFISH: malformed syntax in onload handler causes crash
943         <https://bugs.webkit.org/show_bug.cgi?id=19025>
944
945         Simple fix -- move the use of functionBodyNode to after the null check.
946
947         * kjs/function_object.cpp:
948         (KJS::FunctionObjectImp::construct):
949
950 2008-05-13  Geoffrey Garen  <ggaren@apple.com>
951
952         Reviewed by Oliver Hunt.
953         
954         Fixed a codegen crash with run-time parse errors.
955         
956         SunSpider reports no change.
957         
958         emitThrowError needs to return the temporary holding the error, not dst,
959         since dst may be NULL. In fact, emitThrowError shouldn't take a dst
960         parameter at all, since exceptions should not modify the destination
961         register.
962
963 2008-05-13  Oliver Hunt  <oliver@apple.com>
964
965         Reviewed by Geoff.
966
967         Bug 19027: SquirrelFish: Incorrect codegen for pre-increment
968         <https://bugs.webkit.org/show_bug.cgi?id=19027>
969
970         This fixes the codegen issues for the pre-inc/decrement operators
971         to prevent incorrectly clobbering the destination in the event of
972         an exception.
973
974         * VM/CodeBlock.cpp:
975         (KJS::CodeBlock::dump):
976         * VM/CodeGenerator.cpp:
977         (KJS::CodeGenerator::emitPreInc):
978         (KJS::CodeGenerator::emitPreDec):
979         * VM/CodeGenerator.h:
980         * VM/Machine.cpp:
981         (KJS::Machine::privateExecute):
982         * VM/Opcode.h:
983         * kjs/nodes.cpp:
984         (KJS::PreIncResolveNode::emitCode):
985         (KJS::PreDecResolveNode::emitCode):
986         (KJS::PreIncBracketNode::emitCode):
987         (KJS::PreDecBracketNode::emitCode):
988         (KJS::PreIncDotNode::emitCode):
989         (KJS::PreDecDotNode::emitCode):
990
991 2008-05-13  Geoffrey Garen  <ggaren@apple.com>
992
993         Reviewed by Oliver Hunt.
994         
995         A little more debugger action: supply a real line number, sourceId,
996         and sourceURL in op_new_error.
997         
998         SunSpider reports a .2% speedup. Not sure what that's about.
999
1000         * VM/Machine.cpp:
1001         (KJS::Machine::privateExecute): Use the new good stuff in op_new_error.
1002
1003         * kjs/nodes.cpp:
1004         (KJS::RegExpNode::emitCode): Use the shared emitThrowError instead of
1005         rolling our own.
1006
1007 2008-05-13  Geoffrey Garen  <ggaren@apple.com>
1008
1009         Reviewed by Oliver Hunt.
1010         
1011         A little more debugger action: implemented the exception callback.
1012         
1013         SunSpider reports a .2% speedup. Not sure what that's about.
1014
1015         * VM/CodeBlock.h: A little refactoring here. Store a pointer to our
1016         owner ScopeNode so we can retrieve data from it. This allows us to
1017         stop storing copies of the data ourselves. Also, store a "this" register
1018         instead of a code type, since we were only using the code type to
1019         calculate the "this" register.
1020
1021         * VM/CodeGenerator.cpp:
1022         (KJS::CodeGenerator::generate): Calculate the "this" register mentioned
1023         above. Also, take care of removing "this" from the symbol table after
1024         codegen is done, since relying on the timing of a destructor for correct
1025         behavior is not so good.
1026
1027         * VM/Machine.cpp:
1028         (KJS::Machine::throwException): Invoke the debugger's exception callback.
1029         (KJS::Machine::privateExecute): Use the "this" register mentioned above.
1030
1031 2008-05-13  Geoffrey Garen  <ggaren@apple.com>
1032
1033         Reviewed by Oliver Hunt.
1034         
1035         Removed some unused exception machinery.
1036         
1037         SunSpider reports a .3% speedup.
1038
1039         * API/JSCallbackObject.h:
1040         * API/JSCallbackObjectFunctions.h:
1041         * JavaScriptCore.exp:
1042         * VM/Machine.cpp:
1043         (KJS::Machine::privateExecute):
1044         * kjs/internal.cpp:
1045         * kjs/object.cpp:
1046         * kjs/object.h:
1047         * kjs/value.h:
1048
1049 2008-05-13  Geoffrey Garen  <ggaren@apple.com>
1050
1051         Reviewed by Oliver Hunt.
1052         
1053         A little more debugger action.
1054
1055         * kjs/debugger.cpp:
1056         * kjs/debugger.h: Removed debuggersPresent because it was unused.
1057         Replaced AttachedGlobalObject linked list with a HashSet because HashSet
1058         is faster and simpler. Changed all functions to return void instead of
1059         bool, because no clients ever return false, and we don't want to support
1060         it.
1061
1062         * kjs/nodes.cpp: Did some up-keep to avoid build bustage.
1063         (KJS::Node::handleException):
1064         (KJS::BreakpointCheckStatement::execute):
1065         (KJS::FunctionBodyNodeWithDebuggerHooks::execute):
1066
1067 2008-05-13  Oliver Hunt  <oliver@apple.com>
1068
1069         Reviewed by Darin.
1070
1071         Bug 18752: SQUIRRELFISH: exceptions are not always handled by the vm
1072         <https://bugs.webkit.org/show_bug.cgi?id=18752>
1073
1074         Replace old attempt at "branchless" exceptions as the extra information
1075         being passed made gcc an unhappy compiler, replacing these custom toNumber
1076         calls with ordinary toNumber logic (by relying on toNumber now preventing
1077         side effects after an exception has been thrown) provided sufficient leeway
1078         to add the additional checks for the remaining unchecked cases.
1079
1080         This leaves only toString conversions in certain contexts as possibly
1081         misbehaving.
1082
1083         * VM/Machine.cpp:
1084         (KJS::jsAdd):
1085         (KJS::resolve):
1086         (KJS::resolveBaseAndProperty):
1087         (KJS::resolveBaseAndFunc):
1088         (KJS::Machine::privateExecute):
1089         * VM/Opcode.h:
1090         * kjs/value.h:
1091         (KJS::JSValue::safeGetNumber):
1092
1093 2008-05-13  Geoffrey Garen  <ggaren@apple.com>
1094
1095         Reviewed by Oliver Hunt.
1096         
1097         First steps toward supporting the debugger API: support the sourceParsed
1098         callback; plus some minor fixups.
1099
1100         SunSpider reports no regression.
1101
1102         * VM/CodeGenerator.h: Removed a misleading comment.
1103
1104         * kjs/Parser.h: Changed the parser to take an ExecState*, so it can
1105         implement the sourceParsed callback -- that way, we only have to
1106         implement the callback in one place.
1107
1108         * kjs/debugger.cpp: Nixed DebuggerImp, because its sole purpose in life
1109         was to demonstrate the misapplication of design patterns.
1110
1111         * kjs/debugger.h: Changed sourceParsed to take a SourceProvider, to
1112         reduce copying, and not to return a value, because pausing execution
1113         after parsing is complicated, and no clients needed that ability, anyway.
1114
1115         * kjs/grammar.y: Make sure never to pass a NULL SourceElements* to
1116         didFinishParsing -- that simplifies some code down the road.
1117         
1118         * kjs/nodes.cpp: Don't generate special AST nodes just because the
1119         debugger is attached -- that's a relic of the old AST execution model,
1120         and those nodes haven't been maintained.
1121
1122 2008-05-13  Oliver Hunt  <oliver@apple.com>
1123
1124         Reviewed by Geoff.
1125
1126         Bug 18752: SQUIRRELFISH: exceptions are not always handled by the vm
1127         <https://bugs.webkit.org/show_bug.cgi?id=18752>
1128
1129         First step: prevent incorrect evaluation of valueOf/toString conversion
1130         in right hand side of expression after earlier conversion throws.
1131
1132         * API/JSCallbackObjectFunctions.h:
1133         (KJS::::toNumber):
1134         * kjs/object.cpp:
1135         (KJS::JSObject::defaultValue):
1136
1137 2008-05-12  Oliver Hunt  <oliver@apple.com>
1138
1139         Reviewed by Geoff.
1140
1141         Bug 18934: SQUIRRELFISH: ASSERT @ nytimes.com due to RegisterFile being clobbered
1142         <https://bugs.webkit.org/show_bug.cgi?id=18934>
1143
1144         Unfortunately we cannot create new statically optimised globals if there are any
1145         tainted RegisterFiles on the RegisterFileStack.  To handle this we re-introduce
1146         (in a slightly cleaner form) the inImplicitCall concept to the RegisterFileStack.
1147
1148         * VM/Machine.cpp:
1149         (KJS::Machine::execute):
1150         * VM/RegisterFileStack.cpp:
1151         (KJS::RegisterFileStack::pushFunctionRegisterFile):
1152         * VM/RegisterFileStack.h:
1153
1154 2008-05-12  Geoffrey Garen  <ggaren@apple.com>
1155
1156         Reviewed by Maciej Stachowiak.
1157         
1158         Introduced support for function.caller.
1159         
1160         Improved support for walking interesting scopes for function introspection.
1161         
1162         This fixes all remaining layout tests not blocked by rebasing to trunk.
1163         
1164         SunSpider reports no change.
1165
1166         * VM/Machine.cpp:
1167         (KJS::Machine::dumpRegisters): Fixed a spacing issue.
1168
1169 2008-05-11  Cameron Zwarich  <cwzwarich@uwaterloo.ca>
1170
1171         Reviewed by Oliver.
1172
1173         Bug 18961: SQUIRRELFISH: Gmail doesn't load
1174         <https://bugs.webkit.org/show_bug.cgi?id=18961>
1175
1176         Fix codegen for logical nodes so that they don't use their destination
1177         as a temporary.
1178
1179         * kjs/nodes.cpp:
1180         (KJS::LogicalAndNode::emitCode):
1181         (KJS::LogicalOrNode::emitCode):
1182
1183 2008-05-10  Maciej Stachowiak  <mjs@apple.com>
1184
1185         Reviewed by Oliver.
1186
1187         - JavaScriptCore part of fix for: "SQUIRRELFISH: function toString broken after calling"
1188         https://bugs.webkit.org/show_bug.cgi?id=18869
1189        
1190         Three layout tests are fixed:
1191           fast/js/toString-elision-trailing-comma.html
1192           fast/js/toString-prefix-postfix-preserve-parens.html
1193           fast/js/kde/lval-exceptions.html
1194         
1195         Functions now save a shared subrange of the original source used
1196         to make them (so in the common case this adds no storage above the
1197         memory cache).
1198         
1199         * kjs/SourceProvider.h: Added.
1200         (KJS::SourceProvider): New abstract base class for classes that provide on-demand access
1201         to the source for a JavaScript program. This allows function objects to have access to their
1202         original source without copying.
1203         (KJS::UStringSourceProvider): SourceProvider subclass backed by a KJS::UString.
1204         (KJS::UStringSourceProvider::create):
1205         (KJS::UStringSourceProvider::getRange):
1206         (KJS::UStringSourceProvider::data):
1207         (KJS::UStringSourceProvider::length):
1208         (KJS::UStringSourceProvider::UStringSourceProvider):
1209         * kjs/SourceRange.h: Added.
1210         (KJS::SourceRange::SourceRange): Class that holds a SourceProvider and a character range into
1211         the source, to encapsulate on-demand access to the source of a function.
1212         (KJS::SourceRange::toString):
1213         * VM/Machine.cpp:
1214         (KJS::eval): Pass a UStringSourceProvider to the parser.
1215         * kjs/Parser.cpp:
1216         (KJS::Parser::parse): Take a SourceProvider and pass it on to the lexer.
1217         * kjs/Parser.h:
1218         (KJS::Parser::parse): Take a SourceProvider.
1219         * kjs/lexer.cpp:
1220         (KJS::Lexer::setCode): Take a SourceProvider; keep it around, and
1221         use it to get the raw buffer and length.
1222         * kjs/lexer.h:
1223         (KJS::Lexer::sourceRange): Convenience function to get a source
1224         range based on the lexer's source provieder, and char offsets
1225         right before and after the desired range.
1226         * kjs/function.cpp:
1227         (KJS::globalFuncEval): Pass a UStringSourceProvider to the parser.
1228         * kjs/function_object.cpp:
1229         (KJS::functionProtoFuncToString): Use toSourceString to get the source.
1230         (KJS::FunctionObjectImp::construct): Give the parser a UStringSourceProvider.
1231         * kjs/grammar.y: When parsing a function declaration, function
1232         expression, or getter or setter, tell the function body about its
1233         SourceRange.
1234         * kjs/interpreter.cpp:
1235         (KJS::Interpreter::checkSyntax): Pass a SourceProvider to the parser.
1236         (KJS::Interpreter::evaluate): Pass a SourceProvider to the parser.
1237         * kjs/interpreter.h:
1238         * kjs/nodes.h:
1239         (KJS::FunctionBodyNode::setSource): Establish a SourceRange for this function.
1240         (KJS::FunctionBodyNode::toSourceString): Get the source string out
1241         of the SourceRange.
1242         (KJS::FuncExprNode::): Take a SourceRange and set it on the body.
1243         (KJS::FuncDeclNode::): ditto
1244         * kjs/testkjs.cpp:
1245         (prettyPrintScript): Use a SourceProvider appropriately.
1246         * JavaScriptCore.exp: Export new symbols.
1247         * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: Add new files.
1248         * JavaScriptCore.xcodeproj/project.pbxproj: Add new files.
1249
1250 2008-05-09  Oliver Hunt  <oliver@apple.com>
1251
1252         Reviewed by Maciej.
1253
1254         Bring back RegisterFile tainting in order to correctly handle
1255         natively implemented getters and setters that re-enter JavaScript
1256
1257         * VM/Machine.cpp:
1258         (KJS::Machine::privateExecute):
1259         * VM/RegisterFile.h:
1260         * kjs/function.cpp:
1261         (KJS::FunctionImp::callAsFunction):
1262         * kjs/object.cpp:
1263         (KJS::JSObject::put):
1264         (KJS::tryGetAndCallProperty):
1265         * kjs/property_slot.cpp:
1266         (KJS::PropertySlot::functionGetter):
1267
1268 2008-05-09  Maciej Stachowiak  <mjs@apple.com>
1269
1270         Reviewed by Oliver.
1271         
1272         - track character offsets of open and close braces, in preparation for saving function source
1273         
1274         I verified that there is no performance regression from this change.
1275
1276         * kjs/grammar.y:
1277         * kjs/lexer.cpp:
1278         (KJS::Lexer::lex):
1279         (KJS::Lexer::matchPunctuator):
1280         * kjs/lexer.h:
1281
1282 2008-05-09  Oliver Hunt  <oliver@apple.com>
1283
1284         Reviewed by Nobody (build fix).
1285
1286         Debug build fix
1287
1288         * kjs/JSGlobalObject.cpp:
1289         (KJS::JSGlobalObject::restoreLocalStorage):
1290
1291 2008-05-09  Oliver Hunt  <oliver@apple.com>
1292
1293         Reviewed by Geoff.
1294
1295         Build fixes for SquirrelFish on windows.
1296
1297         * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
1298         * JavaScriptCore.vcproj/testkjs/testkjs.vcproj:
1299         * VM/Register.h:
1300         * kjs/JSGlobalObject.cpp:
1301         (KJS::JSGlobalObject::restoreLocalStorage):
1302         * kjs/collector.cpp:
1303         (KJS::Collector::allocate):
1304         (KJS::Collector::allocateNumber):
1305         * kjs/collector.h:
1306         (KJS::Collector::allocate):
1307         (KJS::Collector::allocateNumber):
1308         * kjs/property_slot.cpp:
1309
1310 2008-05-08  Maciej Stachowiak  <mjs@apple.com>
1311
1312         Reviewed by Geoff.
1313         
1314         - fix activation tearoff in the case where functions are called with too many arguments
1315         
1316         Fixes:
1317         fast/canvas/patternfill-repeat.html
1318         fast/dom/SelectorAPI/bug-17313.html
1319
1320         * VM/Machine.cpp:
1321         (KJS::slideRegisterWindowForCall):
1322         (KJS::scopeChainForCall):
1323         (KJS::Machine::execute):
1324         (KJS::Machine::privateExecute):
1325
1326 2008-05-08  Geoffrey Garen  <ggaren@apple.com>
1327
1328         Reviewed by Oliver Hunt.
1329         
1330         Fixed failure in fast/canvas/canvas-pattern-behaviour.html.
1331         
1332         SunSpider reports a small speedup. Not sure what that's about.
1333
1334         * VM/CodeBlock.cpp:
1335         (KJS::CodeBlock::dump): Fixed op_call_eval to dump as "op_call_eval".
1336         This helped me while debugging.
1337
1338         * VM/Machine.cpp:
1339         (KJS::Machine::unwindCallFrame): When looking for an activation to tear
1340         off, don't use the scope chain. Inside eval, the scope chain doesn't
1341         belong to us; it belongs to our calling function.
1342         
1343         Also, don't use the needsFullScopeChain flag to decide whether to tear
1344         off the activation. "function.arguments" can create an activation
1345         for a function whose needsFullScopeChain flag is set to false.
1346
1347 2008-05-08  Maciej Stachowiak  <mjs@apple.com>
1348
1349         Reviewed by Oliver.
1350         
1351         - fix function.call for calls of more than 8 arguments
1352         
1353         Fixes svg/carto.net/button.svg
1354
1355         * kjs/list.cpp:
1356         (KJS::List::getSlice): properly set up the m_buffer of the target list.
1357
1358 2008-05-08  Maciej Stachowiak  <mjs@apple.com>
1359
1360         Reviewed by Oliver.
1361         
1362         - don't return a null RegisterID from RegExpNode in the exception case, since the caller may need a real register
1363
1364         Fixes:
1365         - fast/regex/early-acid3-86.html
1366         - http/tests/misc/acid3.html
1367         
1368         * kjs/nodes.cpp:
1369         (KJS::RegExpNode::emitCode):
1370
1371 2008-05-07  Cameron Zwarich  <cwzwarich@uwaterloo.ca>
1372
1373         Reviewed by Oliver.
1374
1375         Fix a performance regression caused by the introduction of property
1376         attributes to SymbolTable in r32859 by encoding the attributes and the
1377         register index into a single field of SymbolTableEntry.
1378
1379         This leaves Node::optimizeVariableAccess() definitely broken, although
1380         it was probably not entirely correct in SquirrelFish before this change.
1381
1382         * VM/CodeBlock.h:
1383         (KJS::missingThisObjectMarker):
1384         * VM/CodeGenerator.cpp:
1385         (KJS::CodeGenerator::addVar):
1386         (KJS::CodeGenerator::CodeGenerator):
1387         (KJS::CodeGenerator::registerForLocal):
1388         (KJS::CodeGenerator::registerForLocalConstInit):
1389         (KJS::CodeGenerator::isLocalConstant):
1390         (KJS::CodeGenerator::addConstant):
1391         (KJS::CodeGenerator::emitCall):
1392         * VM/CodeGenerator.h:
1393         (KJS::CodeGenerator::IdentifierMapIndexHashTraits::emptyValue):
1394         * VM/Machine.cpp:
1395         (KJS::Machine::privateExecute):
1396         * kjs/JSGlobalObject.cpp:
1397         (KJS::JSGlobalObject::saveLocalStorage):
1398         * kjs/JSVariableObject.cpp:
1399         (KJS::JSVariableObject::getPropertyNames):
1400         (KJS::JSVariableObject::getPropertyAttributes):
1401         * kjs/JSVariableObject.h:
1402         (KJS::JSVariableObject::symbolTableGet):
1403         (KJS::JSVariableObject::symbolTablePut):
1404         (KJS::JSVariableObject::symbolTablePutWithAttributes):
1405         * kjs/SymbolTable.h:
1406         (KJS::SymbolTableEntry::SymbolTableEntry):
1407         (KJS::SymbolTableEntry::isEmpty):
1408         (KJS::SymbolTableEntry::getIndex):
1409         (KJS::SymbolTableEntry::getAttributes):
1410         (KJS::SymbolTableEntry::setAttributes):
1411         (KJS::SymbolTableEntry::isReadOnly):
1412         * kjs/nodes.cpp:
1413         (KJS::getSymbolTableEntry):
1414         (KJS::PostIncResolveNode::optimizeVariableAccess):
1415         (KJS::PostDecResolveNode::optimizeVariableAccess):
1416         (KJS::DeleteResolveNode::optimizeVariableAccess):
1417         (KJS::TypeOfResolveNode::optimizeVariableAccess):
1418         (KJS::PreIncResolveNode::optimizeVariableAccess):
1419         (KJS::PreDecResolveNode::optimizeVariableAccess):
1420         (KJS::ReadModifyResolveNode::optimizeVariableAccess):
1421         (KJS::AssignResolveNode::optimizeVariableAccess):
1422         (KJS::ProgramNode::initializeSymbolTable):
1423
1424 2008-05-06  Maciej Stachowiak  <mjs@apple.com>
1425
1426         Rubber stamped by Oliver.
1427         
1428         - add missing ! in an assert that I failed to reverse
1429
1430         * VM/CodeGenerator.cpp:
1431         (KJS::CodeGenerator::CodeGenerator):
1432
1433 2008-05-06  Maciej Stachowiak  <mjs@apple.com>
1434
1435         Reviewed by Oliver.
1436         
1437         - fixed "SQUIRRELFISH: window.this shows up as a property, but it shouldn't"
1438         https://bugs.webkit.org/show_bug.cgi?id=18868
1439         
1440         The basic approach is to have "this" only be present in the symbol
1441         table at compile time, not runtime.
1442
1443         * VM/CodeGenerator.cpp:
1444         (KJS::CodeGenerator::~CodeGenerator): Remove "this" from symbol table.
1445         (KJS::CodeGenerator::CodeGenerator): Add "this" back when re-using
1446         a symbol table.
1447         * VM/CodeGenerator.h:
1448         * VM/Machine.cpp:
1449         (KJS::Machine::execute): Don't assert that "this" is in the symbol table.
1450
1451 2008-05-06  Geoffrey Garen  <ggaren@apple.com>
1452
1453         Reviewed by Oliver Hunt.
1454         
1455         Trivial support for function.arguments: Currently, we only support
1456         function.arguments from within the scope of function.
1457         
1458         This fixes the remaining Mozilla JS test failures.
1459         
1460         SunSpider reports no change.
1461
1462         * JavaScriptCore.exp:
1463
1464         * VM/Machine.cpp:
1465         (KJS::Machine::privateExecute): Separated scope chain deref from
1466         activation register copying: since it is now possible for client code
1467         to create an activation on behalf of a function that otherwise wouldn't
1468         need one, having an activation no longer necessarily means that you need
1469         to deref the scope chain.
1470         
1471         (KJS::Machine::getCallFrame): For now, this function only examines the
1472         current scope. Walking parent scopes requires some refactoring in the
1473         way we track execution stacks.
1474
1475         * kjs/ExecState.cpp:
1476         (KJS::ExecState::ExecState): We use a negative call frame offset to
1477         indicate that a given scope is not a function call scope.
1478         
1479 2008-05-05  Oliver Hunt  <oliver@apple.com>
1480
1481         Reviewed by Geoff.
1482
1483         Fix call frame set up for native -> JS function calls.
1484
1485         * VM/Machine.cpp:
1486         (KJS::Machine::execute):
1487
1488 2008-05-05  Geoffrey Garen  <ggaren@apple.com>
1489
1490         Reviewed by Maciej Stachowiak.
1491         
1492         Fixed ecma_3/Object/8.6.2.6-001.js, and similar bugs.
1493         
1494         SunSpider reports a .4% speedup. Not sure what that's about.
1495
1496         * VM/Machine.cpp:
1497         (KJS::Machine::privateExecute): Check for exception return from equal,
1498         since toPrimitive can throw.
1499
1500         * kjs/operations.cpp:
1501         (KJS::strictEqual): In response to an error I made in an earlier version
1502         of this patch, I changed strictEqual to make clear the fact that it
1503         performs no conversions and can't throw, making it slightly more efficient
1504         in the process.
1505
1506 2008-05-05  Maciej Stachowiak  <mjs@apple.com>
1507
1508         Reviewed by Oliver.
1509         
1510         - fix some dumb mistakes in my last patch
1511
1512         * VM/CodeGenerator.cpp:
1513         (KJS::CodeGenerator::emitPushScope):
1514         (KJS::CodeGenerator::emitGetPropertyNames):
1515         * VM/Machine.cpp:
1516         (KJS::Machine::privateExecute):
1517
1518 2008-05-05  Maciej Stachowiak  <mjs@apple.com>
1519
1520         Reviewed by Oliver.
1521         
1522         - document opcodes relating to jumps, scopes, and property name iteration
1523         
1524         Documented jmp, jtrue, false, push_scope, pop_scope, get_pnames,
1525         next_pname and jmp_scopes.
1526
1527         * VM/CodeGenerator.cpp:
1528         (KJS::CodeGenerator::emitJump):
1529         (KJS::CodeGenerator::emitJumpIfTrue):
1530         (KJS::CodeGenerator::emitJumpIfFalse):
1531         (KJS::CodeGenerator::emitPushScope):
1532         (KJS::CodeGenerator::emitNextPropertyName):
1533         (KJS::CodeGenerator::emitGetPropertyNames):
1534         * VM/CodeGenerator.h:
1535         * VM/Machine.cpp:
1536         (KJS::Machine::privateExecute):
1537         * kjs/nodes.cpp:
1538         (KJS::LogicalAndNode::emitCode):
1539         (KJS::LogicalOrNode::emitCode):
1540         (KJS::ConditionalNode::emitCode):
1541         (KJS::IfNode::emitCode):
1542         (KJS::IfElseNode::emitCode):
1543         (KJS::DoWhileNode::emitCode):
1544         (KJS::WhileNode::emitCode):
1545         (KJS::ForNode::emitCode):
1546         (KJS::ForInNode::emitCode):
1547         (KJS::WithNode::emitCode):
1548
1549 2008-05-05  Cameron Zwarich  <cwzwarich@uwaterloo.ca>
1550
1551         Reviewed by Oliver.
1552
1553         Bug 18749: SQUIRRELFISH: const support is broken
1554         <https://bugs.webkit.org/show_bug.cgi?id=18749>
1555
1556         Adds support for const during code generation.
1557
1558         Fixes 2 layout tests.
1559
1560         * ChangeLog:
1561         * VM/CodeGenerator.cpp:
1562         (KJS::CodeGenerator::addVar):
1563         (KJS::CodeGenerator::CodeGenerator):
1564         (KJS::CodeGenerator::isLocalConstant):
1565         * VM/CodeGenerator.h:
1566         (KJS::CodeGenerator::addVar):
1567         * kjs/nodes.cpp:
1568         (KJS::PostIncResolveNode::emitCode):
1569         (KJS::PostDecResolveNode::emitCode):
1570         (KJS::PreIncResolveNode::emitCode):
1571         (KJS::PreDecResolveNode::emitCode):
1572         (KJS::ReadModifyResolveNode::emitCode):
1573         (KJS::AssignResolveNode::emitCode):
1574
1575 2008-05-04  Maciej Stachowiak  <mjs@apple.com>
1576
1577         Reviewed by Geoff.
1578         
1579         - document some more opcodes (and fix argument names)
1580         
1581         Added docs for eq, neq, stricteq, nstriceq, less and lesseq.
1582
1583         * VM/CodeGenerator.cpp:
1584         (KJS::CodeGenerator::emitEqual):
1585         (KJS::CodeGenerator::emitNotEqual):
1586         (KJS::CodeGenerator::emitStrictEqual):
1587         (KJS::CodeGenerator::emitNotStrictEqual):
1588         (KJS::CodeGenerator::emitLess):
1589         (KJS::CodeGenerator::emitLessEq):
1590         * VM/CodeGenerator.h:
1591         * VM/Machine.cpp:
1592         (KJS::Machine::privateExecute):
1593         * kjs/nodes.cpp:
1594         (KJS::LessNode::emitCode):
1595         (KJS::GreaterNode::emitCode):
1596         (KJS::LessEqNode::emitCode):
1597         (KJS::GreaterEqNode::emitCode):
1598         (KJS::EqualNode::emitCode):
1599         (KJS::NotEqualNode::emitCode):
1600         (KJS::StrictEqualNode::emitCode):
1601         (KJS::NotStrictEqualNode::emitCode):
1602         (KJS::CaseBlockNode::emitCodeForBlock):
1603
1604 2008-05-04  Geoffrey Garen  <ggaren@apple.com>
1605
1606         Reviewed by Maciej Stachowiak.
1607
1608         More scaffolding for f.arguments.
1609         
1610         Track the offset of the last call frame in the ExecState, so we can
1611         produce a backtrace at any time.
1612         
1613         Also, record numLocals, the sum of numVars + numParameters, in each code
1614         block, to make updates to the ExecState a little cheaper than they
1615         would be otherwise.
1616         
1617         We now use numLocals in a bunch of places where we used to calculate
1618         numVars + numParameters or -numVars - numParameters.
1619         
1620         Reports are mixed, but all in all, this seems to be a wash on SunSpider.
1621
1622 2008-05-04  Oliver Hunt  <oliver@apple.com>
1623
1624         Reviewed by Geoff.
1625
1626         Whoops, correctly handle properties that don't exist in the 
1627         symbol table.
1628
1629         * kjs/JSVariableObject.h:
1630         (KJS::JSVariableObject::symbolTablePutWithAttributes):
1631
1632 2008-05-04  Oliver Hunt  <oliver@apple.com>
1633
1634         Reviewed by Geoff.
1635
1636         Add attribute information to SymbolTable as ground work for
1637         various DontEnum and ReadOnly issues.
1638
1639         * VM/CodeGenerator.cpp:
1640         (KJS::CodeGenerator::addVar):
1641         (KJS::CodeGenerator::CodeGenerator):
1642         (KJS::CodeGenerator::registerForLocal):
1643         (KJS::CodeGenerator::registerForLocalConstInit):
1644         (KJS::CodeGenerator::addConstant):
1645         * VM/Machine.cpp:
1646         (KJS::Machine::execute):
1647         * kjs/JSGlobalObject.cpp:
1648         (KJS::JSGlobalObject::saveLocalStorage):
1649         * kjs/JSVariableObject.cpp:
1650         (KJS::JSVariableObject::getPropertyNames):
1651         (KJS::JSVariableObject::getPropertyAttributes):
1652         * kjs/JSVariableObject.h:
1653         (KJS::JSVariableObject::symbolTablePut):
1654         (KJS::JSVariableObject::symbolTablePutWithAttributes):
1655         * kjs/SymbolTable.h:
1656         (KJS::SymbolTableEntry::SymbolTableEntry):
1657         (KJS::SymbolTableIndexHashTraits::emptyValue):
1658         * kjs/nodes.cpp:
1659         (KJS::getSymbolTableEntry):
1660         (KJS::ReadModifyResolveNode::optimizeVariableAccess):
1661         (KJS::AssignResolveNode::optimizeVariableAccess):
1662         (KJS::ProgramNode::initializeSymbolTable):
1663
1664 2008-05-04  Geoffrey Garen  <ggaren@apple.com>
1665
1666         Reviewed by Oliver Hunt.
1667         
1668         More scaffolding for f.arguments.
1669         
1670         Store the register file associated with an ExecState in the ExecState.
1671         
1672         SunSpider reports no change.
1673
1674         * kjs/JSGlobalObject.h:
1675         (KJS::JSGlobalObject::JSGlobalObjectData::JSGlobalObjectData): Moved
1676         registerFileStack above globalExec, so it gets initialized first.
1677         Removed remnants of old activation scheme.
1678
1679 2008-05-04  Maciej Stachowiak  <mjs@apple.com>
1680
1681         Rubber stamped by Oliver.
1682         
1683         - renamed a few opcodes and fixed assembly formatting to accomodate the longest opcode
1684         
1685         equal --> eq
1686         nequal --> neq
1687         resolve_base_and_property --> resolve_with_base
1688         resolve_base_and_func --> resolve_func
1689         get_prop_id --> get_by_id
1690         put_prop_id --> put_by_id
1691         delete_prop_id --> del_by_id
1692         get_prop_val --> get_by_val
1693         put_prop_val --> put_by_val
1694         delete_prop_val --> del_by_val
1695         put_prop_index --> put_by_index
1696         
1697         * VM/CodeBlock.cpp:
1698         (KJS::printUnaryOp):
1699         (KJS::printBinaryOp):
1700         (KJS::printConditionalJump):
1701         (KJS::CodeBlock::dump):
1702         * VM/CodeGenerator.cpp:
1703         (KJS::CodeGenerator::emitEqual):
1704         (KJS::CodeGenerator::emitNotEqual):
1705         (KJS::CodeGenerator::emitResolveWithBase):
1706         (KJS::CodeGenerator::emitResolveFunction):
1707         (KJS::CodeGenerator::emitGetById):
1708         (KJS::CodeGenerator::emitPutById):
1709         (KJS::CodeGenerator::emitDeleteById):
1710         (KJS::CodeGenerator::emitGetByVal):
1711         (KJS::CodeGenerator::emitPutByVal):
1712         (KJS::CodeGenerator::emitDeleteByVal):
1713         (KJS::CodeGenerator::emitPutByIndex):
1714         * VM/CodeGenerator.h:
1715         * VM/Machine.cpp:
1716         (KJS::Machine::privateExecute):
1717         * VM/Opcode.h:
1718         * kjs/nodes.cpp:
1719         (KJS::ArrayNode::emitCode):
1720         (KJS::PropertyListNode::emitCode):
1721         (KJS::BracketAccessorNode::emitCode):
1722         (KJS::DotAccessorNode::emitCode):
1723         (KJS::EvalFunctionCallNode::emitCode):
1724         (KJS::FunctionCallResolveNode::emitCode):
1725         (KJS::FunctionCallBracketNode::emitCode):
1726         (KJS::FunctionCallDotNode::emitCode):
1727         (KJS::PostIncResolveNode::emitCode):
1728         (KJS::PostDecResolveNode::emitCode):
1729         (KJS::PostIncBracketNode::emitCode):
1730         (KJS::PostDecBracketNode::emitCode):
1731         (KJS::PostIncDotNode::emitCode):
1732         (KJS::PostDecDotNode::emitCode):
1733         (KJS::DeleteResolveNode::emitCode):
1734         (KJS::DeleteBracketNode::emitCode):
1735         (KJS::DeleteDotNode::emitCode):
1736         (KJS::TypeOfResolveNode::emitCode):
1737         (KJS::PreIncResolveNode::emitCode):
1738         (KJS::PreDecResolveNode::emitCode):
1739         (KJS::PreIncBracketNode::emitCode):
1740         (KJS::PreDecBracketNode::emitCode):
1741         (KJS::PreIncDotNode::emitCode):
1742         (KJS::PreDecDotNode::emitCode):
1743         (KJS::ReadModifyResolveNode::emitCode):
1744         (KJS::AssignResolveNode::emitCode):
1745         (KJS::AssignDotNode::emitCode):
1746         (KJS::ReadModifyDotNode::emitCode):
1747         (KJS::AssignBracketNode::emitCode):
1748         (KJS::ReadModifyBracketNode::emitCode):
1749         (KJS::ConstDeclNode::emitCodeSingle):
1750         (KJS::ForInNode::emitCode):
1751         (KJS::TryNode::emitCode):
1752
1753 2008-05-04  Oliver Hunt  <oliver@apple.com>
1754
1755         Reviewed by Maciej.
1756
1757         Fix assertion when accessing arguments object with too many arguments provided
1758
1759         The arguments constructor was assuming that the register offset given for argv
1760         was an absolute offset into the registerfile, rather than the offset from the
1761         frame.  This patches corrects that issue.
1762
1763         * kjs/JSActivation.cpp:
1764         (KJS::JSActivation::createArgumentsObject):
1765
1766 2008-05-04  Geoffrey Garen  <ggaren@apple.com>
1767
1768         Rubber stamped by Sam Weinig.
1769         
1770         Cleaned up Machine.cpp according to our style guidelines: moved static
1771         data to the top of the file; moved stand-alone functions below that;
1772         moved the Machine constructor above other Machine member functions.
1773
1774 2008-05-03  Maciej Stachowiak  <mjs@apple.com>
1775
1776         Reviewed by Sam.
1777         
1778         - fix accidental breakage from last patch
1779
1780         * VM/Machine.cpp:
1781         (KJS::Machine::privateExecute):
1782
1783 2008-05-03  Maciej Stachowiak  <mjs@apple.com>
1784
1785         Reviewed by Geoff.
1786         
1787         - a bunch more opcode documentation and corresponding parameter name fixes
1788
1789         I renamed a few opcodes:
1790         
1791         type_of --> typeof (that's what the JS operator is named)
1792         instance_of --> instanceof (ditto)
1793         create_error --> new_error (for consistency with other new_* opcodes)
1794         
1795         I documented the following opcodes:
1796         
1797         - load
1798         - new_object
1799         - new_array
1800         - new_regexp
1801         - mov
1802         - pre_inc
1803         - pre_dec
1804         - post_inc
1805         - post_dec
1806         - to_jsnumber
1807         - negate
1808         - bitnot
1809         - not
1810         - instanceof
1811         - typeof
1812         - in
1813         - new_func
1814         - new_funcexp
1815         - new_error
1816
1817         I also fixed formatting on some existing opcode docs.
1818         
1819         * VM/CodeBlock.cpp:
1820         (KJS::CodeBlock::dump):
1821         * VM/CodeGenerator.cpp:
1822         (KJS::CodeGenerator::emitMove):
1823         (KJS::CodeGenerator::emitNot):
1824         (KJS::CodeGenerator::emitPreInc):
1825         (KJS::CodeGenerator::emitPreDec):
1826         (KJS::CodeGenerator::emitPostInc):
1827         (KJS::CodeGenerator::emitPostDec):
1828         (KJS::CodeGenerator::emitToJSNumber):
1829         (KJS::CodeGenerator::emitNegate):
1830         (KJS::CodeGenerator::emitBitNot):
1831         (KJS::CodeGenerator::emitInstanceOf):
1832         (KJS::CodeGenerator::emitTypeOf):
1833         (KJS::CodeGenerator::emitIn):
1834         (KJS::CodeGenerator::emitLoad):
1835         (KJS::CodeGenerator::emitNewObject):
1836         (KJS::CodeGenerator::emitNewArray):
1837         (KJS::CodeGenerator::emitNewRegExp):
1838         (KJS::CodeGenerator::emitNewError):
1839         * VM/CodeGenerator.h:
1840         (KJS::CodeGenerator::scopeDepth):
1841         (KJS::CodeGenerator::addVar):
1842         * VM/Machine.cpp:
1843         (KJS::Machine::privateExecute):
1844         * VM/Opcode.h:
1845         * kjs/nodes.cpp:
1846         (KJS::Node::emitThrowError):
1847         (KJS::RegExpNode::emitCode):
1848         (KJS::TypeOfValueNode::emitCode):
1849         (KJS::UnaryPlusNode::emitCode):
1850         (KJS::NegateNode::emitCode):
1851         (KJS::BitwiseNotNode::emitCode):
1852         (KJS::LogicalNotNode::emitCode):
1853         (KJS::InstanceOfNode::emitCode):
1854         (KJS::InNode::emitCode):
1855
1856 2008-05-03  Maciej Stachowiak  <mjs@apple.com>
1857
1858         Reviewed by Geoff and Sam.
1859         
1860         - generate HTML bytecode docs at build time
1861
1862         * DerivedSources.make:
1863         * docs: Added.
1864         * docs/make-bytecode-docs.pl: Added.
1865
1866 2008-05-03  Geoffrey Garen  <ggaren@apple.com>
1867
1868         Reviewed by Sam Weinig.
1869         
1870         Update ExecState::m_scopeChain when switching scope chains inside the
1871         machine.
1872         
1873         This fixes uses of lexicalGlobalObject, such as, in a subframe
1874
1875             alert(top.makeArray() instanceof Array ? "FAIL" : "PASS");
1876         
1877         and a bunch of the security failures listed in
1878         https://bugs.webkit.org/show_bug.cgi?id=18870. (Those tests still fail,
1879         seemingly because of regressions in exception messages).
1880         
1881         SunSpider reports no change.
1882
1883         * VM/Machine.cpp: Factored out scope chain updating into a common
1884         function that takes care to update ExecState::m_scopeChain, too.
1885
1886         * kjs/ExecState.h: I made Machine a friend of ExecState so that Machine
1887         could update ExecState::m_scopeChain, even though that value is
1888         read-only for everyone else.
1889
1890         * kjs/JSGlobalObject.h:
1891         (KJS::JSGlobalObject::JSGlobalObjectData::JSGlobalObjectData): Changed
1892         this client to be a little friendlier to ExecState's internal
1893         storage type for scope chain data.
1894
1895 2008-05-03  Geoffrey Garen  <ggaren@apple.com>
1896
1897         Reviewed by Sam Weinig.
1898         
1899         Fixed https://bugs.webkit.org/show_bug.cgi?id=18876
1900         Squirrelfish: ScopeChainNode leak in op_jmp_scopes.
1901         
1902         SunSpider reports no change.
1903
1904         * VM/Machine.cpp:
1905         (KJS::Machine::privateExecute): Don't construct a ScopeChain object,
1906         since the direct threaded interpreter will goto across its destructor.
1907
1908 2008-05-03  Geoffrey Garen  <ggaren@apple.com>
1909
1910         Reviewed by Oliver Hunt.
1911         
1912         A bit more efficient fix than r32832: Don't copy globals into function
1913         register files; instead, have the RegisterFileStack track only the base
1914         of the last *global* register file, so the global object's register
1915         references stay good.
1916         
1917         SunSpider reports a .3% speedup. Not sure what that's about.
1918
1919 2008-05-03  Oliver Hunt  <oliver@apple.com>
1920
1921         Reviewed by Maciej.
1922
1923         Bug 18864: SquirrelFish: Support getter and setter definition in object literals
1924         <https://bugs.webkit.org/show_bug.cgi?id=18864>
1925
1926         Add new opcodes to allow us to add getters and setters to an object.  These are
1927         only used by the codegen for object literals.
1928
1929         * VM/CodeGenerator.cpp:
1930         (KJS::CodeGenerator::emitPutGetter):
1931         (KJS::CodeGenerator::emitPutSetter):
1932         * VM/CodeGenerator.h:
1933         * VM/Machine.cpp:
1934         (KJS::Machine::privateExecute):
1935         * VM/Opcode.h:
1936         * kjs/nodes.cpp:
1937         (KJS::PropertyListNode::emitCode):
1938
1939 2008-05-02  Maciej Stachowiak  <mjs@apple.com>
1940
1941         Reviewed by Oliver.
1942         
1943         - properly copy globals into and out of implicit call register
1944         files, otherwise they will fail at global lookup
1945
1946         Fixes fast/js/array-tostring-and-join.html layout test.
1947         
1948         * VM/RegisterFileStack.cpp:
1949         (KJS::RegisterFileStack::pushGlobalRegisterFile):
1950         (KJS::RegisterFileStack::popGlobalRegisterFile):
1951         (KJS::RegisterFileStack::pushFunctionRegisterFile):
1952         (KJS::RegisterFileStack::popFunctionRegisterFile):
1953
1954 2008-05-02  Geoffrey Garen  <ggaren@apple.com>
1955
1956         Reviewed by Oliver Hunt.
1957         
1958         Fixed https://bugs.webkit.org/show_bug.cgi?id=18822
1959         SQUIRRELFISH: incorrect eval used in some cases
1960         
1961         Changed all code inside the machine to fetch the lexical global object
1962         directly from the scope chain, instead of from the ExecState.
1963         
1964         Clients who fetch the lexical global object through the ExecState
1965         still don't work.
1966         
1967         SunSpider reports no change.
1968
1969         * VM/Machine.cpp:
1970         (KJS::Machine::privateExecute): Fetch the lexical global object from
1971         the scope chain.
1972         
1973         * kjs/ExecState.h:
1974         (KJS::ExecState::ExecState::lexicalGlobalObject): Moved the logic for
1975         this function into ScopeChainNode, but kept this function around to
1976         support existing clients.
1977
1978 2008-05-02  Geoffrey Garen  <ggaren@apple.com>
1979
1980         Rubber stamped by Oliver Hunt.
1981         
1982         Removed ExecState.cpp from AllInOneFile.cpp, for a .2% speedup.
1983
1984         * JavaScriptCore.xcodeproj/project.pbxproj:
1985         * kjs/AllInOneFile.cpp:
1986
1987 2008-05-01  Oliver Hunt  <oliver@apple.com>
1988
1989         Reviewed by Geoff and Maciej.
1990
1991         Bug 18827: SquirrelFish: Prevent getters and setters from destroying the current RegisterFile
1992         <https://bugs.webkit.org/show_bug.cgi?id=18827>
1993
1994         Remove safe/unsafe RegisterFile concept, and instead just add additional
1995         logic to ensure we always push/pop RegisterFiles when executing getters
1996         and setters, similar to the logic for valueOf and toString.
1997
1998         * VM/Machine.cpp:
1999         (KJS::Machine::privateExecute):
2000         * VM/RegisterFile.h:
2001         * kjs/function.cpp:
2002         (KJS::FunctionImp::callAsFunction):
2003         * kjs/object.cpp:
2004         (KJS::JSObject::put):
2005         * kjs/property_slot.cpp:
2006         (KJS::PropertySlot::functionGetter):
2007
2008 2008-05-01  Oliver Hunt  <oliver@apple.com>
2009
2010         RS=Geoff
2011
2012         Rename unsafeForReentry to safeForReentry to avoid double negatives.
2013
2014         * VM/Machine.cpp:
2015         (KJS::Machine::privateExecute):
2016         * VM/RegisterFile.h:
2017         * kjs/function.cpp:
2018         (KJS::FunctionImp::callAsFunction):
2019
2020 2008-05-01  Oliver Hunt  <oliver@apple.com>
2021
2022         Reviewed by Maciej.
2023
2024         Bug 18827: SquirrelFish: Prevent getters and setters from destroying the current RegisterFile
2025         <https://bugs.webkit.org/show_bug.cgi?id=18827>
2026         
2027         This patch makes getters and setters work.  It does this by
2028         tracking whether the RegisterFile is "safe", that is whether
2029         the interpreter is in a state that in which it can handle
2030         the RegisterFile being reallocated.
2031
2032         * VM/Machine.cpp:
2033         (KJS::resolve):
2034         (KJS::Machine::privateExecute):
2035         * VM/RegisterFile.h:
2036         * kjs/function.cpp:
2037         (KJS::FunctionImp::callAsFunction):
2038
2039 2008-04-30  Geoffrey Garen  <ggaren@apple.com>
2040
2041         Release build fix: Always compile in "isGlobalObject", since it's
2042         listed in our .exp file.
2043
2044         * kjs/ExecState.cpp:
2045         (KJS::ExecState::isGlobalObject):
2046         * kjs/ExecState.h:
2047
2048 2008-04-30  Oliver Hunt  <oliver@apple.com>
2049
2050         Reviewed by Maciej.
2051
2052         Minor code restructuring to prepare for getters and setters, 
2053         also helps exception semantics a bit.
2054
2055         * VM/Machine.cpp:
2056         (KJS::Machine::privateExecute):
2057
2058 2008-04-30  Geoffrey Garen  <ggaren@apple.com>
2059
2060         Fixed tyop.
2061
2062         * kjs/ExecState.h:
2063
2064 2008-04-30  Geoffrey Garen  <ggaren@apple.com>
2065
2066         Debug build fix: export a missing symbol.
2067
2068         * JavaScriptCore.exp:
2069
2070 2008-04-30  Geoffrey Garen  <ggaren@apple.com>
2071
2072         Reviewed by Oliver Hunt.
2073         
2074         A little more ExecState refactoring: Now, only the global object creates
2075         an ExecState.
2076         
2077         Also inlined ExecState::lexicalGlobalObject().
2078         
2079         SunSpider reports no change.
2080
2081 2008-04-30  Geoffrey Garen  <ggaren@apple.com>
2082
2083         WebCore build fix: forward-declare ScopeChain.
2084
2085         * kjs/interpreter.h:
2086
2087 2008-04-30  Geoffrey Garen  <ggaren@apple.com>
2088
2089         Build fix for JavaScriptGlue: export a missing symbol.
2090
2091         * JavaScriptCore.exp:
2092
2093 2008-04-30  Geoffrey Garen  <ggaren@apple.com>
2094
2095         Reviewed by Oliver Hunt.
2096         
2097         Removed a lot of unused bits from ExecState, moving them into
2098         OldInterpreterExecState, the fake scaffolding class.
2099         
2100         The clutter was making it hard to see the forest from the trees.
2101         
2102         .4% SunSpider speedup, probably because ExecState::lexicalGlobalObject()
2103         is faster now.
2104
2105 2008-04-29  Oliver Hunt  <oliver@apple.com>
2106
2107         Reviewed by Maciej.
2108
2109         Bug 18643: SQUIRRELFISH: need to support implicit function calls (valueOf, toString, getters/setters)
2110         <https://bugs.webkit.org/show_bug.cgi?id=18643>
2111
2112         Prevent static slot optimisation for new variables and functions in
2113         globally re-entrant code called from an an implicit function call.
2114
2115         This is necessary to prevent us from needing to resize the global
2116         slot portion of the root RegisterFile during an implicit (and hence
2117         unguarded) function call.
2118
2119         * VM/CodeGenerator.cpp:
2120         (KJS::CodeGenerator::CodeGenerator):
2121         * VM/CodeGenerator.h:
2122         * VM/Machine.cpp:
2123         (KJS::Machine::execute):
2124         * VM/RegisterFile.h:
2125         * VM/RegisterFileStack.cpp:
2126         (KJS::RegisterFileStack::pushGlobalRegisterFile):
2127         (KJS::RegisterFileStack::popGlobalRegisterFile):
2128         (KJS::RegisterFileStack::pushFunctionRegisterFile):
2129         (KJS::RegisterFileStack::popFunctionRegisterFile):
2130         * VM/RegisterFileStack.h:
2131         (KJS::RegisterFileStack::inImplicitFunctionCall):
2132         (KJS::RegisterFileStack::lastGlobal):
2133         * kjs/nodes.cpp:
2134         (KJS::ProgramNode::generateCode):
2135         * kjs/nodes.h:
2136         (KJS::ProgramNode::):
2137
2138 2008-04-29  Geoffrey Garen  <ggaren@apple.com>
2139
2140         Reviewed by Oliver Hunt.
2141         
2142         In nested program code, don't propogate "this" back to the parent
2143         register file. ("this" should remain constant in the parent register
2144         file, regardless of the scripts it invokes.)
2145
2146         * VM/RegisterFile.cpp:
2147         (KJS::RegisterFile::copyGlobals):
2148
2149 2008-04-28  Oliver Hunt  <oliver@apple.com>
2150
2151         Reviewed by Geoff.
2152
2153         Restore base pointer when popping a global RegisterFile
2154
2155         * VM/RegisterFileStack.cpp:
2156         (KJS::RegisterFileStack::popGlobalRegisterFile):
2157
2158 2008-04-28  Oliver Hunt  <oliver@apple.com>
2159
2160         Reviewed by Geoff.
2161
2162         Bug 18643: SQUIRRELFISH: need to support implicit function calls (valueOf, toString, getters/setters)
2163         <https://bugs.webkit.org/show_bug.cgi?id=18643>
2164
2165         Partial fix.  This results in all implicit calls to toString or valueOf
2166         executing in a separate RegisterFile, so ensuring that the the pointers
2167         in the triggering interpreter don't get trashed.  This still leaves the
2168         task of preventing new global re-entry from toString and valueOf from
2169         clobbering the RegisterFile.
2170
2171         * VM/Machine.cpp:
2172         (KJS::Machine::execute):
2173         * VM/RegisterFileStack.cpp:
2174         (KJS::RegisterFileStack::pushFunctionRegisterFile):
2175         (KJS::RegisterFileStack::popFunctionRegisterFile):
2176         * VM/RegisterFileStack.h:
2177         * kjs/object.cpp:
2178         (KJS::tryGetAndCallProperty):
2179
2180 2008-04-28  Geoffrey Garen  <ggaren@apple.com>
2181
2182         Reviewed by Maciej Stachowiak.
2183         
2184         Simplified activation object a bit: No need to store the callee
2185         in the activation object -- we can pull it out of the call frame
2186         when needed, instead.
2187         
2188         SunSpider reports no change.
2189
2190 2008-04-28  Geoffrey Garen  <ggaren@apple.com>
2191
2192         Reviewed by Maciej Stachowiak.
2193         
2194         RS by Oliver Hunt on moving JSArguments.cpp out of AllInOneFile.cpp.
2195
2196         Substantially more handling of "arguments": "arguments" works fully
2197         now, but "f.arguments" still doesn't work.
2198
2199         Fixes 10 regression tests.
2200         
2201         SunSpider reports no regression.
2202
2203         * kjs/JSActivation.cpp:
2204         (KJS::JSActivation::createArgumentsObject): Reconstruct an arguments
2205         List to pass to the arguments object constructor.
2206
2207         * JavaScriptCore.xcodeproj/project.pbxproj:
2208         * kjs/AllInOneFile.cpp: Removed JSActivation.cpp from AllInOneFile.cpp
2209         because that seems to make GCC happy. (Previously, I had added
2210         JSActivation.cpp to AllInOneFile.cpp because *that* seemed to make GCC
2211         happy. So it goes.)
2212
2213 2008-04-28  Geoffrey Garen  <ggaren@apple.com>
2214
2215         Reviewed by Maciej Stachowiak.
2216         
2217         Groundwork for more handling of "arguments". I'm not checking in the
2218         actual handling of "arguments" yet, because it still needs a little
2219         fiddling to avoid a performance regression.
2220         
2221         SunSpider reports no change.
2222
2223         * VM/Machine.cpp:
2224         (KJS::initializeCallFrame): Put argc in the register file, so the
2225         arguments object can find it later, to determine arguments.length.
2226
2227         * kjs/nodes.h:
2228         (KJS::FunctionBodyNode::): Added a special code accessor for when you
2229         know the code has already been generated, and you don't have a scopeChain
2230         to supply for potential code generation. (This is the case when the
2231         activation object creates the arguments object.)
2232
2233 2008-04-28  Oliver Hunt  <oliver@apple.com>
2234
2235         Reviewed by Geoff.
2236
2237         Replace unsafe use of auto_ptr in Vector with manual memory
2238         management.
2239
2240         * VM/RegisterFileStack.cpp:
2241         (KJS::RegisterFileStack::~RegisterFileStack):
2242         (KJS::RegisterFileStack::popRegisterFile):
2243         * VM/RegisterFileStack.h:
2244
2245 2008-04-27  Cameron Zwarich  <cwzwarich@uwaterloo.ca>
2246
2247         Reviewed by Maciej.
2248
2249         Bug 18746: SQUIRRELFISH: indirect eval used when direct eval should be used
2250         <https://bugs.webkit.org/show_bug.cgi?id=18746>
2251
2252         Change the base to the correct value of the 'this' object after the direct
2253         eval test instead of before.
2254
2255         Fixes 5 layout tests.
2256
2257         * VM/Machine.cpp:
2258         (KJS::Machine::privateExecute):
2259         * kjs/nodes.cpp:
2260         (KJS::EvalFunctionCallNode::emitCode):
2261
2262 2008-04-26  Maciej Stachowiak  <mjs@apple.com>
2263
2264         Reviewed by Oliver.
2265         
2266         - document all property getting, setting and deleting opcodes
2267         
2268         (And fix function parameter names to match corresponding opcode parameter names.)
2269
2270         * VM/CodeGenerator.cpp:
2271         (KJS::CodeGenerator::emitResolve):
2272         (KJS::CodeGenerator::emitResolveBase):
2273         (KJS::CodeGenerator::emitResolveBaseAndProperty):
2274         (KJS::CodeGenerator::emitResolveBaseAndFunc):
2275         (KJS::CodeGenerator::emitGetPropId):
2276         (KJS::CodeGenerator::emitPutPropId):
2277         (KJS::CodeGenerator::emitDeletePropId):
2278         (KJS::CodeGenerator::emitPutPropVal):
2279         * VM/CodeGenerator.h:
2280         * VM/Machine.cpp:
2281         (KJS::resolve):
2282         (KJS::resolveBase):
2283         (KJS::resolveBaseAndProperty):
2284         (KJS::resolveBaseAndFunc):
2285         (KJS::Machine::privateExecute):
2286         * kjs/nodes.cpp:
2287         (KJS::ResolveNode::emitCode):
2288         (KJS::ArrayNode::emitCode):
2289         (KJS::PropertyListNode::emitCode):
2290         (KJS::BracketAccessorNode::emitCode):
2291         (KJS::EvalFunctionCallNode::emitCode):
2292         (KJS::FunctionCallResolveNode::emitCode):
2293         (KJS::FunctionCallBracketNode::emitCode):
2294         (KJS::PostIncResolveNode::emitCode):
2295         (KJS::PostDecResolveNode::emitCode):
2296         (KJS::PostIncBracketNode::emitCode):
2297         (KJS::PostDecBracketNode::emitCode):
2298         (KJS::PostIncDotNode::emitCode):
2299         (KJS::PostDecDotNode::emitCode):
2300         (KJS::DeleteResolveNode::emitCode):
2301         (KJS::TypeOfResolveNode::emitCode):
2302         (KJS::PreIncResolveNode::emitCode):
2303         (KJS::PreDecResolveNode::emitCode):
2304         (KJS::PreIncBracketNode::emitCode):
2305         (KJS::PreDecBracketNode::emitCode):
2306         (KJS::AssignResolveNode::emitCode):
2307         (KJS::AssignDotNode::emitCode):
2308         (KJS::ReadModifyDotNode::emitCode):
2309         (KJS::AssignBracketNode::emitCode):
2310         (KJS::ReadModifyBracketNode::emitCode):
2311         (KJS::ConstDeclNode::emitCodeSingle):
2312
2313 2008-04-26  Oliver Hunt  <oliver@apple.com>
2314
2315         Reviewed by Maciej.
2316
2317         Bug 18628: SQUIRRELFISH: need to support recursion limit
2318         <https://bugs.webkit.org/show_bug.cgi?id=18628>
2319
2320         Basically completes recursion limiting.  There is still some
2321         tuning we may want to do to make things better in the face of
2322         very bad code, but certainly nothing worse than anything already
2323         possible in trunk.
2324
2325         Also fixes a WebKit test by fixing the exception text :D
2326
2327         * JavaScriptCore.exp:
2328         * VM/ExceptionHelpers.cpp:
2329         * VM/Machine.cpp:
2330         (KJS::Machine::execute):
2331         * VM/RegisterFile.cpp:
2332         (KJS::RegisterFile::growBuffer):
2333         (KJS::RegisterFile::addGlobalSlots):
2334         * VM/RegisterFile.h:
2335         (KJS::RegisterFile::grow):
2336         (KJS::RegisterFile::uncheckedGrow):
2337         * VM/RegisterFileStack.cpp:
2338         (KJS::RegisterFileStack::pushRegisterFile):
2339         * VM/RegisterFileStack.h:
2340
2341 2008-04-25  Oliver Hunt  <oliver@apple.com>
2342
2343         Reviewed by Geoff.
2344
2345         Bug 18628: SQUIRRELFISH: need to support recursion limit
2346         <https://bugs.webkit.org/show_bug.cgi?id=18628>
2347
2348         Put a limit on the level of reentry recursion.  128 levels of re-entrant recursion
2349         seems reasonable as it is greater than the old eval limit, and a long way short of
2350         the reentry depth needed to overflow the stack.
2351
2352         * VM/Machine.cpp:
2353         (KJS::Machine::execute):
2354         * VM/Machine.h:
2355
2356 2008-04-25  Geoffrey Garen  <ggaren@apple.com>
2357
2358         Reviewed by Sam Weinig.
2359         
2360         A tiny bit of cleanup to the regexp code.
2361         
2362         Removed some static_cast.
2363         
2364         Removed createRegExpImp because it's no longer used.
2365
2366 2008-04-25  Oliver Hunt  <oliver@apple.com>
2367
2368         Reviewed by Maciej.
2369
2370         Bug 18736: SQUIRRELFISH: switch statements with no default have incorrect codegen
2371         <https://bugs.webkit.org/show_bug.cgi?id=18736>
2372
2373         Ensure the "default" target is correct in the absence of an explicit default handler.
2374
2375         * kjs/nodes.cpp:
2376         (KJS::CaseBlockNode::emitCodeForBlock):
2377
2378 2008-04-25  Oliver Hunt  <oliver@apple.com>
2379
2380         Reviewed by Maciej.
2381
2382         Bug 18628: SQUIRRELFISH: need to support recursion limit
2383         <https://bugs.webkit.org/show_bug.cgi?id=18628>
2384
2385         More bounds checking.
2386
2387         * VM/Machine.cpp:
2388         (KJS::Machine::execute):
2389         * VM/RegisterFile.cpp:
2390         (KJS::RegisterFile::growBuffer):
2391         * VM/RegisterFile.h:
2392
2393 2008-04-25  Maciej Stachowiak  <mjs@apple.com>
2394
2395         Reviewed by Oliver.
2396         
2397         - fix signal catching magic
2398         
2399         The signal handlers are restored to _exit but are only set when
2400         running under run-javascriptcore-tests. fprintf from a signal
2401         handler is not safe.
2402
2403         * kjs/testkjs.cpp:
2404         (main):
2405         (parseArguments):
2406         * tests/mozilla/jsDriver.pl:
2407
2408 2008-04-25  Cameron Zwarich  <cwzwarich@uwaterloo.ca>
2409
2410         Reviewed by Maciej.
2411
2412         Bug 18732: SQUIRRELFISH: exceptions thrown by native constructors are ignored
2413         <https://bugs.webkit.org/show_bug.cgi?id=18732>
2414
2415         Fixes another regression test.
2416
2417         * VM/Machine.cpp:
2418         (KJS::Machine::privateExecute):
2419
2420 2008-04-25  Cameron Zwarich  <cwzwarich@uwaterloo.ca>
2421
2422         Reviewed by Maciej.
2423
2424         Bug 18728: SQUIRRELFISH: invalid regular expression constants should throw exceptions
2425         <https://bugs.webkit.org/show_bug.cgi?id=18728>
2426
2427         Fixes another regression test.
2428
2429         * kjs/nodes.cpp:
2430         (KJS::RegExpNode::emitCode):
2431
2432 2008-04-24  Cameron Zwarich  <cwzwarich@uwaterloo.ca>
2433
2434         Reviewed by Geoffrey Garen.
2435
2436         Bug 18735: SQUIRRELFISH: closures are sometimes given an incorrect 'this' value when called
2437         <https://bugs.webkit.org/show_bug.cgi?id=18735>
2438
2439         The overloaded toThisObject method was not copied over to JSActivation.
2440
2441         Fixes two regression tests.
2442
2443         * kjs/JSActivation.cpp:
2444         (KJS::JSActivation::toThisObject):
2445         * kjs/JSActivation.h:
2446
2447 2008-04-24  Geoffrey Garen  <ggaren@apple.com>
2448
2449         Reviewed by Oliver Hunt.
2450         
2451         Added support for arguments.callee.
2452
2453 2008-04-24  Oliver Hunt  <oliver@apple.com>
2454
2455         Reviewed by Maciej.
2456
2457         Bug 18628: SQUIRRELFISH: need to support recursion limit
2458         <https://bugs.webkit.org/show_bug.cgi?id=18628>
2459
2460         Partial fix -- this gets us some of the required bounds checking, but not
2461         complete coverage.  But it does manage to do them without regressing :D
2462
2463         * VM/ExceptionHelpers.cpp:
2464         (KJS::createError):
2465         (KJS::createStackOverflowError):
2466         * VM/ExceptionHelpers.h:
2467         * VM/Machine.cpp:
2468         (KJS::slideRegisterWindowForCall):
2469         (KJS::Machine::execute):
2470         (KJS::Machine::privateExecute):
2471         * VM/RegisterFile.cpp:
2472         * VM/RegisterFile.h:
2473         (KJS::RegisterFile::):
2474         (KJS::RegisterFile::RegisterFile):
2475         (KJS::RegisterFile::grow):
2476
2477 2008-04-24  Geoffrey Garen  <ggaren@apple.com>
2478
2479         Reviewed by Oliver Hunt.
2480         
2481         A tiny bit more handling of "arguments": create a real, but mostly
2482         hollow, arguments object.
2483         
2484         Fixes 2 regression tests.
2485
2486 2008-04-24  Cameron Zwarich  <cwzwarich@uwaterloo.ca>
2487
2488         Reviewed by Oliver.
2489
2490         Bug 18717: SQUIRRELFISH: eval returns the wrong value for a variable declaration statement
2491         <https://bugs.webkit.org/show_bug.cgi?id=18717>
2492
2493         Fixes a regression test, but exposes the failure of another due to the
2494         lack of getters and setters.
2495
2496         * kjs/nodes.cpp:
2497         (KJS::ConstDeclNode::emitCodeSingle):
2498         (KJS::ConstDeclNode::emitCode):
2499         (KJS::ConstStatementNode::emitCode):
2500         (KJS::VarStatementNode::emitCode):
2501         * kjs/nodes.h:
2502
2503 2008-04-24  Geoffrey Garen  <ggaren@apple.com>
2504
2505         Reviewed by Sam Weinig.
2506         
2507         Print a CRASH statement when crashing, so test failures are not a
2508         mystery.
2509
2510         * kjs/testkjs.cpp:
2511         (handleCrash):
2512         (main):
2513
2514 2008-04-24  Cameron Zwarich  <cwzwarich@uwaterloo.ca>
2515
2516         Reviewed by Geoffrey Garen.
2517
2518         Bug 18716: SQUIRRELFISH: typeof should return undefined for an undefined variable reference
2519         <https://bugs.webkit.org/show_bug.cgi?id=18716>
2520
2521         This fixes 2 more regression tests.
2522
2523         * kjs/nodes.cpp:
2524         (KJS::TypeOfResolveNode::emitCode):
2525
2526 2008-04-24  Geoffrey Garen  <ggaren@apple.com>
2527
2528         Reviewed by Sam Weinig.
2529         
2530         Put the callee in the call frame.
2531         
2532         Necessary in order to support "arguments" and "arguments.callee".
2533
2534         Also fixes a latent GC bug, where an executing function could be
2535         subject to GC if the register holding it were overwritten. Here's
2536         an example that would have caused problems:
2537         
2538         function f()
2539         {
2540             // Flood the machine stack to eliminate any old pointers to f.
2541             g.call({});
2542             
2543             // Overwrite f in the register file.
2544             f = 1;
2545
2546             // Force a GC.
2547             for (var i = 0; i < 5000; ++i) {
2548                 ({});
2549             }
2550             
2551             // Welcome to crash-ville.
2552         }
2553
2554         function g()
2555         {
2556         }
2557
2558         f();
2559
2560         * VM/Machine.h: Changed the order of arguments to
2561         execute(FunctionBodyNode*...) to match the other execute functions.
2562         * kjs/function.cpp: Updated to match new argument requirements from
2563         execute(FunctionBodyNode*...). Renamed newObj to thisObj to match the
2564         rest of JavaScriptCore.
2565
2566         SunSpider reports no change.
2567
2568 2008-04-23  Cameron Zwarich  <cwzwarich@uwaterloo.ca>
2569
2570         Reviewed by Maciej.
2571
2572         Bug 18707: SQUIRRELFISH: eval always performs toString() on its argument
2573         <https://bugs.webkit.org/show_bug.cgi?id=18707>
2574
2575         This fixes 4 more regression tests.
2576
2577         * VM/Machine.cpp:
2578         (KJS::eval):
2579
2580 2008-04-23  Maciej Stachowiak  <mjs@apple.com>
2581
2582         Reviewed by Oliver.
2583         
2584         - fix logic bug in SegmentedVector::grow which would sometimes fail to resize a segment when needed
2585         
2586         Fixes 3 JSC tests.
2587
2588         * VM/SegmentedVector.h:
2589         (KJS::SegmentedVector::grow):
2590
2591 2008-04-23  Geoffrey Garen  <ggaren@apple.com>
2592
2593         Reviewed by Maciej Stachowiak.
2594         
2595         Degenerate handling of "arguments" as a property of the activation
2596         object. Currently, we just return a vanilla object.
2597         
2598         SunSpider reports no change.
2599
2600         Fixes:
2601
2602         ecma_3/Function/regress-94506.js.
2603         
2604         Reveals to have been secretly broken:
2605
2606         ecma_3/Function/15.3.4.3-1.js
2607         ecma_3/Function/15.3.4.4-1.js
2608         
2609         These tests were passing incorrectly. testkjs creates a global array
2610         named "arguments" to hold command-line arguments. That array was
2611         tricking these tests into thinking that an arguments object with length
2612         0 had been created. Since our new vanilla object shadows the global
2613         property named arguments, that object no longer fools these tests into
2614         passing.
2615         
2616         Net change: +1 failing test.
2617
2618         * kjs/AllInOneFile.cpp: Had to put JSActivation.cpp into AllInOneFile.cpp
2619         to solve a surprising 8.6% regression in bitops-3bit-bits-in-byte.
2620
2621 2008-04-23  Maciej Stachowiak  <mjs@apple.com>
2622
2623         Reviewed by Oliver.
2624         
2625         - save and restore callFrame
2626
2627         * VM/Machine.cpp:
2628         (KJS::slideRegisterWindowForCall):
2629         (KJS::Machine::execute):
2630         (KJS::Machine::privateExecute):
2631         * kjs/testkjs.cpp:
2632         (main):
2633
2634 2008-04-23  Geoffrey Garen  <ggaren@apple.com>
2635
2636         Reviewed by Maciej Stachowiak.
2637         
2638         Fixed scopes for named function expressions.
2639         
2640         Fixes one regression test.
2641         
2642         Two changes here:
2643         
2644         (1) The function's name is supposed to have attributes DontDelete,
2645         ReadOnly, regardless of the type of code executing.
2646         
2647         (2) Push the name object on the function's scope chain, rather than
2648         the ExecState's scope chain because, well, that's where it belongs.
2649
2650 2008-04-23  Geoffrey Garen  <ggaren@apple.com>
2651
2652         Reviewed by Oliver Hunt.
2653         
2654         Inlined JSObject::putDirect, for a .4% SunSpider speedup.
2655         
2656         I did this as a first step toward removing nodes.cpp from
2657         AllInOneFile.cpp, but I'm putting that larger project aside for now.
2658
2659 2008-04-23  Maciej Stachowiak  <mjs@apple.com>
2660
2661         Rubber stamped by Geoff.
2662         
2663         - add OldInterpreterExecState class and use it in dead code
2664         
2665         This will allow removing things from the real ExecState class
2666         without having to figure out how to remove all this code without
2667         getting a perf regression.
2668
2669         * kjs/nodes.cpp:
2670         (KJS::ExpressionNode::evaluateToNumber):
2671         (KJS::ExpressionNode::evaluateToBoolean):
2672         (KJS::ExpressionNode::evaluateToInt32):
2673         (KJS::ExpressionNode::evaluateToUInt32):
2674         (KJS::Node::setErrorCompletion):
2675         (KJS::Node::throwError):
2676         (KJS::Node::throwUndefinedVariableError):
2677         (KJS::Node::handleException):
2678         (KJS::Node::rethrowException):
2679         (KJS::BreakpointCheckStatement::execute):
2680         (KJS::BreakpointCheckStatement::optimizeVariableAccess):
2681         (KJS::NullNode::evaluate):
2682         (KJS::FalseNode::evaluate):
2683         (KJS::TrueNode::evaluate):
2684         (KJS::NumberNode::evaluate):
2685         (KJS::NumberNode::evaluateToNumber):
2686         (KJS::NumberNode::evaluateToBoolean):
2687         (KJS::NumberNode::evaluateToInt32):
2688         (KJS::NumberNode::evaluateToUInt32):
2689         (KJS::ImmediateNumberNode::evaluate):
2690         (KJS::ImmediateNumberNode::evaluateToInt32):
2691         (KJS::ImmediateNumberNode::evaluateToUInt32):
2692         (KJS::StringNode::evaluate):
2693         (KJS::StringNode::evaluateToNumber):
2694         (KJS::StringNode::evaluateToBoolean):
2695         (KJS::RegExpNode::evaluate):
2696         (KJS::ThisNode::evaluate):
2697         (KJS::ResolveNode::inlineEvaluate):
2698         (KJS::ResolveNode::evaluate):
2699         (KJS::ResolveNode::evaluateToNumber):
2700         (KJS::ResolveNode::evaluateToBoolean):
2701         (KJS::ResolveNode::evaluateToInt32):
2702         (KJS::ResolveNode::evaluateToUInt32):
2703         (KJS::getSymbolTableEntry):
2704         (KJS::ResolveNode::optimizeVariableAccess):
2705         (KJS::LocalVarAccessNode::inlineEvaluate):
2706         (KJS::LocalVarAccessNode::evaluate):
2707         (KJS::LocalVarAccessNode::evaluateToNumber):
2708         (KJS::LocalVarAccessNode::evaluateToBoolean):
2709         (KJS::LocalVarAccessNode::evaluateToInt32):
2710         (KJS::LocalVarAccessNode::evaluateToUInt32):
2711         (KJS::getNonLocalSymbol):
2712         (KJS::ScopedVarAccessNode::inlineEvaluate):
2713         (KJS::ScopedVarAccessNode::evaluate):
2714         (KJS::ScopedVarAccessNode::evaluateToNumber):
2715         (KJS::ScopedVarAccessNode::evaluateToBoolean):
2716         (KJS::ScopedVarAccessNode::evaluateToInt32):
2717         (KJS::ScopedVarAccessNode::evaluateToUInt32):
2718         (KJS::NonLocalVarAccessNode::inlineEvaluate):
2719         (KJS::NonLocalVarAccessNode::evaluate):
2720         (KJS::NonLocalVarAccessNode::evaluateToNumber):
2721         (KJS::NonLocalVarAccessNode::evaluateToBoolean):
2722         (KJS::NonLocalVarAccessNode::evaluateToInt32):
2723         (KJS::NonLocalVarAccessNode::evaluateToUInt32):
2724         (KJS::ElementNode::optimizeVariableAccess):
2725         (KJS::ElementNode::evaluate):
2726         (KJS::ArrayNode::optimizeVariableAccess):
2727         (KJS::ArrayNode::evaluate):
2728         (KJS::ObjectLiteralNode::optimizeVariableAccess):
2729         (KJS::ObjectLiteralNode::evaluate):
2730         (KJS::PropertyListNode::optimizeVariableAccess):
2731         (KJS::PropertyListNode::evaluate):
2732         (KJS::PropertyNode::optimizeVariableAccess):
2733         (KJS::PropertyNode::evaluate):
2734         (KJS::BracketAccessorNode::optimizeVariableAccess):
2735         (KJS::BracketAccessorNode::inlineEvaluate):
2736         (KJS::BracketAccessorNode::evaluate):
2737         (KJS::BracketAccessorNode::evaluateToNumber):
2738         (KJS::BracketAccessorNode::evaluateToBoolean):
2739         (KJS::BracketAccessorNode::evaluateToInt32):
2740         (KJS::BracketAccessorNode::evaluateToUInt32):
2741         (KJS::DotAccessorNode::optimizeVariableAccess):
2742         (KJS::DotAccessorNode::inlineEvaluate):
2743         (KJS::DotAccessorNode::evaluate):
2744         (KJS::DotAccessorNode::evaluateToNumber):
2745         (KJS::DotAccessorNode::evaluateToBoolean):
2746         (KJS::DotAccessorNode::evaluateToInt32):
2747         (KJS::DotAccessorNode::evaluateToUInt32):
2748         (KJS::ArgumentListNode::optimizeVariableAccess):
2749         (KJS::ArgumentListNode::evaluateList):
2750         (KJS::ArgumentsNode::optimizeVariableAccess):
2751         (KJS::NewExprNode::optimizeVariableAccess):
2752         (KJS::NewExprNode::inlineEvaluate):
2753         (KJS::NewExprNode::evaluate):
2754         (KJS::NewExprNode::evaluateToNumber):
2755         (KJS::NewExprNode::evaluateToBoolean):
2756         (KJS::NewExprNode::evaluateToInt32):
2757         (KJS::NewExprNode::evaluateToUInt32):
2758         (KJS::ExpressionNode::resolveAndCall):
2759         (KJS::EvalFunctionCallNode::optimizeVariableAccess):
2760         (KJS::EvalFunctionCallNode::evaluate):
2761         (KJS::FunctionCallValueNode::optimizeVariableAccess):
2762         (KJS::FunctionCallValueNode::evaluate):
2763         (KJS::FunctionCallResolveNode::optimizeVariableAccess):
2764         (KJS::FunctionCallResolveNode::inlineEvaluate):
2765         (KJS::FunctionCallResolveNode::evaluate):
2766         (KJS::FunctionCallResolveNode::evaluateToNumber):
2767         (KJS::FunctionCallResolveNode::evaluateToBoolean):
2768         (KJS::FunctionCallResolveNode::evaluateToInt32):
2769         (KJS::FunctionCallResolveNode::evaluateToUInt32):
2770         (KJS::LocalVarFunctionCallNode::inlineEvaluate):
2771         (KJS::LocalVarFunctionCallNode::evaluate):
2772         (KJS::LocalVarFunctionCallNode::evaluateToNumber):
2773         (KJS::LocalVarFunctionCallNode::evaluateToBoolean):
2774         (KJS::LocalVarFunctionCallNode::evaluateToInt32):
2775         (KJS::LocalVarFunctionCallNode::evaluateToUInt32):
2776         (KJS::ScopedVarFunctionCallNode::inlineEvaluate):
2777         (KJS::ScopedVarFunctionCallNode::evaluate):
2778         (KJS::ScopedVarFunctionCallNode::evaluateToNumber):
2779         (KJS::ScopedVarFunctionCallNode::evaluateToBoolean):
2780         (KJS::ScopedVarFunctionCallNode::evaluateToInt32):
2781         (KJS::ScopedVarFunctionCallNode::evaluateToUInt32):
2782         (KJS::NonLocalVarFunctionCallNode::inlineEvaluate):
2783         (KJS::NonLocalVarFunctionCallNode::evaluate):
2784         (KJS::NonLocalVarFunctionCallNode::evaluateToNumber):
2785         (KJS::NonLocalVarFunctionCallNode::evaluateToBoolean):
2786         (KJS::NonLocalVarFunctionCallNode::evaluateToInt32):
2787         (KJS::NonLocalVarFunctionCallNode::evaluateToUInt32):
2788         (KJS::FunctionCallBracketNode::optimizeVariableAccess):
2789         (KJS::FunctionCallBracketNode::evaluate):
2790         (KJS::FunctionCallDotNode::optimizeVariableAccess):
2791         (KJS::FunctionCallDotNode::inlineEvaluate):
2792         (KJS::FunctionCallDotNode::evaluate):
2793         (KJS::FunctionCallDotNode::evaluateToNumber):
2794         (KJS::FunctionCallDotNode::evaluateToBoolean):
2795         (KJS::FunctionCallDotNode::evaluateToInt32):
2796         (KJS::FunctionCallDotNode::evaluateToUInt32):
2797         (KJS::PostIncResolveNode::optimizeVariableAccess):
2798         (KJS::PostIncResolveNode::evaluate):
2799         (KJS::PostIncLocalVarNode::evaluate):
2800         (KJS::PostDecResolveNode::optimizeVariableAccess):
2801         (KJS::PostDecResolveNode::evaluate):
2802         (KJS::PostDecLocalVarNode::evaluate):
2803         (KJS::PostDecLocalVarNode::inlineEvaluateToNumber):
2804         (KJS::PostDecLocalVarNode::evaluateToNumber):
2805         (KJS::PostDecLocalVarNode::evaluateToBoolean):
2806         (KJS::PostDecLocalVarNode::evaluateToInt32):
2807         (KJS::PostDecLocalVarNode::evaluateToUInt32):
2808         (KJS::PostfixBracketNode::optimizeVariableAccess):
2809         (KJS::PostIncBracketNode::evaluate):
2810         (KJS::PostDecBracketNode::evaluate):
2811         (KJS::PostfixDotNode::optimizeVariableAccess):
2812         (KJS::PostIncDotNode::evaluate):
2813         (KJS::PostDecDotNode::evaluate):
2814         (KJS::PostfixErrorNode::evaluate):
2815         (KJS::DeleteResolveNode::optimizeVariableAccess):
2816         (KJS::DeleteResolveNode::evaluate):
2817         (KJS::LocalVarDeleteNode::evaluate):
2818         (KJS::DeleteBracketNode::optimizeVariableAccess):
2819         (KJS::DeleteBracketNode::evaluate):
2820         (KJS::DeleteDotNode::optimizeVariableAccess):
2821         (KJS::DeleteDotNode::evaluate):
2822         (KJS::DeleteValueNode::optimizeVariableAccess):
2823         (KJS::DeleteValueNode::evaluate):
2824         (KJS::VoidNode::optimizeVariableAccess):
2825         (KJS::VoidNode::evaluate):
2826         (KJS::TypeOfValueNode::optimizeVariableAccess):
2827         (KJS::TypeOfResolveNode::optimizeVariableAccess):
2828         (KJS::LocalVarTypeOfNode::evaluate):
2829         (KJS::TypeOfResolveNode::evaluate):
2830         (KJS::TypeOfValueNode::evaluate):
2831         (KJS::PreIncResolveNode::optimizeVariableAccess):
2832         (KJS::PreIncLocalVarNode::evaluate):
2833         (KJS::PreIncResolveNode::evaluate):
2834         (KJS::PreDecResolveNode::optimizeVariableAccess):
2835         (KJS::PreDecLocalVarNode::evaluate):
2836         (KJS::PreDecResolveNode::evaluate):
2837         (KJS::PreIncConstNode::evaluate):
2838         (KJS::PreDecConstNode::evaluate):
2839         (KJS::PostIncConstNode::evaluate):
2840         (KJS::PostDecConstNode::evaluate):
2841         (KJS::PrefixBracketNode::optimizeVariableAccess):
2842         (KJS::PreIncBracketNode::evaluate):
2843         (KJS::PreDecBracketNode::evaluate):
2844         (KJS::PrefixDotNode::optimizeVariableAccess):
2845         (KJS::PreIncDotNode::evaluate):
2846         (KJS::PreDecDotNode::evaluate):
2847         (KJS::PrefixErrorNode::evaluate):
2848         (KJS::UnaryPlusNode::optimizeVariableAccess):
2849         (KJS::UnaryPlusNode::evaluate):
2850         (KJS::UnaryPlusNode::evaluateToBoolean):
2851         (KJS::UnaryPlusNode::evaluateToNumber):
2852         (KJS::UnaryPlusNode::evaluateToInt32):
2853         (KJS::UnaryPlusNode::evaluateToUInt32):
2854         (KJS::NegateNode::optimizeVariableAccess):
2855         (KJS::NegateNode::evaluate):
2856         (KJS::NegateNode::evaluateToNumber):
2857         (KJS::BitwiseNotNode::optimizeVariableAccess):
2858         (KJS::BitwiseNotNode::inlineEvaluateToInt32):
2859         (KJS::BitwiseNotNode::evaluate):
2860         (KJS::BitwiseNotNode::evaluateToNumber):
2861         (KJS::BitwiseNotNode::evaluateToBoolean):
2862         (KJS::BitwiseNotNode::evaluateToInt32):
2863         (KJS::BitwiseNotNode::evaluateToUInt32):
2864         (KJS::LogicalNotNode::optimizeVariableAccess):
2865         (KJS::LogicalNotNode::evaluate):
2866         (KJS::LogicalNotNode::evaluateToBoolean):
2867         (KJS::MultNode::optimizeVariableAccess):
2868         (KJS::MultNode::inlineEvaluateToNumber):
2869         (KJS::MultNode::evaluate):
2870         (KJS::MultNode::evaluateToNumber):
2871         (KJS::MultNode::evaluateToBoolean):
2872         (KJS::MultNode::evaluateToInt32):
2873         (KJS::MultNode::evaluateToUInt32):
2874         (KJS::DivNode::optimizeVariableAccess):
2875         (KJS::DivNode::inlineEvaluateToNumber):
2876         (KJS::DivNode::evaluate):
2877         (KJS::DivNode::evaluateToNumber):
2878         (KJS::DivNode::evaluateToInt32):
2879         (KJS::DivNode::evaluateToUInt32):
2880         (KJS::ModNode::optimizeVariableAccess):
2881         (KJS::ModNode::inlineEvaluateToNumber):
2882         (KJS::ModNode::evaluate):
2883         (KJS::ModNode::evaluateToNumber):
2884         (KJS::ModNode::evaluateToBoolean):
2885         (KJS::ModNode::evaluateToInt32):
2886         (KJS::ModNode::evaluateToUInt32):
2887         (KJS::throwOutOfMemoryErrorToNumber):
2888         (KJS::addSlowCase):
2889         (KJS::addSlowCaseToNumber):
2890         (KJS::add):
2891         (KJS::addToNumber):
2892         (KJS::AddNode::optimizeVariableAccess):
2893         (KJS::AddNode::evaluate):
2894         (KJS::AddNode::inlineEvaluateToNumber):
2895         (KJS::AddNode::evaluateToNumber):
2896         (KJS::AddNode::evaluateToInt32):
2897         (KJS::AddNode::evaluateToUInt32):
2898         (KJS::AddNumbersNode::inlineEvaluateToNumber):
2899         (KJS::AddNumbersNode::evaluate):
2900         (KJS::AddNumbersNode::evaluateToNumber):
2901         (KJS::AddNumbersNode::evaluateToInt32):
2902         (KJS::AddNumbersNode::evaluateToUInt32):
2903         (KJS::AddStringsNode::evaluate):
2904         (KJS::AddStringLeftNode::evaluate):
2905         (KJS::AddStringRightNode::evaluate):
2906         (KJS::SubNode::optimizeVariableAccess):
2907         (KJS::SubNode::inlineEvaluateToNumber):
2908         (KJS::SubNode::evaluate):
2909         (KJS::SubNode::evaluateToNumber):
2910         (KJS::SubNode::evaluateToInt32):
2911         (KJS::SubNode::evaluateToUInt32):
2912         (KJS::LeftShiftNode::optimizeVariableAccess):
2913         (KJS::LeftShiftNode::inlineEvaluateToInt32):
2914         (KJS::LeftShiftNode::evaluate):
2915         (KJS::LeftShiftNode::evaluateToNumber):
2916         (KJS::LeftShiftNode::evaluateToInt32):
2917         (KJS::LeftShiftNode::evaluateToUInt32):
2918         (KJS::RightShiftNode::optimizeVariableAccess):
2919         (KJS::RightShiftNode::inlineEvaluateToInt32):
2920         (KJS::RightShiftNode::evaluate):
2921         (KJS::RightShiftNode::evaluateToNumber):
2922         (KJS::RightShiftNode::evaluateToInt32):
2923         (KJS::RightShiftNode::evaluateToUInt32):
2924         (KJS::UnsignedRightShiftNode::optimizeVariableAccess):
2925         (KJS::UnsignedRightShiftNode::inlineEvaluateToUInt32):
2926         (KJS::UnsignedRightShiftNode::evaluate):
2927         (KJS::UnsignedRightShiftNode::evaluateToNumber):
2928         (KJS::UnsignedRightShiftNode::evaluateToInt32):
2929         (KJS::UnsignedRightShiftNode::evaluateToUInt32):
2930         (KJS::lessThan):
2931         (KJS::lessThanEq):
2932         (KJS::LessNode::optimizeVariableAccess):
2933         (KJS::LessNode::inlineEvaluateToBoolean):
2934         (KJS::LessNode::evaluate):
2935         (KJS::LessNode::evaluateToBoolean):
2936         (KJS::LessNumbersNode::inlineEvaluateToBoolean):
2937         (KJS::LessNumbersNode::evaluate):
2938         (KJS::LessNumbersNode::evaluateToBoolean):
2939         (KJS::LessStringsNode::inlineEvaluateToBoolean):
2940         (KJS::LessStringsNode::evaluate):
2941         (KJS::LessStringsNode::evaluateToBoolean):
2942         (KJS::GreaterNode::optimizeVariableAccess):
2943         (KJS::GreaterNode::inlineEvaluateToBoolean):
2944         (KJS::GreaterNode::evaluate):
2945         (KJS::GreaterNode::evaluateToBoolean):
2946         (KJS::LessEqNode::optimizeVariableAccess):
2947         (KJS::LessEqNode::inlineEvaluateToBoolean):
2948         (KJS::LessEqNode::evaluate):
2949         (KJS::LessEqNode::evaluateToBoolean):
2950         (KJS::GreaterEqNode::optimizeVariableAccess):
2951         (KJS::GreaterEqNode::inlineEvaluateToBoolean):
2952         (KJS::GreaterEqNode::evaluate):
2953         (KJS::GreaterEqNode::evaluateToBoolean):
2954         (KJS::InstanceOfNode::optimizeVariableAccess):
2955         (KJS::InstanceOfNode::evaluate):
2956         (KJS::InstanceOfNode::evaluateToBoolean):
2957         (KJS::InNode::optimizeVariableAccess):
2958         (KJS::InNode::evaluate):
2959         (KJS::InNode::evaluateToBoolean):
2960         (KJS::EqualNode::optimizeVariableAccess):
2961         (KJS::EqualNode::inlineEvaluateToBoolean):
2962         (KJS::EqualNode::evaluate):
2963         (KJS::EqualNode::evaluateToBoolean):
2964         (KJS::NotEqualNode::optimizeVariableAccess):
2965         (KJS::NotEqualNode::inlineEvaluateToBoolean):
2966         (KJS::NotEqualNode::evaluate):
2967         (KJS::NotEqualNode::evaluateToBoolean):
2968         (KJS::StrictEqualNode::optimizeVariableAccess):
2969         (KJS::StrictEqualNode::inlineEvaluateToBoolean):
2970         (KJS::StrictEqualNode::evaluate):
2971         (KJS::StrictEqualNode::evaluateToBoolean):
2972         (KJS::NotStrictEqualNode::optimizeVariableAccess):
2973         (KJS::NotStrictEqualNode::inlineEvaluateToBoolean):
2974         (KJS::NotStrictEqualNode::evaluate):
2975         (KJS::NotStrictEqualNode::evaluateToBoolean):
2976         (KJS::BitAndNode::optimizeVariableAccess):
2977         (KJS::BitAndNode::evaluate):
2978         (KJS::BitAndNode::inlineEvaluateToInt32):
2979         (KJS::BitAndNode::evaluateToNumber):
2980         (KJS::BitAndNode::evaluateToBoolean):
2981         (KJS::BitAndNode::evaluateToInt32):
2982         (KJS::BitAndNode::evaluateToUInt32):
2983         (KJS::BitXOrNode::optimizeVariableAccess):
2984         (KJS::BitXOrNode::inlineEvaluateToInt32):
2985         (KJS::BitXOrNode::evaluate):
2986         (KJS::BitXOrNode::evaluateToNumber):
2987         (KJS::BitXOrNode::evaluateToBoolean):
2988         (KJS::BitXOrNode::evaluateToInt32):
2989         (KJS::BitXOrNode::evaluateToUInt32):
2990         (KJS::BitOrNode::optimizeVariableAccess):
2991         (KJS::BitOrNode::inlineEvaluateToInt32):
2992         (KJS::BitOrNode::evaluate):
2993         (KJS::BitOrNode::evaluateToNumber):
2994         (KJS::BitOrNode::evaluateToBoolean):
2995         (KJS::BitOrNode::evaluateToInt32):
2996         (KJS::BitOrNode::evaluateToUInt32):
2997         (KJS::LogicalAndNode::optimizeVariableAccess):
2998         (KJS::LogicalAndNode::evaluate):
2999         (KJS::LogicalAndNode::evaluateToBoolean):
3000         (KJS::LogicalOrNode::optimizeVariableAccess):
3001         (KJS::LogicalOrNode::evaluate):
3002         (KJS::LogicalOrNode::evaluateToBoolean):
3003         (KJS::ConditionalNode::optimizeVariableAccess):
3004         (KJS::ConditionalNode::evaluate):
3005         (KJS::ConditionalNode::evaluateToBoolean):
3006         (KJS::ConditionalNode::evaluateToNumber):
3007         (KJS::ConditionalNode::evaluateToInt32):
3008         (KJS::ConditionalNode::evaluateToUInt32):
3009         (KJS::valueForReadModifyAssignment):
3010         (KJS::ReadModifyResolveNode::optimizeVariableAccess):
3011         (KJS::AssignResolveNode::optimizeVariableAccess):
3012         (KJS::ReadModifyLocalVarNode::evaluate):
3013         (KJS::AssignLocalVarNode::evaluate):
3014         (KJS::ReadModifyConstNode::evaluate):
3015         (KJS::AssignConstNode::evaluate):
3016         (KJS::ReadModifyResolveNode::evaluate):
3017         (KJS::AssignResolveNode::evaluate):
3018         (KJS::AssignDotNode::optimizeVariableAccess):
3019         (KJS::AssignDotNode::evaluate):
3020         (KJS::ReadModifyDotNode::optimizeVariableAccess):
3021         (KJS::ReadModifyDotNode::evaluate):
3022         (KJS::AssignErrorNode::evaluate):
3023         (KJS::AssignBracketNode::optimizeVariableAccess):
3024         (KJS::AssignBracketNode::evaluate):
3025         (KJS::ReadModifyBracketNode::optimizeVariableAccess):
3026         (KJS::ReadModifyBracketNode::evaluate):
3027         (KJS::CommaNode::optimizeVariableAccess):
3028         (KJS::CommaNode::evaluate):
3029         (KJS::ConstDeclNode::optimizeVariableAccess):
3030         (KJS::ConstDeclNode::handleSlowCase):
3031         (KJS::ConstDeclNode::evaluateSingle):
3032         (KJS::ConstDeclNode::evaluate):
3033         (KJS::ConstStatementNode::optimizeVariableAccess):
3034         (KJS::ConstStatementNode::execute):
3035         (KJS::statementListExecute):
3036         (KJS::BlockNode::optimizeVariableAccess):
3037         (KJS::BlockNode::execute):
3038         (KJS::EmptyStatementNode::execute):
3039         (KJS::ExprStatementNode::optimizeVariableAccess):
3040         (KJS::ExprStatementNode::execute):
3041         (KJS::VarStatementNode::optimizeVariableAccess):
3042         (KJS::VarStatementNode::execute):
3043         (KJS::IfNode::optimizeVariableAccess):
3044         (KJS::IfNode::execute):
3045         (KJS::IfElseNode::optimizeVariableAccess):
3046         (KJS::IfElseNode::execute):
3047         (KJS::DoWhileNode::optimizeVariableAccess):
3048         (KJS::DoWhileNode::execute):
3049         (KJS::WhileNode::optimizeVariableAccess):
3050         (KJS::WhileNode::execute):
3051         (KJS::ForNode::optimizeVariableAccess):
3052         (KJS::ForNode::execute):
3053         (KJS::ForInNode::optimizeVariableAccess):
3054         (KJS::ForInNode::execute):
3055         (KJS::ContinueNode::execute):
3056         (KJS::BreakNode::execute):
3057         (KJS::ReturnNode::optimizeVariableAccess):
3058         (KJS::ReturnNode::execute):
3059         (KJS::WithNode::optimizeVariableAccess):
3060         (KJS::WithNode::execute):
3061         (KJS::CaseClauseNode::optimizeVariableAccess):
3062         (KJS::CaseClauseNode::evaluate):
3063         (KJS::CaseClauseNode::executeStatements):
3064         (KJS::ClauseListNode::optimizeVariableAccess):
3065         (KJS::CaseBlockNode::optimizeVariableAccess):
3066         (KJS::CaseBlockNode::executeBlock):
3067         (KJS::SwitchNode::optimizeVariableAccess):
3068         (KJS::SwitchNode::execute):
3069         (KJS::LabelNode::optimizeVariableAccess):
3070         (KJS::LabelNode::execute):
3071         (KJS::ThrowNode::optimizeVariableAccess):
3072         (KJS::ThrowNode::execute):
3073         (KJS::TryNode::optimizeVariableAccess):
3074         (KJS::TryNode::execute):
3075         (KJS::ProgramNode::initializeSymbolTable):
3076         (KJS::ScopeNode::optimizeVariableAccess):
3077         (KJS::ProgramNode::processDeclarations):
3078         (KJS::EvalNode::processDeclarations):
3079         (KJS::ProgramNode::execute):
3080         (KJS::EvalNode::execute):
3081         (KJS::FunctionBodyNodeWithDebuggerHooks::execute):
3082         (KJS::FuncDeclNode::execute):
3083         (KJS::FuncExprNode::evaluate):
3084         * kjs/nodes.h:
3085         (KJS::Node::):
3086         (KJS::FalseNode::):
3087         (KJS::TrueNode::):
3088         (KJS::ArgumentsNode::):
3089
3090 2008-04-23  Oliver Hunt  <oliver@apple.com>
3091
3092         Reviewed by Geoff.
3093
3094         Bug 18672: SQUIRRELFISH: codegen fails with a large number of temporaries
3095         <https://bugs.webkit.org/show_bug.cgi?id=18672>
3096
3097         Add a SegmentedVector type, which provides a Vector<T> which maintains
3098         existing memory locations during resize.  This allows dynamically sizing
3099         local, temporary and label "vectors" in CodeGenerator.
3100
3101         * JavaScriptCore.xcodeproj/project.pbxproj:
3102         * VM/CodeGenerator.cpp:
3103         (KJS::CodeGenerator::addVar):
3104         (KJS::CodeGenerator::CodeGenerator):
3105         (KJS::CodeGenerator::newTemporary):
3106         (KJS::CodeGenerator::newLabel):
3107         * VM/CodeGenerator.h:
3108         * VM/SegmentedVector.h: Added.
3109         (KJS::SegmentedVector::SegmentedVector):
3110         (KJS::SegmentedVector::~SegmentedVector):
3111         (KJS::SegmentedVector::last):
3112         (KJS::SegmentedVector::append):
3113         (KJS::SegmentedVector::removeLast):
3114         (KJS::SegmentedVector::size):
3115         (KJS::SegmentedVector::operator[]):
3116         (KJS::SegmentedVector::resize):
3117         (KJS::SegmentedVector::shrink):
3118         (KJS::SegmentedVector::grow):
3119
3120 2008-04-23  Geoffrey Garen  <ggaren@apple.com>
3121
3122         Reviewed by Maciej Stachowiak.
3123         
3124         A little refactoring in preparation for supporting 'arguments'.
3125         
3126         Fixes 2 regression tests.
3127
3128         SunSpider reports no change.        
3129
3130         We now check the activation register, instead of the codeBlock, to
3131         determine whether we need to tear off the activation. This is to support
3132         "f.arguments", which will create an activation/arguments pair for f,
3133         even though the needsFullScopeChain flag is false for f's codeBlock.
3134         
3135         The test fixes resulted from calling initializeCallFrame for re-entrant
3136         function code, instead of initializing (not enough) parts of the call
3137         frame by hand.
3138
3139 2008-04-22  Maciej Stachowiak  <mjs@apple.com>
3140
3141         Reviewed by Sam.
3142         
3143         - propagate the "this" value properly to local eval
3144         
3145         (fixes a measly one regression test)
3146
3147         * VM/CodeBlock.h:
3148         (KJS::CodeBlock::CodeBlock):
3149         (KJS::ProgramCodeBlock::ProgramCodeBlock):
3150         (KJS::EvalCodeBlock::EvalCodeBlock):
3151         * VM/Machine.cpp:
3152         (KJS::Machine::privateExecute):
3153
3154 2008-04-22  Cameron Zwarich  <cwzwarich@uwaterloo.ca>
3155
3156         Reviewed by Maciej.
3157
3158         Add support for function declarations in eval code.
3159
3160         (this fixes 12 more regression tests)
3161         
3162         * VM/CodeBlock.h:
3163         * VM/CodeGenerator.cpp:
3164         (KJS::CodeGenerator::CodeGenerator):
3165         * VM/CodeGenerator.h:
3166         * VM/Machine.cpp:
3167         (KJS::Machine::execute):
3168         * kjs/nodes.cpp:
3169         (KJS::EvalNode::generateCode):
3170
3171 2008-04-22  Cameron Zwarich  <cwzwarich@uwaterloo.ca>
3172
3173         Reviewed by Oliver.
3174
3175         Implement LabelNode.
3176
3177         * VM/CodeGenerator.cpp:
3178         (KJS::CodeGenerator::pushJumpContext):
3179         (KJS::CodeGenerator::jumpContextForContinue):
3180         (KJS::CodeGenerator::jumpContextForBreak):
3181         * VM/CodeGenerator.h:
3182         * kjs/nodes.cpp:
3183         (KJS::DoWhileNode::emitCode):
3184         (KJS::WhileNode::emitCode):
3185         (KJS::ForNode::emitCode):
3186         (KJS::ForInNode::emitCode):
3187         (KJS::ContinueNode::emitCode):
3188         (KJS::BreakNode::emitCode):
3189         (KJS::SwitchNode::emitCode):
3190         (KJS::LabelNode::emitCode):
3191
3192 2008-04-22  Geoffrey Garen  <ggaren@apple.com>
3193
3194         Reviewed by Oliver Hunt.
3195         
3196         Fixed crash when unwinding from exceptions inside eval.
3197
3198         * VM/Machine.cpp:
3199         (KJS::Machine::unwindCallFrame): Don't assume that the top of the
3200         current call frame's scope chain is an activation: it can be the global
3201         object, instead.
3202
3203 2008-04-22  Maciej Stachowiak  <mjs@apple.com>
3204
3205         Reviewed by Geoff.
3206
3207         * kjs/testkjs.cpp:
3208         (main): Convert signals to exit codes, so that crashing tests are
3209         detected as regression test failures.
3210
3211 2008-04-22  Geoffrey Garen  <ggaren@apple.com>
3212
3213         Reviewed by Oliver Hunt and Maciej Stachowiak.
3214         
3215         Renamed "needsActivation" to "needsFullScopeChain" because lying will
3216         make hair grow on the backs of your hands.
3217
3218 2008-04-21  Geoffrey Garen  <ggaren@apple.com>
3219
3220         Reviewed by Maciej Stachowiak.
3221         
3222         Fixed ScopeChainNode lifetime problems:
3223         
3224         (1) In "with" and "catch" scopes, we would construct a ScopeChain
3225         object and then jump across its destructor, leaking the ScopeChainNode
3226         we had pushed.
3227
3228         (2) In global and eval scopes, we would fail to initially ref
3229         "scopeChain", causing us to overrelease it later. Now that we ref
3230         "scopeChain" properly, we also need to deref it when the script
3231         terminates.
3232
3233         SunSpider reports a .2% regression, but an earlier round of ScopeChain
3234         refactoring was a .4% speedup, so there.
3235
3236 2008-04-22  Maciej Stachowiak  <mjs@apple.com>
3237
3238         Reviewed by Alexey.
3239         
3240         - use global object instead of null for "this" on unqualified calls
3241         
3242         This fixes 10 more JSC test regressions.
3243
3244         * VM/Machine.cpp:
3245         (KJS::Machine::privateExecute):
3246
3247 2008-04-22  Maciej Stachowiak  <mjs@apple.com>
3248
3249         Reviewed by Oliver.
3250         
3251         - throw proper exceptions for objects that don't implement call or construct
3252         
3253         This fixes 21 more JSC test regressions. It is also seemingly an
3254         0.5% progression.
3255
3256         * VM/ExceptionHelpers.cpp:
3257         (KJS::createNotAnObjectError):
3258         (KJS::createNotAConstructorError):
3259         (KJS::createNotAFunctionError):
3260         * VM/ExceptionHelpers.h:
3261         * VM/Machine.cpp:
3262         (KJS::Machine::privateExecute):
3263
3264 2008-04-21  Oliver Hunt  <oliver@apple.com>
3265
3266         Reviewed by Geoff.
3267
3268         Implement emitCode for ConstDeclNode.
3269
3270         This fixes the crash (assertion) in js1_5/Scope/scope-001.js
3271
3272         * VM/CodeGenerator.cpp:
3273         (KJS::CodeGenerator::registerForLocalConstInit):
3274         * VM/CodeGenerator.h:
3275         * kjs/nodes.cpp:
3276         (KJS::AssignResolveNode::emitCode):
3277         (KJS::ConstDeclNode::emitCodeSingle):
3278         (KJS::ConstDeclNode::emitCode):
3279         (KJS::ConstStatementNode::emitCode):
3280         * kjs/nodes.h:
3281
3282 2008-04-21  Maciej Stachowiak  <mjs@apple.com>
3283
3284         Reviewed by Sam.
3285         
3286         - add some support for the split window object
3287
3288         This fixes many layout tests.
3289         
3290         * VM/Machine.cpp:
3291         (KJS::resolveBaseAndFunc): Use toThisObject() to ensure we get the
3292         wrapper global, if one exists, as the "this" object.
3293         * kjs/function.cpp:
3294         (KJS::globalFuncEval): Use toGlobalObject() to handle the wrapper
3295         case properly.
3296
3297 2008-04-21  Maciej Stachowiak  <mjs@apple.com>
3298
3299         Reviewed by Oliver.
3300         
3301         - restore ScopeChain::operator= to avoid crash on many layout tests
3302         
3303         Otherwise, FunctionImp::setScope would cause a reference
3304         underflow. I implemented using the copy construct and swap idiom.
3305
3306         * kjs/scope_chain.h:
3307         (KJS::ScopeChain::swap):
3308         (KJS::ScopeChain::operator=):
3309
3310 2008-04-21  Oliver Hunt  <oliver@apple.com>
3311
3312         Reviewed by Geoff.
3313
3314         Bug 18649: SQUIRRELFISH: correctly handle exceptions in eval code
3315         <https://bugs.webkit.org/show_bug.cgi?id=18649>
3316
3317         Allocate a callframe for eval() and initialise with a null codeBlock to
3318         indicate native code.  This prevents the unwinder from clobbering the
3319         register stack.
3320
3321         * VM/Machine.cpp:
3322         (KJS::Machine::execute):
3323
3324 2008-04-21  Geoffrey Garen  <ggaren@apple.com>
3325
3326         Reviewed by Sam Weinig.
3327         
3328         Removed ScopeChain::push(ScopeChain&) because it was unused. Moved
3329         ScopeChain::print to ScopeChainNode.
3330         
3331         ScopeChain is now nothing more than a resource-handling wrapper around
3332         ScopeChainNode.
3333
3334 2008-04-21  Cameron Zwarich  <cwzwarich@uwaterloo.ca>
3335
3336         Reviewed by Maciej.
3337
3338         Bug 18671: SquirrelFish: continue inside switch fails
3339         <https://bugs.webkit.org/show_bug.cgi?id=18671>
3340
3341         * VM/CodeGenerator.cpp:
3342         (KJS::CodeGenerator::jumpContextForLabel):
3343         * VM/CodeGenerator.h:
3344         * kjs/nodes.cpp:
3345         (KJS::ContinueNode::emitCode):
3346
3347 2008-04-21  Geoffrey Garen  <ggaren@apple.com>
3348
3349         Reviewed by Sam Weinig.
3350         
3351         Moved push(JSObject*) and pop() from ScopeChain to ScopeChainNode,
3352         rearranging scope_chain.h a bit.
3353
3354         SunSpider reports no change.
3355
3356 2008-04-21  Geoffrey Garen  <ggaren@apple.com>
3357
3358         Reviewed by Sam Weinig.
3359         
3360         Moved bottom() from ScopeChain to ScopeChainNode, simplifying it based
3361         on the knowledge that the ScopeChain is never empty.
3362
3363         SunSpider reports no change.
3364
3365 2008-04-21  Geoffrey Garen  <ggaren@apple.com>
3366
3367         Reviewed by Oliver Hunt.
3368         
3369         Moved begin() and end() from ScopeChain to ScopeChainNode. 
3370         
3371         Also marked a few methods "const".
3372
3373         SunSpider reports no change.
3374         
3375 2008-04-21  Geoffrey Garen  <ggaren@apple.com>
3376
3377         Reviewed by Maciej Stachowiak.
3378         
3379         Turned ScopeChain::depth into a stand-alone function, and simplified it
3380         a bit. 
3381         
3382         I also moved ScopeChain::depth to Machine.cpp because it doesn't report
3383         the true depth of the ScopeChain -- just the Machine's perspective of
3384         its depth within a given call frame.
3385
3386         SunSpider reports no change.
3387         
3388 2008-04-21  Geoffrey Garen  <ggaren@apple.com>
3389
3390         Reviewed by Maciej Stachowiak.
3391         
3392         Removed indirection in ScopeChain::ref / ScopeChain::deref.
3393         
3394         SunSpider reports no change.
3395         
3396         * kjs/scope_chain.h:
3397         (KJS::ScopeChain::ScopeChain):
3398         (KJS::ScopeChain::~ScopeChain):
3399         (KJS::ScopeChain::clear):
3400
3401 2008-04-21  Oliver Hunt  <oliver@apple.com>
3402
3403         Reviewed by NOBODY(Build fix)
3404
3405         Fix debug build
3406
3407         * kjs/nodes.cpp:
3408         (KJS::ConstDeclNode::evaluateSingle):
3409
3410 2008-04-21  Cameron Zwarich  <cwzwarich@uwaterloo.ca>
3411
3412         Reviewed by Oliver.
3413
3414         Bug 18664: SQUIRRELFISH: correctly throw a SyntaxError when parsing of eval code fails
3415         <https://bugs.webkit.org/show_bug.cgi?id=18664>
3416
3417         Correctly throw a SyntaxError when parsing of eval code fails.
3418
3419         * VM/Machine.cpp:
3420         (KJS::eval):
3421
3422 2008-04-21  Oliver Hunt  <oliver@apple.com>
3423
3424         Reviewed by Geoff.
3425
3426         Partial fix for Bug 18649: SQUIRRELFISH: correctly handle exceptions in eval code
3427
3428         Make sure we correct the register state before jumping to vm_throw.
3429
3430         * VM/Machine.cpp:
3431         (KJS::Machine::privateExecute):
3432
3433 2008-04-21  Geoffrey Garen  <ggaren@apple.com>
3434
3435         Reviewed by Maciej Stachowiak.
3436         
3437         Simplified ScopeChain ref/deref.
3438         
3439         SunSpider reports a .4% speedup.
3440         
3441         * kjs/scope_chain.h:
3442         (KJS::ScopeChainNode::ref): Removed this function because it was nonsense.
3443         ScopeChainNodes are initialized with a refCount of 1, so the loop was
3444         guaranteed to iterate exactly once.
3445
3446 2008-04-21  Geoffrey Garen  <ggaren@apple.com>
3447
3448         Reviewed by Maciej Stachowiak.
3449         
3450         Removed support for empty ScopeChains.
3451
3452         SunSpider reports no change.
3453
3454 2008-04-21  Geoffrey Garen  <ggaren@apple.com>
3455
3456         Reviewed by Maciej Stachowiak.
3457         
3458         Removed some completely unused ScopeChain member functions.
3459
3460         SunSpider reports no change.
3461
3462 2008-04-21  Geoffrey Garen  <ggaren@apple.com>
3463
3464         Reviewed by Maciej Stachowiak.
3465         
3466         Avoid creating unnecessary ScopeChain objects, to reduce refcount churn.
3467
3468         SunSpider reports no change.
3469
3470 2008-04-21  Maciej Stachowiak  <mjs@apple.com>
3471
3472         Rubber stamped by Alexey.
3473         
3474         Add some braces.x
3475
3476         * kjs/testkjs.cpp:
3477         (runWithScripts):
3478
3479 2008-04-21  Maciej Stachowiak  <mjs@apple.com>
3480
3481         Reviewed by Oliver.
3482         
3483         - only print "End:" output when -d flag is passed.
3484         
3485         This fixes half of our failing JSC regression tests.
3486
3487         * kjs/testkjs.cpp:
3488         (runWithScripts):
3489
3490 2008-04-21  Cameron Zwarich  <cwzwarich@uwaterloo.ca>
3491
3492         Reviewed by Maciej.
3493
3494         Add support for variable declarations in eval code.
3495
3496         * VM/CodeBlock.h:
3497         (KJS::EvalCodeBlock::EvalCodeBlock):
3498         * VM/CodeGenerator.cpp:
3499         (KJS::CodeGenerator::CodeGenerator):
3500         * VM/CodeGenerator.h:
3501         * VM/Machine.cpp:
3502         (KJS::Machine::execute):
3503         * VM/Machine.h:
3504         * kjs/function.cpp:
3505         (KJS::globalFuncEval):
3506         * kjs/nodes.cpp:
3507         (KJS::EvalNode::generateCode):
3508         * kjs/nodes.h:
3509         (KJS::EvalNode::):
3510
3511 2008-04-20  Oliver Hunt  <oliver@apple.com>
3512
3513         Reviewed by Maciej.
3514
3515         Throw exceptions for invalid continue, break, and return statements.
3516
3517         Simple refactoring and extension of Cameron's AssignErrorNode, etc patch
3518
3519         * VM/CodeGenerator.cpp:
3520         (KJS::CodeGenerator::CodeGenerator):
3521         (KJS::CodeGenerator::pushJumpContext):
3522         (KJS::CodeGenerator::popJumpContext):
3523         (KJS::CodeGenerator::jumpContextForLabel):
3524         * VM/CodeGenerator.h:
3525         * kjs/nodes.cpp:
3526         (KJS::Node::emitThrowError):
3527         (KJS::ContinueNode::emitCode):
3528         (KJS::BreakNode::emitCode):
3529         (KJS::ReturnNode::emitCode):
3530         * kjs/nodes.h:
3531
3532 2008-04-20  Geoffrey Garen  <ggaren@apple.com>
3533
3534         Reviewed by Oliver Hunt.
3535         
3536         Removed Machine.cpp from AllInOneFile.cpp, and manually inlined a few
3537         things that used to be inlined automatically.
3538         
3539         1.9% speedup on SunSpider.
3540         
3541         My hope is that we'll face fewer surprises in Machine.cpp codegen, now
3542         that GCC is making fewer decisions. The speedup seems to confirm that.
3543
3544 2008-04-20  Oliver Hunt  <oliver@apple.com>
3545
3546         Reviewed by Maciej.
3547
3548         Bug 18642: Iterator context may get placed into the return register, leading to much badness
3549         <https://bugs.webkit.org/show_bug.cgi?id=18642>
3550
3551         To prevent incorrectly reusing what will become the result register for
3552         eval and global code execution, we need to request and ref the destination
3553         in advance of codegen.  Unfortunately this may lead to unnecessary copying,
3554         although in future we can probably limit this.  Curiously SunSpider shows
3555         a progression in a number of tests, although it comes out as a wash overall.
3556
3557         * kjs/nodes.cpp:
3558         (KJS::EvalNode::emitCode):
3559         (KJS::ProgramNode::emitCode):
3560
3561 2008-04-20  Cameron Zwarich  <cwzwarich@uwaterloo.ca>
3562
3563         Reviewed by Maciej.
3564
3565         Add support for AssignErrorNode, PrefixErrorNode, and PostfixErrorNode.
3566
3567         * VM/CodeBlock.cpp:
3568         (KJS::CodeBlock::dump):
3569         * VM/CodeGenerator.cpp:
3570         (KJS::CodeGenerator::emitCreateError):
3571         * VM/CodeGenerator.h:
3572         * VM/Machine.cpp:
3573         (KJS::Machine::privateExecute):
3574         * VM/Opcode.h:
3575         * kjs/nodes.cpp:
3576         (KJS::PostfixErrorNode::emitCode):
3577         (KJS::PrefixErrorNode::emitCode):
3578         (KJS::AssignErrorNode::emitCode):
3579         * kjs/nodes.h:
3580
3581 2008-04-20  Oliver Hunt  <oliver@apple.com>
3582
3583         Reviewed by Geoff and Mark.
3584
3585         Provide line number information in exceptions
3586
3587         Simple patch, adds line number information metadata to CodeBlock
3588         and a simple method to get the line number responsible for a given
3589         Instruction*.
3590
3591         * VM/CodeBlock.cpp:
3592         (KJS::CodeBlock::lineNumberForVPC):
3593         * VM/CodeBlock.h:
3594         * VM/CodeGenerator.h:
3595         (KJS::CodeGenerator::emitNode):
3596         * VM/Machine.cpp:
3597         (KJS::Machine::throwException):
3598
3599 2008-04-20  Oliver Hunt  <oliver@apple.com>
3600
3601         Reviewed by Maciej.
3602
3603         Provide "sourceURL" in exceptions
3604
3605         * VM/CodeBlock.h:
3606         * VM/Machine.cpp:
3607         (KJS::Machine::throwException):
3608         * kjs/nodes.cpp:
3609         (KJS::EvalNode::generateCode):
3610         (KJS::ProgramNode::generateCode):
3611
3612 2008-04-19  Oliver Hunt  <oliver@apple.com>
3613
3614         Reviewed by Maciej.
3615
3616         Don't call emitCode directly on subnodes, instead use CodeGenerator::emitNode
3617
3618         This patch just a preparation for tracking line numbers.
3619
3620         * kjs/nodes.cpp:
3621         (KJS::ObjectLiteralNode::emitCode):
3622         (KJS::PropertyListNode::emitCode):
3623         (KJS::ArgumentListNode::emitCode):
3624         (KJS::TryNode::emitCode):
3625
3626 2008-04-19  Oliver Hunt  <oliver@apple.com>
3627
3628         Reviewed by Maciej.
3629
3630         Bug 18619: Support continue, break, and return in try .. finally blocks
3631         <https://bugs.webkit.org/show_bug.cgi?id=18619>
3632
3633         This patch replaces the current partial finally support (which uses code
3634         duplication to achieve what it does) with a subroutine based approach.
3635         This has a number of advantages over code duplication:
3636           * Reduced code size
3637           * Simplified exception handling as the finaliser code only exists in 
3638             one place, so no "magic" is needed to get the correct handler for a 
3639             finaliser.
3640           * When we support instruction to line number mapping we won't need to
3641             worry about the dramatic code movement caused by duplication
3642
3643         On the downside it is necessary to add two new opcodes, op_jsr and op_sret
3644         to enter and exit the finaliser subroutines, happily SunSpider reports
3645         a performance progression (gcc amazes me) and ubench reports a wash.
3646
3647         While jsr and sret provide a mechanism that allows us to enter and exit
3648         any arbitrary finaliser we need to, it was still necessary to increase
3649         the amount of information tracked when entering and exiting both finaliser
3650         scopes and dynamic scopes ("with").  This means "scopeDepth" is now
3651         the combination of "finaliserDepth" and "dynamicScopeDepth".  We also
3652         now use a scopeContextStack to ensure that we pop scopes and execute
3653         finalisers in the correct order.  This increases the cost of "with" nodes
3654         during codegen, but it should not be significant enough to effect real
3655         world performance and greatly simplifies codegen for return, break and
3656         continue when interacting with finalisers.
3657
3658         * VM/CodeBlock.cpp:
3659         (KJS::CodeBlock::dump):
3660           Pretty printing of jsr/sret opcodes
3661
3662         * VM/CodeGenerator.cpp:
3663         (KJS::CodeGenerator::CodeGenerator):
3664         (KJS::CodeGenerator::emitPushScope):
3665         (KJS::CodeGenerator::emitPopScope):
3666           Dynamic scopes need to be tracked on the scopeContextStack now
3667
3668         (KJS::CodeGenerator::pushFinallyContext):
3669         (KJS::CodeGenerator::popFinallyContext):
3670           Handle entry and exit from code regions with finalisers.  This is
3671           needed solely to support return, continue and break inside finaliser
3672           regions.
3673
3674         (KJS::CodeGenerator::emitComplexJumpScopes):
3675           Helper function for emitJumpScopes to handle the complex codegen
3676           needed to handle return, continue and break inside a finaliser region
3677
3678         (KJS::CodeGenerator::emitJumpScopes):
3679           Updated to be aware of finalisers, if a cross-scope jump occurs inside
3680           a finaliser we hand off codegen to emitComplexJumpScopes, otherwise
3681           we can handle the normal (trivial) case with a single instruction.
3682
3683         (KJS::CodeGenerator::emitJumpSubroutine):
3684         (KJS::CodeGenerator::emitSubroutineReturn):
3685           Trivial opcode emitter functions.
3686
3687         * VM/CodeGenerator.h:
3688         (KJS::CodeGenerator::scopeDepth):
3689         * VM/Machine.cpp:
3690         (KJS::Machine::privateExecute):
3691           Implement op_jsr and op_sret.
3692
3693         * VM/Opcode.h:
3694           Ad op_jsr and op_sret
3695
3696         * kjs/nodes.cpp:
3697         (KJS::TryNode::emitCode):
3698           Fix codegen for new finaliser model.
3699
3700 2008-04-17  Mark Rowe  <mrowe@apple.com>
3701
3702         Rubber-stamped by Oliver Hunt.
3703
3704         Remove unnecessary files from testkjs, testapi and minidom targets.
3705
3706         * JavaScriptCore.xcodeproj/project.pbxproj:
3707
3708 2008-04-17  Geoffrey Garen  <ggaren@apple.com>
3709
3710         Reviewed by Oliver Hunt.
3711         
3712         Fixed ASSERT seen during run-sunspider of a debug build.
3713
3714         * VM/CodeGenerator.h: Made the default codegen buffers bigger. SunSpider
3715         runs all tests in one global environment, so you end up with more than
3716         128 locals. This is just a stop-gap until we code up a real
3717         solution to arbitrary symbol and label limits.
3718
3719 2008-04-17  Geoffrey Garen  <ggaren@apple.com>
3720
3721         Reviewed by Oliver Hunt.
3722         
3723         Fixed a bug in exception unwinding, where we wouldn't deref the scope
3724         chain in global scope, so we would leak ScopeChainNodes when exceptions
3725         were thrown inside "with" and "catch" scopes.
3726         
3727         Also did some cleanup of the unwinding code along the way.
3728         
3729         Scope chain reference counting is still wrong in a few ways. I thought
3730         I would fix this portion of it first.
3731         
3732         run-sunspider shows no change.
3733
3734         * VM/Machine.cpp:
3735         (KJS::Machine::unwindCallFrame):
3736         (KJS::Machine::throwException):
3737         (KJS::Machine::privateExecute):
3738         * VM/Machine.h:
3739
3740 2008-04-17  Oliver Hunt  <oliver@apple.com>
3741
3742         Reviewed by Maciej.
3743
3744         Add more exception checking to toNumber conversions
3745
3746         This corrects op_pre_dec, op_negate, op_mod and op_sub.
3747
3748         * VM/Machine.cpp:
3749         (KJS::Machine::privateExecute):
3750
3751 2008-04-17  Geoffrey Garen  <ggaren@apple.com> and Cameron Zwarich  <cwzwarich@uwaterloo.ca>
3752
3753         Reviewed by Oliver Hunt.
3754         
3755         Behold: eval.
3756         
3757         Introduced a new opcode: op_call_eval. In the normal case, it performs
3758         an eval. In the case where eval has been overridden in some way, it
3759         performs a function call.
3760
3761         * VM/CodeGenerator.h: Added a feature so the code generator knows not
3762         to optimized locals in eval code.
3763         
3764 2008-04-17  Geoffrey Garen  <ggaren@apple.com>
3765
3766         Reviewed by Sam Weinig.
3767         
3768         Added some ASSERTs to document codegen failures in
3769         run-javascriptcore-tests.
3770         
3771         For all tests, program-level codegen now either succeeds, or fails with
3772         an ASSERT.
3773
3774         * VM/CodeGenerator.cpp:
3775         (KJS::CodeGenerator::addVar):
3776         (KJS::CodeGenerator::CodeGenerator):
3777         (KJS::CodeGenerator::newTemporary):
3778         (KJS::CodeGenerator::newLabel):
3779
3780 2008-04-17  Geoffrey Garen  <ggaren@apple.com>
3781
3782         Reviewed by Maciej Stachowiak.
3783         
3784         Fixed another case of a dst register being an unreferenced temporary
3785         (caused an ASSERT when running the full sunspider suite).
3786
3787         * kjs/nodes.cpp:
3788         (KJS::CaseBlockNode::emitCodeForBlock):
3789
3790 2008-04-16  Maciej Stachowiak  <mjs@apple.com>
3791
3792         Reviewed by Geoff.
3793         
3794         - add documentation (and meaningful parameter names) for arithmetic and bitwise binary ops
3795
3796         * VM/CodeBlock.cpp:
3797         (KJS::CodeBlock::dump):
3798         * VM/CodeGenerator.cpp:
3799         (KJS::CodeGenerator::emitMul):
3800         (KJS::CodeGenerator::emitDiv):
3801         (KJS::CodeGenerator::emitMod):
3802         (KJS::CodeGenerator::emitSub):
3803         (KJS::CodeGenerator::emitLeftShift):
3804         (KJS::CodeGenerator::emitRightShift):
3805         (KJS::CodeGenerator::emitUnsignedRightShift):
3806         (KJS::CodeGenerator::emitBitAnd):
3807         (KJS::CodeGenerator::emitBitXOr):
3808         (KJS::CodeGenerator::emitBitOr):
3809         * VM/CodeGenerator.h:
3810         * VM/Machine.cpp:
3811         (KJS::Machine::privateExecute):
3812         * VM/Opcode.h:
3813         * kjs/nodes.cpp:
3814         (KJS::MultNode::emitCode):
3815         (KJS::DivNode::emitCode):
3816         (KJS::ModNode::emitCode):
3817         (KJS::SubNode::emitCode):
3818         (KJS::LeftShiftNode::emitCode):
3819         (KJS::RightShiftNode::emitCode):
3820         (KJS::UnsignedRightShiftNode::emitCode):
3821         (KJS::BitAndNode::emitCode):
3822         (KJS::BitXOrNode::emitCode):
3823         (KJS::BitOrNode::emitCode):
3824         (KJS::emitReadModifyAssignment):
3825         (KJS::ReadModifyResolveNode::emitCode):
3826
3827 2008-04-16  Oliver Hunt  <oliver@apple.com>
3828
3829         Reviewed by Geoff.
3830
3831         Exception checks for toNumber in op_pre_inc
3832
3833         This is somewhat more convoluted than the simple hadException checks
3834         we currently use.  Instead we use special toNumber conversions that
3835         select between the exception and ordinary vPC.  This allows us to 
3836         remove any branches in the common case (incrementing a number).
3837
3838         * API/JSCallbackObject.h:
3839         * API/JSCallbackObjectFunctions.h:
3840         (KJS::::toNumber):
3841         * ChangeLog:
3842         * JavaScriptCore.exp:
3843         * JavaScriptCore.xcodeproj/project.pbxproj:
3844         * VM/JSPropertyNameIterator.cpp:
3845         (KJS::JSPropertyNameIterator::toNumber):
3846         * VM/JSPropertyNameIterator.h:
3847         * VM/Machine.cpp:
3848         (KJS::Machine::privateExecute):
3849         * VM/Opcode.h:
3850         * kjs/ExecState.cpp:
3851         (KJS::ExecState::ExecState):
3852         * kjs/ExecState.h:
3853         * kjs/JSNotAnObject.cpp:
3854         (KJS::JSNotAnObject::toNumber):
3855         * kjs/JSNotAnObject.h:
3856         * kjs/internal.cpp:
3857         (KJS::StringImp::toNumber):
3858         (KJS::NumberImp::toNumber):
3859         (KJS::GetterSetterImp::toNumber):
3860         * kjs/internal.h:
3861         * kjs/object.cpp:
3862         (KJS::JSObject::toNumber):
3863         * kjs/object.h:
3864         * kjs/value.h:
3865         (KJS::JSValue::toNumber):
3866
3867 2008-04-16  Maciej Stachowiak  <mjs@apple.com>
3868
3869         Reviewed by Geoff.
3870         
3871         - ensure that activations are kept in a register to protect them from GC
3872         
3873         Also renamed OptionalCalleeScopeChain constant to OptionalCalleeActivation, since
3874         that is what is now kept there, and there is no more need to keep the scope chain in
3875         the register file.
3876
3877         * VM/Machine.cpp:
3878         (KJS::initializeCallFrame):
3879         (KJS::scopeChainForCall):
3880         * VM/Machine.h:
3881         (KJS::Machine::):
3882
3883 2008-04-16  Geoffrey Garen  <ggaren@apple.com>
3884
3885         Reviewed by Oliver Hunt.
3886         
3887         Made "this" work in program code / global scope.
3888         
3889         The machine can initialize "this" prior to execution because it knows
3890         that, for program code, "this" is always stored in lr1. 
3891
3892         * VM/Machine.cpp:
3893         (KJS::Machine::execute):
3894         * VM/Machine.h:
3895         (KJS::Machine::):
3896         * kjs/interpreter.cpp:
3897         (KJS::Interpreter::evaluate):
3898
3899 2008-04-16  Geoffrey Garen  <ggaren@apple.com>
3900
3901         Reviewed by Oliver Hunt.
3902         
3903         Fixed a codegen bug when returning from inside a dynamic scope (a with
3904         or catch block): we need to pop any dynamic scope(s) that have been
3905         added so op_ret can find the activation object at the top of the scope
3906         chain.
3907
3908         * kjs/nodes.cpp:
3909         (KJS::ReturnNode::emitCode): If we're returning from inside a dynamic
3910         scope, emit a jmp_scopes to take care of popping any dynamic scope(s)
3911         and then branching to the return instruction.
3912
3913 2008-04-16  Maciej Stachowiak  <mjs@apple.com>
3914
3915         Reviewed by Geoff.
3916         
3917         - document the add and get_prop_id opcodes
3918         
3919         In addition to adding documentation in comments, I changed
3920         references to register IDs or indices relating to these opcodes to
3921         have meaningful names instead of r0 r1 r2.
3922
3923         * VM/CodeGenerator.cpp:
3924         (KJS::CodeGenerator::emitAdd):
3925         * VM/CodeGenerator.h:
3926         * VM/Machine.cpp:
3927         (KJS::Machine::privateExecute):
3928         * kjs/nodes.cpp:
3929         (KJS::DotAccessorNode::emitCode):
3930         (KJS::FunctionCallDotNode::emitCode):
3931         (KJS::PostIncDotNode::emitCode):
3932         (KJS::PostDecDotNode::emitCode):
3933         (KJS::PreIncDotNode::emitCode):
3934         (KJS::PreDecDotNode::emitCode):
3935         (KJS::AddNode::emitCode):
3936         (KJS::ReadModifyDotNode::emitCode):
3937
3938 2008-04-15  Geoffrey Garen  <ggaren@apple.com>
3939
3940         Reviewed by Oliver Hunt and Maciej Stachowiak.
3941         
3942         Fixed a codegen bug in with and switch, and added an ASSERT to
3943         make sure it doesn't happen again.
3944         
3945         emitCode() assumes that dst, if non-zero, is either referenced or
3946         non-temporary (i.e., it assumes that newTemporary() will return a
3947         register not equal to dst). Certain callers to emitCode() weren't
3948         guaranteeing that to be so, so temporary register values were being
3949         overwritten.
3950
3951         * VM/CodeGenerator.h:
3952         (KJS::CodeGenerator::emitNode): ASSERT that dst is referenced or non-temporary.
3953
3954         * kjs/nodes.cpp:
3955         (KJS::CommaNode::emitCode): Reference the dst we pass.
3956
3957         (KJS::WithNode::emitCode): No need to pass an explicit dst register.
3958         
3959         (KJS::CaseBlockNode::emitCodeForBlock): No need to pass an explicit dst register.
3960         (KJS::SwitchNode::emitCode): No need to pass an explicit dst register.
3961
3962         * kjs/nodes.h: Made dst the last parameter to emitCodeForBlock, to match
3963         emitCode.
3964
3965 2008-04-15  Oliver Hunt  <oliver@apple.com>
3966
3967         Reviewed by Maciej.
3968
3969         Bug 18526: Throw exceptions when resolve fails for op_resolve_base_and_func.
3970         <https://bugs.webkit.org/show_bug.cgi?id=18526>
3971
3972         Very simple fix, sunspider shows a 0.7% progression, ubench shows a 0.4% regression.
3973
3974         * VM/Machine.cpp:
3975         (KJS::resolveBaseAndFunc):
3976         (KJS::Machine::privateExecute):
3977
3978 2008-04-15  Maciej Stachowiak  <mjs@apple.com>
3979
3980         Reviewed by Oliver.
3981         
3982         - fix incorrect result on 3d-raytrace test
3983         
3984         Oliver found and tracked down this bug, I just typed in the fix.
3985
3986         * VM/Machine.cpp:
3987         (KJS::slideRegisterWindowForCall): When setting omitted parameters to undefined,
3988         account for the space for local variables.
3989
3990 2008-04-15  Maciej Stachowiak  <mjs@apple.com>
3991
3992         Reviewed by Oliver.
3993         
3994         - fix codegen handling of dst registers
3995         
3996         1.006x speedup (not sure why).
3997         
3998         Most emitCode functions take an optional "dst" parameter that says
3999         where the output of the instruction should be written. I made some
4000         functions for convenient handling of the dst register:
4001
4002         * VM/CodeGenerator.h:
4003         (KJS::CodeGenerator::tempDestination): Takes the dst register. Returns it if
4004         it is not null and is a temporary, otherwise allocates a new temporary. This is
4005         intended for cases where an intermediate value might be written into the dst
4006
4007         (KJS::CodeGenerator::finalDestination): Takes the dst register and an optional
4008         register that was used as a temp destination. Picks the right thing for the final
4009         output. Intended to be used as the output register for the instruction that generates
4010         the final value of a particular node.
4011         
4012         (KJS::CodeGenerator::moveToDestinationIfNeeded): Takes dst and a
4013         RegisterID; moves from the register to dst if dst is defined and
4014         different from the register. This is intended for cases where the
4015         result of a node is already in a specific register (likely a
4016         local), and so no code needs to be generated unless a specific
4017         destination has been requested, in which case a move is needed.
4018         
4019         I also applied these methods throughout emitCode functions. In
4020         some cases this was just cleanup, in other cases I fixed actual
4021         codegen bugs. Below I have given specific comments for the cases
4022         where I believe I fixed a codegen bug, or improved quality of codegen.
4023         
4024         * kjs/nodes.cpp:
4025         (KJS::NullNode::emitCode):
4026         (KJS::FalseNode::emitCode):
4027         (KJS::TrueNode::emitCode):
4028         (KJS::NumberNode::emitCode):
4029         (KJS::StringNode::emitCode):
4030         (KJS::RegExpNode::emitCode):
4031         (KJS::ThisNode::emitCode): Now avoids emitting a mov when dst is
4032         the same as the this register (the unlikely case of "this = this");
4033         (KJS::ResolveNode::emitCode): Now avoids emitting a mov when dst
4034         is the same as the local regiester, in the local var case (the
4035         unlikely case of "x = x");
4036         (KJS::ArrayNode::emitCode): Fixed a codegen bug where array
4037         literal element expressions may have observed an intermediate
4038         value of constructing the array.
4039         (KJS::ObjectLiteralNode::emitCode): 
4040         (KJS::PropertyListNode::emitCode): Fixed a codegen bug where object literal
4041         property definition expressions may have obesrved an intermediate value of
4042         constructing the object.
4043         (KJS::BracketAccessorNode::emitCode):
4044         (KJS::DotAccessorNode::emitCode):
4045         (KJS::NewExprNode::emitCode):
4046         (KJS::FunctionCallValueNode::emitCode):
4047         (KJS::FunctionCallBracketNode::emitCode):
4048         (KJS::FunctionCallDotNode::emitCode):
4049         (KJS::PostIncResolveNode::emitCode):
4050         (KJS::PostDecResolveNode::emitCode):
4051         (KJS::PostIncBracketNode::emitCode):
4052         (KJS::PostDecBracketNode::emitCode):
4053         (KJS::PostIncDotNode::emitCode):
4054         (KJS::PostDecDotNode::emitCode):
4055         (KJS::DeleteResolveNode::emitCode):
4056         (KJS::DeleteBracketNode::emitCode):
4057         (KJS::DeleteDotNode::emitCode):
4058         (KJS::DeleteValueNode::emitCode):
4059         (KJS::VoidNode::emitCode):
4060         (KJS::TypeOfResolveNode::emitCode):
4061         (KJS::TypeOfValueNode::emitCode):
4062         (KJS::PreIncResolveNode::emitCode): Fixed a codegen bug where the final
4063         value would not be output to the dst register in the local var case.
4064         (KJS::PreDecResolveNode::emitCode): Fixed a codegen bug where the final
4065         value would not be output to the dst register in the local var case.
4066         (KJS::PreIncBracketNode::emitCode):
4067         (KJS::PreDecBracketNode::emitCode):
4068         (KJS::PreIncDotNode::emitCode):
4069         (KJS::PreDecDotNode::emitCode):
4070         (KJS::UnaryPlusNode::emitCode):
4071         (KJS::NegateNode::emitCode):
4072         (KJS::BitwiseNotNode::emitCode):
4073         (KJS::LogicalNotNode::emitCode):
4074         (KJS::MultNode::emitCode):
4075         (KJS::DivNode::emitCode):
4076         (KJS::ModNode::emitCode):
4077         (KJS::AddNode::emitCode):
4078         (KJS::SubNode::emitCode):
4079         (KJS::LeftShiftNode::emitCode):
4080         (KJS::RightShiftNode::emitCode):
4081         (KJS::UnsignedRightShiftNode::emitCode):
4082         (KJS::LessNode::emitCode):
4083         (KJS::GreaterNode::emitCode):
4084         (KJS::LessEqNode::emitCode):
4085         (KJS::GreaterEqNode::emitCode):
4086         (KJS::InstanceOfNode::emitCode):
4087         (KJS::InNode::emitCode):
4088         (KJS::EqualNode::emitCode):
4089         (KJS::NotEqualNode::emitCode):
4090         (KJS::StrictEqualNode::emitCode):
4091         (KJS::NotStrictEqualNode::emitCode):
4092         (KJS::BitAndNode::emitCode):
4093         (KJS::BitXOrNode::emitCode):
4094         (KJS::BitOrNode::emitCode):
4095         (KJS::LogicalAndNode::emitCode):
4096         (KJS::LogicalOrNode::emitCode):
4097         (KJS::ConditionalNode::emitCode):
4098         (KJS::emitReadModifyAssignment): Allow an out argument separate from the operands,
4099         needed for fixes below.
4100         (KJS::ReadModifyResolveNode::emitCode): Fixed a codegen bug where the right side of
4101         the expression may observe an intermediate value.
4102         (KJS::AssignResolveNode::emitCode): Fixed a codegen bug where the right side of the
4103         expression may observe an intermediate value.
4104         (KJS::ReadModifyDotNode::emitCode): Fixed a codegen bug where the right side of the
4105         expression may observe an intermediate value.
4106         (KJS::ReadModifyBracketNode::emitCode): Fixed a codegen bug where the right side of the
4107         expression may observe an intermediate value.
4108         (KJS::CommaNode::emitCode): Avoid writing temporary value to dst register.
4109         (KJS::ReturnNode::emitCode): Void return should return undefined, not null.
4110         (KJS::FuncExprNode::emitCode):
4111
4112 2008-04-15  Maciej Stachowiak  <mjs@apple.com>
4113
4114         Reviewed by Geoff.
4115
4116         - fix huge performance regression (from trunk) in string-unpack-code
4117         
4118         This restores string-unpack-code performance to parity with
4119         trunk (2.27x speedup relative to previous SquirrelFish)
4120         
4121         * VM/Machine.cpp:
4122         (KJS::Machine::execute): Shrink register file after call to avoid
4123         growing repeatedly.
4124
4125 2008-04-15  Geoffrey Garen  <ggaren@apple.com>
4126
4127         Reviewed by Sam Weinig.
4128         
4129         Fixed dumpCallFrame to match our new convention of passing around a
4130         ScopeChainNode* instead of a ScopeChain*.
4131
4132         * JavaScriptCore.exp:
4133         * VM/Machine.cpp:
4134         (KJS::Machine::dumpCallFrame):
4135         * VM/Machine.h:
4136
4137 2008-04-15  Oliver Hunt  <oliver@apple.com>
4138
4139         Reviewed by Maciej.
4140
4141         Bug 18436: Need to throw exception on read/modify/write or similar resolve for nonexistent property
4142         <https://bugs.webkit.org/show_bug.cgi?id=18436>
4143
4144         Add op_resolve_base_and_property for read/modify/write operations,
4145         this adds a "superinstruction" to resolve the base and value of a
4146         property simultaneously.  Just using resolveBase and resolve results 
4147         in an 5% regression in ubench, 30% in loop-empty-resolve (which is 
4148         expected).  1.3% progression in sunspider, 2.1% in ubench, with a 
4149         21% gain in loop-empty-resolve.  The only outlier is function-missing-args
4150         which gets a 3% regression that I could never resolve.
4151
4152         * VM/CodeBlock.cpp:
4153         (KJS::CodeBlock::dump):
4154         * VM/CodeGenerator.cpp:
4155         (KJS::CodeGenerator::emitResolveBaseAndProperty):
4156         * VM/CodeGenerator.h:
4157         * VM/Machine.cpp:
4158         (KJS::resolveBaseAndProperty):
4159         (KJS::Machine::privateExecute):
4160         * VM/Opcode.h:
4161         * kjs/nodes.cpp:
4162         (KJS::PostIncResolveNode::emitCode):
4163         (KJS::PostDecResolveNode::emitCode):
4164         (KJS::PreIncResolveNode::emitCode):
4165         (KJS::PreDecResolveNode::emitCode):
4166         (KJS::ReadModifyResolveNode::emitCode):
4167
4168 2008-04-15  Maciej Stachowiak  <mjs@apple.com>
4169
4170         Reviewed by Oliver.
4171         
4172         - fixed "SquirrelFish crashes due to bad scope chain on some SunSpider tests"
4173         https://bugs.webkit.org/show_bug.cgi?id=18508
4174