| Index: src/mksnapshot.cc
|
| ===================================================================
|
| --- src/mksnapshot.cc (revision 3302)
|
| +++ src/mksnapshot.cc (working copy)
|
| @@ -87,28 +87,13 @@
|
| // We statically allocate a set of local counters to be used if we
|
| // don't want to store the stats in a memory-mapped file
|
| static CounterCollection local_counters;
|
| -static CounterCollection* counters = &local_counters;
|
|
|
|
|
| typedef std::map<std::string, int*> CounterMap;
|
| typedef std::map<std::string, int*>::iterator CounterMapIterator;
|
| static CounterMap counter_table_;
|
|
|
| -// Callback receiver when v8 has a counter to track.
|
| -static int* counter_callback(const char* name) {
|
| - std::string counter = name;
|
| - // See if this counter name is already known.
|
| - if (counter_table_.find(counter) != counter_table_.end())
|
| - return counter_table_[counter];
|
|
|
| - Counter* ctr = counters->GetNextCounter();
|
| - if (ctr == NULL) return NULL;
|
| - int* ptr = ctr->Bind(name);
|
| - counter_table_[counter] = ptr;
|
| - return ptr;
|
| -}
|
| -
|
| -
|
| class CppByteSink : public i::SnapshotByteSink {
|
| public:
|
| explicit CppByteSink(const char* snapshot_file) : bytes_written_(0) {
|
| @@ -151,57 +136,6 @@
|
| };
|
|
|
|
|
| -// Write C++ code that defines Snapshot::snapshot_ to contain the snapshot
|
| -// to the file given by filename. Only the first size chars are written.
|
| -static int WriteInternalSnapshotToFile(const char* filename,
|
| - const v8::internal::byte* bytes,
|
| - int size) {
|
| - FILE* f = i::OS::FOpen(filename, "wb");
|
| - if (f == NULL) {
|
| - i::OS::PrintError("Cannot open file %s for writing.\n", filename);
|
| - return 0;
|
| - }
|
| - fprintf(f, "// Autogenerated snapshot file. Do not edit.\n\n");
|
| - fprintf(f, "#include \"v8.h\"\n");
|
| - fprintf(f, "#include \"platform.h\"\n\n");
|
| - fprintf(f, "#include \"snapshot.h\"\n\n");
|
| - fprintf(f, "namespace v8 {\nnamespace internal {\n\n");
|
| - fprintf(f, "const byte Snapshot::data_[] = {");
|
| - int written = 0;
|
| - written += fprintf(f, "0x%x", bytes[0]);
|
| - for (int i = 1; i < size; ++i) {
|
| - written += fprintf(f, ",0x%x", bytes[i]);
|
| - // The following is needed to keep the line length low on Visual C++:
|
| - if (i % 512 == 0) fprintf(f, "\n");
|
| - }
|
| - fprintf(f, "};\n\n");
|
| - fprintf(f, "int Snapshot::size_ = %d;\n\n", size);
|
| - fprintf(f, "} } // namespace v8::internal\n");
|
| - fclose(f);
|
| - return written;
|
| -}
|
| -
|
| -
|
| -int main2(int argc, char** argv) {
|
| - i::Serializer::Enable();
|
| - Persistent<Context> context = v8::Context::New();
|
| - // Make sure all builtin scripts are cached.
|
| - { HandleScope scope;
|
| - for (int i = 0; i < i::Natives::GetBuiltinsCount(); i++) {
|
| - i::Bootstrapper::NativesSourceLookup(i);
|
| - }
|
| - }
|
| - context.Dispose();
|
| - CppByteSink sink(argv[1]);
|
| - i::Serializer2 ser(&sink);
|
| - // This results in a somewhat smaller snapshot, probably because it gets rid
|
| - // of some things that are cached between garbage collections.
|
| - i::Heap::CollectAllGarbage(true);
|
| - ser.Serialize();
|
| - return 0;
|
| -}
|
| -
|
| -
|
| int main(int argc, char** argv) {
|
| #ifdef ENABLE_LOGGING_AND_PROFILING
|
| // By default, log code create information in the snapshot.
|
| @@ -215,38 +149,20 @@
|
| i::FlagList::PrintHelp();
|
| return !i::FLAG_help;
|
| }
|
| -
|
| - if (i::FLAG_new_snapshot) {
|
| - return main2(argc, argv);
|
| - }
|
| -
|
| - v8::V8::SetCounterFunction(counter_callback);
|
| - v8::HandleScope scope;
|
| -
|
| - const int kExtensionCount = 1;
|
| - const char* extension_list[kExtensionCount] = { "v8/gc" };
|
| - v8::ExtensionConfiguration extensions(kExtensionCount, extension_list);
|
| -
|
| i::Serializer::Enable();
|
| - v8::Context::New(&extensions);
|
| -
|
| + Persistent<Context> context = v8::Context::New();
|
| // Make sure all builtin scripts are cached.
|
| { HandleScope scope;
|
| for (int i = 0; i < i::Natives::GetBuiltinsCount(); i++) {
|
| i::Bootstrapper::NativesSourceLookup(i);
|
| }
|
| }
|
| - // Get rid of unreferenced scripts with a global GC.
|
| - i::Heap::CollectAllGarbage(false);
|
| - i::Serializer ser;
|
| + context.Dispose();
|
| + CppByteSink sink(argv[1]);
|
| + i::Serializer ser(&sink);
|
| + // This results in a somewhat smaller snapshot, probably because it gets rid
|
| + // of some things that are cached between garbage collections.
|
| + i::Heap::CollectAllGarbage(true);
|
| ser.Serialize();
|
| - v8::internal::byte* bytes;
|
| - int len;
|
| - ser.Finalize(&bytes, &len);
|
| -
|
| - WriteInternalSnapshotToFile(argv[1], bytes, len);
|
| -
|
| - i::DeleteArray(bytes);
|
| -
|
| return 0;
|
| }
|
|
|