| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 10 matching lines...) Expand all Loading... |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #include <v8.h> | 28 #include <v8.h> |
| 29 #include <v8-testing.h> | 29 #include <v8-testing.h> |
| 30 #include <assert.h> | 30 #include <assert.h> |
| 31 #ifdef COMPRESS_STARTUP_DATA_BZ2 |
| 32 #include <bzlib.h> |
| 33 #endif |
| 31 #include <fcntl.h> | 34 #include <fcntl.h> |
| 32 #include <string.h> | 35 #include <string.h> |
| 33 #include <stdio.h> | 36 #include <stdio.h> |
| 34 #include <stdlib.h> | 37 #include <stdlib.h> |
| 35 | 38 |
| 36 // When building with V8 in a shared library we cannot use functions which | 39 // When building with V8 in a shared library we cannot use functions which |
| 37 // is not explicitly a part of the public V8 API. This extensive use of | 40 // is not explicitly a part of the public V8 API. This extensive use of |
| 38 // #ifndef USING_V8_SHARED/#endif is a hack until we can resolve whether to | 41 // #ifndef USING_V8_SHARED/#endif is a hack until we can resolve whether to |
| 39 // still use the shell sample for testing or change to use the developer | 42 // still use the shell sample for testing or change to use the developer |
| 40 // shell d8 TODO(1272). | 43 // shell d8 TODO(1272). |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 FLAG_stress_deopt = true; | 295 FLAG_stress_deopt = true; |
| 293 argv[i] = NULL; | 296 argv[i] = NULL; |
| 294 } else if (strcmp(argv[i], "--noalways-opt") == 0) { | 297 } else if (strcmp(argv[i], "--noalways-opt") == 0) { |
| 295 // No support for stressing if we can't use --always-opt. | 298 // No support for stressing if we can't use --always-opt. |
| 296 FLAG_stress_opt = false; | 299 FLAG_stress_opt = false; |
| 297 FLAG_stress_deopt = false; | 300 FLAG_stress_deopt = false; |
| 298 break; | 301 break; |
| 299 } | 302 } |
| 300 } | 303 } |
| 301 | 304 |
| 305 #ifdef COMPRESS_STARTUP_DATA_BZ2 |
| 306 ASSERT_EQ(v8::StartupData::kBZip2, |
| 307 v8::V8::GetCompressedStartupDataAlgorithm()); |
| 308 int compressed_data_count = v8::V8::GetCompressedStartupDataCount(); |
| 309 v8::StartupData* compressed_data = new v8::StartupData[compressed_data_count]; |
| 310 v8::V8::GetCompressedStartupData(compressed_data); |
| 311 for (int i = 0; i < compressed_data_count; ++i) { |
| 312 char* decompressed = new char[compressed_data[i].raw_size]; |
| 313 unsigned int decompressed_size = compressed_data[i].raw_size; |
| 314 int result = |
| 315 BZ2_bzBuffToBuffDecompress(decompressed, |
| 316 &decompressed_size, |
| 317 const_cast<char*>(compressed_data[i].data), |
| 318 compressed_data[i].compressed_size, |
| 319 0, 1); |
| 320 if (result != BZ_OK) { |
| 321 fprintf(stderr, "bzip error code: %d\n", result); |
| 322 exit(1); |
| 323 } |
| 324 compressed_data[i].data = decompressed; |
| 325 compressed_data[i].raw_size = decompressed_size; |
| 326 } |
| 327 v8::V8::SetDecompressedStartupData(compressed_data); |
| 328 #endif // COMPRESS_STARTUP_DATA_BZ2 |
| 329 |
| 302 v8::V8::SetFlagsFromCommandLine(&argc, argv, true); | 330 v8::V8::SetFlagsFromCommandLine(&argc, argv, true); |
| 303 int result = 0; | 331 int result = 0; |
| 304 if (FLAG_stress_opt || FLAG_stress_deopt) { | 332 if (FLAG_stress_opt || FLAG_stress_deopt) { |
| 305 v8::Testing::SetStressRunType(FLAG_stress_opt | 333 v8::Testing::SetStressRunType(FLAG_stress_opt |
| 306 ? v8::Testing::kStressTypeOpt | 334 ? v8::Testing::kStressTypeOpt |
| 307 : v8::Testing::kStressTypeDeopt); | 335 : v8::Testing::kStressTypeDeopt); |
| 308 int stress_runs = v8::Testing::GetStressRuns(); | 336 int stress_runs = v8::Testing::GetStressRuns(); |
| 309 for (int i = 0; i < stress_runs && result == 0; i++) { | 337 for (int i = 0; i < stress_runs && result == 0; i++) { |
| 310 printf("============ Stress %d/%d ============\n", | 338 printf("============ Stress %d/%d ============\n", |
| 311 i + 1, stress_runs); | 339 i + 1, stress_runs); |
| 312 v8::Testing::PrepareStressRun(i); | 340 v8::Testing::PrepareStressRun(i); |
| 313 last_run = (i == stress_runs - 1); | 341 last_run = (i == stress_runs - 1); |
| 314 result = RunMain(argc, argv); | 342 result = RunMain(argc, argv); |
| 315 } | 343 } |
| 316 printf("======== Full Deoptimization =======\n"); | 344 printf("======== Full Deoptimization =======\n"); |
| 317 v8::Testing::DeoptimizeAll(); | 345 v8::Testing::DeoptimizeAll(); |
| 318 } else { | 346 } else { |
| 319 result = RunMain(argc, argv); | 347 result = RunMain(argc, argv); |
| 320 } | 348 } |
| 321 v8::V8::Dispose(); | 349 v8::V8::Dispose(); |
| 350 |
| 351 #ifdef COMPRESS_STARTUP_DATA_BZ2 |
| 352 for (int i = 0; i < compressed_data_count; ++i) { |
| 353 delete[] compressed_data[i].data; |
| 354 } |
| 355 delete[] compressed_data; |
| 356 #endif // COMPRESS_STARTUP_DATA_BZ2 |
| 357 |
| 322 return result; | 358 return result; |
| 323 } | 359 } |
| 324 | 360 |
| 325 | 361 |
| 326 // Extracts a C string from a V8 Utf8Value. | 362 // Extracts a C string from a V8 Utf8Value. |
| 327 const char* ToCString(const v8::String::Utf8Value& value) { | 363 const char* ToCString(const v8::String::Utf8Value& value) { |
| 328 return *value ? *value : "<string conversion failed>"; | 364 return *value ? *value : "<string conversion failed>"; |
| 329 } | 365 } |
| 330 | 366 |
| 331 | 367 |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 printf("^"); | 670 printf("^"); |
| 635 } | 671 } |
| 636 printf("\n"); | 672 printf("\n"); |
| 637 v8::String::Utf8Value stack_trace(try_catch->StackTrace()); | 673 v8::String::Utf8Value stack_trace(try_catch->StackTrace()); |
| 638 if (stack_trace.length() > 0) { | 674 if (stack_trace.length() > 0) { |
| 639 const char* stack_trace_string = ToCString(stack_trace); | 675 const char* stack_trace_string = ToCString(stack_trace); |
| 640 printf("%s\n", stack_trace_string); | 676 printf("%s\n", stack_trace_string); |
| 641 } | 677 } |
| 642 } | 678 } |
| 643 } | 679 } |
| OLD | NEW |