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