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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 | 206 |
207 const char** argv_; | 207 const char** argv_; |
208 int begin_offset_; | 208 int begin_offset_; |
209 int end_offset_; | 209 int end_offset_; |
210 }; | 210 }; |
211 | 211 |
212 | 212 |
213 static SourceGroup* isolate_sources = NULL; | 213 static SourceGroup* isolate_sources = NULL; |
214 | 214 |
215 | 215 |
| 216 #ifdef COMPRESS_STARTUP_DATA_BZ2 |
| 217 class BZip2Decompressor : public v8::StartupDataDecompressor { |
| 218 public: |
| 219 virtual ~BZip2Decompressor() { } |
| 220 |
| 221 protected: |
| 222 virtual int DecompressData(char* raw_data, |
| 223 int* raw_data_size, |
| 224 const char* compressed_data, |
| 225 int compressed_data_size) { |
| 226 ASSERT_EQ(v8::StartupData::kBZip2, |
| 227 v8::V8::GetCompressedStartupDataAlgorithm()); |
| 228 unsigned int decompressed_size = *raw_data_size; |
| 229 int result = |
| 230 BZ2_bzBuffToBuffDecompress(raw_data, |
| 231 &decompressed_size, |
| 232 const_cast<char*>(compressed_data), |
| 233 compressed_data_size, |
| 234 0, 1); |
| 235 if (result == BZ_OK) { |
| 236 *raw_data_size = decompressed_size; |
| 237 } |
| 238 return result; |
| 239 } |
| 240 }; |
| 241 #endif |
| 242 |
| 243 |
216 int RunMain(int argc, char* argv[]) { | 244 int RunMain(int argc, char* argv[]) { |
217 v8::V8::SetFlagsFromCommandLine(&argc, argv, true); | 245 v8::V8::SetFlagsFromCommandLine(&argc, argv, true); |
218 v8::HandleScope handle_scope; | 246 v8::HandleScope handle_scope; |
219 v8::Persistent<v8::Context> context = CreateShellContext(); | 247 v8::Persistent<v8::Context> context = CreateShellContext(); |
220 // Enter the newly created execution environment. | 248 // Enter the newly created execution environment. |
221 context->Enter(); | 249 context->Enter(); |
222 if (context.IsEmpty()) { | 250 if (context.IsEmpty()) { |
223 printf("Error creating context\n"); | 251 printf("Error creating context\n"); |
224 return 1; | 252 return 1; |
225 } | 253 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 argv[i] = NULL; | 324 argv[i] = NULL; |
297 } else if (strcmp(argv[i], "--noalways-opt") == 0) { | 325 } else if (strcmp(argv[i], "--noalways-opt") == 0) { |
298 // No support for stressing if we can't use --always-opt. | 326 // No support for stressing if we can't use --always-opt. |
299 FLAG_stress_opt = false; | 327 FLAG_stress_opt = false; |
300 FLAG_stress_deopt = false; | 328 FLAG_stress_deopt = false; |
301 break; | 329 break; |
302 } | 330 } |
303 } | 331 } |
304 | 332 |
305 #ifdef COMPRESS_STARTUP_DATA_BZ2 | 333 #ifdef COMPRESS_STARTUP_DATA_BZ2 |
306 ASSERT_EQ(v8::StartupData::kBZip2, | 334 BZip2Decompressor startup_data_decompressor; |
307 v8::V8::GetCompressedStartupDataAlgorithm()); | 335 int bz2_result = startup_data_decompressor.Decompress(); |
308 int compressed_data_count = v8::V8::GetCompressedStartupDataCount(); | 336 if (bz2_result != BZ_OK) { |
309 v8::StartupData* compressed_data = new v8::StartupData[compressed_data_count]; | 337 fprintf(stderr, "bzip error code: %d\n", bz2_result); |
310 v8::V8::GetCompressedStartupData(compressed_data); | 338 exit(1); |
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 } | 339 } |
327 v8::V8::SetDecompressedStartupData(compressed_data); | 340 #endif |
328 #endif // COMPRESS_STARTUP_DATA_BZ2 | |
329 | 341 |
330 v8::V8::SetFlagsFromCommandLine(&argc, argv, true); | 342 v8::V8::SetFlagsFromCommandLine(&argc, argv, true); |
331 int result = 0; | 343 int result = 0; |
332 if (FLAG_stress_opt || FLAG_stress_deopt) { | 344 if (FLAG_stress_opt || FLAG_stress_deopt) { |
333 v8::Testing::SetStressRunType(FLAG_stress_opt | 345 v8::Testing::SetStressRunType(FLAG_stress_opt |
334 ? v8::Testing::kStressTypeOpt | 346 ? v8::Testing::kStressTypeOpt |
335 : v8::Testing::kStressTypeDeopt); | 347 : v8::Testing::kStressTypeDeopt); |
336 int stress_runs = v8::Testing::GetStressRuns(); | 348 int stress_runs = v8::Testing::GetStressRuns(); |
337 for (int i = 0; i < stress_runs && result == 0; i++) { | 349 for (int i = 0; i < stress_runs && result == 0; i++) { |
338 printf("============ Stress %d/%d ============\n", | 350 printf("============ Stress %d/%d ============\n", |
339 i + 1, stress_runs); | 351 i + 1, stress_runs); |
340 v8::Testing::PrepareStressRun(i); | 352 v8::Testing::PrepareStressRun(i); |
341 last_run = (i == stress_runs - 1); | 353 last_run = (i == stress_runs - 1); |
342 result = RunMain(argc, argv); | 354 result = RunMain(argc, argv); |
343 } | 355 } |
344 printf("======== Full Deoptimization =======\n"); | 356 printf("======== Full Deoptimization =======\n"); |
345 v8::Testing::DeoptimizeAll(); | 357 v8::Testing::DeoptimizeAll(); |
346 } else { | 358 } else { |
347 result = RunMain(argc, argv); | 359 result = RunMain(argc, argv); |
348 } | 360 } |
349 v8::V8::Dispose(); | 361 v8::V8::Dispose(); |
350 | 362 |
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 | |
358 return result; | 363 return result; |
359 } | 364 } |
360 | 365 |
361 | 366 |
362 // Extracts a C string from a V8 Utf8Value. | 367 // Extracts a C string from a V8 Utf8Value. |
363 const char* ToCString(const v8::String::Utf8Value& value) { | 368 const char* ToCString(const v8::String::Utf8Value& value) { |
364 return *value ? *value : "<string conversion failed>"; | 369 return *value ? *value : "<string conversion failed>"; |
365 } | 370 } |
366 | 371 |
367 | 372 |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 printf("^"); | 676 printf("^"); |
672 } | 677 } |
673 printf("\n"); | 678 printf("\n"); |
674 v8::String::Utf8Value stack_trace(try_catch->StackTrace()); | 679 v8::String::Utf8Value stack_trace(try_catch->StackTrace()); |
675 if (stack_trace.length() > 0) { | 680 if (stack_trace.length() > 0) { |
676 const char* stack_trace_string = ToCString(stack_trace); | 681 const char* stack_trace_string = ToCString(stack_trace); |
677 printf("%s\n", stack_trace_string); | 682 printf("%s\n", stack_trace_string); |
678 } | 683 } |
679 } | 684 } |
680 } | 685 } |
OLD | NEW |