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