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