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

Side by Side Diff: src/mksnapshot.cc

Issue 583153002: Reland 24052 - Require V8 to be explicitly initialized before an Isolate is created (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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/isolate.cc ('k') | src/snapshot.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <errno.h> 5 #include <errno.h>
6 #include <stdio.h> 6 #include <stdio.h>
7 #ifdef COMPRESS_STARTUP_DATA_BZ2 7 #ifdef COMPRESS_STARTUP_DATA_BZ2
8 #include <bzlib.h> 8 #include <bzlib.h>
9 #endif 9 #endif
10 #include <signal.h> 10 #include <signal.h>
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 fprintf(stderr, "%s at line %d\n", *message_string, message->GetLineNumber()); 296 fprintf(stderr, "%s at line %d\n", *message_string, message->GetLineNumber());
297 fprintf(stderr, "%s\n", *message_line); 297 fprintf(stderr, "%s\n", *message_line);
298 for (int i = 0; i <= message->GetEndColumn(); ++i) { 298 for (int i = 0; i <= message->GetEndColumn(); ++i) {
299 fprintf(stderr, "%c", i < message->GetStartColumn() ? ' ' : '^'); 299 fprintf(stderr, "%c", i < message->GetStartColumn() ? ' ' : '^');
300 } 300 }
301 fprintf(stderr, "\n"); 301 fprintf(stderr, "\n");
302 } 302 }
303 303
304 304
305 int main(int argc, char** argv) { 305 int main(int argc, char** argv) {
306 V8::InitializeICU();
307 v8::Platform* platform = v8::platform::CreateDefaultPlatform();
308 v8::V8::InitializePlatform(platform);
309 i::CpuFeatures::Probe(true);
310
311 // By default, log code create information in the snapshot. 306 // By default, log code create information in the snapshot.
312 i::FLAG_log_code = true; 307 i::FLAG_log_code = true;
313 308
314 // Print the usage if an error occurs when parsing the command line 309 // Print the usage if an error occurs when parsing the command line
315 // flags or if the help flag is set. 310 // flags or if the help flag is set.
316 int result = i::FlagList::SetFlagsFromCommandLine(&argc, argv, true); 311 int result = i::FlagList::SetFlagsFromCommandLine(&argc, argv, true);
317 if (result > 0 || argc != 2 || i::FLAG_help) { 312 if (result > 0 || argc != 2 || i::FLAG_help) {
318 ::printf("Usage: %s [flag] ... outfile\n", argv[0]); 313 ::printf("Usage: %s [flag] ... outfile\n", argv[0]);
319 i::FlagList::PrintHelp(); 314 i::FlagList::PrintHelp();
320 return !i::FLAG_help; 315 return !i::FLAG_help;
321 } 316 }
317
318 i::CpuFeatures::Probe(true);
319 V8::InitializeICU();
320 v8::Platform* platform = v8::platform::CreateDefaultPlatform();
321 v8::V8::InitializePlatform(platform);
322 v8::V8::Initialize();
323
322 #ifdef COMPRESS_STARTUP_DATA_BZ2 324 #ifdef COMPRESS_STARTUP_DATA_BZ2
323 BZip2Decompressor natives_decompressor; 325 BZip2Decompressor natives_decompressor;
324 int bz2_result = natives_decompressor.Decompress(); 326 int bz2_result = natives_decompressor.Decompress();
325 if (bz2_result != BZ_OK) { 327 if (bz2_result != BZ_OK) {
326 fprintf(stderr, "bzip error code: %d\n", bz2_result); 328 fprintf(stderr, "bzip error code: %d\n", bz2_result);
327 exit(1); 329 exit(1);
328 } 330 }
329 #endif 331 #endif
330 i::FLAG_logfile_per_isolate = false; 332 i::FLAG_logfile_per_isolate = false;
331 333
332 Isolate* isolate = v8::Isolate::New(); 334 Isolate::CreateParams params;
335 params.enable_serializer = true;
336 Isolate* isolate = v8::Isolate::New(params);
333 { Isolate::Scope isolate_scope(isolate); 337 { Isolate::Scope isolate_scope(isolate);
334 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); 338 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
335 internal_isolate->enable_serializer();
336 339
337 Persistent<Context> context; 340 Persistent<Context> context;
338 { 341 {
339 HandleScope handle_scope(isolate); 342 HandleScope handle_scope(isolate);
340 context.Reset(isolate, Context::New(isolate)); 343 context.Reset(isolate, Context::New(isolate));
341 } 344 }
342 345
343 if (context.IsEmpty()) { 346 if (context.IsEmpty()) {
344 fprintf(stderr, 347 fprintf(stderr,
345 "\nException thrown while compiling natives - see above.\n\n"); 348 "\nException thrown while compiling natives - see above.\n\n");
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 writer.WriteSnapshot(snapshot_data, ser, context_data, context_ser); 429 writer.WriteSnapshot(snapshot_data, ser, context_data, context_ser);
427 } 430 }
428 } 431 }
429 432
430 isolate->Dispose(); 433 isolate->Dispose();
431 V8::Dispose(); 434 V8::Dispose();
432 V8::ShutdownPlatform(); 435 V8::ShutdownPlatform();
433 delete platform; 436 delete platform;
434 return 0; 437 return 0;
435 } 438 }
OLDNEW
« no previous file with comments | « src/isolate.cc ('k') | src/snapshot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698