Upgrade to 3.29
Update V8 to 3.29.88.17 and update makefiles to support building on
all the relevant platforms.
Bug: 17370214
Change-Id: Ia3407c157fd8d72a93e23d8318ccaf6ecf77fa4e
diff --git a/test/mjsunit/mjsunit.js b/test/mjsunit/mjsunit.js
index 033c78f..0430279 100644
--- a/test/mjsunit/mjsunit.js
+++ b/test/mjsunit/mjsunit.js
@@ -54,6 +54,10 @@
// and the properties of non-Array objects).
var assertEquals;
+
+// The difference between expected and found value is within certain tolerance.
+var assertEqualsDelta;
+
// The found object is an Array with the same length and elements
// as the expected object. The expected object doesn't need to be an Array,
// as long as it's "array-ish".
@@ -75,7 +79,7 @@
// Checks that the found value is false.
var assertFalse;
-// Checks that the found value is null. Kept for historical compatability,
+// Checks that the found value is null. Kept for historical compatibility,
// please just use assertEquals(null, expected).
var assertNull;
@@ -99,6 +103,14 @@
// Assert that this code is never executed (i.e., always fails if executed).
var assertUnreachable;
+// Assert that the function code is (not) optimized. If "no sync" is passed
+// as second argument, we do not wait for the concurrent optimization thread to
+// finish when polling for optimization status.
+// Only works with --allow-natives-syntax.
+var assertOptimized;
+var assertUnoptimized;
+
+
(function () { // Scope for utility functions.
function classOf(object) {
@@ -219,8 +231,16 @@
return deepObjectEquals(a, b);
}
+ function checkArity(args, arity, name) {
+ if (args.length < arity) {
+ fail(PrettyPrint(arity), args.length,
+ name + " requires " + arity + " or more arguments");
+ }
+ }
assertSame = function assertSame(expected, found, name_opt) {
+ checkArity(arguments, 2, "assertSame");
+
// TODO(mstarzinger): We should think about using Harmony's egal operator
// or the function equivalent Object.is() here.
if (found === expected) {
@@ -233,12 +253,20 @@
assertEquals = function assertEquals(expected, found, name_opt) {
+ checkArity(arguments, 2, "assertEquals");
+
if (!deepEquals(found, expected)) {
fail(PrettyPrint(expected), found, name_opt);
}
};
+ assertEqualsDelta =
+ function assertEqualsDelta(expected, found, delta, name_opt) {
+ assertTrue(Math.abs(expected - found) <= delta, name_opt);
+ };
+
+
assertArrayEquals = function assertArrayEquals(expected, found, name_opt) {
var start = "";
if (name_opt) {
@@ -321,7 +349,7 @@
assertInstanceof = function assertInstanceof(obj, type) {
if (!(obj instanceof type)) {
var actualTypeName = null;
- var actualConstructor = Object.prototypeOf(obj).constructor;
+ var actualConstructor = Object.getPrototypeOf(obj).constructor;
if (typeof actualConstructor == "function") {
actualTypeName = actualConstructor.name || String(actualConstructor);
}
@@ -353,5 +381,28 @@
throw new MjsUnitAssertionError(message);
};
-})();
+ var OptimizationStatusImpl = undefined;
+ var OptimizationStatus = function(fun, sync_opt) {
+ if (OptimizationStatusImpl === undefined) {
+ try {
+ OptimizationStatusImpl = new Function(
+ "fun", "sync", "return %GetOptimizationStatus(fun, sync);");
+ } catch (e) {
+ throw new Error("natives syntax not allowed");
+ }
+ }
+ return OptimizationStatusImpl(fun, sync_opt);
+ }
+
+ assertUnoptimized = function assertUnoptimized(fun, sync_opt, name_opt) {
+ if (sync_opt === undefined) sync_opt = "";
+ assertTrue(OptimizationStatus(fun, sync_opt) != 1, name_opt);
+ }
+
+ assertOptimized = function assertOptimized(fun, sync_opt, name_opt) {
+ if (sync_opt === undefined) sync_opt = "";
+ assertTrue(OptimizationStatus(fun, sync_opt) != 2, name_opt);
+ }
+
+})();