Version 1.2.12.

Added stack traces collection to Error objects accessible through the e.stack property.

Changed RegExp parser to use a recursive data structure instead of stack-based recursion.

Optimized Date object construction and string concatenation.

Improved performance of div, mod, and mul on ARM platforms.


git-svn-id: http://v8.googlecode.com/svn/trunk@2361 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
diff --git a/test/cctest/test-regexp.cc b/test/cctest/test-regexp.cc
index 8761cf5..62597fb 100644
--- a/test/cctest/test-regexp.cc
+++ b/test/cctest/test-regexp.cc
@@ -204,8 +204,8 @@
   CHECK_PARSE_EQ("(?=a){9,10}a", "(: (-> + 'a') 'a')");
   CHECK_PARSE_EQ("(?!a)?a", "'a'");
   CHECK_PARSE_EQ("\\1(a)", "(^ 'a')");
-  CHECK_PARSE_EQ("(?!(a))\\1", "(-> - (^ 'a'))");
-  CHECK_PARSE_EQ("(?!\\1(a\\1)\\1)\\1", "(-> - (: (^ 'a') (<- 1)))");
+  CHECK_PARSE_EQ("(?!(a))\\1", "(: (-> - (^ 'a')) (<- 1))");
+  CHECK_PARSE_EQ("(?!\\1(a\\1)\\1)\\1", "(: (-> - (: (^ 'a') (<- 1))) (<- 1))");
   CHECK_PARSE_EQ("[\\0]", "[\\x00]");
   CHECK_PARSE_EQ("[\\11]", "[\\x09]");
   CHECK_PARSE_EQ("[\\11a]", "[\\x09 a]");
diff --git a/test/mjsunit/div-mod.js b/test/mjsunit/div-mod.js
new file mode 100644
index 0000000..39fab27
--- /dev/null
+++ b/test/mjsunit/div-mod.js
@@ -0,0 +1,95 @@
+// Copyright 2009 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+//       notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+//       copyright notice, this list of conditions and the following
+//       disclaimer in the documentation and/or other materials provided
+//       with the distribution.
+//     * Neither the name of Google Inc. nor the names of its
+//       contributors may be used to endorse or promote products derived
+//       from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Test fast div and mod.
+
+function divmod(div_func, mod_func, x, y) {
+  var div_answer = (div_func)(x);
+  assertEquals(x / y, div_answer, x + "/" + y);
+  var mod_answer = (mod_func)(x);
+  assertEquals(x % y, mod_answer, x + "%" + y);
+  var minus_div_answer = (div_func)(-x);
+  assertEquals(-x / y, minus_div_answer, "-" + x + "/" + y);
+  var minus_mod_answer = (mod_func)(-x);
+  assertEquals(-x % y, minus_mod_answer, "-" + x + "%" + y);
+}
+
+
+function run_tests_for(divisor) {
+  print("(function(left) { return left / " + divisor + "; })");
+  var div_func = this.eval("(function(left) { return left / " + divisor + "; })");
+  var mod_func = this.eval("(function(left) { return left % " + divisor + "; })");
+  var exp;
+  // Strange number test.
+  divmod(div_func, mod_func, 0, divisor);
+  divmod(div_func, mod_func, 1 / 0, divisor);
+  // Floating point number test.
+  for (exp = -1024; exp <= 1024; exp += 4) {
+    divmod(div_func, mod_func, Math.pow(2, exp), divisor);
+    divmod(div_func, mod_func, 0.9999999 * Math.pow(2, exp), divisor);
+    divmod(div_func, mod_func, 1.0000001 * Math.pow(2, exp), divisor);
+  }
+  // Integer number test.
+  for (exp = 0; exp <= 32; exp++) {
+    divmod(div_func, mod_func, 1 << exp, divisor);
+    divmod(div_func, mod_func, (1 << exp) + 1, divisor);
+    divmod(div_func, mod_func, (1 << exp) - 1, divisor);
+  }
+  divmod(div_func, mod_func, Math.floor(0x1fffffff / 3), divisor);
+  divmod(div_func, mod_func, Math.floor(-0x20000000 / 3), divisor);
+}
+
+
+var divisors = [
+  0,
+  1,
+  2,
+  3,
+  4,
+  5,
+  6,
+  7,
+  8,
+  9,
+  10,
+  // These ones in the middle don't add much apart from slowness to the test.
+  0x1000000,
+  0x2000000,
+  0x4000000,
+  0x8000000,
+  0x10000000,
+  0x20000000,
+  0x40000000,
+  12,
+  60,
+  100,
+  1000 * 60 * 60 * 24];
+
+for (var i = 0; i < divisors.length; i++) {
+  run_tests_for(divisors[i]);
+}
+
diff --git a/test/mjsunit/fuzz-natives.js b/test/mjsunit/fuzz-natives.js
index debcc9a..c653b18 100644
--- a/test/mjsunit/fuzz-natives.js
+++ b/test/mjsunit/fuzz-natives.js
@@ -126,7 +126,9 @@
   "CreateArrayLiteralBoilerplate": true,
   "IS_VAR": true,
   "ResolvePossiblyDirectEval": true,
-  "Log": true
+  "Log": true,
+
+  "CollectStackTrace": true
 };
 
 var currentlyUncallable = {
diff --git a/test/mjsunit/regress/regress-396.js b/test/mjsunit/regress/regress-396.js
new file mode 100644
index 0000000..e6f2ce3
--- /dev/null
+++ b/test/mjsunit/regress/regress-396.js
@@ -0,0 +1,39 @@
+// Copyright 2009 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+//       notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+//       copyright notice, this list of conditions and the following
+//       disclaimer in the documentation and/or other materials provided
+//       with the distribution.
+//     * Neither the name of Google Inc. nor the names of its
+//       contributors may be used to endorse or promote products derived
+//       from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// http://code.google.com/p/v8/issues/detail?id=396
+
+function DateYear(date) {
+  var string = date.getYear() + '';
+  if (string.length < 4) {
+    string = '' + (string - 0 + 1900);
+  }
+  return string;
+}
+
+assertEquals('1995', DateYear(new Date('Dec 25, 1995')));
+assertEquals('2005', DateYear(new Date('Dec 25, 2005')));
diff --git a/test/mjsunit/smi-negative-zero.js b/test/mjsunit/smi-negative-zero.js
index 99ddc97..afeb6de 100644
--- a/test/mjsunit/smi-negative-zero.js
+++ b/test/mjsunit/smi-negative-zero.js
@@ -37,64 +37,64 @@
 
 // variable op variable
 
-assertEquals(one / (-zero), -Infinity);
+assertEquals(one / (-zero), -Infinity, "one / -0 I");
 
-assertEquals(one / (zero * minus_one), -Infinity);
-assertEquals(one / (minus_one * zero), -Infinity);
-assertEquals(one / (zero * zero), Infinity);
-assertEquals(one / (minus_one * minus_one), 1);
+assertEquals(one / (zero * minus_one), -Infinity, "one / -1");
+assertEquals(one / (minus_one * zero), -Infinity, "one / -0 II");
+assertEquals(one / (zero * zero), Infinity, "one / 0 I");
+assertEquals(one / (minus_one * minus_one), 1, "one / 1");
 
-assertEquals(one / (zero / minus_one), -Infinity);
-assertEquals(one / (zero / one), Infinity);
+assertEquals(one / (zero / minus_one), -Infinity, "one / -0 III");
+assertEquals(one / (zero / one), Infinity, "one / 0 II");
 
-assertEquals(one / (minus_four % two), -Infinity);
-assertEquals(one / (minus_four % minus_two), -Infinity);
-assertEquals(one / (four % two), Infinity);
-assertEquals(one / (four % minus_two), Infinity);
+assertEquals(one / (minus_four % two), -Infinity, "foo");
+assertEquals(one / (minus_four % minus_two), -Infinity, "foo");
+assertEquals(one / (four % two), Infinity, "foo");
+assertEquals(one / (four % minus_two), Infinity, "foo");
 
 // literal op variable
 
-assertEquals(one / (0 * minus_one), -Infinity);
-assertEquals(one / (-1 * zero), -Infinity);
-assertEquals(one / (0 * zero), Infinity);
-assertEquals(one / (-1 * minus_one), 1);
+assertEquals(one / (0 * minus_one), -Infinity, "bar");
+assertEquals(one / (-1 * zero), -Infinity, "bar");
+assertEquals(one / (0 * zero), Infinity, "bar");
+assertEquals(one / (-1 * minus_one), 1, "bar");
 
-assertEquals(one / (0 / minus_one), -Infinity);
-assertEquals(one / (0 / one), Infinity);
+assertEquals(one / (0 / minus_one), -Infinity, "baz");
+assertEquals(one / (0 / one), Infinity, "baz");
 
-assertEquals(one / (-4 % two), -Infinity);
-assertEquals(one / (-4 % minus_two), -Infinity);
-assertEquals(one / (4 % two), Infinity);
-assertEquals(one / (4 % minus_two), Infinity);
+assertEquals(one / (-4 % two), -Infinity, "baz");
+assertEquals(one / (-4 % minus_two), -Infinity, "baz");
+assertEquals(one / (4 % two), Infinity, "baz");
+assertEquals(one / (4 % minus_two), Infinity, "baz");
 
 // variable op literal
 
-assertEquals(one / (zero * -1), -Infinity);
-assertEquals(one / (minus_one * 0), -Infinity);
-assertEquals(one / (zero * 0), Infinity);
-assertEquals(one / (minus_one * -1), 1);
+assertEquals(one / (zero * -1), -Infinity, "fizz");
+assertEquals(one / (minus_one * 0), -Infinity, "fizz");
+assertEquals(one / (zero * 0), Infinity, "fizz");
+assertEquals(one / (minus_one * -1), 1, "fizz");
 
-assertEquals(one / (zero / -1), -Infinity);
-assertEquals(one / (zero / 1), Infinity);
+assertEquals(one / (zero / -1), -Infinity, "buzz");
+assertEquals(one / (zero / 1), Infinity, "buzz");
 
-assertEquals(one / (minus_four % 2), -Infinity);
-assertEquals(one / (minus_four % -2), -Infinity);
-assertEquals(one / (four % 2), Infinity);
-assertEquals(one / (four % -2), Infinity);
+assertEquals(one / (minus_four % 2), -Infinity, "buzz");
+assertEquals(one / (minus_four % -2), -Infinity, "buzz");
+assertEquals(one / (four % 2), Infinity, "buzz");
+assertEquals(one / (four % -2), Infinity, "buzz");
 
 // literal op literal
 
-assertEquals(one / (-0), -Infinity);
+assertEquals(one / (-0), -Infinity, "fisk1");
 
-assertEquals(one / (0 * -1), -Infinity);
-assertEquals(one / (-1 * 0), -Infinity);
-assertEquals(one / (0 * 0), Infinity);
-assertEquals(one / (-1 * -1), 1);
+assertEquals(one / (0 * -1), -Infinity, "fisk2");
+assertEquals(one / (-1 * 0), -Infinity, "fisk3");
+assertEquals(one / (0 * 0), Infinity, "fisk4");
+assertEquals(one / (-1 * -1), 1, "fisk5");
 
-assertEquals(one / (0 / -1), -Infinity);
-assertEquals(one / (0 / 1), Infinity);
+assertEquals(one / (0 / -1), -Infinity, "hest");
+assertEquals(one / (0 / 1), Infinity, "hest");
 
-assertEquals(one / (-4 % 2), -Infinity);
-assertEquals(one / (-4 % -2), -Infinity);
-assertEquals(one / (4 % 2), Infinity);
-assertEquals(one / (4 % -2), Infinity);
+assertEquals(one / (-4 % 2), -Infinity, "fiskhest");
+assertEquals(one / (-4 % -2), -Infinity, "fiskhest");
+assertEquals(one / (4 % 2), Infinity, "fiskhest");
+assertEquals(one / (4 % -2), Infinity, "fiskhest");
diff --git a/test/mjsunit/stack-traces.js b/test/mjsunit/stack-traces.js
index 6ac8b0a..e457ece 100644
--- a/test/mjsunit/stack-traces.js
+++ b/test/mjsunit/stack-traces.js
@@ -25,8 +25,6 @@
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-Error.captureStackTraces = true;
-
 function testMethodNameInference() {
   function Foo() { }
   Foo.prototype.bar = function () { FAIL; };
@@ -75,6 +73,17 @@
   new Plonk();
 }
 
+function testRenamedMethod() {
+  function a$b$c$d() { return FAIL; }
+  function Wookie() { }
+  Wookie.prototype.d = a$b$c$d;
+  (new Wookie).d();
+}
+
+function testAnonymousMethod() {
+  (function () { FAIL }).call([1, 2, 3]);
+}
+
 // Utility function for testing that the expected strings occur
 // in the stack trace produced when running the given function.
 function testTrace(fun, expected) {
@@ -151,9 +160,11 @@
 testTrace(testMethodNameInference, ["at Foo.bar"]);
 testTrace(testImplicitConversion, ["at Nirk.valueOf"]);
 testTrace(testEval, ["at Doo (eval at testEval"]);
-testTrace(testNestedEval, ["at eval (eval at Inner (eval at Outer"]);
+testTrace(testNestedEval, ["eval at Inner (eval at Outer"]);
 testTrace(testValue, ["at Number.causeError"]);
 testTrace(testConstructor, ["new Plonk"]);
+testTrace(testRenamedMethod, ["Wookie.a$b$c$d [as d]"]);
+testTrace(testAnonymousMethod, ["Array.<anonymous>"]);
 
 testCallerCensorship();
 testUnintendedCallerCensorship();
diff --git a/test/mozilla/mozilla.status b/test/mozilla/mozilla.status
index 760ed41..13ae29c 100644
--- a/test/mozilla/mozilla.status
+++ b/test/mozilla/mozilla.status
@@ -476,12 +476,11 @@
 js1_5/Array/regress-313153: FAIL_OK
 
 
-# Properties stack, fileName, and lineNumber of Error instances are
+# Properties fileName, and lineNumber of Error instances are
 # not supported. Mozilla specific extension.
 js1_5/Exceptions/errstack-001: FAIL_OK
 js1_5/Exceptions/regress-257751: FAIL_OK
 js1_5/Regress/regress-119719: FAIL_OK
-js1_5/Regress/regress-139316: FAIL_OK
 js1_5/Regress/regress-167328: FAIL_OK
 js1_5/Regress/regress-243869: FAIL_OK