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

Side by Side Diff: src/d8.cc

Issue 7046027: Add snapshot compression support into d8. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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 | « src/d8.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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
11 // with the distribution. 11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
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 28
29 #ifdef COMPRESS_STARTUP_DATA_BZ2
30 #include <bzlib.h>
31 #endif
32 #include <errno.h>
29 #include <stdlib.h> 33 #include <stdlib.h>
30 #include <errno.h>
31 34
32 #include "v8.h" 35 #include "v8.h"
33 36
34 #include "d8.h" 37 #include "d8.h"
35 #include "d8-debug.h" 38 #include "d8-debug.h"
36 #include "debug.h" 39 #include "debug.h"
37 #include "api.h" 40 #include "api.h"
38 #include "natives.h" 41 #include "natives.h"
39 #include "platform.h" 42 #include "platform.h"
40 43
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 return GetCounter(name, true); 479 return GetCounter(name, true);
477 } 480 }
478 481
479 482
480 void Shell::AddHistogramSample(void* histogram, int sample) { 483 void Shell::AddHistogramSample(void* histogram, int sample) {
481 Counter* counter = reinterpret_cast<Counter*>(histogram); 484 Counter* counter = reinterpret_cast<Counter*>(histogram);
482 counter->AddSample(sample); 485 counter->AddSample(sample);
483 } 486 }
484 487
485 488
489 #ifdef COMPRESS_STARTUP_DATA_BZ2
490 class BZip2Decompressor : public v8::StartupDataDecompressor {
491 public:
492 virtual ~BZip2Decompressor() { }
493
494 protected:
495 virtual int DecompressData(char* raw_data,
496 int* raw_data_size,
497 const char* compressed_data,
498 int compressed_data_size) {
499 ASSERT_EQ(v8::StartupData::kBZip2,
500 v8::V8::GetCompressedStartupDataAlgorithm());
501 unsigned int decompressed_size = *raw_data_size;
502 int result =
503 BZ2_bzBuffToBuffDecompress(raw_data,
504 &decompressed_size,
505 const_cast<char*>(compressed_data),
506 compressed_data_size,
507 0, 1);
508 if (result == BZ_OK) {
509 *raw_data_size = decompressed_size;
510 }
511 return result;
512 }
513 };
514 #endif
515
516
486 void Shell::Initialize() { 517 void Shell::Initialize() {
518 #ifdef COMPRESS_STARTUP_DATA_BZ2
519 BZip2Decompressor startup_data_decompressor;
520 int bz2_result = startup_data_decompressor.Decompress();
521 if (bz2_result != BZ_OK) {
522 fprintf(stderr, "bzip error code: %d\n", bz2_result);
523 exit(1);
524 }
525 #endif
526
487 Shell::counter_map_ = new CounterMap(); 527 Shell::counter_map_ = new CounterMap();
488 // Set up counters 528 // Set up counters
489 if (i::StrLength(i::FLAG_map_counters) != 0) 529 if (i::StrLength(i::FLAG_map_counters) != 0)
490 MapCounters(i::FLAG_map_counters); 530 MapCounters(i::FLAG_map_counters);
491 if (i::FLAG_dump_counters) { 531 if (i::FLAG_dump_counters) {
492 V8::SetCounterFunction(LookupCounter); 532 V8::SetCounterFunction(LookupCounter);
493 V8::SetCreateHistogramFunction(CreateHistogram); 533 V8::SetCreateHistogramFunction(CreateHistogram);
494 V8::SetAddHistogramSampleFunction(AddHistogramSample); 534 V8::SetAddHistogramSampleFunction(AddHistogramSample);
495 } 535 }
496 536
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 928
889 929
890 } // namespace v8 930 } // namespace v8
891 931
892 932
893 #ifndef GOOGLE3 933 #ifndef GOOGLE3
894 int main(int argc, char* argv[]) { 934 int main(int argc, char* argv[]) {
895 return v8::Shell::Main(argc, argv); 935 return v8::Shell::Main(argc, argv);
896 } 936 }
897 #endif 937 #endif
OLDNEW
« no previous file with comments | « src/d8.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698