379f0052f5e569e733326264aecd59abaf50a47a
[WebKit-https.git] / JavaScriptCore / ChangeLog
1 2007-11-16  Alexey Proskuryakov  <ap@webkit.org>
2
3         Fix Windows debug build.
4         Rubber-stamped by Eric
5
6         * pcre/pcre_exec.cpp: (match): Removed ASSERT_NOT_REACHED assertions that were making MSVC
7         complain about unreachable code.
8
9 2007-11-15  Mark Rowe  <mrowe@apple.com>
10
11         Gtk build fix.
12
13         * kjs/Parser.cpp:
14
15 2007-11-15  Mark Rowe  <mrowe@apple.com>
16
17         Mac build and header search path sanity fix.
18
19         Reviewed by Sam Weinig and Tim Hatcher.
20
21         Move base setting for HEADER_SEARCH_PATHS into Base.xcconfig, and extend
22         it in JavaScriptCore.xcconfig.  This removes the need to override it on a
23         per-target basis inside the .xcodeproj file.
24
25         * Configurations/Base.xcconfig:
26         * Configurations/JavaScriptCore.xcconfig:
27         * JavaScriptCore.xcodeproj/project.pbxproj:
28
29 2007-11-15  Mark Rowe  <mrowe@apple.com>
30
31         Qt build fix.
32
33         * kjs/Parser.h:
34
35 2007-11-15  Geoffrey Garen  <ggaren@apple.com>
36
37         Reviewed by Eric Seidel.
38
39         Another round of grammar / parsing cleanup.
40         
41         1. Created distinct parser calls for parsing function bodies vs
42         programs. This will help later with optimizing global variable access.
43         
44         2. Turned Parser into a singleton. Cleaned up Lexer's singleton 
45         interface.
46         
47         3. Modified Lexer to free a little more memory when done lexing. (Added
48         FIXMEs for similar issues that I didn't fix.)
49         
50         4. Changed Lexer::makeIdentifier and Lexer::makeUString to start 
51         respecting the arguments passed to them. (No behavior change, but this
52         problem could have caused serious problems for an unsuspecting user of
53         these functions.)
54         
55         5. Removed KJS_DEBUG_MEM because it was bit-rotted.
56         
57         6. Removed Parser::prettyPrint because the same work was simpler to do
58         at the call site.
59         
60         7. Some renames:
61         
62             "Parser::accept" => "Parser::didFinishParsing"
63             "Parser::sid" => "Parser::m_sourceID"
64             "Lexer::doneParsing" => "Lexer::clear"
65             "sid" => "sourceId"
66             "lineno" => "lineNo"
67         
68         * JavaScriptCore.exp:
69         * kjs/Parser.cpp:
70         (KJS::Parser::Parser):
71         (KJS::Parser::parseProgram):
72         (KJS::Parser::parseFunctionBody):
73         (KJS::Parser::parse):
74         (KJS::Parser::didFinishParsing):
75         (KJS::parser):
76         * kjs/Parser.h:
77         (KJS::Parser::sourceId):
78         * kjs/function.cpp:
79         (KJS::GlobalFuncImp::callAsFunction):
80         * kjs/function_object.cpp:
81         (FunctionObjectImp::construct):
82         * kjs/grammar.y:
83         * kjs/interpreter.cpp:
84         (KJS::Interpreter::checkSyntax):
85         (KJS::Interpreter::evaluate):
86         * kjs/interpreter.h:
87         * kjs/lexer.cpp:
88         (kjsyylex):
89         (KJS::lexer):
90         (KJS::Lexer::Lexer):
91         (KJS::Lexer::~Lexer):
92         (KJS::Lexer::scanRegExp):
93         (KJS::Lexer::doneParsing):
94         (KJS::Lexer::makeIdentifier):
95         (KJS::Lexer::makeUString):
96         * kjs/lexer.h:
97         (KJS::Lexer::pattern):
98         (KJS::Lexer::flags):
99         (KJS::Lexer::sawError):
100         * kjs/nodes.cpp:
101         (KJS::Node::Node):
102         (KJS::FunctionBodyNode::FunctionBodyNode):
103         * kjs/nodes.h:
104         * kjs/testkjs.cpp:
105         (prettyPrintScript):
106         (kjsmain):
107         * kjs/ustring.cpp:
108         * kjs/ustring.h:
109
110 2007-11-15  Oliver Hunt  <oliver@apple.com>
111
112         Reviewed by Darin.
113
114         <rdar://problem/5601548> REGRESSION: All SourceElements and their children leak after a syntax error
115         
116         Add a stub node to maintain the Vector of SourceElements until assignment.
117
118         * kjs/grammar.y:
119         * kjs/nodes.h:
120         (KJS::SourceElementsStub::SourceElementsStub):
121         (KJS::SourceElementsStub::append):
122         (KJS::SourceElementsStub::release):
123         (KJS::SourceElementsStub::):
124         (KJS::SourceElementsStub::precedence):
125
126 2007-11-15  Eric Seidel  <eric@webkit.org>
127
128         Reviewed by Sam.
129
130         Abstract most of RMATCH into MatchStack functions.
131         
132         SunSpider claims this, combined with the last 2 patches was a 1% speedup, 10% for dna-regexp.
133
134         * pcre/pcre_exec.cpp:
135         (MatchStack::canUseStackBufferForNextFrame):
136         (MatchStack::allocateNextFrame):
137         (MatchStack::pushNewFrame):
138         (MatchStack::frameIsStackAllocated):
139         (MatchStack::popCurrentFrame):
140         (MatchStack::unrollAnyHeapAllocatedFrames):
141         (match):
142
143 2007-11-15  Eric Seidel  <eric@webkit.org>
144
145         Reviewed by Sam.
146
147         Remove RETURN_ERROR, add MatchStack
148         
149         * pcre/pcre_exec.cpp:
150         (MatchStack::MatchStack):
151         (MatchStack::unrollAnyHeapAllocatedFrames):
152         (matchError):
153         (match):
154         
155 2007-11-15  Eric Seidel  <eric@webkit.org>
156
157         Reviewed by Sam.
158
159         Clean up match function to match WebKit style
160
161         * JavaScriptCore.xcodeproj/project.pbxproj:
162         * pcre/pcre_exec.cpp:
163         (match):
164
165 2007-11-15  Steve Falkenburg  <sfalken@apple.com>
166
167         Windows build fix.
168
169         * JavaScriptCore.vcproj/JavaScriptCore.make:
170
171 2007-11-14  Alexey Proskuryakov  <ap@webkit.org>
172
173         Reviewed by Darin.
174
175         http://bugs.webkit.org/show_bug.cgi?id=15982
176         Improve JSString UTF-8 decoding
177
178         * API/JSStringRef.cpp:
179         (JSStringCreateWithUTF8CString): Use strict decoding, return 0 on error.
180
181         * wtf/unicode/UTF8.cpp:
182         (WTF::Unicode::convertUTF16ToUTF8):
183         (WTF::Unicode::convertUTF8ToUTF16):
184         * wtf/unicode/UTF8.h:
185         Made these function names start with a lower case letter.
186
187         * kjs/ustring.cpp: (KJS::UString::UTF8String): Updated for the above renaming.
188
189         * bindings/c/c_utility.cpp:
190         (KJS::Bindings::convertUTF8ToUTF16WithLatin1Fallback): Renamed to highlight the difference
191         from convertUTF8ToUTF16 in wtf/unicode.
192         (KJS::Bindings::convertNPStringToUTF16): Updated for the above renaming.
193         (KJS::Bindings::identifierFromNPIdentifier): Ditto.
194         * bindings/c/c_utility.h: Made convertUTF8ToUTF16WithLatin1Fallback() a file static.
195
196 2007-11-14  Sam Weinig  <sam@webkit.org>
197
198         Rubber-stamped by Anders.
199
200         Fix the Xcode project file after it was messed up in r27402.
201
202         * JavaScriptCore.xcodeproj/project.pbxproj:
203
204 2007-11-14  Eric Seidel  <eric@webkit.org>
205
206         Reviewed by Oliver.
207         
208         More PCRE style cleanup.
209
210         * pcre/pcre_compile.cpp:
211         (compile_regex):
212
213 2007-11-14  Adam Roben  <aroben@apple.com>
214
215         Clean up the bison conflict checking script
216
217         Reviewed by Geoff.
218
219         * DerivedSources.make:
220
221 2007-11-14  Eric Seidel  <eric@webkit.org>
222
223         Reviewed by Geoff.
224
225         Another round of PCRE cleanups: inlines
226         
227         SunSpider claims that this, combined with my previous PCRE cleanup were a 0.7% speedup, go figure.
228
229         * pcre/pcre_compile.cpp:
230         (jsRegExpCompile):
231         * pcre/pcre_exec.cpp:
232         (match):
233         (jsRegExpExecute):
234         * pcre/pcre_internal.h:
235         (PUT):
236         (GET):
237         (PUT2):
238         (GET2):
239         (isNewline):
240
241 2007-11-14  Eric Seidel  <eric@webkit.org>
242
243         Reviewed by Sam.
244         
245         Give PCRE a (small) bath.
246         Fix some formating and break things off into separate functions
247         http://bugs.webkit.org/show_bug.cgi?id=15993
248
249         * pcre/pcre_compile.cpp:
250         (calculateCompiledPatternLengthAndFlags):
251         (printCompiledRegExp):
252         (returnError):
253         (jsRegExpCompile):
254         * pcre/pcre_internal.h:
255         (compile_data::compile_data):
256
257 2007-11-14  Geoffrey Garen  <ggaren@apple.com>
258
259         Reviewed by Eric Seidel.
260         
261         Cleaned up the JavaScript grammar a bit.
262         
263         1. Changed BlockNode to always hold a child vector (which may be empty),
264         eliminating a few NULL-check branches in the common execution case.
265         
266         2. Changed the Block production to correctly report its starting and 
267         ending line numbers to the debugger. (It used to report its ending line
268         as its starting line.) Also, removed duplicate line-reporting code
269         inside the BlockNode constructor.
270         
271         3. Moved curly braces up from FunctionBody production into parent
272         productions. (I had to move the line number reporting code, too, since
273         it depends on the location of the curly braces.) This matches the ECMA
274         spec more closely, and makes some future changes I plan easier.
275         
276         4. Fixed statementList* convenience functions to deal appropriately with
277         empty Vectors.
278
279         SunSpider reports a small and statistically insignificant speedup.
280
281         * kjs/grammar.y:
282         * kjs/nodes.cpp:
283         (KJS::statementListPushFIFO):
284         (KJS::statementListGetDeclarations):
285         (KJS::statementListInitializeDeclarationStack):
286         (KJS::statementListInitializeVariableAccessStack):
287         (KJS::BlockNode::BlockNode):
288         (KJS::BlockNode::optimizeVariableAccess):
289         (KJS::BlockNode::getDeclarations):
290         (KJS::BlockNode::execute):
291         (KJS::FunctionBodyNode::initializeDeclarationStacks):
292         (KJS::FunctionBodyNode::optimizeVariableAccess):
293
294 2007-11-13  Anders Carlsson  <andersca@apple.com>
295
296         Add RefCounted.h (And remove Shared.h)
297         
298         * JavaScriptCore.vcproj/WTF/WTF.vcproj:
299
300 2007-11-13  Geoffrey Garen  <ggaren@apple.com>
301
302         Build fix.
303
304         * kjs/regexp.h:
305
306 2007-11-13  Geoffrey Garen  <ggaren@apple.com>
307
308         Reviewed by Anders Carlsson.
309
310         Renamed Shared to RefCounted.
311
312         * API/JSClassRef.h:
313         * JavaScriptCore.xcodeproj/project.pbxproj:
314         * kjs/interpreter.h:
315         * kjs/regexp.h:
316         * wtf/RefCounted.h: Copied from JavaScriptCore/wtf/Shared.h.
317         (WTF::RefCounted::RefCounted):
318         * wtf/Shared.h: Removed.
319
320 2007-11-13  Adam Roben  <aroben@apple.com>
321
322         Build fix
323
324         Reviewed by Geoff.
325
326         * kjs/regexp.h: Added a missing #include.
327
328 2007-11-13  Geoffrey Garen  <ggaren@apple.com>
329
330         Reviewed by Sam Weinig.
331
332         Moved Shared.h into wtf so it could be used in more places. Deployed
333         Shared in places where JSCore previously had hand-rolled ref-counting
334         classes.
335
336         * API/JSClassRef.cpp:
337         (OpaqueJSClass::OpaqueJSClass):
338         * API/JSClassRef.h:
339         * API/JSObjectRef.cpp:
340         (JSClassRetain):
341         (JSClassRelease):
342         * JavaScriptCore.vcproj/WTF/WTF.vcproj:
343         * JavaScriptCore.xcodeproj/project.pbxproj:
344         * kjs/interpreter.cpp:
345         (KJS::Interpreter::init):
346         * kjs/interpreter.h:
347         * kjs/regexp.cpp:
348         (KJS::RegExp::RegExp):
349         * kjs/regexp.h:
350         * wtf/Shared.h: Copied from WebCore/platform/Shared.h.
351
352 2007-11-13  Eric Seidel  <eric@webkit.org>
353
354         Reviewed by Maciej.
355
356         Add an ASSERT to getTruncatedInt32 to enforce proper usage.
357         Best part about this patch?  It doesn't break the web!
358
359         * kjs/JSImmediate.h:
360         (KJS::JSImmediate::getTruncatedInt32):
361         (KJS::JSImmediate::toDouble):
362         (KJS::JSImmediate::getUInt32):
363
364 2007-11-13  Alexey Proskuryakov  <ap@webkit.org>
365
366         Windows build fix.
367
368         * bindings/c/c_utility.cpp:
369         (KJS::Bindings::convertUTF8ToUTF16):
370         * kjs/ustring.cpp:
371         (KJS::UString::UTF8String):
372         * wtf/unicode/UTF8.cpp:
373         (WTF::Unicode::ConvertUTF8ToUTF16):
374
375 2007-11-13  Darin Adler  <darin@apple.com>
376
377         Reviewed by Geoff.
378
379         - fix http://bugs.webkit.org/show_bug.cgi?id=11231
380           RegExp bug when handling newline characters
381           and a number of other differences between PCRE behvior
382           and JavaScript regular expressions:
383
384           + single-digit sequences like \4 should be treated as octal
385             character constants, unless there is a sufficient number
386             of brackets for them to be treated as backreferences
387
388           + \8 turns into the character "8", not a binary zero character
389             followed by "8" (same for 9)
390
391           + only the first 3 digits should be considered part of an
392             octal character constant (the old behavior was to decode
393             an arbitrarily long sequence and then mask with 0xFF)
394
395           + if \x is followed by anything other than two valid hex digits,
396             then it should simply be treated a the letter "x"; that includes
397             not supporting the \x{41} syntax
398
399           + if \u is followed by anything less than four valid hex digits,
400             then it should simply be treated a the letter "u"
401
402           + an extra "+" should be a syntax error, rather than being treated
403             as the "possessive quantifier"
404
405           + if a "]" character appears immediately after a "[" character that
406             starts a character class, then that's an empty character class,
407             rather than being the start of a character class that includes a
408             "]" character
409
410           + a "$" should not match a terminating newline; we could have gotten
411             PCRE to handle this the way we wanted by passing an appropriate option
412
413         Test: fast/js/regexp-no-extensions.html
414
415         * pcre/pcre_compile.cpp:
416         (check_escape): Check backreferences against bracount to catch both
417         overflows and things that should be treated as octal. Rewrite octal
418         loop to not go on indefinitely. Rewrite both hex loops to match and
419         remove \x{} support.
420         (compile_branch): Restructure loops so that we don't special-case a "]"
421         at the beginning of a character class. Remove code that treated "+" as
422         the possessive quantifier.
423         (jsRegExpCompile): Change the "]" handling here too.
424
425         * pcre/pcre_exec.cpp: (match): Changed CIRC to match the DOLL implementation.
426         Changed DOLL to remove handling of "terminating newline", a Perl concept
427         which we don't need.
428
429         * tests/mozilla/expected.html: Two tests are fixed now:
430         ecma_3/RegExp/regress-100199.js and ecma_3/RegExp/regress-188206.js.
431         One test fails now: ecma_3/RegExp/perlstress-002.js -- our success before
432         was due to a bug (we treated all 1-character numeric escapes as backreferences).
433         The date tests also now both expect success -- whatever was making them fail
434         before was probably due to the time being close to a DST shift; maybe we need
435         to get rid of those tests.
436
437 2007-11-13  Darin Adler  <darin@apple.com>
438
439         * kjs/JSImmediate.h: (KJS::JSImmediate::getTruncatedInt32):
440         Remove too-strong assert that was firing constantly and preventing even basic
441         web browsing from working in a debug build. This function is used in many
442         cases where the immediate value is not a number; the assertion could perhaps
443         be added back later with a bit of reorganization.
444
445 2007-11-13  Alp Toker  <alp@atoker.com>
446
447         Build fix for breakage to non-Mac builds introduced in r27746.
448
449         * kjs/ustring.cpp:
450
451 2007-11-13  Eric Seidel  <eric@webkit.org>
452
453         Reviewed by Maciej.
454
455         Clean up evaluateToBoolean functions to use inlines instead of copy/paste code
456
457         * kjs/JSImmediate.h:
458         * kjs/nodes.cpp:
459         (KJS::GreaterNode::inlineEvaluateToBoolean):
460         (KJS::GreaterNode::evaluate):
461         (KJS::LessEqNode::inlineEvaluateToBoolean):
462         (KJS::LessEqNode::evaluate):
463         (KJS::GreaterEqNode::inlineEvaluateToBoolean):
464         (KJS::GreaterEqNode::evaluate):
465         (KJS::InNode::evaluateToBoolean):
466         (KJS::EqualNode::inlineEvaluateToBoolean):
467         (KJS::EqualNode::evaluate):
468         (KJS::NotEqualNode::inlineEvaluateToBoolean):
469         (KJS::NotEqualNode::evaluate):
470         (KJS::StrictEqualNode::inlineEvaluateToBoolean):
471         (KJS::StrictEqualNode::evaluate):
472         (KJS::NotStrictEqualNode::inlineEvaluateToBoolean):
473         (KJS::NotStrictEqualNode::evaluate):
474         * kjs/nodes.h:
475
476 2007-11-12  Geoffrey Garen  <ggaren@apple.com>
477
478         Reviewed by Sam Weinig.
479         
480         Fixed http://bugs.webkit.org/show_bug.cgi?id=15958
481         base64 spends 1.1% of total time checking for special Infinity case
482         
483         Use a fast character test instead of calling strncmp.
484         
485         1.1% speedup on string-base64. SunSpider reports a .4% speedup overall;
486         Sharks reports only .1%. Who are you going to believe? Huh?
487
488         * kjs/ustring.cpp:
489         (KJS::UString::toDouble):
490
491 2007-11-12  Eric Seidel  <eric@webkit.org>
492
493         Reviewed by Oliver.
494
495         Add evaluateToInt32 and evaluateUInt32 methods and deploy them.
496         Fix a few missing evaluateToBoolean methods
497         Deploy all evaluateTo* functions to more nodes to avoid slowdowns
498         http://bugs.webkit.org/show_bug.cgi?id=15950
499         
500         SunSpider claims this is at least a 1.4% speedup.
501
502         * kjs/JSImmediate.h:
503         (KJS::JSImmediate::getTruncatedInt32):
504         (KJS::JSImmediate::toDouble):
505         (KJS::JSImmediate::getUInt32):
506         * kjs/nodes.cpp:
507         (KJS::ExpressionNode::evaluateToNumber):
508         (KJS::ExpressionNode::evaluateToInt32):
509         (KJS::ExpressionNode::evaluateToUInt32):
510         (KJS::NumberNode::evaluateToInt32):
511         (KJS::NumberNode::evaluateToUInt32):
512         (KJS::ImmediateNumberNode::evaluateToInt32):
513         (KJS::ImmediateNumberNode::evaluateToUInt32):
514         (KJS::ResolveNode::evaluate):
515         (KJS::ResolveNode::evaluateToNumber):
516         (KJS::ResolveNode::evaluateToBoolean):
517         (KJS::ResolveNode::evaluateToInt32):
518         (KJS::ResolveNode::evaluateToUInt32):
519         (KJS::LocalVarAccessNode::evaluateToInt32):
520         (KJS::LocalVarAccessNode::evaluateToUInt32):
521         (KJS::BracketAccessorNode::evaluateToNumber):
522         (KJS::BracketAccessorNode::evaluateToBoolean):
523         (KJS::BracketAccessorNode::evaluateToInt32):
524         (KJS::BracketAccessorNode::evaluateToUInt32):
525         (KJS::DotAccessorNode::inlineEvaluate):
526         (KJS::DotAccessorNode::evaluate):
527         (KJS::DotAccessorNode::evaluateToNumber):
528         (KJS::DotAccessorNode::evaluateToBoolean):
529         (KJS::DotAccessorNode::evaluateToInt32):
530         (KJS::DotAccessorNode::evaluateToUInt32):
531         (KJS::NewExprNode::inlineEvaluate):
532         (KJS::NewExprNode::evaluate):
533         (KJS::NewExprNode::evaluateToNumber):
534         (KJS::NewExprNode::evaluateToBoolean):
535         (KJS::NewExprNode::evaluateToInt32):
536         (KJS::NewExprNode::evaluateToUInt32):
537         (KJS::FunctionCallResolveNode::inlineEvaluate):
538         (KJS::FunctionCallResolveNode::evaluate):
539         (KJS::FunctionCallResolveNode::evaluateToNumber):
540         (KJS::FunctionCallResolveNode::evaluateToBoolean):
541         (KJS::FunctionCallResolveNode::evaluateToInt32):
542         (KJS::FunctionCallResolveNode::evaluateToUInt32):
543         (KJS::LocalVarFunctionCallNode::evaluate):
544         (KJS::LocalVarFunctionCallNode::evaluateToNumber):
545         (KJS::LocalVarFunctionCallNode::evaluateToBoolean):
546         (KJS::LocalVarFunctionCallNode::evaluateToInt32):
547         (KJS::LocalVarFunctionCallNode::evaluateToUInt32):
548         (KJS::FunctionCallDotNode::evaluate):
549         (KJS::FunctionCallDotNode::evaluateToNumber):
550         (KJS::FunctionCallDotNode::evaluateToBoolean):
551         (KJS::FunctionCallDotNode::evaluateToInt32):
552         (KJS::FunctionCallDotNode::evaluateToUInt32):
553         (KJS::PostDecLocalVarNode::inlineEvaluateToNumber):
554         (KJS::PostDecLocalVarNode::evaluateToNumber):
555         (KJS::PostDecLocalVarNode::evaluateToBoolean):
556         (KJS::PostDecLocalVarNode::evaluateToInt32):
557         (KJS::PostDecLocalVarNode::evaluateToUInt32):
558         (KJS::typeStringForValue):
559         (KJS::UnaryPlusNode::evaluate):
560         (KJS::UnaryPlusNode::evaluateToBoolean):
561         (KJS::UnaryPlusNode::evaluateToNumber):
562         (KJS::UnaryPlusNode::evaluateToInt32):
563         (KJS::BitwiseNotNode::inlineEvaluateToInt32):
564         (KJS::BitwiseNotNode::evaluate):
565         (KJS::BitwiseNotNode::evaluateToNumber):
566         (KJS::BitwiseNotNode::evaluateToBoolean):
567         (KJS::BitwiseNotNode::evaluateToInt32):
568         (KJS::MultNode::evaluateToBoolean):
569         (KJS::MultNode::evaluateToInt32):
570         (KJS::MultNode::evaluateToUInt32):
571         (KJS::DivNode::evaluateToInt32):
572         (KJS::DivNode::evaluateToUInt32):
573         (KJS::ModNode::evaluateToBoolean):
574         (KJS::ModNode::evaluateToInt32):
575         (KJS::ModNode::evaluateToUInt32):
576         (KJS::AddNode::evaluateToNumber):
577         (KJS::AddNode::evaluateToInt32):
578         (KJS::AddNode::evaluateToUInt32):
579         (KJS::AddNumbersNode::evaluateToInt32):
580         (KJS::AddNumbersNode::evaluateToUInt32):
581         (KJS::SubNode::evaluateToInt32):
582         (KJS::SubNode::evaluateToUInt32):
583         (KJS::LeftShiftNode::inlineEvaluateToInt32):
584         (KJS::LeftShiftNode::evaluate):
585         (KJS::LeftShiftNode::evaluateToNumber):
586         (KJS::LeftShiftNode::evaluateToInt32):
587         (KJS::RightShiftNode::inlineEvaluateToInt32):
588         (KJS::RightShiftNode::evaluate):
589         (KJS::RightShiftNode::evaluateToNumber):
590         (KJS::RightShiftNode::evaluateToInt32):
591         (KJS::UnsignedRightShiftNode::inlineEvaluateToUInt32):
592         (KJS::UnsignedRightShiftNode::evaluate):
593         (KJS::UnsignedRightShiftNode::evaluateToNumber):
594         (KJS::UnsignedRightShiftNode::evaluateToInt32):
595         (KJS::LessNode::inlineEvaluateToBoolean):
596         (KJS::LessNode::evaluate):
597         (KJS::LessNode::evaluateToBoolean):
598         (KJS::LessNumbersNode::inlineEvaluateToBoolean):
599         (KJS::LessNumbersNode::evaluate):
600         (KJS::LessNumbersNode::evaluateToBoolean):
601         (KJS::LessStringsNode::inlineEvaluateToBoolean):
602         (KJS::LessStringsNode::evaluate):
603         (KJS::BitAndNode::evaluate):
604         (KJS::BitAndNode::inlineEvaluateToInt32):
605         (KJS::BitAndNode::evaluateToNumber):
606         (KJS::BitAndNode::evaluateToBoolean):
607         (KJS::BitAndNode::evaluateToInt32):
608         (KJS::BitXOrNode::inlineEvaluateToInt32):
609         (KJS::BitXOrNode::evaluate):
610         (KJS::BitXOrNode::evaluateToNumber):
611         (KJS::BitXOrNode::evaluateToBoolean):
612         (KJS::BitXOrNode::evaluateToInt32):
613         (KJS::BitOrNode::inlineEvaluateToInt32):
614         (KJS::BitOrNode::evaluate):
615         (KJS::BitOrNode::evaluateToNumber):
616         (KJS::BitOrNode::evaluateToBoolean):
617         (KJS::BitOrNode::evaluateToInt32):
618         (KJS::ConditionalNode::evaluateToNumber):
619         (KJS::ConditionalNode::evaluateToInt32):
620         (KJS::ConditionalNode::evaluateToUInt32):
621         (KJS::valueForReadModifyAssignment):
622         (KJS::AssignExprNode::evaluate):
623         (KJS::AssignExprNode::evaluateToBoolean):
624         (KJS::AssignExprNode::evaluateToNumber):
625         (KJS::AssignExprNode::evaluateToInt32):
626         (KJS::VarDeclNode::handleSlowCase):
627         * kjs/nodes.h:
628         (KJS::FunctionCallResolveNode::precedence):
629         (KJS::AddNode::precedence):
630         (KJS::AddNode::):
631         (KJS::LessNumbersNode::):
632         (KJS::LessStringsNode::):
633         * kjs/value.cpp:
634         (KJS::JSValue::toInt32SlowCase):
635         (KJS::JSValue::toUInt32SlowCase):
636         * kjs/value.h:
637         (KJS::JSValue::asCell):
638         (KJS::JSValue::toInt32):
639         (KJS::JSValue::toUInt32):
640
641 2007-11-12  Alexey Proskuryakov  <ap@webkit.org>
642
643         Reviewed by Darin.
644
645         http://bugs.webkit.org/show_bug.cgi?id=15953
646         Add UTF-8 encoding/decoding to WTF
647
648         * kjs/ustring.h: Moved UTF8SequenceLength() and decodeUTF8Sequence() to wtf/unicode.
649         * kjs/ustring.cpp: (KJS::UString::UTF8String): Changed this function to take a strict/lenient
650         parameter. Callers are not interested in getting decoding results in strict mode, so 
651         this allows for bailing out as soon as an error is seen.
652
653         * kjs/function.cpp:
654         (KJS::encode): Updated for new UString::UTF8String() signature.
655
656         * API/JSStringRef.cpp:
657         (JSStringCreateWithCharacters): Disambiguate UChar.
658         (JSStringCreateWithUTF8CString): Actually use UTF-8 when creating the string!
659         * bindings/c/c_utility.cpp: (KJS::Bindings::convertUTF8ToUTF16): Use ConvertUTF8ToUTF16().
660
661         * wtf/unicode/UTF8.cpp: Added.
662         (WTF::Unicode::inlineUTF8SequenceLengthNonASCII):
663         (WTF::Unicode::inlineUTF8SequenceLength):
664         (WTF::Unicode::UTF8SequenceLength):
665         (WTF::Unicode::decodeUTF8Sequence):
666         (WTF::Unicode::):
667         (WTF::Unicode::ConvertUTF16ToUTF8):
668         (WTF::Unicode::isLegalUTF8):
669         (WTF::Unicode::ConvertUTF8ToUTF16):
670         * wtf/unicode/UTF8.h: Added.
671         (WTF::Unicode::):
672         Some code moved from ustring.h, some adapted from unicode.org sources.
673
674         * JavaScriptCore.exp:
675         * JavaScriptCore.pri:
676         * JavaScriptCore.vcproj/WTF/WTF.vcproj:
677         * JavaScriptCore.xcodeproj/project.pbxproj:
678         * JavaScriptCoreSources.bkl:
679         Added UTF8.{h,cpp}
680
681 2007-11-12  Josh Aas  <joshmoz@gmail.com>
682
683         Reviewed by Darin.
684
685         - http://bugs.webkit.org/show_bug.cgi?id=15946
686           add NPPValue NPPVpluginDrawingModel (Mozilla bug 403418 compat)
687
688         * bindings/npapi.h:
689
690 2007-11-12  Darin Adler  <darin@apple.com>
691
692         Reviewed by Sam.
693
694         - http://bugs.webkit.org/show_bug.cgi?id=15951
695           REGRESSION: assertion failure in regexp match() when running JS tests
696
697         Test: fast/js/regexp-many-brackets.html
698
699         * pcre/pcre_exec.cpp: (match): Added back accidentally-removed case for
700         the BRANUMBER opcode.
701
702 2007-11-12  Darin Adler  <darin@apple.com>
703
704         Reviewed by Geoff.
705
706         - fix use of prefix and config.h, got rid of a few unneeded things in
707           the PCRE code; no behavior changes
708
709         * API/JSBase.cpp: Added include of config.h.
710         * API/JSCallbackConstructor.cpp: Ditto.
711         * API/JSCallbackFunction.cpp: Ditto.
712         * API/JSCallbackObject.cpp: Ditto.
713         * API/JSClassRef.cpp: Ditto.
714         * API/JSContextRef.cpp: Ditto.
715         * API/JSObjectRef.cpp: Ditto.
716         * API/JSStringRef.cpp: Ditto.
717         * API/JSValueRef.cpp: Ditto.
718
719         * JavaScriptCorePrefix.h: Removed obsolete <ctype.h> workaround.
720         Moved new/delete macros after includes, as they are in WebCore's prefix.
721         Removed "config.h".
722
723         * pcre/dftables.cpp: (main): Changed back to not use a separate maketables
724         function. This is needed for PCRE, but not helpful for our use. Also changed
725         the tables to all be 128 entries long instead of 256, since only the first
726         128 are ever used.
727
728         * pcre/pcre_compile.cpp: Added include of config.h. Eliminated digitab,
729         which was only being used to check hex digits. Changed all uses of TRUE and
730         FALSE to use the C++ true and false instead.
731         (check_escape): Just the TRUE/FALSE thing.
732         (is_counted_repeat): Ditto.
733         (could_be_empty_branch): Ditto.
734         (get_othercase_range): Ditto.
735         (compile_branch): Ditto.
736         (compile_regex): Ditto.
737         (is_anchored): Ditto.
738         (is_startline): Ditto.
739         (find_firstassertedchar): Ditto.
740         (jsRegExpCompile): Ditto.
741
742         * pcre/pcre_exec.cpp: Added include of config.h. Changed all uses of TRUE and
743         FALSE to use the C++ true and false instead.
744         (match_ref): Just the TRUE/FALSE thing.
745         (match): Ditto. Removed some unneeded braces.
746         (jsRegExpExecute): Just the TRUE/FALSE thing.
747
748         * pcre/pcre_internal.h: Moved the constants needed by dftables.cpp to the top
749         of the file instead of the bottom, so they can be used. Also changed the table
750         sizes to 128 instead of 256. Removed macro definitions of FALSE and TRUE.
751         Set array sizes for all the const arrays. Changed _pcre_utf8_table1_size to
752         be a macro instead of a extern int.
753
754         * pcre/pcre_maketables.cpp: Removed. It's all in dftables.cpp now.
755
756         * pcre/pcre_tables.cpp: Made table sizes explicit.
757
758         * pcre/pcre_xclass.cpp: Just the TRUE/FALSE thing.
759
760 2007-11-12  Adam Roben  <aroben@apple.com>
761
762         Build fix
763
764         * wtf/FastMalloc.h: Add missing using statement.
765
766 2007-11-11  Oliver Hunt  <oliver@apple.com>
767
768         Reviewed by Darin.
769
770         Add special fastZeroedMalloc function to replace a 
771         number of fastCalloc calls where one argument was 1.
772         
773         This results in a 0.4% progression in SunSpider, more
774         than making up for the earlier regression caused by 
775         additional overflow checks.
776
777         * JavaScriptCore.exp:
778         * kjs/array_instance.cpp:
779         * kjs/property_map.cpp:
780         * wtf/FastMalloc.cpp:
781         * wtf/FastMalloc.h:
782         * wtf/HashTable.h:
783
784 2007-11-11  Adam Roben  <aroben@apple.com>
785
786         Fix <rdar://5578982> ASSERT in HashTable::checkTableConsistencyExceptSize beneath WebNotificationCenter
787
788         The bug was due to a mismatch between HashMap::remove and
789         HashTable::checkTableConsistency. HashMap::remove can delete the value
790         stored in the HashTable (by derefing it), which is not normally
791         allowed by HashTable. It's OK in this case because the value is about
792         to be removed from the table, but HashTable wasn't aware of this.
793
794         HashMap::remove now performs the consistency check itself before
795         derefing the value.
796
797         Darin noticed that the same bug would occur in HashSet, so I've fixed
798         it there as well.
799
800         Reviewed by Darin.
801
802         * wtf/HashMap.h:
803         (WTF::HashMap::remove): Perform the HashTable consistency check
804         manually before calling deref.
805         * wtf/HashSet.h:
806         (WTF::HashSet::remove): Ditto.
807         * wtf/HashTable.h: Made checkTableConsistency public so that HashMap
808         and HashSet can call it.
809         (WTF::HashTable::removeAndInvalidateWithoutEntryConsistencyCheck):
810         Added.
811         (WTF::HashTable::removeAndInvalidate): Added.
812         (WTF::HashTable::remove):
813         (WTF::HashTable::removeWithoutEntryConsistencyCheck): Added.
814
815 2007-11-11  Mark Rowe  <mrowe@apple.com>
816
817         Build fix.  Use the correct filename case.
818
819         * kjs/nodes.h:
820
821 2007-11-11  Geoffrey Garen  <ggaren@apple.com>
822
823         Reviewed by Sam Weinig.
824         
825         Fixed http://bugs.webkit.org/show_bug.cgi?id=15902
826         15% of string-validate-input.js is spent compiling the same regular expression
827         
828         Store a compiled representation of the regular expression in the AST.
829         
830         Only a .2% SunSpider speedup overall, but a 10.6% speedup on 
831         string-validate-input.js.
832
833         * kjs/nodes.cpp:
834         (KJS::RegExpNode::evaluate):
835         * kjs/nodes.h:
836         (KJS::RegExpNode::):
837         * kjs/nodes2string.cpp:
838         (KJS::RegExpNode::streamTo):
839         * kjs/regexp.cpp:
840         (KJS::RegExp::flags):
841         * kjs/regexp.h:
842         (KJS::RegExp::pattern):
843         * kjs/regexp_object.cpp:
844         (KJS::RegExpObjectImp::construct):
845         (KJS::RegExpObjectImp::createRegExpImp):
846         * kjs/regexp_object.h:
847
848 2007-11-11  Oliver Hunt  <oliver@apple.com>
849
850         Reviewed by Eric.
851
852         Partial fix for <rdar://problem/5585334> numfuzz: integer overflows opening malformed SVG file in WebCore::ImageBuffer::create
853
854         Unfortunately this is a very slight regression, but is unavoidable.
855
856         * wtf/FastMalloc.cpp:
857
858 2007-11-10  Eric Seidel  <eric@webkit.org>
859
860         Reviewed by darin.
861         
862         Add simple type inferencing to the parser, and create custom
863         AddNode and LessNode subclasses based on inferred types.
864         http://bugs.webkit.org/show_bug.cgi?id=15884
865         
866         SunSpider claims this is at least a 0.5% speedup.
867
868         * JavaScriptCore.exp:
869         * kjs/grammar.y:
870         * kjs/internal.cpp:
871         (KJS::NumberImp::getPrimitiveNumber):
872         (KJS::GetterSetterImp::getPrimitiveNumber):
873         * kjs/internal.h:
874         * kjs/lexer.cpp:
875         (KJS::Lexer::lex):
876         * kjs/nodes.cpp:
877         (KJS::Node::Node):
878         (KJS::StringNode::evaluate):
879         (KJS::StringNode::evaluateToNumber):
880         (KJS::StringNode::evaluateToBoolean):
881         (KJS::RegExpNode::evaluate):
882         (KJS::UnaryPlusNode::optimizeVariableAccess):
883         (KJS::AddNode::evaluate):
884         (KJS::AddNode::evaluateToNumber):
885         (KJS::AddNumbersNode::inlineEvaluateToNumber):
886         (KJS::AddNumbersNode::evaluate):
887         (KJS::AddNumbersNode::evaluateToNumber):
888         (KJS::AddStringsNode::evaluate):
889         (KJS::AddStringLeftNode::evaluate):
890         (KJS::AddStringRightNode::evaluate):
891         (KJS::lessThan):
892         (KJS::lessThanEq):
893         (KJS::LessNumbersNode::evaluate):
894         (KJS::LessStringsNode::evaluate):
895         * kjs/nodes.h:
896         (KJS::ExpressionNode::):
897         (KJS::RegExpNode::):
898         (KJS::RegExpNode::precedence):
899         (KJS::TypeOfResolveNode::):
900         (KJS::LocalVarTypeOfNode::):
901         (KJS::UnaryPlusNode::):
902         (KJS::UnaryPlusNode::precedence):
903         (KJS::AddNode::):
904         (KJS::AddNode::precedence):
905         (KJS::AddNumbersNode::):
906         (KJS::AddStringLeftNode::):
907         (KJS::AddStringRightNode::):
908         (KJS::AddStringsNode::):
909         (KJS::LessNode::):
910         (KJS::LessNode::precedence):
911         (KJS::LessNumbersNode::):
912         (KJS::LessStringsNode::):
913         * kjs/nodes2string.cpp:
914         (KJS::StringNode::streamTo):
915         * kjs/object.cpp:
916         * kjs/object.h:
917         * kjs/value.h:
918         (KJS::JSValue::getPrimitiveNumber):
919
920 2007-11-11  Darin Adler  <darin@apple.com>
921
922         - try another way of fixing dftables builds -- refactor pcre_internal.h a bit
923
924         * pcre/pcre_internal.h: Make most of this header do nothing when DFTABLES is set.
925         Later we can break it into two files.
926
927         * JavaScriptCore.vcproj/dftables/dftables.vcproj: Take out now-unneeded include paths.
928         * pcre/dftables.cpp: Set DFTABLES. Use delete instead of free.
929         * pcre/dftables.pro: Take out now-unneeded include paths.
930         * pcre/pcre_maketables.cpp: Use new instead of malloc.
931
932 2007-11-11  Darin Adler  <darin@apple.com>
933
934         * pcre/dftables.pro: Try fixing Qt builds (I looked at qt-win) by adding
935         another include path.
936
937 2007-11-11  Darin Adler  <darin@apple.com>
938
939         * JavaScriptCore.xcodeproj/project.pbxproj: Try fixing Mac Tiger builds
940         by adding another include path.
941
942 2007-11-11  Darin Adler  <darin@apple.com>
943
944         Reviewed by Sam.
945
946         - http://bugs.webkit.org/show_bug.cgi?id=15924
947           next round of changes to JSRegExp (formerly PCRE)
948
949         This is a combination of converting to C++, tweaking the API, and adding
950         some additional optimizations.
951
952         Future steps will involve getting rid of the use of UTF-8 completely
953         (we'll use UTF-16 exclusively instead), eliminating more source files,
954         and some more speed-ups.
955
956         SunSpider says the current round is an 0.9% speed-up overall, and a
957         5.3% speed-up for regexp.
958
959         * JavaScriptCore.exp: Updated for new entry points.
960
961         * JavaScriptCore.pri:
962         * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
963         * JavaScriptCore.vcproj/dftables/dftables.vcproj:
964         * JavaScriptCore.xcodeproj/project.pbxproj:
965         * JavaScriptCoreSources.bkl:
966         * jscore.bkl:
967         Updated for new source file names and ForwardingHeaders.
968
969         * kjs/regexp.cpp:
970         (KJS::RegExp::RegExp): Changed to use the error message without calling
971         strdup on it and to pass the new types and options.
972         (KJS::RegExp::~RegExp): Removed the now-unneeded free of the error message.
973         (KJS::RegExp::match): Pass the new types and options.
974         * kjs/regexp.h: Update type of m_constructionError.
975
976         * pcre/AUTHORS: Update to reflect the status of the project -- we don't include
977         the Google parts, and this isn't the PCRE library, per se.
978         * pcre/COPYING: Ditto.
979
980         * pcre/dftables.cpp: Copied from JavaScriptCore/pcre/dftables.c.
981         (main): Removed unneeded ctype_digit.
982
983         * pcre/pcre.h: Convert to C++, tweak API a bit. Use UChar instead of JSRegExpChar.
984
985         * pcre/pcre_compile.cpp: Copied from JavaScriptCore/pcre/pcre_compile.c.
986         Moved a lot of private stuff used only within this file here from pcre_internal.h.
987         Renumbered the error codes.
988         (error_text): Use a single string with embedded nulls for the error text (I got
989         this idea from newer versions of PCRE).
990         (check_escape): Changed return type to be enum instead of int. Replaced ctype_digit
991         uses with isASCIIDigit.
992         (is_counted_repeat): Ditto.
993         (read_repeat_counts): Ditto.
994         (first_significant_code): Ditto.
995         (find_fixedlength): Ditto.
996         (could_be_empty_branch): Ditto.
997         (compile_branch): Ditto. Also removed some code that handles changing options.
998         JavaScript doesn't have any of the features that allow options to change.
999         (compile_regex): Updated for change to options parameter.
1000         (is_anchored): Ditto.
1001         (find_firstassertedchar): Ditto.
1002         (jsRegExpCompile): Changed to take separate flags instead of an options int.
1003         Also changed to call new/delete instead of pcre_malloc/free.
1004         (jsRegExpFree): Ditto.
1005
1006         * pcre/pcre_exec.cpp: Copied from JavaScriptCore/pcre/pcre_exec.c.
1007         Added a case that uses computed goto for the opcode loop, but did not turn it on.
1008         Changed the RMATCH macro to handle returns more efficiently by putting the where
1009         pointer in the new frame instead of the old one, allowing us to branch to the
1010         return with a single statement. Switched to new/delete from pcre_malloc/free.
1011         Changed many RRETURN callers to not set the return value since it's already
1012         set correctly. Replaced the rrc variable with an is_match variable. Values other
1013         than "match" and "no match" are now handled differently. This allows us to remove
1014         the code to check for those cases in various rules.
1015         (match): All the case statements use a macro BEGIN_OPCODE instead. And all the
1016         continue statements, or break statements that break out of the outer case use
1017         a macro NEXT_OPCODE instead. Replaced a few if statements with assertions.
1018         (jsRegExpExecute): Use new/delete instead of pcre_malloc/free. Removed unused
1019         start_match field from the match block.
1020
1021         * pcre/pcre_internal.h: Moved the last few configuration macros from pcre-config.h
1022         in here. Removed various unused types. Converted from JSRegExpChar to UChar.
1023         Eliminated pcre_malloc/free. Replaced the opcode enum with a macro that can be
1024         used in multiple places. Unfortunately we lose the comments for each opcode; we
1025         should find a place to put those back. Removed ctype_digit.
1026
1027         * pcre/pcre_maketables.cpp: Copied from JavaScriptCore/pcre/pcre_maketables.c.
1028         (pcre_maketables): Got rid of the conditional code that allows this to be compiled
1029         in -- it's only used for dftables now (and soon may be obsolete entirely).
1030         Changed code for cbit_digit to not use isdigit, and took the "_" case out of the
1031         loop. Removed ctype_digit.
1032
1033         * pcre/pcre_ord2utf8.cpp: Copied from JavaScriptCore/pcre/pcre_ord2utf8.c.
1034
1035         * pcre/pcre_tables.cpp: Copied from JavaScriptCore/pcre/pcre_tables.c.
1036         Moved _pcre_OP_lengths out of here into pcre_exec.cpp.
1037
1038         * pcre/pcre_ucp_searchfuncs.cpp: Copied from JavaScriptCore/pcre/pcre_ucp_searchfuncs.c.
1039         Updated for other file name changes.
1040
1041         * pcre/pcre_xclass.cpp: Copied from JavaScriptCore/pcre/pcre_xclass.c.
1042
1043         * pcre/ucpinternal.h: Updated header.
1044
1045         * pcre/ucptable.cpp: Copied from JavaScriptCore/pcre/ucptable.c.
1046
1047         * wtf/ASCIICType.h: (WTF::isASCIIDigit): Removed a branch by changing from && to
1048         & for this operation. Also added an overload that takes an int because that's
1049         useful for PCRE. Later we could optimize for int and overload other functions in
1050         this file; stuck to this simple one for now.
1051
1052         * wtf/unicode/icu/UnicodeIcu.h: Removed unused isUpper.
1053         * wtf/unicode/qt4/UnicodeQt4.h: Ditto.
1054
1055         * pcre/LICENCE: Removed.
1056         * pcre/pcre-config.h: Removed.
1057         * wtf/FastMallocPCRE.cpp: Removed.
1058
1059         * pcre/dftables.c: Renamed to cpp.
1060         * pcre/pcre_compile.c: Ditto.
1061         * pcre/pcre_exec.c: Ditto.
1062         * pcre/pcre_maketables.c: Ditto.
1063         * pcre/pcre_ord2utf8.c: Ditto.
1064         * pcre/pcre_tables.c: Ditto.
1065         * pcre/pcre_ucp_searchfuncs.c: Ditto.
1066         * pcre/pcre_xclass.c: Ditto.
1067         * pcre/ucptable.c: Ditto.
1068
1069 2007-11-11  Eric Seidel  <eric@webkit.org>
1070
1071         Reviewed by Oliver.
1072
1073         Add KJS_CHECKEXCEPTIONBOOLEAN to match rest of nodes.cpp
1074
1075         * kjs/nodes.cpp:
1076         (KJS::ExpressionNode::evaluateToBoolean):
1077         (KJS::LessNode::evaluateToBoolean):
1078         (KJS::GreaterNode::evaluateToBoolean):
1079         (KJS::LessEqNode::evaluateToBoolean):
1080         (KJS::GreaterEqNode::evaluateToBoolean):
1081         (KJS::InstanceOfNode::evaluateToBoolean):
1082         (KJS::InNode::evaluateToBoolean):
1083         (KJS::EqualNode::evaluateToBoolean):
1084         (KJS::NotEqualNode::evaluateToBoolean):
1085         (KJS::StrictEqualNode::evaluateToBoolean):
1086         (KJS::NotStrictEqualNode::evaluateToBoolean):
1087         (KJS::LogicalAndNode::evaluateToBoolean):
1088         (KJS::LogicalOrNode::evaluateToBoolean):
1089         (KJS::ConditionalNode::evaluateToBoolean):
1090
1091 2007-11-10  Darin Adler  <darin@apple.com>
1092
1093         Reviewed by Sam.
1094
1095         - fix http://bugs.webkit.org/show_bug.cgi?id=15927
1096           REGRESSION(r27487): delete a.c followed by __defineGetter__("c", ...) incorrectly deletes another property
1097           and <rdar://problem/5586384> REGRESSION (r27487): Can't switch out of Edit HTML Source mode on Leopard Wiki
1098
1099         Test: fast/js/delete-then-put.html
1100
1101         * kjs/property_map.cpp:
1102         (KJS::PropertyMap::put): Added a missing "- 1"; code to find an empty slot was not working.
1103         (KJS::PropertyMap::checkConsistency): Added a missing range check that would have caught this
1104         problem before.
1105
1106         - roll out a last-minute change to my evaluateToBoolean patch that was incorrect.
1107
1108         * kjs/nodes.h: (KJS::ExprStatementNode::ExprStatementNode): Take out call to
1109         optimizeForUnnecessaryResult, since the result is used in some cases.
1110
1111 2007-11-10  Adam Roben  <aroben@apple.com>
1112
1113         Windows build fix
1114
1115         Roll out some changes that were (seemingly accidentally) checked in
1116         with r27664.
1117
1118         * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
1119
1120 2007-11-10  Darin Adler  <darin@apple.com>
1121
1122         Reviewed by Sam.
1123
1124         - http://bugs.webkit.org/show_bug.cgi?id=15915
1125           add an evaluation path for booleans like the one we have for numbers
1126
1127         Gives 1.1% on SunSpider.
1128
1129         * kjs/grammar.y: Create TrueNode and FalseNode instead of BooleanNode.
1130
1131         * kjs/nodes.h: Changed to use Noncopyable. Moved optimizeForUnnecessaryResult
1132         down from Node to ExpressionNode. Changed some classes to not inherit from
1133         ExpressionNode where not necessary, and removed unnneeded evaluate functions
1134         as well as evaluate functions that need not be virtual. Call the
1135         optimizeForUnnecessaryResult function on the start of a for loop too.
1136         * kjs/nodes.cpp:
1137         (KJS::ExpressionNode::evaluateToBoolean): Added.
1138         (KJS::FalseNode::evaluate): Added.
1139         (KJS::TrueNode::evaluate): Added.
1140         (KJS::NumberNode::evaluateToBoolean): Added.
1141         (KJS::StringNode::evaluateToBoolean): Added.
1142         (KJS::LocalVarAccessNode::evaluateToBoolean): Added.
1143         (KJS::BracketAccessorNode::evaluateToBoolean): Added.
1144         (KJS::LogicalNotNode::evaluate): Changed to call evaluateToBoolean.
1145         (KJS::LogicalNotNode::evaluateToBoolean): Added.
1146         (KJS::lessThan): Changed to return bool.
1147         (KJS::lessThanEq): Ditto.
1148         (KJS::LessNode::evaluate): Changed since lessThan returns bool.
1149         (KJS::LessNode::evaluateToBoolean): Added.
1150         (KJS::GreaterNode::evaluate): Changed since lessThanEq returns bool.
1151         (KJS::GreaterNode::evaluateToBoolean): Added.
1152         (KJS::LessEqNode::evaluate): Changed since lessThanEq returns bool.
1153         (KJS::LessEqNode::evaluateToBoolean): Added.
1154         (KJS::GreaterEqNode::evaluate): Changed since lessThan returns bool.
1155         (KJS::GreaterEqNode::evaluateToBoolean): Added.
1156         (KJS::InstanceOfNode::evaluateToBoolean): Added.
1157         (KJS::InNode::evaluateToBoolean): Added.
1158         (KJS::EqualNode::evaluateToBoolean): Added.
1159         (KJS::NotEqualNode::evaluateToBoolean): Added.
1160         (KJS::StrictEqualNode::evaluateToBoolean): Added.
1161         (KJS::NotStrictEqualNode::evaluateToBoolean): Added.
1162         (KJS::ConditionalNode::evaluate): Changed to call evaluateToBoolean.
1163         (KJS::IfNode::execute): Ditto.
1164         (KJS::DoWhileNode::execute): Ditto.
1165         (KJS::WhileNode::execute): Ditto.
1166         (KJS::ForNode::execute): Ditto.
1167
1168         * kjs/nodes2string.cpp:
1169         (KJS::FalseNode::streamTo): Added.
1170         (KJS::TrueNode::streamTo): Added.
1171
1172 2007-11-09  Adam Roben  <aroben@apple.com>
1173
1174         Windows build fix
1175
1176         Reviewed by Darin.
1177
1178         * kjs/value.h:
1179         (KJS::jsNumber): Add some explicit casts.
1180
1181 2007-11-08  Darin Adler  <darin@apple.com>
1182
1183         - fix build
1184
1185         * kjs/grammar.y:
1186         * kjs/nodes.h:
1187         * kjs/property_map.cpp:
1188
1189 2007-11-08  Darin Adler  <darin@apple.com>
1190
1191         - roll out accidentally-checked in changes
1192
1193         * kjs/nodes.cpp: Back to previous version.
1194         * kjs/nodes.h: Ditto.
1195         * kjs/grammar.y: Ditto.
1196
1197 2007-11-08  Darin Adler  <darin@apple.com>
1198
1199         Reviewed by Maciej.
1200
1201         - http://bugs.webkit.org/show_bug.cgi?id=15912
1202           fasta spends a lot of time in qsort
1203
1204         * kjs/property_map.cpp:
1205         (KJS::PropertyMap::getEnumerablePropertyNames):
1206         Use insertion sort instead of qsort for small sets of property names.
1207         We can probably do some even-better speedups of for/in, but this nets
1208         0.6% overall and 6.7% on fasta.
1209
1210 2007-11-08  Darin Adler  <darin@apple.com>
1211
1212         Reviewed by Maciej.
1213
1214         - http://bugs.webkit.org/show_bug.cgi?id=15906
1215           getting characters by indexing into a string is very slow
1216
1217         This fixes one source of the slowness -- the conversion to an unused
1218         Identifier as we call the get function from the slot -- but doesn't
1219         fix others, such as the fact that we have to allocate a new UString::Rep
1220         for every single character.
1221
1222         Speeds up string-base64 30%, and at least 0.5% overall.
1223         But does slow down access-fannkuch quite a bit. Might be worth
1224         revisiting in the future to see what we can do about that (although
1225         I did look at a profile for a while).
1226
1227         * kjs/property_slot.h: Add a new marker for "numeric" property slots;
1228         slots where we don't need to pass the identifier to the get function.
1229         (KJS::PropertySlot::getValue): Added code to call the numeric get function.
1230         (KJS::PropertySlot::setCustomNumeric): Added.
1231         * kjs/string_object.cpp:
1232         (KJS::StringInstance::indexGetter): Changed to use substr() instead
1233         of constructing a wholly new UString each time.
1234         (KJS::stringInstanceNumericPropertyGetter): Added. Like indexGetter, but
1235         takes advantage of setCustomNumeric to avoid creating an Identifier.
1236         (KJS::StringInstance::getOwnPropertySlot): Changed to use setCustomNumeric.
1237
1238 2007-11-08  Darin Adler  <darin@apple.com>
1239
1240         Reviewed by Oliver.
1241
1242         - http://bugs.webkit.org/show_bug.cgi?id=15904
1243           more speed-ups possible by tightening up int version of JSImmediate
1244
1245         1% improvement of SunSpider
1246
1247         * kjs/JSImmediate.h: Eliminate the now-unneeded FPBitValues struct template.
1248         (KJS::JSImmediate::from): Overload for most numeric types; many types can
1249         do fewer branches and checks.
1250         (KJS::JSImmediate::getUInt32): Removed unneeded check for undefined.
1251         (KJS::JSImmediate::getTruncatedInt32): Ditto.
1252         (KJS::JSImmediate::getTruncatedUInt32): Ditto. There's no difference any more
1253         between getUInt32 and getTruncatedUInt32, so that's worth a rename and merge later.
1254
1255         * kjs/grammar.y: Update since fromDouble is now just from.
1256         * kjs/nodes.h: Ditto.
1257
1258         * kjs/value.h: (KJS::jsNumber): Overload for most numeric types.
1259
1260 2007-11-08  Kevin Ollivier  <kevino@theolliviers.com>
1261
1262         Bakefiles for building JavaScriptCore, needed by wx port.
1263
1264         Reviewed by Mark Rowe.
1265
1266         * JavaScriptCoreSources.bkl: Added.
1267         * jscore.bkl: Added.
1268
1269 2007-11-08  Oliver Hunt  <oliver@apple.com>
1270
1271         Reviewed by Maciej.
1272
1273         Fix regression caused by earlier bitwise and optimisation.  1 & undefined != 1.
1274
1275         The implementation of JSImmediate::areBothImmediateNumbers relies on 
1276         (JSImmediate::getTag(immediate1) & JSImmediate::getTag(immediate2)) having 
1277         a unique result when both immediate values are numbers.
1278
1279         The regression was due to UndefinedType & NumberType returning NumberType (3 & 1).
1280         By swapping the value of NumberType and UndefinedType this ceases to be a problem.
1281
1282         * kjs/JSType.h:
1283         (KJS::):
1284
1285 2007-11-08  Darin Adler  <darin@apple.com>
1286
1287         - fix build
1288
1289         * kjs/nodes.h: Add missing parameter name.
1290
1291 2007-11-08  Eric Seidel  <eric@webkit.org>
1292
1293         Reviewed by darin.
1294
1295         Add ExpressionNode subclass of Node, use it.
1296
1297         * kjs/grammar.y:
1298         * kjs/nodes.cpp:
1299         (KJS::ForInNode::ForInNode):
1300         * kjs/nodes.h:
1301         (KJS::ExpressionNode::):
1302         (KJS::NullNode::):
1303         (KJS::NullNode::precedence):
1304         (KJS::BooleanNode::):
1305         (KJS::BooleanNode::precedence):
1306         (KJS::RegExpNode::):
1307         (KJS::RegExpNode::precedence):
1308         (KJS::ThisNode::):
1309         (KJS::ThisNode::precedence):
1310         (KJS::ResolveNode::):
1311         (KJS::ElementNode::):
1312         (KJS::ArrayNode::):
1313         (KJS::PropertyNode::):
1314         (KJS::PropertyNode::precedence):
1315         (KJS::PropertyNode::name):
1316         (KJS::PropertyListNode::):
1317         (KJS::ObjectLiteralNode::):
1318         (KJS::ObjectLiteralNode::precedence):
1319         (KJS::BracketAccessorNode::):
1320         (KJS::DotAccessorNode::):
1321         (KJS::DotAccessorNode::precedence):
1322         (KJS::ArgumentListNode::):
1323         (KJS::ArgumentsNode::):
1324         (KJS::NewExprNode::):
1325         (KJS::NewExprNode::precedence):
1326         (KJS::FunctionCallValueNode::):
1327         (KJS::FunctionCallValueNode::precedence):
1328         (KJS::FunctionCallResolveNode::):
1329         (KJS::FunctionCallBracketNode::):
1330         (KJS::FunctionCallBracketNode::precedence):
1331         (KJS::FunctionCallDotNode::):
1332         (KJS::FunctionCallDotNode::precedence):
1333         (KJS::PrePostResolveNode::):
1334         (KJS::PostfixBracketNode::):
1335         (KJS::PostfixBracketNode::precedence):
1336         (KJS::PostIncBracketNode::):
1337         (KJS::PostIncBracketNode::isIncrement):
1338         (KJS::PostDecBracketNode::):
1339         (KJS::PostDecBracketNode::isIncrement):
1340         (KJS::PostfixDotNode::):
1341         (KJS::PostfixDotNode::precedence):
1342         (KJS::PostIncDotNode::):
1343         (KJS::PostIncDotNode::isIncrement):
1344         (KJS::PostDecDotNode::):
1345         (KJS::PostDecDotNode::isIncrement):
1346         (KJS::PostfixErrorNode::):
1347         (KJS::PostfixErrorNode::precedence):
1348         (KJS::DeleteResolveNode::):
1349         (KJS::DeleteBracketNode::):
1350         (KJS::DeleteBracketNode::precedence):
1351         (KJS::DeleteDotNode::):
1352         (KJS::DeleteDotNode::precedence):
1353         (KJS::DeleteValueNode::):
1354         (KJS::DeleteValueNode::precedence):
1355         (KJS::VoidNode::):
1356         (KJS::VoidNode::precedence):
1357         (KJS::TypeOfResolveNode::):
1358         (KJS::TypeOfValueNode::):
1359         (KJS::PrefixBracketNode::):
1360         (KJS::PrefixBracketNode::precedence):
1361         (KJS::PreIncBracketNode::):
1362         (KJS::PreIncBracketNode::isIncrement):
1363         (KJS::PreDecBracketNode::):
1364         (KJS::PreDecBracketNode::isIncrement):
1365         (KJS::PrefixDotNode::):
1366         (KJS::PrefixDotNode::precedence):
1367         (KJS::PreIncDotNode::):
1368         (KJS::PreIncDotNode::isIncrement):
1369         (KJS::PreDecDotNode::):
1370         (KJS::PreDecDotNode::isIncrement):
1371         (KJS::PrefixErrorNode::):
1372         (KJS::PrefixErrorNode::precedence):
1373         (KJS::UnaryPlusNode::):
1374         (KJS::UnaryPlusNode::precedence):
1375         (KJS::NegateNode::):
1376         (KJS::NegateNode::precedence):
1377         (KJS::BitwiseNotNode::):
1378         (KJS::BitwiseNotNode::precedence):
1379         (KJS::LogicalNotNode::):
1380         (KJS::LogicalNotNode::precedence):
1381         (KJS::AddNode::):
1382         (KJS::AddNode::precedence):
1383         (KJS::LeftShiftNode::):
1384         (KJS::LeftShiftNode::precedence):
1385         (KJS::RightShiftNode::):
1386         (KJS::RightShiftNode::precedence):
1387         (KJS::UnsignedRightShiftNode::):
1388         (KJS::UnsignedRightShiftNode::precedence):
1389         (KJS::LessNode::):
1390         (KJS::LessNode::precedence):
1391         (KJS::GreaterNode::):
1392         (KJS::GreaterNode::precedence):
1393         (KJS::LessEqNode::):
1394         (KJS::LessEqNode::precedence):
1395         (KJS::GreaterEqNode::):
1396         (KJS::GreaterEqNode::precedence):
1397         (KJS::InstanceOfNode::):
1398         (KJS::InstanceOfNode::precedence):
1399         (KJS::InNode::):
1400         (KJS::InNode::precedence):
1401         (KJS::EqualNode::):
1402         (KJS::EqualNode::precedence):
1403         (KJS::NotEqualNode::):
1404         (KJS::NotEqualNode::precedence):
1405         (KJS::StrictEqualNode::):
1406         (KJS::StrictEqualNode::precedence):
1407         (KJS::NotStrictEqualNode::):
1408         (KJS::NotStrictEqualNode::precedence):
1409         (KJS::BitAndNode::):
1410         (KJS::BitAndNode::precedence):
1411         (KJS::BitOrNode::):
1412         (KJS::BitOrNode::precedence):
1413         (KJS::BitXOrNode::):
1414         (KJS::BitXOrNode::precedence):
1415         (KJS::LogicalAndNode::):
1416         (KJS::LogicalAndNode::precedence):
1417         (KJS::LogicalOrNode::):
1418         (KJS::LogicalOrNode::precedence):
1419         (KJS::ConditionalNode::):
1420         (KJS::ConditionalNode::precedence):
1421         (KJS::ReadModifyResolveNode::):
1422         (KJS::ReadModifyResolveNode::precedence):
1423         (KJS::AssignResolveNode::):
1424         (KJS::AssignResolveNode::precedence):
1425         (KJS::ReadModifyBracketNode::):
1426         (KJS::ReadModifyBracketNode::precedence):
1427         (KJS::AssignBracketNode::):
1428         (KJS::AssignBracketNode::precedence):
1429         (KJS::AssignDotNode::):
1430         (KJS::AssignDotNode::precedence):
1431         (KJS::ReadModifyDotNode::):
1432         (KJS::ReadModifyDotNode::precedence):
1433         (KJS::AssignErrorNode::):
1434         (KJS::AssignErrorNode::precedence):
1435         (KJS::CommaNode::):
1436         (KJS::CommaNode::precedence):
1437         (KJS::AssignExprNode::):
1438         (KJS::AssignExprNode::precedence):
1439         (KJS::ExprStatementNode::):
1440         (KJS::IfNode::):
1441         (KJS::DoWhileNode::):
1442         (KJS::WhileNode::):
1443         (KJS::ReturnNode::):
1444         (KJS::WithNode::):
1445         (KJS::ThrowNode::):
1446         (KJS::ParameterNode::):
1447         (KJS::CaseClauseNode::):
1448         (KJS::CaseClauseNode::precedence):
1449         (KJS::ClauseListNode::):
1450         (KJS::SwitchNode::):
1451
1452 2007-11-08  Oliver Hunt  <oliver@apple.com>
1453
1454         Reviewed by Sam.
1455
1456         Add a fast path for bitwise-and of two immediate numbers for a 0.7% improvement in SunSpider (4% bitop improvement).
1457
1458         This only improves bitwise-and performance, as the additional logic required 
1459         for similar code paths on or, xor, and shifting requires additional operations
1460         and branches that negate (and in certain cases, regress) any advantage we might
1461         otherwise receive.
1462
1463         This improves performance on all bitop tests, the cryptography tests, as well as 
1464         the string-base64 and string-unpack-code tests.  No significant degradation on 
1465         any other tests.
1466
1467         * kjs/JSImmediate.h:
1468         (KJS::JSImmediate::areBothImmediateNumbers):
1469         (KJS::JSImmediate::andImmediateNumbers):
1470         * kjs/nodes.cpp:
1471         (KJS::BitAndNode::evaluate):
1472         * kjs/value.h:
1473         (KJS::jsNumberFromAnd):
1474
1475 2007-11-08  Adam Roben  <aroben@apple.com>
1476
1477         Stop using KJS inside of MathExtras.h
1478
1479         Reviewed by Darin.
1480
1481         * wtf/MathExtras.h: Removed an unused header, and a now-unused
1482         forward-declaration.
1483         (wtf_atan2): Use std::numeric_limits intead of KJS.
1484
1485 2007-11-08  Sam Weinig  <sam@webkit.org>
1486
1487         Windows build fix.
1488
1489         * kjs/date_object.cpp:
1490         (KJS::DateProtoFuncToLocaleString::callAsFunction): Fix unused arg warning.
1491         (KJS::DateProtoFuncToLocaleDateString::callAsFunction): ditto
1492         (KJS::DateProtoFuncToLocaleTimeString::callAsFunction): ditto
1493
1494 2007-11-08  Mark Rowe  <mrowe@apple.com>
1495
1496         Gtk build fix.
1497
1498         * kjs/lookup.h: Add missing include.
1499
1500 2007-11-08  Sam Weinig  <sam@webkit.org>
1501
1502         Reviewed by Darin.
1503
1504         Convert JavaScript internal function objects to use one class per
1505         function.  This avoids a switch statement inside what used to be
1506         the shared function classes and will allow Shark to better analyze
1507         the code.
1508
1509         To make this switch, the value property of the HashEntry was changed
1510         to a union of an intptr_t (which is used to continue handle valueGetters)
1511         and function pointer which points to a static constructor for the
1512         individual new function objects.
1513
1514         SunSpider claims this is a 1.0% speedup.
1515
1516         * kjs/array_object.cpp:
1517         (KJS::ArrayPrototype::getOwnPropertySlot):
1518         (KJS::getProperty):
1519         (KJS::ArrayProtoFuncToString::callAsFunction):
1520         (KJS::ArrayProtoFuncToLocaleString::callAsFunction):
1521         (KJS::ArrayProtoFuncJoin::callAsFunction):
1522         (KJS::ArrayProtoFuncConcat::callAsFunction):
1523         (KJS::ArrayProtoFuncPop::callAsFunction):
1524         (KJS::ArrayProtoFuncPush::callAsFunction):
1525         (KJS::ArrayProtoFuncReverse::callAsFunction):
1526         (KJS::ArrayProtoFuncShift::callAsFunction):
1527         (KJS::ArrayProtoFuncSlice::callAsFunction):
1528         (KJS::ArrayProtoFuncSort::callAsFunction):
1529         (KJS::ArrayProtoFuncSplice::callAsFunction):
1530         (KJS::ArrayProtoFuncUnShift::callAsFunction):
1531         (KJS::ArrayProtoFuncFilter::callAsFunction):
1532         (KJS::ArrayProtoFuncMap::callAsFunction):
1533         (KJS::ArrayProtoFuncEvery::callAsFunction):
1534         (KJS::ArrayProtoFuncForEach::callAsFunction):
1535         (KJS::ArrayProtoFuncSome::callAsFunction):
1536         (KJS::ArrayProtoFuncIndexOf::callAsFunction):
1537         (KJS::ArrayProtoFuncLastIndexOf::callAsFunction):
1538         * kjs/array_object.h:
1539         (KJS::ArrayPrototype::classInfo):
1540         * kjs/create_hash_table:
1541         * kjs/date_object.cpp:
1542         (KJS::DatePrototype::getOwnPropertySlot):
1543         (KJS::DateProtoFuncToString::callAsFunction):
1544         (KJS::DateProtoFuncToUTCString::callAsFunction):
1545         (KJS::DateProtoFuncToDateString::callAsFunction):
1546         (KJS::DateProtoFuncToTimeString::callAsFunction):
1547         (KJS::DateProtoFuncToLocaleString::callAsFunction):
1548         (KJS::DateProtoFuncToLocaleDateString::callAsFunction):
1549         (KJS::DateProtoFuncToLocaleTimeString::callAsFunction):
1550         (KJS::DateProtoFuncValueOf::callAsFunction):
1551         (KJS::DateProtoFuncGetTime::callAsFunction):
1552         (KJS::DateProtoFuncGetFullYear::callAsFunction):
1553         (KJS::DateProtoFuncGetUTCFullYear::callAsFunction):
1554         (KJS::DateProtoFuncToGMTString::callAsFunction):
1555         (KJS::DateProtoFuncGetMonth::callAsFunction):
1556         (KJS::DateProtoFuncGetUTCMonth::callAsFunction):
1557         (KJS::DateProtoFuncGetDate::callAsFunction):
1558         (KJS::DateProtoFuncGetUTCDate::callAsFunction):
1559         (KJS::DateProtoFuncGetDay::callAsFunction):
1560         (KJS::DateProtoFuncGetUTCDay::callAsFunction):
1561         (KJS::DateProtoFuncGetHours::callAsFunction):
1562         (KJS::DateProtoFuncGetUTCHours::callAsFunction):
1563         (KJS::DateProtoFuncGetMinutes::callAsFunction):
1564         (KJS::DateProtoFuncGetUTCMinutes::callAsFunction):
1565         (KJS::DateProtoFuncGetSeconds::callAsFunction):
1566         (KJS::DateProtoFuncGetUTCSeconds::callAsFunction):
1567         (KJS::DateProtoFuncGetMilliSeconds::callAsFunction):
1568         (KJS::DateProtoFuncGetUTCMilliseconds::callAsFunction):
1569         (KJS::DateProtoFuncGetTimezoneOffset::callAsFunction):
1570         (KJS::DateProtoFuncSetTime::callAsFunction):
1571         (KJS::DateProtoFuncSetMilliSeconds::callAsFunction):
1572         (KJS::DateProtoFuncSetUTCMilliseconds::callAsFunction):
1573         (KJS::DateProtoFuncSetSeconds::callAsFunction):
1574         (KJS::DateProtoFuncSetUTCSeconds::callAsFunction):
1575         (KJS::DateProtoFuncSetMinutes::callAsFunction):
1576         (KJS::DateProtoFuncSetUTCMinutes::callAsFunction):
1577         (KJS::DateProtoFuncSetHours::callAsFunction):
1578         (KJS::DateProtoFuncSetUTCHours::callAsFunction):
1579         (KJS::DateProtoFuncSetDate::callAsFunction):
1580         (KJS::DateProtoFuncSetUTCDate::callAsFunction):
1581         (KJS::DateProtoFuncSetMonth::callAsFunction):
1582         (KJS::DateProtoFuncSetUTCMonth::callAsFunction):
1583         (KJS::DateProtoFuncSetFullYear::callAsFunction):
1584         (KJS::DateProtoFuncSetUTCFullYear::callAsFunction):
1585         (KJS::DateProtoFuncSetYear::callAsFunction):
1586         (KJS::DateProtoFuncGetYear::callAsFunction):
1587         * kjs/date_object.h:
1588         * kjs/lookup.cpp:
1589         (KJS::Lookup::find):
1590         * kjs/lookup.h:
1591         (KJS::HashEntry::):
1592         (KJS::staticFunctionGetter):
1593         (KJS::staticValueGetter):
1594         (KJS::getStaticPropertySlot):
1595         (KJS::getStaticFunctionSlot):
1596         (KJS::lookupPut):
1597         * kjs/math_object.cpp:
1598         (KJS::MathObjectImp::getOwnPropertySlot):
1599         (KJS::MathProtoFuncAbs::callAsFunction):
1600         (KJS::MathProtoFuncACos::callAsFunction):
1601         (KJS::MathProtoFuncASin::callAsFunction):
1602         (KJS::MathProtoFuncATan::callAsFunction):
1603         (KJS::MathProtoFuncATan2::callAsFunction):
1604         (KJS::MathProtoFuncCeil::callAsFunction):
1605         (KJS::MathProtoFuncCos::callAsFunction):
1606         (KJS::MathProtoFuncExp::callAsFunction):
1607         (KJS::MathProtoFuncFloor::callAsFunction):
1608         (KJS::MathProtoFuncLog::callAsFunction):
1609         (KJS::MathProtoFuncMax::callAsFunction):
1610         (KJS::MathProtoFuncMin::callAsFunction):
1611         (KJS::MathProtoFuncPow::callAsFunction):
1612         (KJS::MathProtoFuncRandom::callAsFunction):
1613         (KJS::MathProtoFuncRound::callAsFunction):
1614         (KJS::MathProtoFuncSin::callAsFunction):
1615         (KJS::MathProtoFuncSqrt::callAsFunction):
1616         (KJS::MathProtoFuncTan::callAsFunction):
1617         * kjs/math_object.h:
1618         (KJS::MathObjectImp::classInfo):
1619         (KJS::MathObjectImp::):
1620         * kjs/string_object.cpp:
1621         (KJS::StringPrototype::getOwnPropertySlot):
1622         (KJS::StringProtoFuncToString::callAsFunction):
1623         (KJS::StringProtoFuncValueOf::callAsFunction):
1624         (KJS::StringProtoFuncCharAt::callAsFunction):
1625         (KJS::StringProtoFuncCharCodeAt::callAsFunction):
1626         (KJS::StringProtoFuncConcat::callAsFunction):
1627         (KJS::StringProtoFuncIndexOf::callAsFunction):
1628         (KJS::StringProtoFuncLastIndexOf::callAsFunction):
1629         (KJS::StringProtoFuncMatch::callAsFunction):
1630         (KJS::StringProtoFuncSearch::callAsFunction):
1631         (KJS::StringProtoFuncReplace::callAsFunction):
1632         (KJS::StringProtoFuncSlice::callAsFunction):
1633         (KJS::StringProtoFuncSplit::callAsFunction):
1634         (KJS::StringProtoFuncSubstr::callAsFunction):
1635         (KJS::StringProtoFuncSubstring::callAsFunction):
1636         (KJS::StringProtoFuncToLowerCase::callAsFunction):
1637         (KJS::StringProtoFuncToUpperCase::callAsFunction):
1638         (KJS::StringProtoFuncToLocaleLowerCase::callAsFunction):
1639         (KJS::StringProtoFuncToLocaleUpperCase::callAsFunction):
1640         (KJS::StringProtoFuncLocaleCompare::callAsFunction):
1641         (KJS::StringProtoFuncBig::callAsFunction):
1642         (KJS::StringProtoFuncSmall::callAsFunction):
1643         (KJS::StringProtoFuncBlink::callAsFunction):
1644         (KJS::StringProtoFuncBold::callAsFunction):
1645         (KJS::StringProtoFuncFixed::callAsFunction):
1646         (KJS::StringProtoFuncItalics::callAsFunction):
1647         (KJS::StringProtoFuncStrike::callAsFunction):
1648         (KJS::StringProtoFuncSub::callAsFunction):
1649         (KJS::StringProtoFuncSup::callAsFunction):
1650         (KJS::StringProtoFuncFontcolor::callAsFunction):
1651         (KJS::StringProtoFuncFontsize::callAsFunction):
1652         (KJS::StringProtoFuncAnchor::callAsFunction):
1653         (KJS::StringProtoFuncLink::callAsFunction):
1654         * kjs/string_object.h:
1655
1656 2007-11-08  Adam Roben  <aroben@apple.com>
1657
1658         Windows build fix
1659
1660         Reviewed by Sam and Ada.
1661
1662         * wtf/MathExtras.h: Get rid of a circular #include dependency to fix
1663         the build.
1664
1665 2007-11-08  Adam Roben  <aroben@apple.com>
1666
1667         Fix a precedence warning on Windows
1668
1669         * kjs/JSImmediate.h:
1670         (KJS::JSImmediate::toBoolean):
1671
1672 2007-11-08  Mark Rowe  <mrowe@apple.com>
1673
1674         Build fix for JavaScriptGlue.
1675
1676         * wtf/MathExtras.h: Include stdlib.h for srand and RAND_MAX.
1677
1678 2007-11-08  Darin Adler  <darin@apple.com>
1679
1680         - Windows build fix
1681
1682         * kjs/JSImmediate.h: Include MathExtras.h rather than math.h since this file uses "signbit".
1683
1684 2007-11-08  Oliver Hunt  <oliver@apple.com>
1685
1686         Reviewed by Darin.
1687
1688         Replace the use of floats for immediate values with the use of integers for a 4.5% improvement in SunSpider.
1689
1690         Unfortunately this change results in NaN, +Inf, -Inf, and -0 being heap allocated now, but
1691         we should now have faster array access, faster immediate to double conversion, and the 
1692         potential to further improve bitwise operators in future.
1693
1694         This also removes the need for unions to avoid strict aliasing problems when extracting 
1695         a value from immediates.
1696
1697         * kjs/JSImmediate.h:
1698         (KJS::):
1699         (KJS::JSImmediate::trueImmediate):
1700         (KJS::JSImmediate::falseImmediate):
1701         (KJS::JSImmediate::undefinedImmediate):
1702         (KJS::JSImmediate::nullImmediate):
1703         (KJS::JSImmediate::toBoolean):
1704         * kjs/value.h:
1705         (KJS::jsNaN):
1706
1707 2007-11-07  Eric Seidel  <eric@webkit.org>
1708
1709         Reviewed by Darin and Oliver.
1710         
1711         Add evaluateToNumber parallel evaluation tree to speed up number operations.
1712         Make ImmediateNumberNode a subclass of NumberNode.
1713         Share evaluate logic between evaluate and evaluateToNumber using inline functions
1714         There is still a lot of improvement to be made here.
1715         
1716         SunSpider claims this is a 1.0% speedup overall (nbody 7.9%), base64 slowing 2.0%
1717         Given the huge win that this prepares us for with simple type inferencing I see the small
1718         regression in base64 being worth the substantial overall improvement.
1719
1720         * kjs/grammar.y:
1721         * kjs/nodes.cpp:
1722         (KJS::Node::evaluateToNumber):
1723         (KJS::NumberNode::evaluate):
1724         (KJS::NumberNode::evaluateToNumber):
1725         (KJS::StringNode::evaluateToNumber):
1726         (KJS::LocalVarAccessNode::inlineEvaluate):
1727         (KJS::LocalVarAccessNode::evaluate):
1728         (KJS::LocalVarAccessNode::evaluateToNumber):
1729         (KJS::BracketAccessorNode::inlineEvaluate):
1730         (KJS::BracketAccessorNode::evaluate):
1731         (KJS::BracketAccessorNode::evaluateToNumber):
1732         (KJS::NegateNode::evaluate):
1733         (KJS::NegateNode::evaluateToNumber):
1734         (KJS::MultNode::inlineEvaluateToNumber):
1735         (KJS::MultNode::evaluate):
1736         (KJS::MultNode::evaluateToNumber):
1737         (KJS::DivNode::inlineEvaluateToNumber):
1738         (KJS::DivNode::evaluate):
1739         (KJS::DivNode::evaluateToNumber):
1740         (KJS::ModNode::inlineEvaluateToNumber):
1741         (KJS::ModNode::evaluate):
1742         (KJS::ModNode::evaluateToNumber):
1743         (KJS::throwOutOfMemoryErrorToNumber):
1744         (KJS::addSlowCaseToNumber):
1745         (KJS::add):
1746         (KJS::addToNumber):
1747         (KJS::AddNode::evaluateToNumber):
1748         (KJS::SubNode::inlineEvaluateToNumber):
1749         (KJS::SubNode::evaluate):
1750         (KJS::SubNode::evaluateToNumber):
1751         (KJS::valueForReadModifyAssignment):
1752         (KJS::ReadModifyLocalVarNode::evaluate):
1753         (KJS::ReadModifyResolveNode::evaluate):
1754         (KJS::ReadModifyDotNode::evaluate):
1755         (KJS::ReadModifyBracketNode::evaluate):
1756         * kjs/nodes.h:
1757         (KJS::Node::):
1758         (KJS::NumberNode::):
1759         (KJS::ImmediateNumberNode::):
1760         (KJS::AddNode::precedence):
1761         * kjs/nodes2string.cpp:
1762         (KJS::NumberNode::streamTo):
1763
1764 2007-11-07  Mark Rowe  <mrowe@apple.com>
1765
1766         Reviewed by Eric.
1767
1768         Fix up initialization after being mangled in r27572, and remove the
1769         ternary expression as extraCost will always be zero for the numeric
1770         heap.
1771
1772         * kjs/collector.cpp:
1773         (KJS::Collector::heapAllocate):
1774
1775 2007-11-07  Mark Rowe  <mrowe@apple.com>
1776
1777         Gtk build fix.
1778
1779         * kjs/regexp_object.cpp:
1780
1781 2007-11-07  Geoffrey Garen  <ggaren@apple.com>
1782
1783         Reviewed by Beth Dakin.
1784         
1785         Eliminated a bogus (though compiled-out) branch in the collector.
1786
1787         * kjs/collector.cpp:
1788         (KJS::Collector::heapAllocate):
1789
1790 2007-11-06  Geoffrey Garen  <ggaren@apple.com>
1791
1792         Reviewed by Darin Adler.
1793         
1794         Fixed part of http://bugs.webkit.org/show_bug.cgi?id=15861 
1795         5.8% of string-validate-input.js is spent creating RegExpImps
1796
1797         Put RegExpImp properties into a static hashtable to avoid a slew of
1798         PropertyMap churn when creating a RegExpImp.
1799         
1800         Factored important bits of regular expression implementation out of
1801         RegExpImp (the JS object) and into RegExp (the PCRE wrapper class), 
1802         making RegExp a ref-counted class. (This will help later.)
1803
1804         Removed PCRE_POSIX support because I didn't quite know how to test it 
1805         and keep it working with these changes.
1806         
1807         1.1% SunSpider speedup. 5.8% speedup on string-validate-input.js.
1808
1809         * kjs/regexp.h: A few interface changes:
1810         1. Renamed "subpatterns()" => "numSubpatterns()"
1811         2. Made flag enumeration private and replaced it with public getters for
1812         specific flags.
1813         3. Made RegExp ref-counted so RegExps can be shared by RegExpImps.
1814         4. Made RegExp take a string of flags instead of an int, eliminating 
1815         duplicated flag parsing code elsewhere.
1816
1817         * kjs/regexp_object.cpp:
1818         (KJS::RegExpProtoFunc::callAsFunction): For RegExp.compile: 
1819         - Fixed a bug where compile(undefined) would throw an exception. 
1820         - Removed some now-redundant code.
1821         - Used RegExp sharing to eliminate an allocation and a bunch of 
1822         PropertyMap thrash. (Not a big win since compile is a deprecated 
1823         function. I mainly did this to test the plubming.)
1824
1825 2007-11-07  Simon Hausmann  <hausmann@kde.org>
1826
1827         Reviewed by nobody, Qt/Windows build fix.
1828
1829         JavaScriptCore.pri expects OBJECTS_DIR to be set, so set it in
1830         testkjs.pro, too, where it's included from.
1831
1832         * kjs/testkjs.pro:
1833
1834 2007-11-07  Simon Hausmann  <shausman@trolltech.com>
1835
1836         Reviewed by Lars.
1837
1838         Fix "nmake clean" for the Qt/Windows build by replacing tmp/ with a variable that ends with the correct type of slash/backslash depending on the choice of compiler/make tool.
1839
1840         * JavaScriptCore.pri:
1841         * pcre/pcre.pri:
1842
1843 2007-11-07  Lars Knoll  <lars@trolltech.com>
1844
1845         Reviewed by Simon.
1846
1847         fix umemcasecmp
1848         
1849         Pretty embarrassing bug. Has the potential to fix quite a few test failures.
1850
1851         * wtf/unicode/qt4/UnicodeQt4.h:
1852         (WTF::Unicode::umemcasecmp):
1853
1854 2007-11-06  Maciej Stachowiak  <mjs@apple.com>
1855
1856         Reviewed by Eric.        
1857         
1858         - only collect when the heap is full, unless we have lots of extra cost garbage
1859         
1860         1.1% SunSpider speedup.
1861         
1862         This shouldn't hit memory use much since the extra space in those
1863         blocks hangs around either way.
1864
1865         * kjs/collector.cpp:
1866         (KJS::Collector::heapAllocate):
1867         (KJS::Collector::collect): Fix logic error that reversed the sense of collect's 
1868         return value.
1869
1870 2007-11-06  Oliver Hunt  <oliver@apple.com>
1871
1872         Reviewed by Maciej.
1873
1874         Avoid unnecessarily boxing the result from post inc/decrement for 0.3% gain in sunspider
1875         
1876         We now convert the common 'for (...; ...; <var>++) ...' to the semantically identical
1877         'for (...; ...; ++<var>) ...'.
1878
1879         * kjs/nodes.cpp:
1880         (KJS::PostIncResolveNode::optimizeForUnnecessaryResult):
1881         (KJS::PostIncLocalVarNode::evaluate):
1882         (KJS::PostIncLocalVarNode::optimizeForUnnecessaryResult):
1883         (KJS::PostDecResolveNode::optimizeForUnnecessaryResult):
1884         (KJS::PostDecLocalVarNode::evaluate):
1885         (KJS::PostDecLocalVarNode::optimizeForUnnecessaryResult):
1886         * kjs/nodes.h:
1887         (KJS::PrePostResolveNode::):
1888         (KJS::PostIncResolveNode::):
1889         (KJS::PostIncLocalVarNode::):
1890         (KJS::PostDecResolveNode::):
1891         (KJS::PostDecLocalVarNode::):
1892         (KJS::PreIncResolveNode::):
1893         (KJS::PreDecResolveNode::):
1894         (KJS::ForNode::ForNode):
1895
1896 2007-11-06  Eric Seidel  <eric@webkit.org>
1897
1898         Reviewed by darin.
1899
1900         This fixes a regressed layout test for string + object
1901         
1902         SunSpider claims this was an overall 0.3% speedup, although some individual tests were slower.
1903
1904         * kjs/nodes.cpp:
1905         (KJS::add): remove erroneous "fast path" for string + *
1906
1907 2007-11-06  Geoffrey Garen  <ggaren@apple.com>
1908
1909         Reviewed by Eric Seidel.
1910         
1911         Added toJSNumber, a fast path for converting a JSValue to a JS number,
1912         and deployed it in postfix expressions. In the fast case this 
1913         eliminates a call to jsNumber.
1914         
1915         0.4% speedup on SunSpider.
1916
1917         * ChangeLog:
1918         * kjs/nodes.cpp:
1919         (KJS::PostIncResolveNode::evaluate):
1920         (KJS::PostIncLocalVarNode::evaluate):
1921         (KJS::PostDecResolveNode::evaluate):
1922         (KJS::PostDecLocalVarNode::evaluate):
1923         (KJS::PostIncBracketNode::evaluate):
1924         (KJS::PostDecBracketNode::evaluate):
1925         (KJS::PostIncDotNode::evaluate):
1926         (KJS::PostDecDotNode::evaluate):
1927         (KJS::UnaryPlusNode::evaluate):
1928         * kjs/value.h:
1929         (KJS::JSValue::toJSNumber):
1930
1931 2007-11-06  Darin Adler  <darin@apple.com>
1932
1933         Reviewed by Maciej.
1934
1935         - http://bugs.webkit.org/show_bug.cgi?id=15846
1936           REGRESSION (r27387): Memory corruption when running fast/js/kde/delete.html
1937
1938         There was a mistake in the algorithm used to find an empty slot in the property
1939         map entries vector; when we were putting in a new property value and not overwriting
1940         an existing deleted sentinel, we would enlarge the entries vector, but would not
1941         overwrite the stale data that's in the new part. It was easy to pin this down by
1942         turning on property map consistency checks -- I never would have landed with this
1943         bug if I had run the regression tests once with consistency checks on!
1944
1945         * kjs/property_map.cpp: (KJS::PropertyMap::put): Changed logic for the case where
1946         foundDeletedElement is false to always use the item at the end of the entries vector.
1947         Also allowed me to merge with the logic for the "no deleted sentinels at all" case.
1948
1949 2007-11-06  Oliver Hunt  <oliver@apple.com>
1950
1951         RS=Darin.
1952
1953         Fix previous patch to use a 3 bit shift, a 16 bit shift causes a regression in sunspider.
1954
1955         * kjs/nodes.cpp:
1956         (KJS::add):
1957
1958 2007-11-06  Oliver Hunt  <oliver@apple.com>
1959
1960         Reviewed by Darin.
1961
1962         Replace boolean comparisons in AddNode with mask
1963         comparisons for a 0.2% improvement in sunspider.
1964
1965         * JavaScriptCore.xcodeproj/project.pbxproj:
1966         * kjs/nodes.cpp:
1967         (KJS::add):
1968
1969 2007-11-06  Eric Seidel  <eric@webkit.org>
1970
1971         Reviewed by darin.
1972         
1973         SunSpider claims this is a 1.1% speedup.
1974
1975         * kjs/nodes.cpp:
1976         (KJS::throwOutOfMemoryError): Added, non inline.
1977         (KJS::addSlowCase): renamed from add(), non inline.
1978         (KJS::add): add fast path for String + String, Number + Number and String + *
1979
1980 2007-11-06  Eric Seidel  <eric@webkit.org>
1981
1982         Reviewed by mjs.
1983         
1984         Avoid more UString creation.
1985         
1986         SunSpider claims this is a 0.4% speedup.
1987
1988         * kjs/regexp_object.cpp:
1989         (KJS::RegExpObjectImp::construct): use UString::find(UChar)
1990
1991 2007-11-05  Mark Rowe  <mrowe@apple.com>
1992
1993         Mac build fix.
1994
1995         * kjs/array_object.cpp:
1996         (KJS::ArrayProtoFunc::callAsFunction):
1997
1998 2007-11-05  Adam Roben  <aroben@apple.com>
1999
2000         Windows build fix
2001
2002         * kjs/list.h:
2003
2004 2007-11-05  Mark Rowe  <mrowe@apple.com>
2005
2006         Build fix.  Add missing #include.
2007
2008         * kjs/operations.cpp:
2009
2010 2007-11-05  Eric Seidel  <eric@webkit.org>
2011
2012         Reviewed by mjs.
2013         
2014         Remove another call to toString(exec)
2015         
2016         SunSpider claims this is a 0.5% speedup.
2017
2018         * kjs/operations.cpp:
2019         (KJS::equal): remove another toString
2020
2021 2007-11-05  Eric Seidel  <eric@webkit.org>
2022
2023         * kjs/operations.cpp:
2024         (KJS::equal): correct broken change.
2025
2026 2007-11-05  Eric Seidel  <eric@webkit.org>
2027
2028         Reviewed by mjs.
2029
2030         Remove one more call to toString(exec).
2031         
2032         SunSpider claims this is a 0.7% speedup.
2033
2034         * kjs/operations.cpp:
2035         (KJS::equal): remove a call to toString()
2036
2037 2007-11-05  Mark Rowe  <mrowe@apple.com>
2038
2039         Gtk build fix.
2040
2041         * pcre/pcre.pri:
2042
2043 2007-11-05  Mark Rowe  <mrowe@apple.com>
2044
2045         Gtk build fix.
2046
2047         * kjs/list.cpp:
2048
2049 2007-11-05  Geoffrey Garen  <ggaren@apple.com>
2050
2051         Touched a file to test my new HTTP access.
2052
2053         * kjs/scope_chain.cpp:
2054
2055 2007-11-05  Alp Toker  <alp@atoker.com>
2056
2057         Unreviewed build fix for qmake-based ports.
2058
2059         Someone with a better understanding of qmake still needs to sort out
2060         the INCLUDEPATH/DEPENDPATH mess.
2061
2062         * JavaScriptCore.pri:
2063
2064 2007-11-05  Geoffrey Garen  <ggaren@apple.com>
2065
2066         Reviewed by Darin Adler.
2067         
2068         http://bugs.webkit.org/show_bug.cgi?id=15835
2069
2070         Switched List implementation from a custom heap allocator to an inline
2071         Vector, for a disappointing .5% SunSpider speedup.
2072         
2073         Also renamed List::slice to List::getSlice because "get" is the 
2074         conventional prefix for functions returning a value through an out 
2075         parameter.
2076
2077         * kjs/array_object.cpp:
2078         (KJS::ArrayProtoFunc::callAsFunction): Removed some redundant function
2079         calls and memory accesses.
2080
2081         * kjs/bool_object.cpp:
2082         (BooleanObjectImp::construct): Removed questionable use of iterator.
2083
2084         * kjs/list.cpp:
2085         * kjs/list.h: New List class, implemented in terms of Vector. Two 
2086         interesting differences:
2087             1. The inline capacity is 8, not 5. Many of the Lists constructed 
2088             during a SunSpider run are larger than 5; almost none are larger
2089             than 8.
2090
2091             2. The growth factor is 4, not 2. Since we can guarantee that Lists
2092             aren't long-lived, we can grow them more aggressively, to avoid
2093             excessive copying.
2094
2095         * kjs/regexp_object.cpp:
2096         (RegExpObjectImp::construct): Removed redundant function calls.
2097
2098         * kjs/string_object.cpp:
2099         (KJS::StringObjectImp::construct): Removed questionable use of iterator.
2100
2101         * wtf/Vector.h:
2102         (WTF::::uncheckedAppend): Added a fast, unchecked version of append.
2103
2104 2007-11-05  Mark Rowe  <mrowe@apple.com>
2105
2106         Reviewed by Alp Toker.
2107
2108         Add DEPENDPATH to JavaScriptCore and pcre to help qmake with dependencies.
2109
2110         * JavaScriptCore.pri:
2111         * pcre/pcre.pri:
2112
2113 2007-11-04  Darin Adler  <darin@apple.com>
2114
2115         Reviewed by Maciej.
2116
2117         - http://bugs.webkit.org/show_bug.cgi?id=15826
2118           optimize opcode loop and case insensitive ASCII compares for a 30% speedup
2119
2120         SunSpider says it's 2.6% faster overall, 32.5% in the regular expression tests.
2121
2122         * pcre/pcre_internal.h: Added OP_ASCII_CHAR and OP_ASCII_LETTER_NC.
2123
2124         * pcre/pcre_compile.c:
2125         (find_fixedlength): Added cases for OP_ASCII_CHAR and OP_ASCII_LETTER_NC. Also
2126         added OP_NOT since there was no reason it should not be in here.
2127         (could_be_empty_branch): Ditto.
2128         (compile_branch): Streamlined all the single-character cases; there was a bit of
2129         duplicate code. Added cases for OP_ASCII_CHAR and OP_ASCII_LETTER_NC as needed.
2130         But in particular, compile to those opcodes when the single character match is
2131         ASCII.
2132         (find_firstassertedchar): Added cases for OP_ASCII_CHAR and OP_ASCII_LETTER_NC.
2133
2134         * pcre/pcre_exec.c: (match): Removed the "min", "minimize", and "op" fields from
2135         the matchframe, after I discovered that none of them needed to be saved and restored
2136         across recursive match calls. Also eliminated the ignored result field from the
2137         matchframe, since I discovered that rrc ("recursive result code") was already the
2138         exact same thing. Moved the handling of opcodes higher than OP_BRA into the default
2139         statement of the switch instead of doing them before the switch. This removes a
2140         branch from each iteration of the opcode interpreter, just as removal of "op"
2141         removed at least one store from each iteration. Last, but not least, add the
2142         OP_ASCII_CHAR and OP_ASCII_LETTER_NC functions. Neither can ever match a
2143         surrogate pair and the letter case can be handled efficiently.
2144
2145 2007-11-04  Darin Adler  <darin@apple.com>
2146
2147         * pcre/pcre_exec.c: (match): Try to fix the Windows build by removing unreachable code.
2148
2149 2007-11-03  Darin Adler  <darin@apple.com>
2150
2151         - fix non-Mac builds; remove some more unused PCRE stuff
2152
2153         * pcre/pcre_compile.c:
2154         (compile_branch): Removed branch chain and some unused ESC values.
2155         (compile_regex): Ditto.
2156         (jsRegExpCompile): Ditto.
2157         * pcre/pcre_exec.c:
2158         (match): Removed unused branch targets. Don't use macros any more.
2159         (jsRegExpExecute): More of the same.
2160
2161         * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: Update for removed files.
2162         * JavaScriptCore.xcodeproj/project.pbxproj: Ditto.
2163         * pcre/pcre.pri: Ditto.
2164
2165         * pcre/MERGING: Removed.
2166         * pcre/pcre_fullinfo.c: Removed.
2167         * pcre/pcre_get.c: Removed.
2168         * pcre/pcre_internal.h:
2169         * pcre/ucp.h: Removed.
2170
2171 2007-11-03  Darin Adler  <darin@apple.com>
2172
2173         Reviewed by Maciej.
2174
2175         - http://bugs.webkit.org/show_bug.cgi?id=15821
2176           remove unused PCRE features for speed
2177
2178         A first step toward removing the PCRE features we don't use.
2179         This gives a 0.8% speedup on SunSpider, and a 6.5% speedup on
2180         the SunSpider regular expression test.
2181
2182         Replaced the public interface with one that doesn't use the
2183         name PCRE. Removed code we don't need for JavaScript and various
2184         configurations we don't use. This is in preparation for still
2185         more changes in the future. We'll probably switch to C++ and
2186         make some even more significant changes to the regexp engine
2187         to get some additional speed.
2188
2189         There's probably additional unused stuff that I haven't
2190         deleted yet.
2191
2192         This does mean that our PCRE is now a fork, but I think that's
2193         not really a big deal.
2194
2195         * JavaScriptCore.exp: Remove the 5 old entry points and add
2196         the 3 new entry points for WebCore's direct use of the regular
2197         expression engine.
2198
2199         * kjs/config.h: Remove the USE(PCRE16) define. I decided to flip
2200         its sense and now there's a USE(POSIX_REGEX) instead, which should
2201         probably not be set by anyone. Maybe later we'll just get rid of it
2202         altogether.
2203
2204         * kjs/regexp.h:
2205         * kjs/regexp.cpp:
2206         (KJS::RegExp::RegExp): Switch to new jsRegExp function names and
2207         defines. Cut down on the number of functions used.
2208         (KJS::RegExp::~RegExp): Ditto.
2209         (KJS::RegExp::match): Ditto.
2210
2211         * pcre/dftables.c: (main): Get rid of ctype_letter and ctype_meta,
2212         which are unused.
2213
2214         * pcre/pcre-config.h: Get rid of EBCIDIC, PCRE_DATA_SCOPE, const,
2215         size_t, HAVE_STRERROR, HAVE_MEMMOVE, HAVE_BCOPY, NEWLINE,
2216         POSIX_MALLOC_THRESHOLD, NO_RECURSE, SUPPORT_UCP, SUPPORT_UTF8,
2217         and JAVASCRIPT. These are all no longer configurable in our copy
2218         of the library.
2219
2220         * pcre/pcre.h: Remove the macro-based kjs prefix hack, the PCRE
2221         version macros, PCRE_UTF16, the code to set up PCRE_DATA_SCOPE,
2222         the include of <stdlib.h>, and most of the constants and
2223         functions defined in this header. Changed the naming scheme to
2224         use a JSRegExp prefix rather than a pcre prefix. In the future,
2225         we'll probably change this to be a C++ header.
2226
2227         * pcre/pcre_compile.c: Removed all unused code branches,
2228         including many whole functions and various byte codes.
2229         Kept changes outside of removal to a minimum.
2230         (check_escape):
2231         (first_significant_code):
2232         (find_fixedlength):
2233         (find_recurse):
2234         (could_be_empty_branch):
2235         (compile_branch):
2236         (compile_regex):
2237         (is_anchored):
2238         (is_startline):
2239         (find_firstassertedchar):
2240         (jsRegExpCompile): Renamed from pcre_compile2 and changed the
2241         parameters around a bit.
2242         (jsRegExpFree): Added.
2243
2244         * pcre/pcre_exec.c: Removed many unused opcodes and variables.
2245         Also started tearing down the NO_RECURSE mechanism since it's
2246         now the default. In some cases there were things in the explicit
2247         frame that could be turned into plain old local variables and
2248         other small like optimizations.
2249         (pchars):
2250         (match_ref):
2251         (match): Changed parameters quite a bit since it's now not used
2252         recursively.
2253         (jsRegExpExecute): Renamed from pcre_exec.
2254
2255         * pcre/pcre_internal.h: Get rid of PCRE_DEFINITION, PCRE_SPTR,
2256         PCRE_IMS, PCRE_ICHANGED, PCRE_NOPARTIAL, PCRE_STUDY_MAPPED,
2257         PUBLIC_OPTIONS, PUBLIC_EXEC_OPTIONS, PUBLIC_DFA_EXEC_OPTIONS,
2258         PUBLIC_STUDY_OPTIONS, MAGIC_NUMBER, 16 of the opcodes,
2259         _pcre_utt, _pcre_utt_size, _pcre_try_flipped, _pcre_ucp_findprop,
2260         and _pcre_valid_utf8. Also moved pcre_malloc and pcre_free here.
2261
2262         * pcre/pcre_maketables.c: Changed to only compile in dftables.
2263         Also got rid of many of the tables that we don't use.
2264
2265         * pcre/pcre_tables.c: Removed the unused Unicode property tables.
2266
2267         * pcre/pcre_ucp_searchfuncs.c: Removed everything except for
2268         _pcre_ucp_othercase.
2269
2270         * pcre/pcre_xclass.c: (_pcre_xclass): Removed uneeded support
2271         for classes based on Unicode properties.
2272
2273         * wtf/FastMallocPCRE.cpp: Removed unused bits. It would be good
2274         to eliminate this completely, but we need the regular expression
2275         code to be C++ first.
2276
2277         * pcre/pcre_fullinfo.c:
2278         * pcre/pcre_get.c:
2279         * pcre/ucp.h:
2280         Files that are no longer needed. I didn't remove them with this
2281         check-in, because I didn't want to modify all the project files.
2282
2283 2007-11-03  Maciej Stachowiak  <mjs@apple.com>
2284
2285         Reviewed by Sam.
2286         
2287         - remove NaN check from JSImmediate::fromDouble for 0.5% SunSpider speedup
2288
2289         It turns out that doing this check costs more than it saves.
2290         
2291         * kjs/JSImmediate.h:
2292         (KJS::JSImmediate::fromDouble):
2293
2294 2007-11-03  Sam Weinig  <sam@webkit.org>
2295
2296         Reviewed by Oliver.
2297
2298         Remove dummy variable from ClassInfo reducing the size of the struct by 1 word.
2299         The variable had been kept around for binary compatibility, but since nothing
2300         else is there is no point in continuing to keep it around.
2301
2302         * API/JSCallbackConstructor.cpp:
2303         (KJS::):
2304         * API/JSCallbackFunction.cpp:
2305         (KJS::):
2306         * API/JSCallbackObject.cpp:
2307         (KJS::):
2308         * bindings/objc/objc_runtime.mm:
2309         * bindings/runtime_array.cpp:
2310         * bindings/runtime_object.cpp:
2311         * kjs/array_instance.cpp:
2312         (KJS::):
2313         * kjs/array_object.cpp:
2314         (KJS::):
2315         * kjs/bool_object.cpp:
2316         * kjs/date_object.cpp:
2317         (KJS::):
2318         * kjs/error_object.cpp:
2319         * kjs/function.cpp:
2320         (KJS::):
2321         * kjs/internal.cpp:
2322         (KJS::):
2323         * kjs/lookup.h:
2324         * kjs/math_object.cpp:
2325         * kjs/number_object.cpp:
2326         * kjs/object.h:
2327         * kjs/regexp_object.cpp:
2328         * kjs/string_object.cpp:
2329         (KJS::):
2330
2331 2007-11-03  Kevin McCullough  <kmccullough@apple.com>
2332
2333         - Updated testkjs results to make the build bots green until we
2334         can fix the tests that are failing.  The new failures are in DST.
2335
2336         * tests/mozilla/expected.html:
2337
2338 2007-11-03  Maciej Stachowiak  <mjs@apple.com>
2339
2340         Reviewed by Adam.
2341         
2342         - don't print the var twice for ForInNodes with a var declaration
2343
2344         * kjs/nodes2string.cpp:
2345         (KJS::ForInNode::streamTo):
2346
2347 2007-11-03  Darin Adler  <darin@apple.com>
2348
2349         * pcre/pcre_compile.c: (check_escape): Windows build fix. Get rid of
2350         C-incompatible declaration.
2351
2352 2007-11-03  Mark Rowe  <mrowe@apple.com>
2353
2354         Gtk build fix.
2355
2356         * kjs/nodes.cpp:  Add missing include.
2357
2358 2007-11-03  Darin Adler  <darin@apple.com>
2359
2360         Reviewed by Maciej.
2361
2362         - fix http://bugs.webkit.org/show_bug.cgi?id=15814
2363           <rdar://problem/5536644> fast/js/kde/encode_decode_uri.html fails
2364
2365         These changes cause us to match the JavaScript specification and pass the
2366         fast/js/kde/encode_decode_uri.html test.
2367
2368         * kjs/function.cpp: (KJS::encode): Call the UTF-8 string conversion in its
2369         new strict mode, throwing an exception if there are malformed UTF-16 surrogate
2370         pairs in the text.
2371
2372         * kjs/ustring.h: Added a strict version of the UTF-8 string conversion.
2373         * kjs/ustring.cpp:
2374         (KJS::decodeUTF8Sequence): Removed code to disallow U+FFFE and U+FFFF; while
2375         those might be illegal in some sense, they aren't supposed to get any special
2376         handling in the place where this function is currently used.
2377         (KJS::UString::UTF8String): Added the strictness.
2378
2379 2007-11-03  Darin Adler  <darin@apple.com>
2380
2381         Reviewed by Maciej.
2382
2383         - http://bugs.webkit.org/show_bug.cgi?id=15812
2384           some JavaScript tests (from the Mozilla test suite) are failing
2385
2386         Two or three fixes get 7 more of the Mozilla tests passing.
2387         This gets us down from 61 failing tests to 54.
2388
2389         * kjs/interpreter.h: (KJS::Interpreter::builtinRegExp):
2390         Made this inline and gave it a more specific type. Some day we should
2391         probably do that for all of these -- might even get a bit of a speed
2392         boost from it.
2393         * kjs/interpreter.cpp: Removed Interpreter::builtinRegExp now that it's
2394         inline in the header.
2395
2396         * kjs/regexp_object.h:
2397         * kjs/regexp_object.cpp:
2398         (KJS::RegExpProtoFunc::callAsFunction): Moved test and exec out of the
2399         switch statement into the RegExpImp object, so they can be shared with
2400         RegExpImp::callAsFunction.
2401         (KJS::RegExpImp::match): Added. Common code used by both test and exec.
2402         (KJS::RegExpImp::test): Added.
2403         (KJS::RegExpImp::exec): Added.
2404         (KJS::RegExpImp::implementsCall): Added.
2405         (KJS::RegExpImp::callAsFunction): Added.
2406         (KJS::RegExpObjectImpPrivate::RegExpObjectImpPrivate): Initialize
2407         lastInput to null rather than empty string -- we take advantage of the
2408         difference in RegExpImp::match.
2409         (KJS::RegExpObjectImp::input): Added. No reason to go through hash tables
2410         just to get at a field like this.
2411
2412         * pcre/pcre_compile.c: (check_escape): Changed the \u handling to match
2413         the JavaScript specification. If there are not 4 hex digits after the \u,
2414         then it's processed as if it wasn't an escape sequence at all.
2415
2416         * pcre/pcre_internal.h: Added IS_NEWLINE, with the appropriate definition
2417         for JavaScript (4 specific Unicode values).
2418         * pcre/pcre_exec.c:
2419         (match): Changed all call sites to use IS_NEWLINE.
2420         (pcre_exec): Ditto.
2421
2422         * tests/mozilla/expected.html: Updated to expect 7 more successful tests.
2423
2424 2007-11-03  David D. Kilzer  <ddkilzer@webkit.org>
2425
2426         Sort files(...); sections of Xcode project files.
2427
2428         Rubber-stamped by Darin.
2429
2430         * JavaScriptCore.xcodeproj/project.pbxproj:
2431
2432 2007-11-03  Maciej Stachowiak  <mjs@apple.com>
2433
2434         Reviewed by Oliver.
2435         
2436         - remove VarDeclListNode and simplify VarDeclNode evaluation for 0.4% SunSpider speedup
2437
2438         * kjs/grammar.y:
2439         * kjs/nodes.cpp:
2440         (KJS::VarDeclNode::optimizeVariableAccess):
2441         (KJS::VarDeclNode::getDeclarations):
2442         (KJS::VarDeclNode::handleSlowCase):
2443         (KJS::VarDeclNode::evaluateSingle):
2444         (KJS::VarDeclNode::evaluate):
2445         (KJS::VarStatementNode::execute):
2446         * kjs/nodes.h:
2447         (KJS::VarDeclNode::):
2448         (KJS::VarStatementNode::):
2449         * kjs/nodes2string.cpp:
2450         (KJS::VarDeclNode::streamTo):
2451
2452 2007-11-03  Alexey Proskuryakov  <ap@webkit.org>
2453
2454         Reviewed by Darin.
2455
2456         http://bugs.webkit.org/show_bug.cgi?id=15800
2457         REGRESSION (r27303): RegExp leaks
2458
2459         * kjs/regexp_object.h:
2460         (KJS::RegExpImp::setRegExp):
2461         (KJS::RegExpImp::regExp):
2462         (KJS::RegExpImp::classInfo):
2463         * kjs/regexp_object.cpp:
2464         (RegExpImp::RegExpImp):
2465         (RegExpImp::~RegExpImp):
2466         Renamed reg member variable to m_regExp, changed it to use OwnPtr.
2467
2468 2007-11-02  Maciej Stachowiak  <mjs@apple.com>
2469
2470         Reviewed by Oliver.
2471         
2472         - add SourceElements as a typedef for Vector<RefPtr<StatementNode> >.
2473
2474         * kjs/grammar.y:
2475         * kjs/nodes.cpp:
2476         (KJS::statementListPushFIFO):
2477         (KJS::statementListGetDeclarations):
2478         (KJS::statementListInitializeDeclarationStacks):
2479         (KJS::statementListInitializeVariableAccessStack):
2480         (KJS::statementListExecute):
2481         (KJS::BlockNode::BlockNode):
2482         (KJS::FunctionBodyNode::FunctionBodyNode):
2483         (KJS::ProgramNode::ProgramNode):
2484         * kjs/nodes.h:
2485         (KJS::CaseClauseNode::):
2486
2487 2007-11-02  Darin Adler  <darin@apple.com>
2488
2489         Reviewed by Maciej.
2490
2491         - http://bugs.webkit.org/show_bug.cgi?id=15791
2492           change property map data structure for less memory use, better speed
2493
2494         The property map now has an array of indices and a separate array of
2495         property map entries. This slightly slows down lookup because of a second
2496         memory acess, but makes property maps smaller and faster to iterate in
2497         functions like mark().
2498
2499         SunSpider says this is 1.2% faster, although it makes the bitwise-end test
2500         more than 10% slower. To fix that we'll need to optimize global variable lookup.
2501
2502         * kjs/property_map.cpp:
2503         (KJS::PropertyMapEntry::PropertyMapEntry):
2504         (KJS::PropertyMapHashTable::entries):
2505         (KJS::PropertyMapHashTable::allocationSize):
2506         (KJS::SavedProperties::SavedProperties):
2507         (KJS::SavedProperties::~SavedProperties):
2508         (KJS::PropertyMap::checkConsistency):
2509         (KJS::PropertyMap::~PropertyMap):
2510         (KJS::PropertyMap::clear):
2511         (KJS::PropertyMap::get):
2512         (KJS::PropertyMap::getLocation):
2513         (KJS::PropertyMap::put):
2514         (KJS::PropertyMap::insert):
2515         (KJS::PropertyMap::createTable):
2516         (KJS::PropertyMap::rehash):
2517         (KJS::PropertyMap::remove):
2518         (KJS::PropertyMap::mark):
2519         (KJS::comparePropertyMapEntryIndices):
2520         (KJS::PropertyMap::containsGettersOrSetters):
2521         (KJS::PropertyMap::getEnumerablePropertyNames):
2522         (KJS::PropertyMap::save):
2523         (KJS::PropertyMap::restore):
2524         * kjs/property_map.h:
2525
2526 2007-11-02  Darin Adler  <darin@apple.com>
2527
2528         Reviewed by Maciej.
2529
2530         - http://bugs.webkit.org/show_bug.cgi?id=15807
2531           HashMap needs a take() function that combines get and remove
2532
2533         * wtf/HashMap.h: Added take function. Simplistic implementation for now,
2534         but still does only one hash table lookup.
2535
2536         * kjs/array_instance.cpp: (KJS::ArrayInstance::put): Use take rather than
2537         a find followed by a remove.
2538
2539 2007-11-02  David Carson  <dacarson@gmail.com>
2540
2541         Reviewed by Darin.
2542
2543         Fix compiler warning "warning: suggest parentheses around && within ||"
2544         http://bugs.webkit.org/show_bug.cgi?id=15764
2545
2546         * kjs/value.h: (KJS::JSValue::isNumber): Add parentheses.
2547
2548 2007-11-01  Geoffrey Garen  <ggaren@apple.com>
2549
2550         Reviewed by Maciej Stachowiak.
2551         
2552         In preparation for making List a simple stack-allocated Vector:
2553
2554         Removed all instances of List copying and/or assignment, and made List 
2555         inherit from Noncopyable.
2556         
2557         Functions that used to return a List by copy now take List& out 
2558         parameters.
2559         
2560         Layout tests and JS tests pass.
2561
2562         * kjs/list.cpp:
2563         (KJS::List::slice): Replaced copyTail with a more generic slice 
2564         alternative. (JavaScriptCore only calls slice(1), but WebCore calls 
2565         slice(2)).
2566
2567 2007-11-01  Geoffrey Garen  <ggaren@apple.com>
2568
2569         Reviewed by Maciej Stachowiak.
2570
2571         Fixed http://bugs.webkit.org/show_bug.cgi?id=15785
2572         REGRESSION(r27344): Crash on load at finance.yahoo.com
2573         
2574         Reverted a small portion of my last check-in. (The speedup and the List 
2575         removal are still there, though.)
2576         
2577         ActivationImp needs to hold a pointer to its function, and mark that 
2578         pointer (rather than accessing its function through its ExecState, and 
2579         counting on the active scope to mark its function) because a closure 
2580         can cause an ActivationImp to outlive its ExecState along with any 
2581         active scope.
2582
2583         * kjs/ExecState.cpp:
2584         (KJS::ExecState::ExecState):
2585         * kjs/function.cpp:
2586         (KJS::FunctionImp::~FunctionImp):
2587         (KJS::ActivationImp::ActivationImp):
2588         * kjs/function.h:
2589         (KJS::ActivationImp::ActivationImpPrivate::ActivationImpPrivate):
2590
2591         Also made HashTable a little more crash-happy in debug builds, so 
2592         problems like this will show up earlier:
2593         
2594         * wtf/HashTable.h:
2595         (WTF::HashTable::~HashTable):
2596
2597 2007-11-01  Geoffrey Garen  <ggaren@apple.com>
2598
2599         Reviewed by Adam Roben.
2600         
2601         Addressed some of Darin's review comments.
2602         
2603         Used perl -p, which is the shorthand while(<>) {}.
2604         
2605         Made sure not to suppress bison's output.
2606         
2607         Added line to removed bison_out.txt, since this script removes other 
2608         intermediate files, too.
2609
2610         * DerivedSources.make:
2611
2612 2007-11-01  Geoffrey Garen  <ggaren@apple.com>
2613
2614         Reviewed by Oliver Hunt.
2615         
2616         Removed List from ActivationImp, in preparation for making all lists
2617         stack-allocated.
2618         
2619         Tests pass.
2620         
2621         1.0% speedup on SunSpider, presumably due to reduced List refcount thrash.
2622
2623         * kjs/ExecState.cpp:
2624         (KJS::ExecState::ExecState):
2625         (KJS::ExecState::~ExecState):
2626         * kjs/function.cpp:
2627         (KJS::ActivationImp::ActivationImp):
2628         (KJS::ActivationImp::createArgumentsObject):
2629         * kjs/function.h:
2630         (KJS::ActivationImp::ActivationImpPrivate::ActivationImpPrivate):
2631
2632 2007-11-01  Adam Roben  <aroben@apple.com>
2633
2634         Use jsNumberCell instead of jsNumber when converting double constants to JSValues
2635
2636         This fixes fast/js/math.html, ecma/Date/15.9.5.10-1.js, and
2637         ecma/Date/15.9.5.12-1.js, which were suffering from a bug in MSVC.
2638
2639         It also gets rid of an MSVC warning that we previously had to silence.
2640
2641         Reviewed by Geoff.
2642
2643         * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: Turn
2644         back on the "overflow in constant arithmetic" warning.
2645         * kjs/number_object.cpp:
2646         (NumberObjectImp::getValueProperty): Use jsNumberCell instead of
2647         jsNumber.
2648
2649 2007-10-31  Adam Roben  <aroben@apple.com>
2650
2651         Windows build fix
2652
2653         * kjs/ExecState.h:
2654
2655 2007-10-31  Maciej Stachowiak  <mjs@apple.com>
2656
2657         Reviewed by Oliver.
2658         
2659         - shave some cycles off of local storage access for a 1% SunSpider speedup
2660         
2661         Keep the LocalStorage pointer in the ExecState, instead of getting
2662         it from the ActivationImp all the time.
2663
2664         * kjs/ExecState.cpp:
2665         (KJS::ExecState::updateLocalStorage):
2666         * kjs/ExecState.h:
2667         (KJS::ExecState::localStorage):
2668         * kjs/nodes.cpp:
2669         (KJS::LocalVarAccessNode::evaluate):
2670         (KJS::LocalVarFunctionCallNode::evaluate):
2671         (KJS::PostIncLocalVarNode::evaluate):
2672         (KJS::PostDecLocalVarNode::evaluate):
2673         (KJS::LocalVarTypeOfNode::evaluate):
2674         (KJS::PreIncLocalVarNode::evaluate):
2675         (KJS::PreDecLocalVarNode::evaluate):
2676         (KJS::ReadModifyLocalVarNode::evaluate):
2677         (KJS::AssignLocalVarNode::evaluate):
2678         (KJS::FunctionBodyNode::processDeclarationsForFunctionCode):
2679
2680 2007-10-31  Adam Roben  <aroben@apple.com>
2681
2682         Fix a crash on launch due to a static initializer race
2683
2684         We now use fast inline assembler spinlocks which can be statically
2685         initialized at compile time.
2686
2687         As a side benefit, this speeds up SunSpider by 0.4%.
2688
2689         Reviewed by Oliver.
2690
2691         * wtf/FastMalloc.cpp:
2692         * wtf/TCSpinLock.h:
2693         (TCMalloc_SpinLock::Lock):
2694         (TCMalloc_SpinLock::Unlock):
2695         (TCMalloc_SlowLock):
2696         * wtf/TCSystemAlloc.cpp:
2697
2698 2007-10-31  Kevin McCullough  <kmccullough@apple.com>
2699
2700         Reviewed by Sam.
2701
2702         - Corrected spelling.
2703
2704         * wtf/HashTraits.h:
2705
2706 2007-10-31  Mark Rowe  <mrowe@apple.com>
2707
2708         Further Gtk build fixage.
2709
2710         * kjs/regexp_object.cpp:
2711
2712 2007-10-31  Mark Rowe  <mrowe@apple.com>
2713
2714         Gtk build fix.
2715
2716         * kjs/regexp.h:
2717
2718 2007-10-31  Darin Adler  <darin@apple.com>
2719
2720         Reviewed by Maciej.
2721
2722         - fix http://bugs.webkit.org/show_bug.cgi?id=15749
2723           RegExp/RegExpObjectImp cause needless UString creation
2724
2725         Speeds things up 0.4% according to SunSpider.
2726
2727         * kjs/config.h: Define USE(PCRE16) instead of HAVE(PCREPOSIX),
2728         because this library doesn't use the real PCRE -- it uses its
2729         own PCRE that works on UTF-16.
2730
2731         * kjs/regexp.h: Removed a few unused functions. Changed the ifdef.
2732         Use Noncopyable. Change the return value of match.
2733         * kjs/regexp.cpp:
2734         (KJS::RegExp::RegExp): Call pcre_compile2, for a slight speed boost.
2735         (KJS::RegExp::~RegExp): PCRE16 rather than PCREPOSIX.
2736         (KJS::RegExp::match): Change to return the position as an int and the
2737         ovector as a OwnArrayPtr<int> for efficiency and clearer storage management.
2738
2739         * kjs/regexp_object.h: Change performMatch and arrayOfMatches to no longer
2740         require a result string.
2741         * kjs/regexp_object.cpp:
2742         (RegExpProtoFunc::callAsFunction): Update for new signature of performMatch.
2743         (RegExpObjectImp::performMatch): Change so it doesn't return a string.
2744         (RegExpObjectImp::arrayOfMatches): Simplify by unifying the handling of
2745         the main result with the backreferences; now it doesn't need to take
2746         a result parameter.
2747         (RegExpObjectImp::getBackref): Minor tweaks.
2748         (RegExpObjectImp::getLastParen): Ditto.
2749         (RegExpObjectImp::getLeftContext): Ditto.
2750         (RegExpObjectImp::getRightContext): Ditto.
2751         (RegExpObjectImp::getValueProperty): Change LastMatch case to call
2752         getBackref(0) so we don't need a separate getLastMatch function.
2753
2754         * kjs/string_object.cpp:
2755         (KJS::replace): Update to use new performMatch, including merging the
2756         matched string section with the other substrings.
2757         (KJS::StringProtoFunc::callAsFunction): Update functions to use the
2758         new performMatch and match. Also change to use OwnArrayPtr.
2759
2760 2007-10-31  Oliver Hunt  <oliver@apple.com>
2761
2762         * kjs/nodes.h: include OwnPtr.h
2763
2764 2007-10-31  Oliver Hunt  <oliver@apple.com>
2765
2766         Reviewed by Maciej.
2767
2768         Remove SourceCodeElement class and replaced with a Vector for a 0.8% gain on sunspider
2769
2770         * kjs/grammar.y:
2771         * kjs/nodes.cpp:
2772         (KJS::statementListPushFIFO):
2773         (KJS::statementListGetDeclarations):
2774         (KJS::statementListInitializeDeclarationStacks):
2775         (KJS::statementListInitializeVariableAccessStack):
2776         (KJS::statementListExecute):
2777         (KJS::BlockNode::optimizeVariableAccess):
2778         (KJS::BlockNode::BlockNode):
2779         (KJS::BlockNode::getDeclarations):
2780         (KJS::BlockNode::execute):
2781         (KJS::CaseClauseNode::optimizeVariableAccess):
2782         (KJS::CaseClauseNode::getDeclarations):
2783         (KJS::CaseClauseNode::evalStatements):
2784         (KJS::FunctionBodyNode::initializeDeclarationStacks):
2785         (KJS::FunctionBodyNode::optimizeVariableAccess):
2786         * kjs/nodes.h:
2787         * kjs/nodes2string.cpp:
2788         (KJS::statementListStreamTo):
2789         (KJS::BlockNode::streamTo):
2790         (KJS::CaseClauseNode::streamTo):
2791
2792 2007-10-30  Mark Rowe  <mrowe@apple.com>
2793
2794         * kjs/property_map.cpp: Added a missing using directive to fix the build
2795         for non-Mac ports. Mac worked only because it does the AllInOneFile compile.
2796
2797 2007-10-31  Maciej Stachowiak  <mjs@apple.com>
2798
2799         * kjs/property_map.cpp: Include HashTable.h the right way to fix the build
2800         for non-Mac ports.
2801
2802 2007-10-31  Alexey Proskuryakov  <ap@webkit.org>
2803
2804         Reviewed by Darin.
2805
2806         http://bugs.webkit.org/show_bug.cgi?id=11001
2807         WebKit doesn't support RegExp.compile method
2808
2809         Test: fast/js/regexp-compile.html
2810
2811         * kjs/regexp_object.cpp:
2812         (RegExpPrototype::RegExpPrototype):
2813         (RegExpProtoFunc::callAsFunction):
2814         * kjs/regexp_object.h:
2815         (KJS::RegExpProtoFunc::):
2816         Added RegExp.compile.
2817
2818         * tests/mozilla/expected.html: js1_2/regexp/compile.js now passes.
2819
2820 2007-10-31  Maciej Stachowiak  <mjs@apple.com>
2821
2822         Reviewed by Oliver.
2823         
2824         - get rid of integer divide in PropertyMap and HashTable for 1% SunSpider speedup
2825         
2826         Integer divide sucks. Fortunately, a bunch of shifts and XORs
2827         biased towards the high bits is sufficient to provide a good
2828         double hash. Besides the SunSpider win, I used the dump statistics
2829         mode for both to verify that collisions did not increase and that
2830         the longest collision chain is not any longer.
2831
2832         * kjs/property_map.cpp:
2833         (KJS::doubleHash):
2834         (KJS::PropertyMap::get):
2835         (KJS::PropertyMap::getLocation):
2836         (KJS::PropertyMap::put):
2837         (KJS::PropertyMap::insert):
2838         (KJS::PropertyMap::remove):
2839         (KJS::PropertyMap::checkConsistency):
2840         * wtf/HashTable.h:
2841         (WTF::doubleHash):
2842         (WTF::::lookup):
2843         (WTF::::lookupForWriting):
2844         (WTF::::fullLookupForWriting):
2845         (WTF::::add):
2846
2847 2007-10-30  Adam Roben  <aroben@apple.com>
2848
2849         * kjs/collector.h: Make HeapType public so it can be used for non-member
2850         things like the HeapConstants struct template. Fixes the build on Windows.
2851
2852 2007-10-30  Adam Roben  <aroben@apple.com>
2853
2854         Change ALWAYS_INLINE and WTF_PRIVATE_INLINE to use __forceinline on Windows
2855
2856         Speeds up SunSpider by 0.4%.
2857
2858         Reviewed by Steve and Maciej.
2859
2860         * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: Disable
2861         a warning during LTCG in release builds about double -> float
2862         conversion.
2863         * wtf/AlwaysInline.h:
2864         * wtf/FastMalloc.h:
2865
2866 2007-10-30  Adam Roben  <aroben@apple.com>
2867
2868         Use GetCurrentThreadId instead of pthread_self in FastMalloc
2869
2870         Speeds up SunSpider by 0.3%.
2871
2872         Reviewed by Steve.
2873
2874         * wtf/FastMalloc.cpp:
2875         (WTF::TCMalloc_ThreadCache::InitTSD):
2876         (WTF::TCMalloc_ThreadCache::CreateCacheIfNecessary):
2877
2878 2007-10-30  Adam Roben  <aroben@apple.com>
2879
2880         Switch to a Win32 critical section implementation of spinlocks
2881         
2882         Speeds up SunSpider by 0.4%.
2883         
2884         Reviewed by Steve.
2885         
2886         * wtf/FastMalloc.cpp:
2887         * wtf/TCSpinLock.h:
2888         (TCMalloc_SpinLock::TCMalloc_SpinLock):
2889         (TCMalloc_SpinLock::Init):
2890         (TCMalloc_SpinLock::Finalize):
2891         (TCMalloc_SpinLock::Lock):
2892         (TCMalloc_SpinLock::Unlock):
2893         * wtf/TCSystemAlloc.cpp:
2894
2895 2007-10-30  Adam Roben  <aroben@apple.com>
2896
2897         Fix Bug 15586: REGRESSION (r26759-r26785): Windows nightly builds crash with Safari 3 Public Beta
2898
2899         http://bugs.webkit.org/show_bug.cgi?id=15586
2900
2901         Also fixes: <rdar://5565303> Cannot use regsvr32.exe to register WebKit.dll
2902
2903         Use Win32 TLS functions instead of __declspec(thread), which breaks
2904         delay-loading.
2905
2906         Reviewed by Steve.
2907
2908         * wtf/FastMalloc.cpp:
2909         (WTF::getThreadHeap):
2910         (WTF::TCMalloc_ThreadCache::InitModule):
2911
2912 2007-10-30  Maciej Stachowiak  <mjs@apple.com>
2913
2914         Reviewed by Oliver.
2915         
2916         - allocate numbers in half-size cells, for an 0.5% SunSpider speedup
2917         http://bugs.webkit.org/show_bug.cgi?id=15772
2918         
2919         We do this by using a single mark bit per two number cells, and
2920         tweaking marking.
2921         
2922         Besides being an 0.5% win overall, this is a 7.1% win on morph.
2923
2924         * kjs/collector.cpp:
2925         (KJS::):
2926         (KJS::Collector::heapAllocate):
2927         (KJS::Collector::markStackObjectsConservatively):
2928         (KJS::Collector::sweep):
2929         * kjs/collector.h:
2930         (KJS::SmallCollectorCell::):
2931
2932 2007-10-30  Geoffrey Garen  <ggaren@apple.com>
2933
2934         Reviewed by Adam Roben, Sam Weinig.
2935         
2936         Made conflicts in grammar.y a persistent build failure.
2937
2938         * DerivedSources.make:
2939
2940 2007-10-30  Kevin McCullough  <kmccullough@apple.com>
2941
2942         Reviewed by Adam and Geoff.
2943
2944         - Added a new cast so all the casts are in the same place.
2945
2946         * API/APICast.h:
2947         (toGlobalRef):
2948
2949 2007-10-30  Geoffrey Garen  <ggaren@apple.com>
2950
2951         Reviewed by Darin Adler.
2952
2953         Fixed <rdar://problem/5567504> shift/reduce conflict introduced in r24457
2954         
2955         JS tests, including 
2956
2957             ecma_2/Statements/dowhile-001.js
2958             ecma_2/Statements/dowhile-002.js
2959             ecma_2/Statements/dowhile-003.js
2960             ecma_2/Statements/dowhile-004.js
2961             ecma_2/Statements/dowhile-005.js
2962             ecma_2/Statements/dowhile-006.js
2963             ecma_2/Statements/dowhile-007.js
2964             js1_2/statements/do_while.js
2965
2966         and layout tests, including
2967
2968             do-while-expression-value.html
2969             do-while-semicolon.html
2970             do-while-without-semicolon.html
2971         
2972         pass.
2973         
2974         * kjs/grammar.y: Use the explicit "error" production, as we do with other
2975         automatic semicolon insertions, to disambiguate "do { } while();" from
2976         "do { } while()" followed by ";" (the empty statement).
2977
2978 2007-10-29  Oliver Hunt  <oliver@apple.com>
2979
2980         Reviewed by Maciej.
2981
2982         Debranching remaining assignment nodes, and miscellaneous cleanup
2983         
2984         Split read-modify code paths out of AssignBracketNode and AssignDotNode
2985         Removed now unnecessary check for write-only assignment in ReadModifyLocalVarNode 
2986         and ReadModifyResolveNode evaluate methods
2987
2988         Leads to a 1% gain in SunSpider.
2989
2990         * kjs/grammar.y:
2991         * kjs/nodes.cpp:
2992         (KJS::ReadModifyLocalVarNode::evaluate):
2993         (KJS::ReadModifyResolveNode::evaluate):
2994         (KJS::AssignDotNode::evaluate):
2995         (KJS::ReadModifyDotNode::optimizeVariableAccess):
2996         (KJS::ReadModifyDotNode::evaluate):
2997         (KJS::AssignBracketNode::evaluate):
2998         (KJS::ReadModifyBracketNode::optimizeVariableAccess):
2999         (KJS::ReadModifyBracketNode::evaluate):
3000         * kjs/nodes.h:
3001         (KJS::AssignBracketNode::):
3002         (KJS::AssignBracketNode::precedence):
3003         (KJS::AssignDotNode::):
3004         (KJS::AssignDotNode::precedence):
3005         * kjs/nodes2string.cpp:
3006         (KJS::ReadModifyBracketNode::streamTo):
3007         (KJS::AssignBracketNode::streamTo):
3008         (KJS::ReadModifyDotNode::streamTo):
3009         (KJS::AssignDotNode::streamTo):
3010
3011 2007-10-29  Oliver Hunt  <oliver@apple.com>
3012
3013         Debranching various Node::evaluate implementations
3014         
3015         Reviewed by Maciej.
3016         
3017         Split the read-modify-write assignment cases out of AssignResolveNode and into ReadModifyResolveNode
3018         Split the increment and decrement cases for Prefix- and Postfix- ResolveNode, BracketNode, and DotNode
3019         
3020         Gains 1.6% on SunSpider
3021
3022         * JavaScriptCore.xcodeproj/project.pbxproj:
3023         * kjs/grammar.y:
3024         * kjs/nodes.cpp:
3025         (KJS::PostIncResolveNode::optimizeVariableAccess):
3026         (KJS::PostIncResolveNode::evaluate):
3027         (KJS::PostIncLocalVarNode::evaluate):
3028         (KJS::PostDecResolveNode::optimizeVariableAccess):
3029         (KJS::PostDecResolveNode::evaluate):
3030         (KJS::PostDecLocalVarNode::evaluate):
3031         (KJS::PostIncBracketNode::evaluate):
3032         (KJS::PostDecBracketNode::evaluate):
3033         (KJS::PostIncDotNode::evaluate):
3034         (KJS::PostDecDotNode::evaluate):
3035         (KJS::PreIncResolveNode::optimizeVariableAccess):
3036         (KJS::PreIncLocalVarNode::evaluate):
3037         (KJS::PreIncResolveNode::evaluate):
3038         (KJS::PreDecResolveNode::optimizeVariableAccess):
3039         (KJS::PreDecLocalVarNode::evaluate):
3040         (KJS::PreDecResolveNode::evaluate):
3041         (KJS::PreIncBracketNode::evaluate):
3042         (KJS::PreDecBracketNode::evaluate):
3043         (KJS::PreIncDotNode::evaluate):
3044         (KJS::PreDecDotNode::evaluate):
3045         (KJS::ReadModifyResolveNode::optimizeVariableAccess):
3046         (KJS::AssignResolveNode::optimizeVariableAccess):
3047         (KJS::AssignLocalVarNode::evaluate):
3048         (KJS::AssignResolveNode::evaluate):
3049         * kjs/nodes.h:
3050         (KJS::PostDecResolveNode::):
3051         (KJS::PostDecResolveNode::precedence):
3052         (KJS::PostDecLocalVarNode::):
3053         (KJS::PostfixBracketNode::):
3054         (KJS::PostfixBracketNode::precedence):
3055         (KJS::PostIncBracketNode::):
3056         (KJS::PostIncBracketNode::isIncrement):
3057         (KJS::PostDecBracketNode::):
3058         (KJS::PostDecBracketNode::isIncrement):
3059         (KJS::PostfixDotNode::):
3060         (KJS::PostfixDotNode::precedence):
3061         (KJS::PostIncDotNode::):
3062         (KJS::PostIncDotNode::isIncrement):
3063         (KJS::PostDecDotNode::):
3064         (KJS::PreIncResolveNode::):
3065         (KJS::PreDecResolveNode::):
3066         (KJS::PreDecResolveNode::precedence):
3067         (KJS::PreDecLocalVarNode::):
3068         (KJS::PrefixBracketNode::):
3069         (KJS::PrefixBracketNode::precedence):
3070         (KJS::PreIncBracketNode::):
3071         (KJS::PreIncBracketNode::isIncrement):
3072         (KJS::PreDecBracketNode::):
3073         (KJS::PreDecBracketNode::isIncrement):
3074         (KJS::PrefixDotNode::):
3075         (KJS::PrefixDotNode::precedence):
3076         (KJS::PreIncDotNode::):
3077         (KJS::PreIncDotNode::isIncrement):
3078         (KJS::PreDecDotNode::):
3079         (KJS::ReadModifyResolveNode::):
3080         (KJS::ReadModifyLocalVarNode::):
3081         (KJS::AssignResolveNode::):
3082         (KJS::AssignResolveNode::precedence):
3083         * kjs/nodes2string.cpp:
3084         (KJS::PostIncResolveNode::streamTo):
3085         (KJS::PostDecResolveNode::streamTo):
3086         (KJS::PostfixBracketNode::streamTo):
3087         (KJS::PostfixDotNode::streamTo):
3088         (KJS::PreIncResolveNode::streamTo):
3089         (KJS::PreDecResolveNode::streamTo):
3090         (KJS::ReadModifyResolveNode::streamTo):
3091         (KJS::AssignResolveNode::streamTo):
3092
3093 2007-10-29  Maciej Stachowiak  <mjs@apple.com>
3094
3095         Not reviewed, build fix.
3096         
3097         - Include Vector.h in a way that actually works.
3098
3099         * kjs/LocalStorage.h:
3100
3101 2007-10-29  Maciej Stachowiak  <mjs@apple.com>
3102
3103         Not reviewed, build fix.
3104         
3105         - Install LocalStorage.h as a private header.
3106
3107         * JavaScriptCore.xcodeproj/project.pbxproj:
3108
3109 2007-10-29  Maciej Stachowiak  <mjs@apple.com>
3110
3111         Reviewed by Darin.
3112         
3113         - Define good VectorTraits for LocalStorage entry for 0.5% speed improvement on SunSpider.
3114
3115         * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
3116         * JavaScriptCore.xcodeproj/project.pbxproj:
3117         * kjs/LocalStorage.h: Added.
3118         (KJS::LocalStorageEntry::LocalStorageEntry):
3119         (WTF::):
3120         * kjs/function.h:
3121         * kjs/nodes.cpp:
3122         (KJS::FunctionBodyNode::processDeclarationsForFunctionCode):
3123
3124 2007-10-29  Geoffrey Garen  <ggaren@apple.com>
3125
3126         Reviewed by Oliver Hunt.
3127         
3128         Some small tweaks that I notice while reviewing Oliver's last patch.
3129         
3130         Includes removal of an unnecessary KJS_CHECKEXCEPTIONVALUE.
3131         
3132         No change in SunSpider because SunSpider doesn't take the code path that
3133         would execute the unnecessary KJS_CHECKEXCEPTIONVALUE much.
3134
3135         * kjs/nodes.cpp:
3136         (KJS::LocalVarPostfixNode::evaluate):
3137         (KJS::TypeOfResolveNode::optimizeVariableAccess):
3138         (KJS::LocalVarTypeOfNode::evaluate):
3139         (KJS::PrefixResolveNode::optimizeVariableAccess):
3140         (KJS::LocalVarPrefixNode::evaluate):
3141         (KJS::AssignResolveNode::optimizeVariableAccess):
3142         (KJS::LocalVarAssignNode::evaluate):
3143         * kjs/nodes.h:
3144         (KJS::LocalVarTypeOfNode::):
3145         (KJS::PrefixResolveNode::):
3146         (KJS::LocalVarPrefixNode::):
3147         (KJS::AssignResolveNode::):
3148         (KJS::LocalVarAssignNode::):
3149
3150 2007-10-29  Eric Seidel  <eric@webkit.org>
3151
3152         Reviewed by Maciej.
3153         
3154         SunSpider claims this was a 0.7% speedup.
3155
3156         * kjs/string_object.cpp:
3157         (KJS::StringProtoFunc::callAsFunction): avoid mallocing a jsString in the common case
3158
3159 2007-10-29  Maciej Stachowiak  <mjs@apple.com>
3160
3161         Reviewed by Mark.
3162         
3163         - re-enable asserts for access to empty or deleted keys
3164
3165         * wtf/HashTable.h:
3166         (WTF::::lookup):
3167         (WTF::::lookupForWriting):
3168         (WTF::::fullLookupForWriting):
3169         (WTF::::add):
3170
3171 2007-10-29  Eric Seidel  <eric@webkit.org>
3172
3173         Build fix only, no review.
3174
3175         * JavaScriptCore.exp: Export symbol for new StringInstance::getOwnPropertySlot
3176
3177 2007-10-29  Mark Rowe  <mrowe@apple.com>
3178
3179         Gtk build fix.  Move struct declarations into nodes.h.
3180
3181         * kjs/grammar.y:
3182         * kjs/nodes.h:
3183
3184 2007-10-29  Eric Seidel  <eric@webkit.org>
3185
3186         Reviewed by darin.
3187         
3188         Give StringInstance a getOwnPropertySlot(ExecState, unsigned, PropertySlot) fastpath, just like Arrays.
3189         Make it a compile time error to use toString(ExecState) on a StringInstance
3190         
3191         SunSpider claims this was a 6.6% speedup overall (22% on string-base64)
3192
3193         * kjs/internal.h:
3194         (KJS::StringImp::getLength):
3195         * kjs/string_object.cpp:
3196         (KJS::StringInstance::lengthGetter):
3197         (KJS::StringInstance::inlineGetOwnPropertySlot):
3198         (KJS::StringInstance::getOwnPropertySlot):
3199         * kjs/string_object.h:
3200
3201 2007-10-28  Oliver Hunt  <oliver@apple.com>
3202
3203         Reviewed by Darin.
3204
3205         Add nodes to allow Assignment, TypeOf, and prefix operators to 
3206         make use of the new optimised local variable look up.
3207
3208         5% gain on sunspider
3209
3210         * kjs/nodes.cpp:
3211         (KJS::TypeOfResolveNode::optimizeVariableAccess):
3212         (KJS::LocalTypeOfAccessNode::evaluate):
3213         (KJS::PrefixResolveNode::optimizeVariableAccess):
3214         (KJS::PrefixLocalAccessNode::evaluate):
3215         (KJS::AssignResolveNode::optimizeVariableAccess):
3216         (KJS::AssignLocalAccessNode::evaluate):
3217         * kjs/nodes.h:
3218         (KJS::TypeOfResolveNode::):
3219         (KJS::TypeOfResolveNode::precedence):
3220         (KJS::LocalTypeOfAccessNode::):
3221         (KJS::PrefixResolveNode::):
3222         (KJS::PrefixResolveNode::precedence):
3223         (KJS::PrefixLocalAccessNode::):
3224         (KJS::AssignResolveNode::):
3225         (KJS::AssignLocalAccessNode::):
3226
3227 2007-10-28  Maciej Stachowiak  <mjs@apple.com>
3228
3229         Reviewed by Darin.
3230         
3231         - avoid creating and then breaking circular lists in the parser, instead track head and tail pointers at parse time
3232         http://bugs.webkit.org/show_bug.cgi?id=15748
3233         
3234         Not a significant speedup or slowdown on SunSpider.
3235
3236         * kjs/Parser.cpp:
3237         (KJS::clearNewNodes):
3238         * kjs/Parser.h:
3239         * kjs/grammar.y:
3240         * kjs/nodes.cpp:
3241         (KJS::BlockNode::BlockNode):
3242         (KJS::CaseBlockNode::CaseBlockNode):
3243         (KJS::FunctionBodyNode::FunctionBodyNode):
3244         (KJS::SourceElementsNode::SourceElementsNode):
3245         (KJS::ProgramNode::ProgramNode):
3246         * kjs/nodes.h:
3247         (KJS::ElementNode::):
3248         (KJS::ArrayNode::):
3249         (KJS::PropertyListNode::):
3250         (KJS::ObjectLiteralNode::):
3251         (KJS::ArgumentListNode::):
3252         (KJS::ArgumentsNode::):
3253         (KJS::VarDeclListNode::):
3254         (KJS::VarStatementNode::):
3255         (KJS::ForNode::):
3256         (KJS::ParameterNode::):
3257         (KJS::FuncExprNode::):
3258         (KJS::FuncDeclNode::):
3259         (KJS::SourceElementsNode::):
3260         (KJS::CaseClauseNode::):
3261         (KJS::ClauseListNode::):
3262
3263 2007-10-28  Mark Rowe  <mrowe@apple.com>
3264
3265         Disable assertions in a manner that doesn't break the Qt Windows build.
3266
3267         * wtf/HashTable.h:
3268         (WTF::::lookup):
3269         (WTF::::lookupForWriting):
3270         (WTF::::fullLookupForWriting):
3271
3272 2007-10-28  Geoffrey Garen  <ggaren@apple.com>
3273
3274         Temporarily disabling some ASSERTs I introduced in my last check-in 
3275         because of http://bugs.webkit.org/show_bug.cgi?id=15747
3276         Lots of layout tests fail the !HashTranslator::equal(KeyTraits::emptyValue() ASSERT
3277
3278         * wtf/HashTable.h:
3279         (WTF::::lookup):
3280         (WTF::::lookupForWriting):
3281         (WTF::::fullLookupForWriting):
3282         (WTF::::add):
3283
3284 2007-10-28  Geoffrey Garen  <ggaren@apple.com>
3285
3286         Reviewed by Darin Adler.
3287         
3288         Fixed http://bugs.webkit.org/show_bug.cgi?id=15746
3289         #ifndef ASSERT_DISABLED is no good!
3290         
3291         Replaced with #if !ASSERT_DISABLED.
3292
3293         * wtf/HashTable.h:
3294         (WTF::::lookup):
3295         (WTF::::lookupForWriting):
3296         (WTF::::fullLookupForWriting):
3297         (WTF::::add):
3298
3299 2007-10-28  Geoffrey Garen  <ggaren@apple.com>
3300
3301         Reviewed by Darin Adler.
3302         
3303         Added FunctionCallResolveNode, PostfixResolveNode, and DeleteResolveNode
3304         to the AST transfom that replaces slow resolve nodes with fast local 
3305         variable alternatives.
3306         
3307         2.5% speedup on SunSpider.
3308         
3309         Also added some missing copyright notices.
3310         
3311         * kjs/nodes.cpp:
3312         (KJS::FunctionCallResolveNode::optimizeVariableAccess):
3313         (KJS::FunctionCallResolveNode::evaluate):
3314         (KJS::LocalVarFunctionCallNode::evaluate):
3315         (KJS::PostfixResolveNode::optimizeVariableAccess):
3316         (KJS::PostfixResolveNode::evaluate):
3317         (KJS::LocalVarPostfixNode::evaluate):
3318         (KJS::DeleteResolveNode::optimizeVariableAccess):
3319         (KJS::DeleteResolveNode::evaluate):
3320         (KJS::LocalVarDeleteNode::evaluate):
3321         * kjs/nodes.h:
3322         (KJS::FunctionCallResolveNode::):
3323         (KJS::LocalVarFunctionCallNode::LocalVarFunctionCallNode):
3324         (KJS::PostfixResolveNode::):
3325         (KJS::LocalVarPostfixNode::LocalVarPostfixNode):
3326         (KJS::DeleteResolveNode::):
3327         (KJS::LocalVarDeleteNode::LocalVarDeleteNode):
3328
3329 2007-10-28  Eric Seidel  <eric@webkit.org>
3330
3331         Reviewed by darin.
3332         
3333         Inline UString::Rep::deref() for a 0.8% improvement in SunSpider
3334         Add virtual keyword to a few virtual functions previously unmarked.
3335
3336         * kjs/internal.h:
3337         (KJS::StringImp::type):
3338         (KJS::NumberImp::type):
3339         * kjs/ustring.h:
3340         (KJS::UString::Rep::deref):
3341
3342 2007-10-28  Darin Adler  <darin@apple.com>
3343
3344         - fix "broken everything" from the storage leak fix
3345
3346         * wtf/RefPtr.h: (WTF::RefPtr::RefPtr): Added a PlacementNewAdopt constructor.
3347         * kjs/ustring.h: (KJS::UString::UString): Pass PlacementNewAdopt along to RefPtr.
3348
3349 2007-10-28  Darin Adler  <darin@apple.com>
3350
3351         Reviewed by Adam.
3352
3353         - turn on unused parameter waring on Mac OS X because it's already on elsewhere
3354
3355         * Configurations/Base.xcconfig: Took out -wno-unused-parameter.
3356
3357         * API/JSNode.c:
3358         * API/JSNodeList.c:
3359         * API/minidom.c:
3360         * API/testapi.c:
3361         Fixed unused variables by using them or marked them with UNUSED_PARAM.
3362
3363         * kjs/CollectorHeapIntrospector.h: (KJS::CollectorHeapIntrospector::zoneCalloc):
3364         Removed parameter names to indicate they are unused.
3365
3366 2007-10-28  Darin Adler  <darin@apple.com>
3367
3368         Reviewed by Maciej.
3369
3370         - fix a storage leak where we ref the UString every time we replace
3371           a ResolveNode with a LocalVarAccessNode
3372
3373         * kjs/identifier.h: (KJS::Identifier::Identifier): Added a constructor
3374         that takes PlacementNewAdopt.
3375
3376         * kjs/nodes.h: (KJS::ResolveNode::ResolveNode): Initialize the ident
3377         with PlacementNewAdopt instead of the old value of ident.
3378
3379         * kjs/ustring.h: (KJS::UString::UString): Added a constructor that
3380         takes PlacementNewAdopt.
3381
3382 2007-10-28  Darin Adler  <darin@apple.com>
3383
3384         - Windows build fix; get rid of unused parameter
3385
3386         * kjs/nodes.cpp: (KJS::ResolveNode::optimizeVariableAccess): Don't pass it.
3387         * kjs/nodes.h: (KJS::LocalVarAccessNode::LocalVarAccessNode): Remove it.
3388         The assertions weren't all that helpful.
3389
3390 2007-10-28  Mark Rowe  <mrowe@apple.com>
3391
3392         Gtk build fix.  Add include of MathExtras.h.
3393
3394         * kjs/string_object.cpp:
3395
3396 2007-10-28  Mark Rowe  <mrowe@apple.com>
3397
3398         Reviewed by Maciej and Tim.
3399
3400         Replace uses of isNaN and isInf with isnan and isinf, and
3401         remove isNaN and isInf.
3402
3403         * kjs/config.h: Remove unused HAVE_'s.
3404         * kjs/date_object.cpp:
3405         (KJS::DateInstance::getTime):
3406         (KJS::DateInstance::getUTCTime):
3407         (KJS::DateProtoFunc::callAsFunction):
3408         (KJS::DateObjectImp::construct):
3409         (KJS::DateObjectFuncImp::callAsFunction):
3410         * kjs/function.cpp:
3411         (KJS::GlobalFuncImp::callAsFunction):
3412         * kjs/math_object.cpp:
3413         (MathFuncImp::callAsFunction):
3414         * kjs/nodes2string.cpp:
3415         (KJS::isParserRoundTripNumber):
3416         * kjs/number_object.cpp:
3417         (NumberProtoFunc::callAsFunction):
3418         * kjs/operations.cpp:
3419         * kjs/operations.h:
3420         * kjs/string_object.cpp:
3421         (KJS::StringProtoFunc::callAsFunction):
3422         * kjs/ustring.cpp:
3423         (KJS::UString::from):
3424         * kjs/value.cpp:
3425         (KJS::JSValue::toInteger):
3426         (KJS::JSValue::toInt32SlowCase):
3427         (KJS::JSValue::toUInt32SlowCase):
3428
3429 2007-10-28  Geoffrey Garen  <ggaren@apple.com>
3430
3431         Build fix: use the new-fangled missingSymbolMarker().
3432
3433         * kjs/nodes.cpp:
3434         (KJS::ResolveNode::optimizeVariableAccess):
3435         * kjs/nodes.h:
3436         (KJS::LocalVarAccessNode::LocalVarAccessNode):
3437
3438 2007-10-28  Geoffrey Garen  <ggaren@apple.com>
3439
3440         Reviewed by Maciej Stachowiak, Darin Adler.
3441         
3442         Much supporting work done by Maciej Stachowiak, Maks Orlovich, and 
3443         Cameron Zwarich.
3444         
3445         AST transfom to replace slow resolve nodes with fast local variable
3446         alternatives that do direct memory access. Currently, only ResolveNode
3447         provides a fast local variable alternative. 6 others are soon to come.
3448         
3449         16.7% speedup on SunSpider.
3450         
3451         Most of this patch is just scaffolding to support iterating all the 
3452         resolve nodes in the AST through optimizeResolveNodes(). In 
3453         optimizeResolveNodes(), most classes just push their child nodes onto 
3454         the processing stack, while ResolveNodes actually replace themselves in 
3455         the tree with more optimized alternatives, if possible.
3456
3457         Here are the interesting bits:
3458
3459         * kjs/nodes.h: Added PlacementNewAdoptTag, along with implementations 
3460         in Node and ResolveNode. This tag allows you to use placement new to 
3461         swap out a base class Node in favor of a subclass copy that holds the
3462         same data. (Without this tag, default initialization would NULL out
3463         RefPtrs, change line numbers, etc.)
3464
3465         * kjs/nodes.cpp:
3466         (KJS::ResolveNode::evaluate): Since we're taking the slow path, ASSERT
3467         that the fast path is impossible, to make sure we didn't leave anything
3468         on the table.
3469
3470         (KJS::FunctionBodyNode::optimizeResolveNodes): Here's where the AST 
3471         transformation happens.
3472         
3473         (KJS::ResolveNode::optimizeResolveNodes): Here's where the ResolveNode
3474         optimization happens.
3475
3476         * kjs/function.h: Added symbolTable() accessor for, for the sake of 
3477         an ASSERT.
3478
3479 2007-10-28  Mark Rowe  <mrowe@apple.com>
3480
3481         Reviewed by Maciej.
3482
3483         Fix "AllInOneFile.o has a global initializer in it".
3484
3485         Some versions of gcc generate a global initializer for std::numeric_limits<size_t>::max().
3486         We can avoid this by moving it inside an inline function.
3487
3488         * kjs/SymbolTable.h:
3489         (KJS::missingSymbolMarker):
3490         * kjs/function.cpp:
3491         (KJS::ActivationImp::getOwnPropertySlot):
3492         (KJS::ActivationImp::put):
3493
3494 2007-10-28  Maciej Stachowiak  <mjs@apple.com>
3495
3496         Reviewed by Mark.
3497         
3498         - Added assertions to protect against adding empty or deleted keys to a HashTable
3499
3500         * wtf/HashTable.h:
3501         (WTF::HashTable::lookup):
3502         (WTF::HashTable::lookupForWriting):
3503         (WTF::HashTable::fullLookupForWriting):
3504         (WTF::HashTable::add):
3505
3506 2007-10-28  Darin Adler  <darin@apple.com>
3507
3508         - fix GTK build
3509
3510         * kjs/nodes2string.cpp: (KJS::isParserRoundTripNumber):
3511         Use isNaN and isInf instead of isnan and isinf.
3512
3513 2007-10-28  Darin Adler  <darin@apple.com>
3514
3515         Reviewed by Maciej.
3516
3517         - http://bugs.webkit.org/show_bug.cgi?id=15735
3518           remove GroupNode to simplify AST and possibly get a modest speedup
3519
3520         This patch removes 4 node types: GroupNode, PropertyNameNode,
3521         FunctionCallParenBracketNode, and FunctionCallParenDotNode.
3522
3523         To remove GroupNode, we add knowledge of precedence to the tree nodes,
3524         and use that when serializing to determine where parentheses are needed.
3525         This means we no longer have to represent parentheses in the tree.
3526
3527         The precedence values are named after productions in the grammar from the
3528         JavaScript standard.
3529
3530         SunSpider says this is an 0.4% speedup.
3531
3532         * kjs/function.h:
3533         * kjs/function.cpp: Removed escapeStringForPrettyPrinting -- it's part of
3534         serialization, so I moved it to the file that takes care of that.
3535
3536         * kjs/grammar.y: Changed makeGetterOrSetterPropertyNode to use 0 to
3537         indicate failure instead of a separate boolean. Got rid of PropertyNameNode
3538         by merging the PropertyName rule into the Property rule (which was easier
3539         than figuring out how to pass the Identifier from one node to another).
3540         Got rid of GroupNode, nodeInsideAllParens(), FunctionCallParenBracketNode,
3541         and FunctionCallParenDotNode.
3542
3543         * kjs/nodes.h: Removed unused forward declarations and Operator values.
3544         Added Precedence enum, and precedence function to all nodes. Removed
3545         nodeInsideAllParens. Added streamBinaryOperator function for serialization.
3546         Removed GroupNode and PropertyNameNode. Made PropertyNode store an Identifier.
3547         Removed FunctionCallParenBracketNode and FunctionCallParenDotNode.
3548
3549         * kjs/nodes.cpp: Removed Node::nodinsideAllParens, GroupNode, and PropertyNameNode.
3550         (KJS::PropertyListNode::evaluate): Changed code to get name directly instead
3551         of converting it from an Identifier to a jsString then back to a UString
3552         then into an Identifier again!
3553
3554         * kjs/nodes2string.cpp: Changed special-token implementation to use a separate
3555         function for each of Endl, Indent, Unindent, and DotExpr instead of using a
3556         single function with a switch. Added a precedence that you can stream in, to
3557         cause the next node serialized to add parentheses based on that precedence value.
3558         (KJS::operatorString): Moved to the top of the file.
3559         (KJS::escapeStringForPrettyPrinting): Moved here from function.cpp. Removed old
3560         workaround for snprintf, since StringExtras.h takes care of that.
3561         (KJS::operator<<): Made the char and char* versions faster by using UString's
3562         character append functions instead of constructing a UString. Added the logic
3563         to the Node* version to add parentheses if needed.
3564         (KJS::Node::streamLeftAssociativeBinaryOperator): Added helper function.
3565         (KJS::ElementNode::streamTo): Use PrecAssignment for the elements.
3566         (KJS::BracketAccessorNode::streamTo): Use PrecCall for the expression before
3567         the bracket.
3568         (KJS::DotAccessorNode::streamTo): Use PrecCall for the expression before the dot.
3569         (KJS::ArgumentListNode::streamTo): Use PrecAssignment for the arguments.
3570         (KJS::NewExprNode::streamTo): Use PrecMember for the expression.
3571         (KJS::FunctionCallValueNode::streamTo): Use PrecCall.
3572         (KJS::FunctionCallBracketNode::streamTo): Ditto.
3573         (KJS::FunctionCallDotNode::streamTo): Ditto.
3574         (KJS::PostfixBracketNode::streamTo): Ditto.
3575         (KJS::PostfixDotNode::streamTo): Ditto.
3576         (KJS::PostfixErrorNode::streamTo): Use PrecLeftHandSide.
3577         (KJS::DeleteBracketNode::streamTo): Use PrecCall.
3578         (KJS::DeleteDotNode::streamTo): Ditto.
3579         (KJS::DeleteValueNode::streamTo): Use PrecUnary.
3580         (KJS::VoidNode::streamTo): Ditto.
3581         (KJS::TypeOfValueNode::streamTo): Ditto.
3582         (KJS::PrefixBracketNode::streamTo): Use PrecCall.
3583         (KJS::PrefixDotNode::streamTo): Ditto.
3584         (KJS::PrefixErrorNode::streamTo): Use PrecUnary.
3585         (KJS::UnaryPlusNode::streamTo): Ditto.
3586         (KJS::NegateNode::streamTo): Ditto.
3587         (KJS::BitwiseNotNode::streamTo): Ditto.
3588         (KJS::LogicalNotNode::streamTo): Ditto.
3589         (KJS::MultNode::streamTo): Use streamLeftAssociativeBinaryOperator.
3590         (KJS::DivNode::streamTo): Ditto.
3591         (KJS::ModNode::streamTo): Ditto.
3592         (KJS::AddNode::streamTo): Ditto.
3593         (KJS::SubNode::streamTo): Ditto.
3594         (KJS::LeftShiftNode::streamTo): Ditto.
3595         (KJS::RightShiftNode::streamTo): Ditto.
3596         (KJS::UnsignedRightShiftNode::streamTo): Ditto.
3597         (KJS::LessNode::streamTo): Ditto.
3598         (KJS::GreaterNode::streamTo): Ditto.
3599         (KJS::LessEqNode::streamTo): Ditto.
3600         (KJS::GreaterEqNode::streamTo): Ditto.
3601         (KJS::InstanceOfNode::streamTo): Ditto.
3602         (KJS::InNode::streamTo): Ditto.
3603         (KJS::EqualNode::streamTo): Ditto.
3604         (KJS::NotEqualNode::streamTo): Ditto.
3605         (KJS::StrictEqualNode::streamTo): Ditto.
3606         (KJS::NotStrictEqualNode::streamTo): Ditto.
3607         (KJS::BitAndNode::streamTo): Ditto.
3608         (KJS::BitXOrNode::streamTo): Ditto.
3609         (KJS::BitOrNode::streamTo): Ditto.
3610         (KJS::LogicalAndNode::streamTo): Ditto.
3611         (KJS::LogicalOrNode::streamTo): Ditto.
3612         (KJS::ConditionalNode::streamTo): Ditto.
3613         (KJS::AssignResolveNode::streamTo): Use PrecAssignment for the right side.
3614         (KJS::AssignBracketNode::streamTo): Use PrecCall for the expression before
3615         the bracket and PrecAssignment for the right side.
3616         (KJS::AssignDotNode::streamTo): Ditto.
3617         (KJS::AssignErrorNode::streamTo): Use PrecLeftHandSide for the left side
3618         and PrecAssignment for the right side.
3619         (KJS::CommaNode::streamTo): Use PrecAssignment for both expressions.
3620         (KJS::AssignExprNode::streamTo): Use PrecAssignment.
3621
3622 2007-10-28  Kevin Ollivier  <kevino@theolliviers.com>
3623
3624         Define wx port and set wx port USE options.
3625
3626         Reviewed by Adam Roben.
3627
3628         * wtf/Platform.h:
3629
3630 2007-10-28  Mark Rowe  <mrowe@apple.com>
3631
3632         We don't include "config.h" in headers.
3633
3634         * bindings/jni/jni_instance.h:
3635         * kjs/regexp.h:
3636         * wtf/TCPageMap.h:
3637         * wtf/TCSpinLock.h:
3638
3639 2007-10-28  Maciej Stachowiak  <mjs@apple.com>
3640
3641         Rubber stamped by Mark.
3642         
3643         - avoid using non-portable SIZE_T_MAX in favor of std::numeric_limits
3644
3645         * kjs/SymbolTable.h:
3646         (KJS::SymbolTableIndexHashTraits::emptyValue):
3647         * kjs/function.cpp:
3648         (KJS::ActivationImp::getOwnPropertySlot):
3649         (KJS::ActivationImp::put):
3650
3651 2007-10-28  Maciej Stachowiak  <mjs@apple.com>
3652
3653         Reviewed by Eric.
3654         
3655         - switch SymbolTable to be a HashMap instead of a PropertyMap for 3% SunSpider speedup
3656
3657         * kjs/SymbolTable.h:
3658         (KJS::IdentifierRepHash::hash): Special hash function for identifier reps.
3659         (KJS::IdentifierRepHash::equal): ditto
3660         (KJS::SymbolTableIndexHashTraits::emptyValue): Special HashTraits for the index value.
3661         (KJS::SymbolTable): change to a typedef for a HashMap.
3662         * kjs/function.cpp:
3663         (KJS::ActivationImp::getOwnPropertySlot): Adjusted for new SymbolTable API.
3664         (KJS::ActivationImp::deleteProperty): ditto
3665         (KJS::ActivationImp::put): ditto
3666
3667         * kjs/nodes.cpp:
3668         (KJS::FunctionBodyNode::initializesymbolTable): Adjusted, since
3669         you now have to store a UString::rep, not an identifier.
3670
3671 2007-10-27  Maciej Stachowiak  <mjs@apple.com>
3672
3673         Reviewed by Oliver.
3674         
3675         - numerous HashTable performance improvements
3676         
3677         This does not quite add up to a measurable win on SunSpider, but it allows a
3678         follow-on > 3% improvement and probably helps WebCore too.
3679         
3680         I made the following improvements, among others:
3681         
3682         - Made HashFunctions note whether it is ok to compare a real value with the equal() function
3683         to the empty or deleted value, and used this to optimize the comparisons done in hash lookup.
3684         
3685         - Specialized lookup so it doesn't have to do so many extra branches and build so many extra
3686         std::pairs for cases that don't need them. There are now four versions, one for read-only access,
3687         two for writing, and one folded directly into add() (these all were improvments).
3688         
3689         - Made HashMap::get() use lookup() directly instead of find() to avoid having to build iterators.
3690         
3691         - Made a special constructor for iterators that knows it points to
3692         a valid filled cell and so skips updating itself.
3693
3694         - Reordered memory accesses in the various lookup functions for better code generation
3695         
3696         - Made simple translators avoid passing a hash code around
3697         
3698         - Other minor tweaks
3699         
3700         * wtf/HashTable.h:
3701         (WTF::):
3702         (WTF::HashTableConstIterator::HashTableConstIterator):
3703         (WTF::HashTableIterator::HashTableIterator):
3704         (WTF::IdentityHashTranslator::translate):
3705         (WTF::HashTable::end):
3706         (WTF::HashTable::lookup):
3707         (WTF::HashTable::lookupForWriting):
3708         (WTF::HashTable::makeKnownGoodIterator):
3709         (WTF::HashTable::makeKnownGoodConstIterator):
3710         (WTF::::lookup):
3711         (WTF::::lookupForWriting):
3712         (WTF::::fullLookupForWriting):
3713         (WTF::::add):
3714         (WTF::::addPassingHashCode):
3715         (WTF::::reinsert):
3716         (WTF::::find):
3717         (WTF::::contains):
3718         * kjs/identifier.cpp:
3719         (WTF::):
3720         * wtf/HashFunctions.h:
3721         (WTF::):
3722         * wtf/HashMap.h:
3723         (WTF::):
3724         (WTF::::get):
3725         * wtf/HashSet.h:
3726         (WTF::):
3727         (WTF::::add):
3728         * wtf/ListHashSet.h:
3729         (WTF::ListHashSetTranslator::translate):
3730
3731 2007-10-27  Darin Adler  <darin@apple.com>
3732
3733         Reviewed by Eric.
3734
3735         - fix ASCIICType.h for some Windows compiles
3736
3737         * wtf/ASCIICType.h: Check the compiler, not the OS, since it's the
3738         compiler/library that has the wchar_t that is just a typedef.
3739
3740 2007-10-27  Kevin McCullough  <kmccullough@apple.com>
3741
3742         - BuildFix
3743         - Forgot to change the build step when I changed the filename.
3744
3745         * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
3746
3747 2007-10-27  Geoffrey Garen  <ggaren@apple.com>
3748
3749         Reviewed by Darin Adler.
3750         
3751         Fixed the rest of "ASSERTION FAILED: _hash in KJS::UString::Rep::
3752         computedHash()"
3753         http://bugs.webkit.org/show_bug.cgi?id=15718
3754
3755         * kjs/identifier.cpp: Fixed more cases where an Identifier didn't get a 
3756         hash value. Also changed O(n) strlen to O(1) check for empty string.
3757         (KJS::Identifier::add):
3758
3759         * kjs/ustring.cpp: Changed O(n) strlens to O(1) checks for empty string.
3760         (KJS::UString::UString):
3761         (KJS::UString::operator=):
3762
3763 2007-10-27  Darin Adler  <darin@apple.com>
3764
3765         Reviewed by Eric.
3766
3767         - fix pow on Windows
3768
3769         * wtf/MathExtras.h: (wtf_pow): Add a special case for MSVC, which has
3770         a "pow" function that does not properly handle the case where arg1 is
3771         NaN and arg2 is 0.
3772
3773         * kjs/math_object.cpp: (MathFuncImp::callAsFunction): Don't explicity
3774         specify "::pow" -- just "pow" is fine.
3775
3776 2007-10-27  Darin Adler  <darin@apple.com>
3777
3778         Reviewed by Maciej.
3779
3780         - http://bugs.webkit.org/show_bug.cgi?id=15711
3781           force JSImmediate to be inlined for roughly 1.2% SunSpider speedup
3782
3783         * kjs/JSImmediate.h: Put ALWAYS_INLINE on everything.
3784
3785         * kjs/object.h: Removed redundant includes.
3786         * kjs/value.h: Ditto.
3787
3788 2007-10-27  Maciej Stachowiak  <mjs@apple.com>
3789
3790         Reviewed by Mark.
3791         
3792         - fixed "ASSERTION FAILED: _hash in KJS::UString::Rep::computedHash()"
3793         http://bugs.webkit.org/show_bug.cgi?id=15718
3794
3795         * kjs/identifier.cpp:
3796         (KJS::Identifier::addSlowCase): Ensure that empty Identifiers have a hash computed,
3797         now that we count on all Identifiers already having one.
3798
3799 2007-10-27  Mark Rowe  <mrowe@apple.com>
3800
3801         Silence a warning.
3802
3803         * kjs/SymbolTable.h:
3804
3805 2007-10-27  Mark Rowe  <mrowe@apple.com>
3806
3807         Gtk build fix.
3808
3809         * kjs/function.h:
3810
3811 2007-10-26  Kevin McCullough  <kmccullough@apple.com>
3812
3813        Rubber stamp by Adam. 
3814
3815         - Renamed JSStringRefCOM to JSStringRefBSTR since it he only thing the
3816         files contain are functions that operate on BSTRs.
3817
3818         * API/JSStringRefBSTR.cpp: Copied from API/JSStringRefCOM.cpp.
3819         * API/JSStringRefBSTR.h: Copied from API/JSStringRefCOM.h.
3820         * API/JSStringRefCOM.cpp: Removed.
3821         * API/JSStringRefCOM.h: Removed.
3822         * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
3823
3824 2007-10-26  Kevin McCullough  <kmccullough@apple.com>
3825
3826         Reviewed by Adam.
3827
3828         - Made JSStringCreateWithBSTR capable of handling null BSTRs.
3829
3830         * API/JSStringRefCOM.cpp:
3831         (JSStringCreateWithBSTR):
3832
3833 2007-10-26  Sam Weinig  <sam@webkit.org>
3834
3835         Windows build fix.
3836
3837         * kjs/SymbolTable.h: Add header gaurd.
3838         * kjs/nodes.h: #include "SymbolTable.h"
3839
3840 2007-10-26  Geoffrey Garen  <ggaren@apple.com>
3841
3842         Suggested by Anders Carlsson.
3843         
3844         Fixed tyop.
3845
3846         * kjs/function.cpp:
3847         (KJS::ActivationImp::getOwnPropertySlot):
3848
3849 2007-10-26  Geoffrey Garen  <ggaren@apple.com>
3850
3851         Suggested by Darin Adler.
3852         
3853         Use computedHash(), which is safer than just directly accessing _hash.
3854
3855         * kjs/lookup.cpp:
3856         (KJS::Lookup::findEntry):
3857         (KJS::Lookup::find):
3858
3859 2007-10-26  Geoffrey Garen  <ggaren@apple.com>
3860
3861         Build fix: svn add SymbolTable.h
3862
3863         * kjs/SymbolTable.h: Added.
3864         (KJS::SymbolTable::set):
3865         (KJS::SymbolTable::get):
3866
3867 2007-10-26  Geoffrey Garen  <ggaren@apple.com>
3868
3869         Build fix: export SymbolTable.h to WebCore.
3870
3871         * JavaScriptCore.xcodeproj/project.pbxproj:
3872
3873 2007-10-26  Geoffrey Garen  <ggaren@apple.com>
3874
3875         Comment tweak suggested by Maciej.
3876
3877         * kjs/function.cpp:
3878         (KJS::ActivationImp::getOwnPropertySlot):
3879
3880 2007-10-26  Geoffrey Garen  <ggaren@apple.com>
3881
3882         Reviewed by Maciej Stachowiak.
3883         
3884         Tweaked property maps to remove 2 branches. 2.5% speedup on SunSpider.
3885
3886         * kjs/property_map.cpp: Use a special no branch accessor to the UString's
3887         hash value. Also, return immediately instead of branching to the end
3888         of the loop if the value is not found.
3889         (KJS::PropertyMap::get):
3890         (KJS::PropertyMap::getLocation):
3891         (KJS::PropertyMap::put):
3892         (KJS::PropertyMap::insert):
3893         (KJS::PropertyMap::remove):
3894         (KJS::PropertyMap::checkConsistency):
3895
3896         * kjs/ustring.h:
3897         (KJS::UString::Rep::computedHash): Special no branch accessor to the
3898         UString's hash value. Used when the caller knows that the hash value
3899         has already been computed. (For example, if the caller got the UString
3900         from an Identifier.)
3901
3902 2007-10-26  Geoffrey Garen  <ggaren@apple.com>
3903
3904         Reviewed by Maciej Stachowiak.
3905         
3906         Switched ActivationImp to using a symbol table. For now, though, all
3907         clients take the slow path.
3908         
3909         Net .6% speedup on SunSpider.
3910         
3911         Slowdowns:
3912             - ActivationImp now mallocs in its constructor
3913             - Local variable hits use an extra level of indirection to retrieve 
3914             data
3915             - Local variable misses do two lookups
3916
3917         Speedups:
3918             - Fast initialization of local variables upon function entry
3919
3920         * JavaScriptCore.xcodeproj/project.pbxproj: Added SymbolTable.h
3921         
3922         * kjs/function.cpp:
3923         (KJS::ActivationImp::ActivationImp): Malloc a private structure to hold
3924         data that won't fit in a JSCell.
3925         (KJS::ActivationImp::argumentsGetter): Use slow symbol table path for 
3926         lookup.
3927         (KJS::ActivationImp::getOwnPropertySlot): ditto
3928         (KJS::ActivationImp::deleteProperty): ditto
3929         (KJS::ActivationImp::put): ditto
3930         (KJS::ActivationImp::createArgumentsObject): ditto
3931
3932         (KJS::ActivationImp::mark): Call JSObject::mark first so that one of
3933         our properties doesn't try to recursively mark us. (This caused a crash
3934         in earlier testing. Not sure why we haven't run into it before.)
3935
3936         * kjs/nodes.cpp: Functions now build a symbol table the first time 
3937         they're called.
3938         (KJS::VarDeclNode::evaluate):
3939         (KJS::FunctionBodyNode::FunctionBodyNode):
3940         (KJS::FunctionBodyNode::initializeSymbolTable):
3941         (KJS::FunctionBodyNode::processDeclarations):
3942         (KJS::FunctionBodyNode::processDeclarationsForFunctionCode):
3943         (KJS::FunctionBodyNode::processDeclarationsForProgramCode):
3944
3945         * kjs/nodes.h:
3946         (KJS::FunctionBodyNode::symbolTable):
3947
3948         * wtf/Forward.h: Added Vector.
3949
3950 2007-10-26  Kevin McCullough  <kmccullough@apple.com>
3951
3952         - Corrected function name mistake in this changelog.
3953
3954 2007-10-26  Kevin McCullough  <kmccullough@apple.com>
3955         Reviewed by Sam and Steve.
3956
3957         - Added convenience methods for converting between BSTR and JSStringRefs
3958
3959         * API/JSStringRefCOM.cpp: Added.
3960         (JSStringCreateWithBSTR):
3961         (JSStringCopyBSTR):
3962         * API/JSStringRefCOM.h: Added.
3963         * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
3964
3965 2007-10-26  Mark Rowe  <mrowe@apple.com>
3966
3967         Windows build fix.
3968
3969         * kjs/collector.cpp:
3970         (KJS::Collector::collect):
3971
3972 2007-10-26  Oliver Hunt  <oliver@apple.com>
3973
3974         Reviewed by Maciej.
3975
3976         Make the JSC GC use a separate heap for JSNumbers to get a 0.7-1.4% progression in SunSpider.
3977
3978         * kjs/CollectorHeapIntrospector.cpp:
3979         (KJS::CollectorHeapIntrospector::init):
3980         (KJS::CollectorHeapIntrospector::enumerate):
3981         * kjs/CollectorHeapIntrospector.h:
3982         * kjs/collector.cpp:
3983         (KJS::Collector::recordExtraCost):
3984         (KJS::Collector::heapAllocate):
3985         (KJS::Collector::allocate):
3986         (KJS::Collector::allocateNumber):
3987         (KJS::Collector::registerThread):
3988         (KJS::Collector::markStackObjectsConservatively):
3989         (KJS::Collector::markMainThreadOnlyObjects):
3990         (KJS::Collector::sweep):
3991         (KJS::Collector::collect):
3992         * kjs/collector.h:
3993         * kjs/internal.h:
3994         (KJS::NumberImp::operator new):
3995           Force numbers to be allocated in the secondary heap.
3996
3997 2007-10-26  Maciej Stachowiak  <mjs@apple.com>
3998
3999         Reviewed by Oliver.
4000         
4001         - encourage GCC a little harder to inline a few hot functions for 1.5% improvement on SunSpider.
4002
4003         * kjs/value.h:
4004         (KJS::JSValue::getUInt32):
4005         (KJS::JSValue::getTruncatedInt32):
4006         (KJS::JSValue::toNumber):
4007         * wtf/PassRefPtr.h:
4008         (WTF::PassRefPtr::~PassRefPtr):
4009         * wtf/RefPtr.h:
4010         (WTF::RefPtr::operator->):
4011
4012 2007-10-26  Mark Rowe  <mrowe@apple.com>
4013
4014         Gtk build fix.
4015
4016         * kjs/ExecState.h:
4017
4018 2007-10-26  Maciej Stachowiak  <mjs@apple.com>
4019
4020         Reviewed by Mark.
4021
4022         - Merge Context class fully into ExecState, since they are always created and used together.
4023
4024         No measurable performance impact but this is a useful cleanup.
4025
4026         * JavaScriptCore.pri:
4027         * kjs/ExecState.cpp:
4028         (KJS::ExecState::ExecState):
4029         (KJS::ExecState::~ExecState):
4030         (KJS::ExecState::mark):
4031         (KJS::ExecState::lexicalInterpreter):
4032         * kjs/ExecState.h:
4033         (KJS::ExecState::dynamicInterpreter):
4034         (KJS::ExecState::setException):
4035         (KJS::ExecState::clearException):
4036         (KJS::ExecState::exception):
4037         (KJS::ExecState::exceptionSlot):
4038         (KJS::ExecState::hadException):
4039         (KJS::ExecState::scopeChain):
4040         (KJS::ExecState::callingExecState):
4041         (KJS::ExecState::propertyNames):
4042         * kjs/collector.cpp:
4043         (KJS::Collector::reportOutOfMemoryToAllInterpreters):
4044         * kjs/function.cpp:
4045         (KJS::FunctionImp::callAsFunction):
4046         (KJS::FunctionImp::argumentsGetter):
4047         (KJS::FunctionImp::callerGetter):
4048         (KJS::GlobalFuncImp::callAsFunction):
4049         * kjs/interpreter.cpp:
4050         (KJS::Interpreter::Interpreter):
4051         (KJS::Interpreter::init):
4052         (KJS::Interpreter::evaluate):
4053         (KJS::Interpreter::mark):
4054         * kjs/interpreter.h:
4055         (KJS::Interpreter::setCurrentExec):
4056         (KJS::Interpreter::currentExec):
4057         * kjs/nodes.cpp:
4058         (KJS::currentSourceId):
4059         (KJS::currentSourceURL):
4060         (KJS::ThisNode::evaluate):
4061         (KJS::ResolveNode::evaluate):
4062         (KJS::FunctionCallResolveNode::evaluate):
4063         (KJS::PostfixResolveNode::evaluate):
4064         (KJS::DeleteResolveNode::evaluate):
4065         (KJS::TypeOfResolveNode::evaluate):
4066         (KJS::PrefixResolveNode::evaluate):
4067         (KJS::AssignResolveNode::evaluate):
4068         (KJS::VarDeclNode::evaluate):
4069         (KJS::DoWhileNode::execute):
4070         (KJS::WhileNode::execute):
4071         (KJS::ForNode::execute):
4072         (KJS::ForInNode::execute):
4073         (KJS::ContinueNode::execute):
4074         (KJS::BreakNode::execute):
4075         (KJS::ReturnNode::execute):
4076         (KJS::WithNode::execute):
4077         (KJS::SwitchNode::execute):
4078         (KJS::LabelNode::execute):
4079         (KJS::TryNode::execute):
4080         (KJS::FunctionBodyNode::processDeclarationsFunctionCode):
4081         (KJS::FunctionBodyNode::processDeclarationsProgramCode):
4082         (KJS::FunctionBodyNode::processDeclarations):
4083         (KJS::FuncDeclNode::makeFunction):
4084         (KJS::FuncExprNode::evaluate):
4085
4086 2007-10-26  Mark Rowe  <mrowe@apple.com>
4087
4088         Windows build fix.
4089
4090         * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
4091
4092 2007-10-26  Mark Rowe  <mrowe@apple.com>
4093
4094         Gtk build fix.
4095
4096         * JavaScriptCore.pri:
4097         * kjs/ExecState.cpp:
4098
4099 2007-10-26  Maciej Stachowiak  <mjs@apple.com>
4100
4101         Reviewed by Oliver.
4102         
4103         - moved Context class into ExecState.{h,cpp} in preparation for merging 
4104         ExecState and Context classes.
4105
4106         * kjs/ExecState.h: Moved CodeType enum and Context class here in
4107         preparation for merging ExecState and Context.
4108         * kjs/ExecState.cpp: Moved Context class here from Context.cpp.
4109         (KJS::Context::Context):
4110         (KJS::Context::~Context):
4111         (KJS::Context::mark):
4112         * kjs/context.h: Removed.
4113         * kjs/Context.cpp: Removed.
4114         * kjs/function.h: Removed CodeType enum.
4115         * kjs/LabelStack.h: Added. Pulled LabelStack class out of internal.h.
4116         * kjs/internal.h: Removed LabelStack.
4117         * JavaScriptCore.xcodeproj/project.pbxproj: Added new file, removed ones that are gone.
4118         * kjs/collector.cpp: Fixed includes.
4119         * kjs/function.cpp: ditto
4120         * kjs/internal.cpp: ditto
4121         * kjs/interpreter.cpp: ditto
4122         * kjs/lookup.h: ditto
4123         * kjs/nodes.cpp: ditto
4124
4125 2007-10-26  Mark Rowe  <mrowe@apple.com>
4126
4127         Windows build fix.
4128
4129         * kjs/string_object.cpp:
4130         (KJS::StringObjectFuncImp::callAsFunction):
4131
4132 2007-10-25  Darin Adler  <darin@apple.com>
4133
4134         Reviewed by Maciej.
4135
4136         - http://bugs.webkit.org/show_bug.cgi?id=15703
4137           fix numeric functions -- improve correctness and speed
4138
4139         Gives about 1% gain on SunSpider.
4140
4141         * kjs/value.h: Added toIntegerPreserveNan, removed toUInt16.
4142         (KJS::JSValue::toInt32): Changed to call getTruncatedInt32 in a way that works
4143         with both immediate and number values.
4144         (KJS::JSValue::toUInt32): Ditto.
4145         * kjs/value.cpp:
4146         (KJS::JSValue::toInteger): Moved the logic from roundValue here, with a couple
4147         differences. One is that it now correctly returns 0 for NaN, and another is that
4148         there's no special case for 0 or infinity, since the general case already handles
4149         those correctly.
4150         (KJS::JSValue::toIntegerPreserveNaN): Added. Like toInteger, but without the
4151         check for NaN.
4152         (KJS::JSValue::toInt32SlowCase): Call toNumber instead of roundValue. The
4153         truncation done by the typecast already does the necessary truncation that
4154         roundValue was doing.
4155         (KJS::JSValue::toUInt32SlowCase): Ditto.
4156         (KJS::JSValue::toUInt16): Removed.
4157
4158         * kjs/internal.h: Removed roundValue.
4159         * kjs/internal.cpp: Ditto.
4160
4161         * kjs/array_object.cpp: (KJS::ArrayProtoFunc::callAsFunction): Remove unneeded
4162         code to handle NaN in Array.slice; toInteger now never returns NaN as specified.
4163
4164         * kjs/date_object.cpp:
4165         (KJS::fillStructuresUsingTimeArgs): Replaced call to roundValue with a call to
41