Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: samples/shell.cc

Issue 7066048: Compress sources of JS libraries in addition to the snapshot. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Comments addressed Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/SConscript » ('j') | src/bz2-decompress.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 27 matching lines...) Expand all
38 38
39 // 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
40 // 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
41 // #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
42 // 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
43 // shell d8 TODO(1272). 43 // shell d8 TODO(1272).
44 #if !(defined(USING_V8_SHARED) || defined(V8_SHARED)) 44 #if !(defined(USING_V8_SHARED) || defined(V8_SHARED))
45 #include "../src/v8.h" 45 #include "../src/v8.h"
46 #endif // USING_V8_SHARED 46 #endif // USING_V8_SHARED
47 47
48 // Natives decompressor is a part of V8 sources because it is used in
49 // mksnapshot.
50 #ifdef COMPRESS_STARTUP_DATA_BZ2
51 #include "../src/bz2-decompress.h"
52 #endif
53
48 #if !defined(_WIN32) && !defined(_WIN64) 54 #if !defined(_WIN32) && !defined(_WIN64)
49 #include <unistd.h> // NOLINT 55 #include <unistd.h> // NOLINT
50 #endif 56 #endif
51 57
52 static void ExitShell(int exit_code) { 58 static void ExitShell(int exit_code) {
53 // Use _exit instead of exit to avoid races between isolate 59 // Use _exit instead of exit to avoid races between isolate
54 // threads and static destructors. 60 // threads and static destructors.
55 fflush(stdout); 61 fflush(stdout);
56 fflush(stderr); 62 fflush(stderr);
57 _exit(exit_code); 63 _exit(exit_code);
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 argv[i] = NULL; 302 argv[i] = NULL;
297 } else if (strcmp(argv[i], "--noalways-opt") == 0) { 303 } else if (strcmp(argv[i], "--noalways-opt") == 0) {
298 // No support for stressing if we can't use --always-opt. 304 // No support for stressing if we can't use --always-opt.
299 FLAG_stress_opt = false; 305 FLAG_stress_opt = false;
300 FLAG_stress_deopt = false; 306 FLAG_stress_deopt = false;
301 break; 307 break;
302 } 308 }
303 } 309 }
304 310
305 #ifdef COMPRESS_STARTUP_DATA_BZ2 311 #ifdef COMPRESS_STARTUP_DATA_BZ2
306 ASSERT_EQ(v8::StartupData::kBZip2, 312 BZip2Decompressor startup_data_decompressor;
Vitaly Repeshko 2011/06/06 15:59:15 It seems unfortunate that the shell sample is usin
307 v8::V8::GetCompressedStartupDataAlgorithm()); 313 int bz2_result = startup_data_decompressor.DecompressStartupData();
308 int compressed_data_count = v8::V8::GetCompressedStartupDataCount(); 314 if (bz2_result != BZ_OK) {
309 v8::StartupData* compressed_data = new v8::StartupData[compressed_data_count]; 315 fprintf(stderr, "bzip error code: %d\n", bz2_result);
310 v8::V8::GetCompressedStartupData(compressed_data); 316 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 } 317 }
327 v8::V8::SetDecompressedStartupData(compressed_data); 318 #endif
328 #endif // COMPRESS_STARTUP_DATA_BZ2
329 319
330 v8::V8::SetFlagsFromCommandLine(&argc, argv, true); 320 v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
331 int result = 0; 321 int result = 0;
332 if (FLAG_stress_opt || FLAG_stress_deopt) { 322 if (FLAG_stress_opt || FLAG_stress_deopt) {
333 v8::Testing::SetStressRunType(FLAG_stress_opt 323 v8::Testing::SetStressRunType(FLAG_stress_opt
334 ? v8::Testing::kStressTypeOpt 324 ? v8::Testing::kStressTypeOpt
335 : v8::Testing::kStressTypeDeopt); 325 : v8::Testing::kStressTypeDeopt);
336 int stress_runs = v8::Testing::GetStressRuns(); 326 int stress_runs = v8::Testing::GetStressRuns();
337 for (int i = 0; i < stress_runs && result == 0; i++) { 327 for (int i = 0; i < stress_runs && result == 0; i++) {
338 printf("============ Stress %d/%d ============\n", 328 printf("============ Stress %d/%d ============\n",
339 i + 1, stress_runs); 329 i + 1, stress_runs);
340 v8::Testing::PrepareStressRun(i); 330 v8::Testing::PrepareStressRun(i);
341 last_run = (i == stress_runs - 1); 331 last_run = (i == stress_runs - 1);
342 result = RunMain(argc, argv); 332 result = RunMain(argc, argv);
343 } 333 }
344 printf("======== Full Deoptimization =======\n"); 334 printf("======== Full Deoptimization =======\n");
345 v8::Testing::DeoptimizeAll(); 335 v8::Testing::DeoptimizeAll();
346 } else { 336 } else {
347 result = RunMain(argc, argv); 337 result = RunMain(argc, argv);
348 } 338 }
349 v8::V8::Dispose(); 339 v8::V8::Dispose();
350 340
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; 341 return result;
359 } 342 }
360 343
361 344
362 // Extracts a C string from a V8 Utf8Value. 345 // Extracts a C string from a V8 Utf8Value.
363 const char* ToCString(const v8::String::Utf8Value& value) { 346 const char* ToCString(const v8::String::Utf8Value& value) {
364 return *value ? *value : "<string conversion failed>"; 347 return *value ? *value : "<string conversion failed>";
365 } 348 }
366 349
367 350
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 printf("^"); 654 printf("^");
672 } 655 }
673 printf("\n"); 656 printf("\n");
674 v8::String::Utf8Value stack_trace(try_catch->StackTrace()); 657 v8::String::Utf8Value stack_trace(try_catch->StackTrace());
675 if (stack_trace.length() > 0) { 658 if (stack_trace.length() > 0) {
676 const char* stack_trace_string = ToCString(stack_trace); 659 const char* stack_trace_string = ToCString(stack_trace);
677 printf("%s\n", stack_trace_string); 660 printf("%s\n", stack_trace_string);
678 } 661 }
679 } 662 }
680 } 663 }
OLDNEW
« no previous file with comments | « no previous file | src/SConscript » ('j') | src/bz2-decompress.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698