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

Side by Side Diff: src/mksnapshot.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
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-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 17 matching lines...) Expand all
28 #ifdef COMPRESS_STARTUP_DATA_BZ2 28 #ifdef COMPRESS_STARTUP_DATA_BZ2
29 #include <bzlib.h> 29 #include <bzlib.h>
30 #endif 30 #endif
31 #include <signal.h> 31 #include <signal.h>
32 #include <string> 32 #include <string>
33 #include <map> 33 #include <map>
34 34
35 #include "v8.h" 35 #include "v8.h"
36 36
37 #include "bootstrapper.h" 37 #include "bootstrapper.h"
38 #include "bz2-decompress.h"
38 #include "natives.h" 39 #include "natives.h"
39 #include "platform.h" 40 #include "platform.h"
40 #include "serialize.h" 41 #include "serialize.h"
41 #include "list.h" 42 #include "list.h"
42 43
43 // use explicit namespace to avoid clashing with types in namespace v8 44 // use explicit namespace to avoid clashing with types in namespace v8
44 namespace i = v8::internal; 45 namespace i = v8::internal;
45 using namespace v8; 46 using namespace v8;
46 47
47 static const unsigned int kMaxCounters = 256; 48 static const unsigned int kMaxCounters = 256;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 char at(int i) { return data_[i]; } 130 char at(int i) { return data_[i]; }
130 bool Compress(Compressor* compressor) { 131 bool Compress(Compressor* compressor) {
131 ASSERT_EQ(-1, raw_size_); 132 ASSERT_EQ(-1, raw_size_);
132 raw_size_ = data_.length(); 133 raw_size_ = data_.length();
133 if (!compressor->Compress(data_.ToVector())) return false; 134 if (!compressor->Compress(data_.ToVector())) return false;
134 data_.Clear(); 135 data_.Clear();
135 data_.AddAll(*compressor->output()); 136 data_.AddAll(*compressor->output());
136 return true; 137 return true;
137 } 138 }
138 int raw_size() { return raw_size_; } 139 int raw_size() { return raw_size_; }
140
139 private: 141 private:
140 i::List<char> data_; 142 i::List<char> data_;
141 int raw_size_; 143 int raw_size_;
142 }; 144 };
143 145
144 146
145 class CppByteSink : public PartialSnapshotSink { 147 class CppByteSink : public PartialSnapshotSink {
146 public: 148 public:
147 explicit CppByteSink(const char* snapshot_file) { 149 explicit CppByteSink(const char* snapshot_file) {
148 fp_ = i::OS::FOpen(snapshot_file, "wb"); 150 fp_ = i::OS::FOpen(snapshot_file, "wb");
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 i::FLAG_log_code = true; 276 i::FLAG_log_code = true;
275 #endif 277 #endif
276 // Print the usage if an error occurs when parsing the command line 278 // Print the usage if an error occurs when parsing the command line
277 // flags or if the help flag is set. 279 // flags or if the help flag is set.
278 int result = i::FlagList::SetFlagsFromCommandLine(&argc, argv, true); 280 int result = i::FlagList::SetFlagsFromCommandLine(&argc, argv, true);
279 if (result > 0 || argc != 2 || i::FLAG_help) { 281 if (result > 0 || argc != 2 || i::FLAG_help) {
280 ::printf("Usage: %s [flag] ... outfile\n", argv[0]); 282 ::printf("Usage: %s [flag] ... outfile\n", argv[0]);
281 i::FlagList::PrintHelp(); 283 i::FlagList::PrintHelp();
282 return !i::FLAG_help; 284 return !i::FLAG_help;
283 } 285 }
286 #ifdef COMPRESS_STARTUP_DATA_BZ2
287 BZip2Decompressor natives_decompressor;
288 int bz2_result = natives_decompressor.DecompressStartupData();
289 if (bz2_result != BZ_OK) {
290 fprintf(stderr, "bzip error code: %d\n", bz2_result);
291 exit(1);
292 }
293 #endif
284 i::Serializer::Enable(); 294 i::Serializer::Enable();
285 Persistent<Context> context = v8::Context::New(); 295 Persistent<Context> context = v8::Context::New();
286 ASSERT(!context.IsEmpty()); 296 ASSERT(!context.IsEmpty());
287 // Make sure all builtin scripts are cached. 297 // Make sure all builtin scripts are cached.
288 { HandleScope scope; 298 { HandleScope scope;
289 for (int i = 0; i < i::Natives::GetBuiltinsCount(); i++) { 299 for (int i = 0; i < i::Natives::GetBuiltinsCount(); i++) {
290 i::Isolate::Current()->bootstrapper()->NativesSourceLookup(i); 300 i::Isolate::Current()->bootstrapper()->NativesSourceLookup(i);
291 } 301 }
292 } 302 }
293 // If we don't do this then we end up with a stray root pointing at the 303 // If we don't do this then we end up with a stray root pointing at the
(...skipping 25 matching lines...) Expand all
319 sink.WriteSpaceUsed( 329 sink.WriteSpaceUsed(
320 partial_ser.CurrentAllocationAddress(i::NEW_SPACE), 330 partial_ser.CurrentAllocationAddress(i::NEW_SPACE),
321 partial_ser.CurrentAllocationAddress(i::OLD_POINTER_SPACE), 331 partial_ser.CurrentAllocationAddress(i::OLD_POINTER_SPACE),
322 partial_ser.CurrentAllocationAddress(i::OLD_DATA_SPACE), 332 partial_ser.CurrentAllocationAddress(i::OLD_DATA_SPACE),
323 partial_ser.CurrentAllocationAddress(i::CODE_SPACE), 333 partial_ser.CurrentAllocationAddress(i::CODE_SPACE),
324 partial_ser.CurrentAllocationAddress(i::MAP_SPACE), 334 partial_ser.CurrentAllocationAddress(i::MAP_SPACE),
325 partial_ser.CurrentAllocationAddress(i::CELL_SPACE), 335 partial_ser.CurrentAllocationAddress(i::CELL_SPACE),
326 partial_ser.CurrentAllocationAddress(i::LO_SPACE)); 336 partial_ser.CurrentAllocationAddress(i::LO_SPACE));
327 return 0; 337 return 0;
328 } 338 }
OLDNEW
« src/bz2-decompress.h ('K') | « src/d8.cc ('k') | src/natives.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698