OLD | NEW |
(Empty) | |
| 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
| 2 /* ***** BEGIN LICENSE BLOCK ***** |
| 3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
| 4 * |
| 5 * The contents of this file are subject to the Mozilla Public License Version |
| 6 * 1.1 (the "License"); you may not use this file except in compliance with |
| 7 * the License. You may obtain a copy of the License at |
| 8 * http://www.mozilla.org/MPL/ |
| 9 * |
| 10 * Software distributed under the License is distributed on an "AS IS" basis, |
| 11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
| 12 * for the specific language governing rights and limitations under the |
| 13 * License. |
| 14 * |
| 15 * The Original Code is JavaScript Engine testing utilities. |
| 16 * |
| 17 * The Initial Developer of the Original Code is |
| 18 * Mozilla Foundation. |
| 19 * Portions created by the Initial Developer are Copyright (C) 2008 |
| 20 * the Initial Developer. All Rights Reserved. |
| 21 * |
| 22 * Contributor(s): Boris Zbarsky |
| 23 * |
| 24 * Alternatively, the contents of this file may be used under the terms of |
| 25 * either the GNU General Public License Version 2 or later (the "GPL"), or |
| 26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), |
| 27 * in which case the provisions of the GPL or the LGPL are applicable instead |
| 28 * of those above. If you wish to allow use of your version of this file only |
| 29 * under the terms of either the GPL or the LGPL, and not to allow others to |
| 30 * use your version of this file under the terms of the MPL, indicate your |
| 31 * decision by deleting the provisions above and replace them with the notice |
| 32 * and other provisions required by the GPL or the LGPL. If you do not delete |
| 33 * the provisions above, a recipient may use your version of this file under |
| 34 * the terms of any one of the MPL, the GPL or the LGPL. |
| 35 * |
| 36 * ***** END LICENSE BLOCK ***** */ |
| 37 |
| 38 var gTestfile = 'regress-456826.js'; |
| 39 //----------------------------------------------------------------------------- |
| 40 var BUGNUMBER = 456826; |
| 41 var summary = 'Do not assert with JIT during OOM'; |
| 42 var actual = 'No Crash'; |
| 43 var expect = 'No Crash'; |
| 44 |
| 45 |
| 46 //----------------------------------------------------------------------------- |
| 47 test(); |
| 48 //----------------------------------------------------------------------------- |
| 49 |
| 50 function test() |
| 51 { |
| 52 enterFunc ('test'); |
| 53 printBugNumber(BUGNUMBER); |
| 54 printStatus (summary); |
| 55 |
| 56 jit(true); |
| 57 |
| 58 if (typeof gcparam != 'undefined') |
| 59 { |
| 60 gcparam("maxBytes", 22000); |
| 61 } |
| 62 |
| 63 const numRows = 600; |
| 64 const numCols = 600; |
| 65 var scratch = {}; |
| 66 var scratchZ = {}; |
| 67 |
| 68 function complexMult(a, b) { |
| 69 var newr = a.r * b.r - a.i * b.i; |
| 70 var newi = a.r * b.i + a.i * b.r; |
| 71 scratch.r = newr; |
| 72 scratch.i = newi; |
| 73 return scratch; |
| 74 } |
| 75 |
| 76 function complexAdd(a, b) { |
| 77 scratch.r = a.r + b.r; |
| 78 scratch.i = a.i + b.i; |
| 79 return scratch; |
| 80 } |
| 81 |
| 82 function abs(a) { |
| 83 return Math.sqrt(a.r * a.r + a.i * a.i); |
| 84 } |
| 85 |
| 86 function computeEscapeSpeed(c) { |
| 87 scratchZ.r = scratchZ.i = 0; |
| 88 const scaler = 5; |
| 89 const threshold = (colors.length - 1) * scaler + 1; |
| 90 for (var i = 1; i < threshold; ++i) { |
| 91 scratchZ = complexAdd(c, complexMult(scratchZ, scratchZ)); |
| 92 if (scratchZ.r * scratchZ.r + scratchZ.i * scratchZ.i > 4) { |
| 93 return Math.floor((i - 1) / scaler) + 1; |
| 94 } |
| 95 } |
| 96 return 0; |
| 97 } |
| 98 |
| 99 const colorStrings = [ |
| 100 "black", |
| 101 "green", |
| 102 "blue", |
| 103 "red", |
| 104 "purple", |
| 105 "orange", |
| 106 "cyan", |
| 107 "yellow", |
| 108 "magenta", |
| 109 "brown", |
| 110 "pink", |
| 111 "chartreuse", |
| 112 "darkorange", |
| 113 "crimson", |
| 114 "gray", |
| 115 "deeppink", |
| 116 "firebrick", |
| 117 "lavender", |
| 118 "lawngreen", |
| 119 "lightsalmon", |
| 120 "lime", |
| 121 "goldenrod" |
| 122 ]; |
| 123 |
| 124 var colors = []; |
| 125 |
| 126 function createMandelSet(realRange, imagRange) { |
| 127 var start = new Date(); |
| 128 |
| 129 // Set up our colors |
| 130 for each (var color in colorStrings) { |
| 131 var [r, g, b] = [0, 0, 0]; |
| 132 colors.push([r, g, b, 0xff]); |
| 133 } |
| 134 |
| 135 var realStep = (realRange.max - realRange.min)/numCols; |
| 136 var imagStep = (imagRange.min - imagRange.max)/numRows; |
| 137 for (var i = 0, curReal = realRange.min; |
| 138 i < numCols; |
| 139 ++i, curReal += realStep) { |
| 140 for (var j = 0, curImag = imagRange.max; |
| 141 j < numRows; |
| 142 ++j, curImag += imagStep) { |
| 143 var c = { r: curReal, i: curImag } |
| 144 var n = computeEscapeSpeed(c); |
| 145 } |
| 146 } |
| 147 print(Date.now() - start); |
| 148 } |
| 149 |
| 150 var realRange = { min: -2.1, max: 2 }; |
| 151 var imagRange = { min: -2, max: 2 }; |
| 152 createMandelSet(realRange, imagRange); |
| 153 |
| 154 jit(false); |
| 155 |
| 156 reportCompare(expect, actual, summary); |
| 157 |
| 158 exitFunc ('test'); |
| 159 } |
OLD | NEW |