[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

darin darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 06:16:51 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 0c2dc3fbd302e75240a72457ab9b95db62cc4833
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Jun 4 22:33:26 2002 +0000

    	Improve the speed of the JavaScript string append operation by growing
    	the capacity so we don't need to reallocate the string every time.
    
    	Also fix script execution so it doesn't use recursion to advance from
    	one statement to the next, using iteration instead.
    
    	* Makefile.am: Stop using BUILT_SOURCES to build JavaScriptCore-stamp,
    	because this causes the Project Builder project to build *before* the
    	subdir. Intead, use an all-am rule in a way more similar to all our
    	other directories.
    
    	* kjs/grammar.y: Link the SourceElementsNode in the opposite direction,
    	so we can walk the list and execute each element instead of using
    	recursion to reverse the list.
    	* kjs/grammar.cpp: Check in new generated file.
    
    	* kjs/nodes.cpp:
    	(SourceElementsNode::execute):
    	(SourceElementsNode::processFuncDecl):
    	(SourceElementsNode::processVarDecls):
    	Use loops instead of recursion.
    
    	* kjs/ustring.h: Don't initialize all UChar objects to 0. This was
    	wasting a *huge* amount of time.
    	* kjs/ustring.cpp:
    	(UString::Rep::create): Add a "capacity" along with the length.
    	(UString::append): Include 50% extra capacity when appending.
    	(UString::operator=): Reuse the buffer if possible rather than
    	always creating a new one.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1272 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index b9bdef3..1afaf9e 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,35 @@
+2002-06-04  Darin Adler  <darin at apple.com>
+
+	Improve the speed of the JavaScript string append operation by growing
+	the capacity so we don't need to reallocate the string every time.
+
+	Also fix script execution so it doesn't use recursion to advance from
+	one statement to the next, using iteration instead.
+
+	* Makefile.am: Stop using BUILT_SOURCES to build JavaScriptCore-stamp,
+	because this causes the Project Builder project to build *before* the
+	subdir. Intead, use an all-am rule in a way more similar to all our
+	other directories.
+
+	* kjs/grammar.y: Link the SourceElementsNode in the opposite direction,
+	so we can walk the list and execute each element instead of using
+	recursion to reverse the list.
+	* kjs/grammar.cpp: Check in new generated file.
+
+	* kjs/nodes.cpp:
+	(SourceElementsNode::execute):
+	(SourceElementsNode::processFuncDecl):
+	(SourceElementsNode::processVarDecls):
+	Use loops instead of recursion.
+
+	* kjs/ustring.h: Don't initialize all UChar objects to 0. This was
+	wasting a *huge* amount of time.
+	* kjs/ustring.cpp:
+	(UString::Rep::create): Add a "capacity" along with the length.
+	(UString::append): Include 50% extra capacity when appending.
+	(UString::operator=): Reuse the buffer if possible rather than
+	always creating a new one.
+
 2002-06-02  Darin Adler  <darin at apple.com>
 
 	* COPYING.LIB: Fix line endings. It was using CRs.
diff --git a/JavaScriptCore/ChangeLog-2002-12-03 b/JavaScriptCore/ChangeLog-2002-12-03
index b9bdef3..1afaf9e 100644
--- a/JavaScriptCore/ChangeLog-2002-12-03
+++ b/JavaScriptCore/ChangeLog-2002-12-03
@@ -1,3 +1,35 @@
+2002-06-04  Darin Adler  <darin at apple.com>
+
+	Improve the speed of the JavaScript string append operation by growing
+	the capacity so we don't need to reallocate the string every time.
+
+	Also fix script execution so it doesn't use recursion to advance from
+	one statement to the next, using iteration instead.
+
+	* Makefile.am: Stop using BUILT_SOURCES to build JavaScriptCore-stamp,
+	because this causes the Project Builder project to build *before* the
+	subdir. Intead, use an all-am rule in a way more similar to all our
+	other directories.
+
+	* kjs/grammar.y: Link the SourceElementsNode in the opposite direction,
+	so we can walk the list and execute each element instead of using
+	recursion to reverse the list.
+	* kjs/grammar.cpp: Check in new generated file.
+
+	* kjs/nodes.cpp:
+	(SourceElementsNode::execute):
+	(SourceElementsNode::processFuncDecl):
+	(SourceElementsNode::processVarDecls):
+	Use loops instead of recursion.
+
+	* kjs/ustring.h: Don't initialize all UChar objects to 0. This was
+	wasting a *huge* amount of time.
+	* kjs/ustring.cpp:
+	(UString::Rep::create): Add a "capacity" along with the length.
+	(UString::append): Include 50% extra capacity when appending.
+	(UString::operator=): Reuse the buffer if possible rather than
+	always creating a new one.
+
 2002-06-02  Darin Adler  <darin at apple.com>
 
 	* COPYING.LIB: Fix line endings. It was using CRs.
diff --git a/JavaScriptCore/ChangeLog-2003-10-25 b/JavaScriptCore/ChangeLog-2003-10-25
index b9bdef3..1afaf9e 100644
--- a/JavaScriptCore/ChangeLog-2003-10-25
+++ b/JavaScriptCore/ChangeLog-2003-10-25
@@ -1,3 +1,35 @@
+2002-06-04  Darin Adler  <darin at apple.com>
+
+	Improve the speed of the JavaScript string append operation by growing
+	the capacity so we don't need to reallocate the string every time.
+
+	Also fix script execution so it doesn't use recursion to advance from
+	one statement to the next, using iteration instead.
+
+	* Makefile.am: Stop using BUILT_SOURCES to build JavaScriptCore-stamp,
+	because this causes the Project Builder project to build *before* the
+	subdir. Intead, use an all-am rule in a way more similar to all our
+	other directories.
+
+	* kjs/grammar.y: Link the SourceElementsNode in the opposite direction,
+	so we can walk the list and execute each element instead of using
+	recursion to reverse the list.
+	* kjs/grammar.cpp: Check in new generated file.
+
+	* kjs/nodes.cpp:
+	(SourceElementsNode::execute):
+	(SourceElementsNode::processFuncDecl):
+	(SourceElementsNode::processVarDecls):
+	Use loops instead of recursion.
+
+	* kjs/ustring.h: Don't initialize all UChar objects to 0. This was
+	wasting a *huge* amount of time.
+	* kjs/ustring.cpp:
+	(UString::Rep::create): Add a "capacity" along with the length.
+	(UString::append): Include 50% extra capacity when appending.
+	(UString::operator=): Reuse the buffer if possible rather than
+	always creating a new one.
+
 2002-06-02  Darin Adler  <darin at apple.com>
 
 	* COPYING.LIB: Fix line endings. It was using CRs.
diff --git a/JavaScriptCore/Makefile.am b/JavaScriptCore/Makefile.am
index 80a472d..7c5ff60 100644
--- a/JavaScriptCore/Makefile.am
+++ b/JavaScriptCore/Makefile.am
@@ -9,12 +9,6 @@ noinst_PROGRAMS = kjs/testkjs
 kjs_testkjs_SOURCES = kjs/testkjs.cpp JavaScriptCore-stamp
 kjs_testkjs_LDFLAGS = -F$(SYMROOTS) -framework JavaScriptCore
 
-BUILT_SOURCES = JavaScriptCore-stamp
-CLEANFILES = $(BUILT_SOURCES)
-
-JavaScriptCore-stamp: kjs/*.cpp kjs/*.h
-	pbxbuild -buildstyle $(BUILDSTYLE) && touch $@
-
 FRAMEWORK_NAME = JavaScriptCore
 FRAMEWORK_DIR = $(SYMROOTS)/$(FRAMEWORK_NAME).framework
 FRAMEWORK_DYLIB = $(FRAMEWORK_DIR)/Versions/Current/$(FRAMEWORK_NAME)
@@ -41,5 +35,12 @@ embed:
 		exit 1; \
         fi
 
+all-am: JavaScriptCore-stamp
+
+JavaScriptCore-stamp: kjs/*.cpp kjs/*.h
+	pbxbuild -buildstyle $(BUILDSTYLE) && touch $@
+
 clean-am:
 	pbxbuild clean
+
+CLEANFILES = JavaScriptCore-stamp
diff --git a/JavaScriptCore/kjs/grammar.cpp b/JavaScriptCore/kjs/grammar.cpp
index dc411a7..caf78f9 100644
--- a/JavaScriptCore/kjs/grammar.cpp
+++ b/JavaScriptCore/kjs/grammar.cpp
@@ -306,8 +306,8 @@ static const short yyrhs[] = {     3,
     63,   145,     0,    15,    58,    62,   144,    63,   145,     0,
     15,    62,    63,   145,     0,    15,    62,   144,    63,   145,
      0,    58,     0,   144,    68,    58,     0,    64,    65,     0,
-    64,   147,    65,     0,     0,   147,     0,   148,     0,   147,
-   148,     0,   115,     0,   142,     0
+    64,   147,    65,     0,     0,   147,     0,   148,     0,   148,
+   147,     0,   115,     0,   142,     0
 };
 
 #endif
@@ -333,7 +333,7 @@ static const short yyrline[] = { 0,
    520,   521,   527,   532,   537,   539,   543,   545,   548,   550,
    553,   555,   558,   560,   563,   569,   573,   575,   576,   579,
    583,   587,   590,   594,   596,   601,   603,   607,   610,   614,
-   617,   621,   623,   626,   628
+   617,   621,   624,   630,   632
 };
 #endif
 
@@ -460,100 +460,100 @@ static const short yydefgoto[] = {    39,
    356,   124,    79
 };
 
-static const short yypact[] = {   779,
--32768,-32768,-32768,-32768,-32768,     5,   -28,   111,   -30,     6,
-   -31,   335,  1252,  1252,   -16,-32768,   853,    -5,  1252,     9,
-    57,  1252,   -20,  1252,  1252,-32768,   -21,  1252,  1252,-32768,
-  1252,   409,    -1,  1252,  1252,  1252,  1252,-32768,-32768,-32768,
--32768,    42,-32768,    43,   179,-32768,-32768,   -14,    12,   195,
-    82,   118,    72,    85,    93,   151,   -23,-32768,-32768,    11,
+static const short yypact[] = {   631,
+-32768,-32768,-32768,-32768,-32768,     3,   -38,   111,   -24,     5,
+   -14,   335,  1066,  1066,   -12,-32768,   705,     9,  1066,    47,
+    51,  1066,     0,  1066,  1066,-32768,    50,  1066,  1066,-32768,
+  1066,   409,    12,  1066,  1066,  1066,  1066,-32768,-32768,-32768,
+-32768,    42,-32768,    83,   315,-32768,-32768,    71,   -25,    38,
+    82,   239,    54,    68,    84,   133,   -23,-32768,-32768,    11,
 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
--32768,-32768,-32768,-32768,-32768,-32768,-32768,   779,-32768,-32768,
-     7,-32768,   964,   161,-32768,    45,    42,-32768,   136,    17,
--32768,-32768,     8,-32768,   192,    24,-32768,-32768,    18,    90,
--32768,-32768,  1252,   236,  1252,-32768,  1252,  1252,   -45,   483,
-   231,-32768,-32768,   853,-32768,-32768,    59,   191,   196,   -21,
-   935,   123,   208,   557,-32768,   200,  1036,   203,-32768,-32768,
--32768,-32768,  1108,  1252,   222,-32768,  1252,   224,-32768,-32768,
+-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,   631,-32768,
+     6,-32768,   778,   114,-32768,    45,    42,-32768,   105,    17,
+-32768,-32768,     7,-32768,   129,   -42,-32768,-32768,    18,   112,
+-32768,-32768,  1066,   230,  1066,-32768,  1066,  1066,   -45,   483,
+   162,-32768,-32768,   705,-32768,-32768,    -6,   150,   176,    50,
+   220,   -37,   185,   212,-32768,   154,   850,   214,-32768,-32768,
+-32768,-32768,   922,  1066,   234,-32768,  1066,   237,-32768,-32768,
 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
--32768,-32768,-32768,  1252,  1252,  1252,  1252,  1252,  1252,  1252,
-  1252,  1252,  1252,  1252,  1252,  1252,  1252,  1252,  1252,  1252,
-  1252,  1252,  1252,  1252,  1252,  1252,  1252,  1252,-32768,  1252,
--32768,-32768,-32768,-32768,   226,    87,   217,   204,-32768,-32768,
--32768,-32768,-32768,  1252,-32768,-32768,   -30,-32768,-32768,-32768,
-   105,-32768,   223,   103,-32768,-32768,   113,   227,   115,   116,
-   117,-32768,-32768,   228,   -20,   253,-32768,-32768,-32768,-32768,
-    35,  1252,-32768,-32768,    -1,-32768,-32768,-32768,-32768,   119,
--32768,   202,-32768,   206,-32768,-32768,-32768,-32768,-32768,   -14,
-   -14,    12,    12,    12,   195,   195,   195,   195,   195,   195,
-    82,    82,    82,    82,   118,   118,   118,    93,   151,   225,
--32768,    -3,   -44,  1252,  1252,-32768,-32768,   223,   126,   631,
--32768,   223,   233,   853,  1252,   853,   229,   853,   234,-32768,
--32768,   232,-32768,  1180,-32768,  1252,-32768,-32768,  1252,  1252,
-   271,  1252,   127,   212,-32768,   223,-32768,   705,-32768,-32768,
-   274,   157,-32768,   289,-32768,-32768,   237,  1252,-32768,-32768,
--32768,-32768,   174,  1252,   218,   853,  1252,-32768,-32768,   853,
--32768,  1252,    23,   289,-32768,   -20,-32768,   853,   175,  1252,
--32768,   243,-32768,   207,   238,-32768,   289,-32768,-32768,-32768,
-   853,   246,   853,   853,   853,   245,-32768,   853,-32768,-32768,
-   853,   853,-32768,-32768,-32768,   312,   314,-32768
+-32768,-32768,-32768,  1066,  1066,  1066,  1066,  1066,  1066,  1066,
+  1066,  1066,  1066,  1066,  1066,  1066,  1066,  1066,  1066,  1066,
+  1066,  1066,  1066,  1066,  1066,  1066,  1066,  1066,-32768,  1066,
+-32768,-32768,-32768,-32768,   244,    87,   241,   226,-32768,-32768,
+-32768,-32768,-32768,  1066,-32768,-32768,   -24,-32768,-32768,-32768,
+    64,-32768,   248,   100,-32768,-32768,   103,   252,   121,   122,
+   124,-32768,-32768,   253,     0,   283,-32768,-32768,-32768,-32768,
+    35,  1066,-32768,-32768,    12,-32768,-32768,-32768,-32768,   181,
+-32768,   203,-32768,   223,-32768,-32768,-32768,-32768,-32768,    71,
+    71,   -25,   -25,   -25,    38,    38,    38,    38,    38,    38,
+    82,    82,    82,    82,   239,   239,   239,    84,   133,   249,
+-32768,   -15,   -41,  1066,  1066,-32768,-32768,   248,   190,   557,
+-32768,   248,   259,   705,  1066,   705,   255,   705,   262,-32768,
+-32768,   254,-32768,   994,-32768,  1066,-32768,-32768,  1066,  1066,
+   298,  1066,   197,   245,-32768,   248,-32768,   260,-32768,-32768,
+   307,   199,-32768,   323,-32768,-32768,   270,  1066,-32768,-32768,
+-32768,-32768,   200,  1066,   261,   705,  1066,-32768,-32768,   705,
+-32768,  1066,    23,   323,-32768,     0,-32768,   705,   201,  1066,
+-32768,   274,-32768,   232,   275,-32768,   323,-32768,-32768,-32768,
+   705,   280,   705,   705,   705,   281,-32768,   705,-32768,-32768,
+   705,   705,-32768,-32768,-32768,   348,   349,-32768
 };
 
 static const short yypgoto[] = {-32768,
--32768,-32768,-32768,    91,-32768,-32768,    94,   309,   310,-32768,
-   -34,-32768,    41,-32768,     1,   120,    88,   -18,    75,    78,
--32768,-32768,   143,   145,-32768,-32768,  -122,-32768,    -9,   -17,
-   -22,   -25,-32768,   138,   128,    67,-32768,-32768,-32768,-32768,
-  -249,-32768,-32768,-32768,-32768,-32768,-32768,    -7,-32768,    13,
--32768,-32768,-32768,-32768,-32768,   129,-32768,-32768,   131,  -223,
--32768,     2,   -74
+-32768,-32768,-32768,   126,-32768,-32768,   135,   346,   351,-32768,
+   -34,-32768,    41,-32768,     1,   148,   -10,    15,   117,   123,
+-32768,-32768,   184,   196,-32768,-32768,  -122,-32768,    -9,   -17,
+   -22,    29,-32768,   191,   178,   118,-32768,-32768,-32768,-32768,
+  -225,-32768,-32768,-32768,-32768,-32768,-32768,    44,-32768,    55,
+-32768,-32768,-32768,-32768,-32768,   166,-32768,-32768,   182,  -223,
+-32768,     2,-32768
 };
 
 
-#define	YYLAST		1326
+#define	YYLAST		1140
 
 
 static const short yytable[] = {   104,
-   111,    78,    99,   182,   227,    80,    92,   183,   199,   139,
-   231,   179,   109,   101,   102,   294,   177,   196,   205,   106,
-   290,   117,   180,   197,   112,   113,    95,    89,   115,   116,
-    96,   236,   335,    83,   129,   130,   131,   132,   212,   292,
-   189,   190,   315,   110,   295,   103,   155,   114,   299,   182,
-   189,   190,   193,   100,   100,   260,   105,   261,   178,   100,
-   156,   157,    81,    93,   100,   100,   125,   332,   100,   100,
-   107,   266,   318,   187,   100,   100,   100,   100,   180,   194,
-   342,   202,   158,   159,   197,   180,   203,   336,    82,    94,
-   184,   200,   191,   207,   181,   209,   218,   210,   211,   283,
-   198,   206,   191,   133,   133,   163,   164,   134,   137,   192,
-   264,   135,   138,     1,     2,     3,     4,     5,   108,   165,
-   166,   219,     8,   186,   232,    84,   180,   234,   140,   141,
-    16,   140,   141,   142,   143,   144,   145,   146,   147,   148,
-   149,   150,   151,   152,   245,   246,   247,   248,   249,   250,
-   173,   169,   170,   171,   172,   237,   238,   239,   167,   168,
-    26,   310,   202,   311,   174,   272,   312,   268,    85,   153,
-   273,    30,    31,   175,    86,   274,    33,   276,   277,   278,
-   180,   285,   180,   180,   180,   327,   286,   220,   296,   316,
-   221,   176,   280,   273,   180,   100,   100,   100,   100,   100,
+   111,    78,    99,    80,   227,    92,   183,   199,   290,   139,
+   231,   179,   109,   101,   102,   202,   177,   196,   205,   106,
+   203,   117,   180,    83,   112,   113,   197,   220,   115,   116,
+   221,   236,   335,    89,   129,   130,   131,   132,   212,   294,
+   189,   190,   292,    95,   295,   158,   159,    96,   299,   103,
+   189,   190,   193,   100,   100,   260,   219,   261,   178,   100,
+    81,   180,    93,   110,   100,   100,   315,   194,   100,   100,
+   105,   266,   318,   187,   100,   100,   100,   100,   180,   125,
+   182,   160,   161,   162,   197,   180,    82,   336,    94,   184,
+   200,   332,   191,   207,   181,   209,   218,   210,   211,   283,
+   198,   206,   191,   133,   342,   163,   164,   134,   107,   192,
+   264,   135,   108,     1,     2,     3,     4,     5,   114,   165,
+   166,   202,     8,   186,   232,    84,   268,   234,   140,   141,
+    16,   155,   173,   142,   143,   144,   145,   146,   147,   148,
+   149,   150,   151,   152,   133,   156,   157,   174,   137,   242,
+   243,   244,   138,   140,   141,   237,   238,   239,   167,   168,
+    26,   310,   272,   311,   175,   274,   312,   273,    85,   153,
+   180,    30,    31,   176,    86,    96,    33,   245,   246,   247,
+   248,   249,   250,   276,   277,   327,   278,   194,   180,   180,
+   201,   180,   280,   214,   215,   100,   100,   100,   100,   100,
    100,   100,   100,   100,   100,   100,   100,   100,   100,   100,
-   100,   100,   100,   100,   100,   100,   100,   100,   194,   321,
-   140,   141,    96,   182,   180,   142,   143,   144,   145,   146,
-   147,   148,   149,   150,   151,   152,   328,   341,   160,   161,
-   162,   180,   180,   251,   252,   253,   254,   242,   243,   244,
-   255,   256,   257,   201,   293,   187,   301,   208,   303,   -27,
-   306,   153,   214,   215,   -28,   302,   224,   225,   287,   180,
-   228,   298,   288,   180,   180,   344,   222,   240,   241,   233,
-   313,   235,   187,   262,   180,   215,   270,   265,   275,   279,
-   300,   307,   304,   289,   314,   317,   320,   322,   331,   326,
-   308,   330,   333,   339,   329,   343,   345,   187,   348,   353,
-   340,   357,   334,   358,   282,   284,    87,    88,   258,   352,
-   187,   259,   263,   347,   267,   349,   350,   350,   291,   346,
-   354,   269,     0,   355,   355,    97,   338,     1,     2,     3,
-     4,     5,     0,     0,   281,     0,     8,     0,     0,    84,
-     0,    13,    14,     0,    16,     0,     0,     0,     0,     0,
-    19,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-     0,     0,     0,     0,     0,     0,    24,    25,     0,     0,
-     0,     0,     0,     0,    26,     0,     0,     0,     0,     0,
-     0,     0,    85,    28,    29,    30,    31,     0,    86,     0,
+   100,   100,   100,   100,   100,   100,   100,   100,   -27,  -126,
+   224,   225,  -126,  -126,  -126,  -126,  -126,  -126,  -126,  -126,
+  -126,  -126,  -126,  -126,  -126,  -126,  -126,  -126,  -126,  -126,
+  -126,  -126,  -126,   285,   -28,  -126,  -126,  -126,   286,  -126,
+  -126,   208,   296,   222,   293,   187,   301,   273,   303,   316,
+   306,   321,   328,   341,   180,   302,   180,   180,   180,   287,
+   180,   298,   169,   170,   171,   172,   223,  -126,  -126,  -126,
+   313,   228,   187,  -126,  -126,   251,   252,   253,   254,   288,
+   180,   233,  -126,  -126,   235,   255,   256,   257,   331,   180,
+   344,   262,   333,   339,   329,   240,   241,   187,   180,   265,
+   340,   270,   334,   275,   279,   215,   300,   289,   304,   307,
+   187,   314,   308,   347,   319,   349,   350,   350,   317,   320,
+   354,   322,   326,   355,   355,    97,   343,     1,     2,     3,
+     4,     5,   348,   345,   330,   353,     8,   357,   358,    84,
+   284,    13,    14,    87,    16,   282,   140,   141,    88,   258,
+    19,   142,   143,   144,   145,   146,   147,   148,   149,   150,
+   151,   152,   259,   352,   267,   263,    24,    25,   338,   291,
+   346,   281,   269,     0,    26,     0,     0,     0,     0,     0,
+     0,     0,    85,    28,    29,    30,    31,   153,    86,     0,
     33,     0,     0,     0,     0,    34,    35,    36,    37,     0,
      0,     1,     2,     3,   118,   119,     6,     0,    98,     7,
      8,     9,    10,    11,    12,    13,    14,    15,    16,    17,
@@ -576,120 +576,101 @@ static const short yytable[] = {   104,
      0,     0,     0,     0,     0,     0,     0,     0,    24,    25,
      0,     0,     0,     0,     0,     0,    26,     0,     0,     0,
      0,     0,     0,     0,    27,    28,    29,    30,    31,     0,
-    32,   223,    33,     0,     0,     0,     0,    34,    35,    36,
+    32,   297,    33,     0,     0,     0,     0,    34,    35,    36,
     37,     0,     0,     1,     2,     3,     4,     5,     6,     0,
     38,     7,     8,     9,    10,    11,    12,    13,    14,    15,
     16,    17,    18,     0,     0,     0,    19,    20,    21,     0,
     22,    23,     0,     0,     0,     0,     0,     0,     0,     0,
      0,     0,    24,    25,     0,     0,     0,     0,     0,     0,
     26,     0,     0,     0,     0,     0,     0,     0,    27,    28,
-    29,    30,    31,     0,    32,   297,    33,     0,     0,     0,
+    29,    30,    31,     0,    32,     0,    33,     0,     0,     0,
      0,    34,    35,    36,    37,     0,     0,     1,     2,     3,
-     4,     5,     6,     0,    38,     7,     8,     9,    10,    11,
+     4,     5,     6,     0,    38,     7,     8,     9,    10,    84,
     12,    13,    14,    15,    16,    17,    18,     0,     0,     0,
     19,    20,    21,     0,    22,    23,     0,     0,     0,     0,
      0,     0,     0,     0,     0,     0,    24,    25,     0,     0,
      0,     0,     0,     0,    26,     0,     0,     0,     0,     0,
-     0,     0,    27,    28,    29,    30,    31,     0,    32,   319,
+     0,     0,    27,    28,    29,    30,    31,     0,    32,     0,
     33,     0,     0,     0,     0,    34,    35,    36,    37,     0,
-     0,     1,     2,     3,     4,     5,     6,     0,    38,     7,
-     8,     9,    10,    11,    12,    13,    14,    15,    16,    17,
-    18,     0,     0,     0,    19,    20,    21,     0,    22,    23,
-     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-    24,    25,     0,     0,     0,     0,     0,     0,    26,     0,
-     0,     0,     0,     0,     0,     0,    27,    28,    29,    30,
-    31,     0,    32,     0,    33,     0,     0,     0,     0,    34,
-    35,    36,    37,     0,     0,     1,     2,     3,     4,     5,
-     6,     0,    38,     7,     8,     9,    10,    84,    12,    13,
-    14,    15,    16,    17,    18,     0,     0,     0,    19,    20,
-    21,     0,    22,    23,     0,     0,     0,     0,     0,     0,
-     0,     0,     0,     0,    24,    25,     0,     0,     0,     0,
-     0,     0,    26,     0,     0,     0,     0,     0,     0,     0,
-    27,    28,    29,    30,    31,     0,    32,     0,    33,     0,
-     0,     0,     0,    34,    35,    36,    37,     0,     0,     0,
-     0,     0,     0,     0,  -126,     0,    38,  -126,  -126,  -126,
-  -126,  -126,  -126,  -126,  -126,  -126,  -126,  -126,  -126,  -126,
-  -126,  -126,  -126,  -126,  -126,  -126,  -126,  -126,     0,     0,
-  -126,  -126,  -126,     0,  -126,  -126,     1,     2,     3,     4,
-     5,     0,     0,     0,     0,     8,   185,     0,    84,     0,
-    13,    14,     0,    16,     0,     0,     0,     0,     0,    19,
-     0,     0,  -126,  -126,  -126,     0,     0,     0,  -126,  -126,
-     0,     0,     0,     0,     0,    24,    25,  -126,  -126,     0,
-     0,     0,     0,    26,     0,     0,     0,     0,     0,     0,
-     0,    85,    28,    29,    30,    31,     0,    86,     0,    33,
-     0,     0,     0,     0,    34,    35,    36,    37,     1,     2,
-     3,     4,     5,     0,     0,     0,     0,     8,     0,     0,
-    84,     0,    13,    14,     0,    16,     0,     0,     0,     0,
-     0,    19,     0,     0,     0,     0,     0,     0,     0,     0,
-     0,     0,     0,     0,     0,     0,     0,    24,    25,     0,
-     0,     0,     0,     0,     0,    26,     0,     0,     0,     0,
-     0,     0,     0,    85,    28,    29,    30,    31,     0,    86,
-     0,    33,   226,     0,     0,     0,    34,    35,    36,    37,
-     1,     2,     3,     4,     5,     0,     0,     0,     0,     8,
-     0,     0,    84,     0,    13,    14,     0,    16,     0,     0,
+     1,     2,     3,     4,     5,     0,     0,     0,    38,     8,
+   185,     0,    84,     0,    13,    14,     0,    16,     0,     0,
      0,     0,     0,    19,     0,     0,     0,     0,     0,     0,
      0,     0,     0,     0,     0,     0,     0,     0,     0,    24,
     25,     0,     0,     0,     0,     0,     0,    26,     0,     0,
      0,     0,     0,     0,     0,    85,    28,    29,    30,    31,
-   229,    86,     0,    33,     0,     0,     0,     0,    34,    35,
+     0,    86,     0,    33,     0,     0,     0,     0,    34,    35,
     36,    37,     1,     2,     3,     4,     5,     0,     0,     0,
      0,     8,     0,     0,    84,     0,    13,    14,     0,    16,
      0,     0,     0,     0,     0,    19,     0,     0,     0,     0,
      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
      0,    24,    25,     0,     0,     0,     0,     0,     0,    26,
      0,     0,     0,     0,     0,     0,     0,    85,    28,    29,
-    30,    31,     0,    86,     0,    33,   309,     0,     0,     0,
+    30,    31,     0,    86,     0,    33,   226,     0,     0,     0,
     34,    35,    36,    37,     1,     2,     3,     4,     5,     0,
      0,     0,     0,     8,     0,     0,    84,     0,    13,    14,
      0,    16,     0,     0,     0,     0,     0,    19,     0,     0,
      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
      0,     0,     0,    24,    25,     0,     0,     0,     0,     0,
      0,    26,     0,     0,     0,     0,     0,     0,     0,    85,
-    28,    29,    30,    31,     0,    86,     0,    33,     0,     0,
-     0,     0,    34,    35,    36,    37
+    28,    29,    30,    31,   229,    86,     0,    33,     0,     0,
+     0,     0,    34,    35,    36,    37,     1,     2,     3,     4,
+     5,     0,     0,     0,     0,     8,     0,     0,    84,     0,
+    13,    14,     0,    16,     0,     0,     0,     0,     0,    19,
+     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,    24,    25,     0,     0,     0,
+     0,     0,     0,    26,     0,     0,     0,     0,     0,     0,
+     0,    85,    28,    29,    30,    31,     0,    86,     0,    33,
+   309,     0,     0,     0,    34,    35,    36,    37,     1,     2,
+     3,     4,     5,     0,     0,     0,     0,     8,     0,     0,
+    84,     0,    13,    14,     0,    16,     0,     0,     0,     0,
+     0,    19,     0,     0,     0,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,     0,     0,    24,    25,     0,
+     0,     0,     0,     0,     0,    26,     0,     0,     0,     0,
+     0,     0,     0,    85,    28,    29,    30,    31,     0,    86,
+     0,    33,     0,     0,     0,     0,    34,    35,    36,    37
 };
 
 static const short yycheck[] = {    17,
-    23,     0,    12,    78,   127,     1,     1,     1,     1,    44,
-   133,     1,    22,    13,    14,   265,    40,     1,     1,    19,
-    24,    31,    68,    68,    24,    25,    58,    58,    28,    29,
-    62,   154,    10,    62,    34,    35,    36,    37,    84,    84,
-     6,     7,   292,    64,   268,    62,    61,    69,   272,   124,
-     6,     7,    87,    13,    14,   178,    62,   180,    82,    19,
-    75,    76,    58,    58,    24,    25,    68,   317,    28,    29,
-    62,   194,   296,    83,    34,    35,    36,    37,    68,    83,
-   330,    58,    71,    72,    68,    68,    63,    65,    84,    84,
-    84,    84,    58,   103,    84,   105,   114,   107,   108,   222,
-    84,    84,    58,    62,    62,    24,    25,    66,    66,    65,
-    24,    70,    70,     3,     4,     5,     6,     7,    62,    38,
-    39,    63,    12,    83,   134,    15,    68,   137,    42,    43,
-    20,    42,    43,    47,    48,    49,    50,    51,    52,    53,
-    54,    55,    56,    57,   163,   164,   165,   166,   167,   168,
-    79,    34,    35,    36,    37,   155,   156,   157,    77,    78,
-    50,   284,    58,   286,    80,    63,   289,    63,    58,    83,
-    68,    61,    62,    81,    64,    63,    66,    63,    63,    63,
-    68,    63,    68,    68,    68,   308,    68,    65,    63,    63,
-    68,    41,   215,    68,    68,   155,   156,   157,   158,   159,
+    23,     0,    12,     1,   127,     1,     1,     1,    24,    44,
+   133,     1,    22,    13,    14,    58,    40,     1,     1,    19,
+    63,    31,    68,    62,    24,    25,    68,    65,    28,    29,
+    68,   154,    10,    58,    34,    35,    36,    37,    84,   265,
+     6,     7,    84,    58,   268,    71,    72,    62,   272,    62,
+     6,     7,    87,    13,    14,   178,    63,   180,    82,    19,
+    58,    68,    58,    64,    24,    25,   292,    83,    28,    29,
+    62,   194,   296,    83,    34,    35,    36,    37,    68,    68,
+    79,    44,    45,    46,    68,    68,    84,    65,    84,    84,
+    84,   317,    58,   103,    84,   105,   114,   107,   108,   222,
+    84,    84,    58,    62,   330,    24,    25,    66,    62,    65,
+    24,    70,    62,     3,     4,     5,     6,     7,    69,    38,
+    39,    58,    12,    83,   134,    15,    63,   137,    42,    43,
+    20,    61,    79,    47,    48,    49,    50,    51,    52,    53,
+    54,    55,    56,    57,    62,    75,    76,    80,    66,   160,
+   161,   162,    70,    42,    43,   155,   156,   157,    77,    78,
+    50,   284,    63,   286,    81,    63,   289,    68,    58,    83,
+    68,    61,    62,    41,    64,    62,    66,   163,   164,   165,
+   166,   167,   168,    63,    63,   308,    63,    83,    68,    68,
+    62,    68,   215,    32,    33,   155,   156,   157,   158,   159,
    160,   161,   162,   163,   164,   165,   166,   167,   168,   169,
-   170,   171,   172,   173,   174,   175,   176,   177,    83,    63,
-    42,    43,    62,   298,    68,    47,    48,    49,    50,    51,
-    52,    53,    54,    55,    56,    57,    63,    63,    44,    45,
-    46,    68,    68,   169,   170,   171,   172,   160,   161,   162,
-   173,   174,   175,    62,   264,   265,   274,    22,   276,    69,
-   278,    83,    32,    33,    69,   275,    67,    68,    67,    68,
-    68,   270,    67,    68,    68,    69,    69,   158,   159,    58,
-   290,    58,   292,    58,    68,    33,    64,    84,    62,    62,
-    58,    58,    64,    69,    24,    84,    23,     9,   316,    63,
-    69,    84,   320,   326,   314,    63,    69,   317,    63,    65,
-   328,     0,   322,     0,   221,   225,     8,     8,   176,   345,
-   330,   177,   185,   341,   197,   343,   344,   345,   262,   337,
-   348,   201,    -1,   351,   352,     1,   324,     3,     4,     5,
-     6,     7,    -1,    -1,   216,    -1,    12,    -1,    -1,    15,
-    -1,    17,    18,    -1,    20,    -1,    -1,    -1,    -1,    -1,
-    26,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-    -1,    -1,    -1,    -1,    -1,    -1,    42,    43,    -1,    -1,
-    -1,    -1,    -1,    -1,    50,    -1,    -1,    -1,    -1,    -1,
-    -1,    -1,    58,    59,    60,    61,    62,    -1,    64,    -1,
+   170,   171,   172,   173,   174,   175,   176,   177,    69,     0,
+    67,    68,     3,     4,     5,     6,     7,     8,     9,    10,
+    11,    12,    13,    14,    15,    16,    17,    18,    19,    20,
+    21,    22,    23,    63,    69,    26,    27,    28,    68,    30,
+    31,    22,    63,    69,   264,   265,   274,    68,   276,    63,
+   278,    63,    63,    63,    68,   275,    68,    68,    68,    67,
+    68,   270,    34,    35,    36,    37,    65,    58,    59,    60,
+   290,    68,   292,    64,    65,   169,   170,   171,   172,    67,
+    68,    58,    73,    74,    58,   173,   174,   175,   316,    68,
+    69,    58,   320,   326,   314,   158,   159,   317,    68,    84,
+   328,    64,   322,    62,    62,    33,    58,    69,    64,    58,
+   330,    24,    69,   341,    65,   343,   344,   345,    84,    23,
+   348,     9,    63,   351,   352,     1,    63,     3,     4,     5,
+     6,     7,    63,    69,    84,    65,    12,     0,     0,    15,
+   225,    17,    18,     8,    20,   221,    42,    43,     8,   176,
+    26,    47,    48,    49,    50,    51,    52,    53,    54,    55,
+    56,    57,   177,   345,   197,   185,    42,    43,   324,   262,
+   337,   216,   201,    -1,    50,    -1,    -1,    -1,    -1,    -1,
+    -1,    -1,    58,    59,    60,    61,    62,    83,    64,    -1,
     66,    -1,    -1,    -1,    -1,    71,    72,    73,    74,    -1,
     -1,     3,     4,     5,     6,     7,     8,    -1,    84,    11,
     12,    13,    14,    15,    16,    17,    18,    19,    20,    21,
@@ -719,55 +700,22 @@ static const short yycheck[] = {    17,
     30,    31,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
     -1,    -1,    42,    43,    -1,    -1,    -1,    -1,    -1,    -1,
     50,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    58,    59,
-    60,    61,    62,    -1,    64,    65,    66,    -1,    -1,    -1,
+    60,    61,    62,    -1,    64,    -1,    66,    -1,    -1,    -1,
     -1,    71,    72,    73,    74,    -1,    -1,     3,     4,     5,
      6,     7,     8,    -1,    84,    11,    12,    13,    14,    15,
     16,    17,    18,    19,    20,    21,    22,    -1,    -1,    -1,
     26,    27,    28,    -1,    30,    31,    -1,    -1,    -1,    -1,
     -1,    -1,    -1,    -1,    -1,    -1,    42,    43,    -1,    -1,
     -1,    -1,    -1,    -1,    50,    -1,    -1,    -1,    -1,    -1,
-    -1,    -1,    58,    59,    60,    61,    62,    -1,    64,    65,
+    -1,    -1,    58,    59,    60,    61,    62,    -1,    64,    -1,
     66,    -1,    -1,    -1,    -1,    71,    72,    73,    74,    -1,
-    -1,     3,     4,     5,     6,     7,     8,    -1,    84,    11,
-    12,    13,    14,    15,    16,    17,    18,    19,    20,    21,
-    22,    -1,    -1,    -1,    26,    27,    28,    -1,    30,    31,
-    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-    42,    43,    -1,    -1,    -1,    -1,    -1,    -1,    50,    -1,
-    -1,    -1,    -1,    -1,    -1,    -1,    58,    59,    60,    61,
-    62,    -1,    64,    -1,    66,    -1,    -1,    -1,    -1,    71,
-    72,    73,    74,    -1,    -1,     3,     4,     5,     6,     7,
-     8,    -1,    84,    11,    12,    13,    14,    15,    16,    17,
-    18,    19,    20,    21,    22,    -1,    -1,    -1,    26,    27,
-    28,    -1,    30,    31,    -1,    -1,    -1,    -1,    -1,    -1,
-    -1,    -1,    -1,    -1,    42,    43,    -1,    -1,    -1,    -1,
-    -1,    -1,    50,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-    58,    59,    60,    61,    62,    -1,    64,    -1,    66,    -1,
-    -1,    -1,    -1,    71,    72,    73,    74,    -1,    -1,    -1,
-    -1,    -1,    -1,    -1,     0,    -1,    84,     3,     4,     5,
-     6,     7,     8,     9,    10,    11,    12,    13,    14,    15,
-    16,    17,    18,    19,    20,    21,    22,    23,    -1,    -1,
-    26,    27,    28,    -1,    30,    31,     3,     4,     5,     6,
-     7,    -1,    -1,    -1,    -1,    12,    13,    -1,    15,    -1,
-    17,    18,    -1,    20,    -1,    -1,    -1,    -1,    -1,    26,
-    -1,    -1,    58,    59,    60,    -1,    -1,    -1,    64,    65,
-    -1,    -1,    -1,    -1,    -1,    42,    43,    73,    74,    -1,
-    -1,    -1,    -1,    50,    -1,    -1,    -1,    -1,    -1,    -1,
-    -1,    58,    59,    60,    61,    62,    -1,    64,    -1,    66,
-    -1,    -1,    -1,    -1,    71,    72,    73,    74,     3,     4,
-     5,     6,     7,    -1,    -1,    -1,    -1,    12,    -1,    -1,
-    15,    -1,    17,    18,    -1,    20,    -1,    -1,    -1,    -1,
-    -1,    26,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-    -1,    -1,    -1,    -1,    -1,    -1,    -1,    42,    43,    -1,
-    -1,    -1,    -1,    -1,    -1,    50,    -1,    -1,    -1,    -1,
-    -1,    -1,    -1,    58,    59,    60,    61,    62,    -1,    64,
-    -1,    66,    67,    -1,    -1,    -1,    71,    72,    73,    74,
-     3,     4,     5,     6,     7,    -1,    -1,    -1,    -1,    12,
-    -1,    -1,    15,    -1,    17,    18,    -1,    20,    -1,    -1,
+     3,     4,     5,     6,     7,    -1,    -1,    -1,    84,    12,
+    13,    -1,    15,    -1,    17,    18,    -1,    20,    -1,    -1,
     -1,    -1,    -1,    26,    -1,    -1,    -1,    -1,    -1,    -1,
     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    42,
     43,    -1,    -1,    -1,    -1,    -1,    -1,    50,    -1,    -1,
     -1,    -1,    -1,    -1,    -1,    58,    59,    60,    61,    62,
-    63,    64,    -1,    66,    -1,    -1,    -1,    -1,    71,    72,
+    -1,    64,    -1,    66,    -1,    -1,    -1,    -1,    71,    72,
     73,    74,     3,     4,     5,     6,     7,    -1,    -1,    -1,
     -1,    12,    -1,    -1,    15,    -1,    17,    18,    -1,    20,
     -1,    -1,    -1,    -1,    -1,    26,    -1,    -1,    -1,    -1,
@@ -781,8 +729,22 @@ static const short yycheck[] = {    17,
     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
     -1,    -1,    -1,    42,    43,    -1,    -1,    -1,    -1,    -1,
     -1,    50,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    58,
-    59,    60,    61,    62,    -1,    64,    -1,    66,    -1,    -1,
-    -1,    -1,    71,    72,    73,    74
+    59,    60,    61,    62,    63,    64,    -1,    66,    -1,    -1,
+    -1,    -1,    71,    72,    73,    74,     3,     4,     5,     6,
+     7,    -1,    -1,    -1,    -1,    12,    -1,    -1,    15,    -1,
+    17,    18,    -1,    20,    -1,    -1,    -1,    -1,    -1,    26,
+    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+    -1,    -1,    -1,    -1,    -1,    42,    43,    -1,    -1,    -1,
+    -1,    -1,    -1,    50,    -1,    -1,    -1,    -1,    -1,    -1,
+    -1,    58,    59,    60,    61,    62,    -1,    64,    -1,    66,
+    67,    -1,    -1,    -1,    71,    72,    73,    74,     3,     4,
+     5,     6,     7,    -1,    -1,    -1,    -1,    12,    -1,    -1,
+    15,    -1,    17,    18,    -1,    20,    -1,    -1,    -1,    -1,
+    -1,    26,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+    -1,    -1,    -1,    -1,    -1,    -1,    -1,    42,    43,    -1,
+    -1,    -1,    -1,    -1,    -1,    50,    -1,    -1,    -1,    -1,
+    -1,    -1,    -1,    58,    59,    60,    61,    62,    -1,    64,
+    -1,    66,    -1,    -1,    -1,    -1,    71,    72,    73,    74
 };
 /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
 #line 3 "/usr/share/bison.simple"
@@ -2001,15 +1963,15 @@ case 192:
 { yyval.srcs = new SourceElementsNode(yyvsp[0].src); ;
     break;}
 case 193:
-#line 623 "grammar.y"
-{ yyval.srcs = new SourceElementsNode(yyvsp[-1].srcs, yyvsp[0].src); ;
+#line 624 "grammar.y"
+{ yyval.srcs = new SourceElementsNode(yyvsp[0].srcs, yyvsp[-1].src); ;
     break;}
 case 194:
-#line 627 "grammar.y"
+#line 631 "grammar.y"
 { yyval.src = new SourceElementNode(yyvsp[0].stat); ;
     break;}
 case 195:
-#line 628 "grammar.y"
+#line 632 "grammar.y"
 { yyval.src = new SourceElementNode(yyvsp[0].func); ;
     break;}
 }
@@ -2234,7 +2196,7 @@ yyerrhandle:
     }
   return 1;
 }
-#line 631 "grammar.y"
+#line 635 "grammar.y"
 
 
 int yyerror (const char *)  /* Called by yyparse on error */
diff --git a/JavaScriptCore/kjs/grammar.y b/JavaScriptCore/kjs/grammar.y
index fbda947..44fcf23 100644
--- a/JavaScriptCore/kjs/grammar.y
+++ b/JavaScriptCore/kjs/grammar.y
@@ -620,7 +620,11 @@ Program:
 
 SourceElements:
     SourceElement                  { $$ = new SourceElementsNode($1); }
-  | SourceElements SourceElement   { $$ = new SourceElementsNode($1, $2); }
+/* #ifdef APPLE_CHANGES (not using an actual ifdef because this is yacc) */
+  | SourceElement SourceElements   { $$ = new SourceElementsNode($2, $1); }
+/* #else */
+/*| SourceElements SourceElement   { $$ = new SourceElementsNode($1, $2); } */
+/* #endif */
 ;
 
 SourceElement:
diff --git a/JavaScriptCore/kjs/nodes.cpp b/JavaScriptCore/kjs/nodes.cpp
index ace34aa..41c0498 100644
--- a/JavaScriptCore/kjs/nodes.cpp
+++ b/JavaScriptCore/kjs/nodes.cpp
@@ -3135,6 +3135,24 @@ Completion SourceElementsNode::execute(ExecState *exec)
 {
   KJS_CHECKEXCEPTION
 
+#ifdef APPLE_CHANGES
+  Completion c1 = element->execute(exec);
+  KJS_CHECKEXCEPTION;
+  if (c1.complType() != Normal)
+    return c1;
+  
+  for (SourceElementsNode *node = elements; node; node = node->elements) {
+    Completion c2 = node->element->execute(exec);
+    if (c2.complType() != Normal)
+      return c2;
+    // The spec says to return c2 here, but it seems that mozilla returns c1 if
+    // c2 doesn't have a value
+    if (!c2.value().isNull())
+      c1 = c2;
+  }
+  
+  return c1;
+#else
   if (!elements)
     return element->execute(exec);
 
@@ -3152,23 +3170,36 @@ Completion SourceElementsNode::execute(ExecState *exec)
     return c1;
   else
     return c2;
+#endif
 }
 
 // ECMA 14
 void SourceElementsNode::processFuncDecl(ExecState *exec)
 {
+#ifdef APPLE_CHANGES
+  for (SourceElementsNode *node = this; node; node = node->elements) {
+    node->element->processFuncDecl(exec);
+  }
+#else
   if (elements)
     elements->processFuncDecl(exec);
 
   element->processFuncDecl(exec);
+#endif
 }
 
 void SourceElementsNode::processVarDecls(ExecState *exec)
 {
+#ifdef APPLE_CHANGES
+  for (SourceElementsNode *node = this; node; node = node->elements) {
+    node->element->processVarDecls(exec);
+  }
+#else
   if (elements)
     elements->processVarDecls(exec);
 
   element->processVarDecls(exec);
+#endif
 }
 
 ProgramNode::ProgramNode(SourceElementsNode *s): FunctionBodyNode(s) {
diff --git a/JavaScriptCore/kjs/ustring.cpp b/JavaScriptCore/kjs/ustring.cpp
index fe17987..e0fa10e 100644
--- a/JavaScriptCore/kjs/ustring.cpp
+++ b/JavaScriptCore/kjs/ustring.cpp
@@ -119,7 +119,11 @@ bool KJS::operator==(const KJS::CString& c1, const KJS::CString& c2)
 }
 
 UChar UChar::null;
+#ifdef APPLE_CHANGES
+UString::Rep UString::Rep::null = { 0, 0, 0, 1 };
+#else
 UString::Rep UString::Rep::null = { 0, 0, 1 };
+#endif
 UString UString::null;
 #ifdef APPLE_CHANGES
 // FIXME: fix this once static initializers for pthread_once_t
@@ -173,6 +177,9 @@ UString::Rep *UString::Rep::create(UChar *d, int l)
   Rep *r = new Rep;
   r->dat = d;
   r->len = l;
+#ifdef APPLE_CHANGES
+  r->capacity = l;
+#endif
   r->rc = 1;
 
   return r;
@@ -268,12 +275,31 @@ UString UString::from(double d)
 
 UString &UString::append(const UString &t)
 {
+#ifdef APPLE_CHANGES
+  int l = size();
+  int tLen = t.size();
+  int newLen = l + tLen;
+  if (rep->rc == 1 && newLen <= rep->capacity) {
+    memcpy(rep->dat+l, t.data(), tLen * sizeof(UChar));
+    rep->len = newLen;
+    return *this;
+  }
+  
+  int newCapacity = (newLen * 3 + 1) / 2;
+  UChar *n = new UChar[newCapacity];
+  memcpy(n, data(), l * sizeof(UChar));
+  memcpy(n+l, t.data(), tLen * sizeof(UChar));
+  release();
+  rep = Rep::create(n, newLen);
+  rep->capacity = newCapacity;
+#else
   int l = size();
   UChar *n = new UChar[l+t.size()];
   memcpy(n, data(), l * sizeof(UChar));
   memcpy(n+l, t.data(), t.size() * sizeof(UChar));
   release();
   rep = Rep::create(n, l + t.size());
+#endif
 
   return *this;
 }
@@ -318,12 +344,27 @@ char *UString::ascii() const
 
 UString &UString::operator=(const char *c)
 {
+#ifdef APPLE_CHANGES
+  int l = c ? strlen(c) : 0;
+  UChar *d;
+  if (rep->rc == 1 && l < rep->capacity) {
+    d = rep->dat;
+  } else {
+    release();
+    d = new UChar[l];
+    rep = Rep::create(d, l);
+  }
+  for (int i = 0; i < l; i++)
+    d[i].uc = (uchar)c[i];
+#else
   release();
   int l = c ? strlen(c) : 0;
+
   UChar *d = new UChar[l];
   for (int i = 0; i < l; i++)
     d[i].uc = c[i];
   rep = Rep::create(d, l);
+#endif
 
   return *this;
 }
diff --git a/JavaScriptCore/kjs/ustring.h b/JavaScriptCore/kjs/ustring.h
index 2658cb6..0c8f5f5 100644
--- a/JavaScriptCore/kjs/ustring.h
+++ b/JavaScriptCore/kjs/ustring.h
@@ -56,9 +56,15 @@ namespace KJS {
    * possible to exchange data with X and Qt with shallow copies.
    */
   struct UChar {
+#ifdef APPLE_CHANGES
+    /**
+     * Construct a character with uninitialized value.    
+     */
+#else
     /**
-     * Construct a character with value 0.
+     * Construct a character with value 0.    
      */
+#endif
     UChar();
     /**
      * Construct a character with the value denoted by the arguments.
@@ -107,7 +113,11 @@ namespace KJS {
     unsigned short uc;
   };
 
+#ifdef APPLE_CHANGES
   inline UChar::UChar() : uc(0) { }
+#else
+  inline UChar::UChar() { }
+#endif
   inline UChar::UChar(unsigned char h , unsigned char l) : uc(h << 8 | l) { }
   inline UChar::UChar(unsigned short u) : uc(u) { }
 
@@ -209,6 +219,9 @@ namespace KJS {
 
       UChar *dat;
       int len;
+#ifdef APPLE_CHANGES
+      int capacity;
+#endif
       int rc;
       static Rep null;
     };
@@ -231,12 +244,21 @@ namespace KJS {
      * length.
      */
     UString(const UChar *c, int length);
+#ifdef APPLE_CHANGES
+    /**
+     * If copy is false the string data will be adopted.
+     * That means that the data will NOT be copied and the pointer will
+     * be deleted when the UString object is modified or destroyed.
+     * Behaviour defaults to a deep copy if copy is true.
+     */
+#else
     /**
      * If copy is false a shallow copy of the string will be created. That
      * means that the data will NOT be copied and you'll have to guarantee that
      * it doesn't get deleted during the lifetime of the UString object.
      * Behaviour defaults to a deep copy if copy is true.
      */
+#endif
     UString(UChar *c, int length, bool copy);
     /**
      * Copy constructor. Makes a shallow copy only.

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list