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