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