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