1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/js1_6/extensions/regress-456826.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,130 @@ 1.4 +// |reftest| skip-if(!xulRuntime.shell||Android) slow -- bug 504632 1.5 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +//----------------------------------------------------------------------------- 1.11 +var BUGNUMBER = 456826; 1.12 +var summary = 'Do not assert with JIT during OOM'; 1.13 +var actual = 'No Crash'; 1.14 +var expect = 'No Crash'; 1.15 + 1.16 + 1.17 +//----------------------------------------------------------------------------- 1.18 +test(); 1.19 +//----------------------------------------------------------------------------- 1.20 + 1.21 +function test() 1.22 +{ 1.23 + enterFunc ('test'); 1.24 + printBugNumber(BUGNUMBER); 1.25 + printStatus (summary); 1.26 + 1.27 + jit(true); 1.28 + 1.29 + if (typeof gcparam != 'undefined') 1.30 + { 1.31 + gc(); 1.32 + gc(); 1.33 + gcparam("maxBytes", gcparam("gcBytes") + 4*1024); 1.34 + expectExitCode(5); 1.35 + } 1.36 + 1.37 + const numRows = 600; 1.38 + const numCols = 600; 1.39 + var scratch = {}; 1.40 + var scratchZ = {}; 1.41 + 1.42 + function complexMult(a, b) { 1.43 + var newr = a.r * b.r - a.i * b.i; 1.44 + var newi = a.r * b.i + a.i * b.r; 1.45 + scratch.r = newr; 1.46 + scratch.i = newi; 1.47 + return scratch; 1.48 + } 1.49 + 1.50 + function complexAdd(a, b) { 1.51 + scratch.r = a.r + b.r; 1.52 + scratch.i = a.i + b.i; 1.53 + return scratch; 1.54 + } 1.55 + 1.56 + function abs(a) { 1.57 + return Math.sqrt(a.r * a.r + a.i * a.i); 1.58 + } 1.59 + 1.60 + function computeEscapeSpeed(c) { 1.61 + scratchZ.r = scratchZ.i = 0; 1.62 + const scaler = 5; 1.63 + const threshold = (colors.length - 1) * scaler + 1; 1.64 + for (var i = 1; i < threshold; ++i) { 1.65 + scratchZ = complexAdd(c, complexMult(scratchZ, scratchZ)); 1.66 + if (scratchZ.r * scratchZ.r + scratchZ.i * scratchZ.i > 4) { 1.67 + return Math.floor((i - 1) / scaler) + 1; 1.68 + } 1.69 + } 1.70 + return 0; 1.71 + } 1.72 + 1.73 + const colorStrings = [ 1.74 + "black", 1.75 + "green", 1.76 + "blue", 1.77 + "red", 1.78 + "purple", 1.79 + "orange", 1.80 + "cyan", 1.81 + "yellow", 1.82 + "magenta", 1.83 + "brown", 1.84 + "pink", 1.85 + "chartreuse", 1.86 + "darkorange", 1.87 + "crimson", 1.88 + "gray", 1.89 + "deeppink", 1.90 + "firebrick", 1.91 + "lavender", 1.92 + "lawngreen", 1.93 + "lightsalmon", 1.94 + "lime", 1.95 + "goldenrod" 1.96 + ]; 1.97 + 1.98 + var colors = []; 1.99 + 1.100 + function createMandelSet(realRange, imagRange) { 1.101 + var start = new Date(); 1.102 + 1.103 + // Set up our colors 1.104 + for each (var color in colorStrings) { 1.105 + var [r, g, b] = [0, 0, 0]; 1.106 + colors.push([r, g, b, 0xff]); 1.107 + } 1.108 + 1.109 + var realStep = (realRange.max - realRange.min)/numCols; 1.110 + var imagStep = (imagRange.min - imagRange.max)/numRows; 1.111 + for (var i = 0, curReal = realRange.min; 1.112 + i < numCols; 1.113 + ++i, curReal += realStep) { 1.114 + for (var j = 0, curImag = imagRange.max; 1.115 + j < numRows; 1.116 + ++j, curImag += imagStep) { 1.117 + var c = { r: curReal, i: curImag } 1.118 + var n = computeEscapeSpeed(c); 1.119 + } 1.120 + } 1.121 + print(Date.now() - start); 1.122 + } 1.123 + 1.124 + var realRange = { min: -2.1, max: 2 }; 1.125 + var imagRange = { min: -2, max: 2 }; 1.126 + createMandelSet(realRange, imagRange); 1.127 + 1.128 + jit(false); 1.129 + 1.130 + reportCompare(expect, actual, summary); 1.131 + 1.132 + exitFunc ('test'); 1.133 +}