OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 // Assert that the passed function or eval code does not throw an exception. | 92 // Assert that the passed function or eval code does not throw an exception. |
93 var assertDoesNotThrow; | 93 var assertDoesNotThrow; |
94 | 94 |
95 // Asserts that the found value is an instance of the constructor passed | 95 // Asserts that the found value is an instance of the constructor passed |
96 // as the second argument. | 96 // as the second argument. |
97 var assertInstanceof; | 97 var assertInstanceof; |
98 | 98 |
99 // Assert that this code is never executed (i.e., always fails if executed). | 99 // Assert that this code is never executed (i.e., always fails if executed). |
100 var assertUnreachable; | 100 var assertUnreachable; |
101 | 101 |
| 102 // Assert that the function code is (not) optimized. If "no sync" is passed |
| 103 // as second argument, we do not wait for the parallel optimization thread to |
| 104 // finish when polling for optimization status. |
| 105 // Only works with --allow-natives-syntax. |
| 106 var assertOptimized; |
| 107 var assertUnoptimized; |
| 108 |
| 109 |
102 (function () { // Scope for utility functions. | 110 (function () { // Scope for utility functions. |
103 | 111 |
104 function classOf(object) { | 112 function classOf(object) { |
105 // Argument must not be null or undefined. | 113 // Argument must not be null or undefined. |
106 var string = Object.prototype.toString.call(object); | 114 var string = Object.prototype.toString.call(object); |
107 // String has format [object <ClassName>]. | 115 // String has format [object <ClassName>]. |
108 return string.substring(8, string.length - 1); | 116 return string.substring(8, string.length - 1); |
109 } | 117 } |
110 | 118 |
111 | 119 |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 | 354 |
347 assertUnreachable = function assertUnreachable(name_opt) { | 355 assertUnreachable = function assertUnreachable(name_opt) { |
348 // Fix this when we ditch the old test runner. | 356 // Fix this when we ditch the old test runner. |
349 var message = "Fail" + "ure: unreachable"; | 357 var message = "Fail" + "ure: unreachable"; |
350 if (name_opt) { | 358 if (name_opt) { |
351 message += " - " + name_opt; | 359 message += " - " + name_opt; |
352 } | 360 } |
353 throw new MjsUnitAssertionError(message); | 361 throw new MjsUnitAssertionError(message); |
354 }; | 362 }; |
355 | 363 |
| 364 |
| 365 var OptimizationStatus; |
| 366 try { |
| 367 OptimizationStatus = |
| 368 new Function("fun", "sync", "return %GetOptimizationStatus(fun, sync);"); |
| 369 } catch (e) { |
| 370 OptimizationStatus = function() { |
| 371 throw new Error("natives syntax not allowed"); |
| 372 } |
| 373 } |
| 374 |
| 375 assertUnoptimized = function assertUnoptimized(fun, sync_opt, name_opt) { |
| 376 if (sync_opt === undefined) sync_opt = ""; |
| 377 assertTrue(OptimizationStatus(fun, sync_opt) != 1, name_opt); |
| 378 } |
| 379 |
| 380 assertOptimized = function assertOptimized(fun, sync_opt, name_opt) { |
| 381 if (sync_opt === undefined) sync_opt = ""; |
| 382 assertTrue(OptimizationStatus(fun, sync_opt) != 2, name_opt); |
| 383 } |
| 384 |
356 })(); | 385 })(); |
357 | 386 |
OLD | NEW |