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