| OLD | NEW |
| 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 // Print the usage if an error occurs when parsing the command line | 144 // Print the usage if an error occurs when parsing the command line |
| 145 // flags or if the help flag is set. | 145 // flags or if the help flag is set. |
| 146 int result = i::FlagList::SetFlagsFromCommandLine(&argc, argv, true); | 146 int result = i::FlagList::SetFlagsFromCommandLine(&argc, argv, true); |
| 147 if (result > 0 || argc != 2 || i::FLAG_help) { | 147 if (result > 0 || argc != 2 || i::FLAG_help) { |
| 148 ::printf("Usage: %s [flag] ... outfile\n", argv[0]); | 148 ::printf("Usage: %s [flag] ... outfile\n", argv[0]); |
| 149 i::FlagList::PrintHelp(); | 149 i::FlagList::PrintHelp(); |
| 150 return !i::FLAG_help; | 150 return !i::FLAG_help; |
| 151 } | 151 } |
| 152 i::Serializer::Enable(); | 152 i::Serializer::Enable(); |
| 153 Persistent<Context> context = v8::Context::New(); | 153 Persistent<Context> context = v8::Context::New(); |
| 154 ASSERT(!context.IsEmpty()); |
| 154 // Make sure all builtin scripts are cached. | 155 // Make sure all builtin scripts are cached. |
| 155 { HandleScope scope; | 156 { HandleScope scope; |
| 156 for (int i = 0; i < i::Natives::GetBuiltinsCount(); i++) { | 157 for (int i = 0; i < i::Natives::GetBuiltinsCount(); i++) { |
| 157 i::Bootstrapper::NativesSourceLookup(i); | 158 i::Bootstrapper::NativesSourceLookup(i); |
| 158 } | 159 } |
| 159 } | 160 } |
| 160 context.Dispose(); | 161 context.Dispose(); |
| 161 CppByteSink sink(argv[1]); | 162 CppByteSink sink(argv[1]); |
| 162 i::Serializer ser(&sink); | 163 i::Serializer ser(&sink); |
| 163 // This results in a somewhat smaller snapshot, probably because it gets rid | 164 // This results in a somewhat smaller snapshot, probably because it gets rid |
| 164 // of some things that are cached between garbage collections. | 165 // of some things that are cached between garbage collections. |
| 165 i::Heap::CollectAllGarbage(true); | 166 i::Heap::CollectAllGarbage(true); |
| 166 ser.Serialize(); | 167 ser.Serialize(); |
| 167 return 0; | 168 return 0; |
| 168 } | 169 } |
| OLD | NEW |