OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 "src/api.h" | 5 #include "src/api.h" |
6 | 6 |
7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 StartupData V8::CreateSnapshotDataBlob(const char* custom_source) { | 360 StartupData V8::CreateSnapshotDataBlob(const char* custom_source) { |
361 i::Isolate* internal_isolate = new i::Isolate(true); | 361 i::Isolate* internal_isolate = new i::Isolate(true); |
362 ArrayBufferAllocator allocator; | 362 ArrayBufferAllocator allocator; |
363 internal_isolate->set_array_buffer_allocator(&allocator); | 363 internal_isolate->set_array_buffer_allocator(&allocator); |
364 Isolate* isolate = reinterpret_cast<Isolate*>(internal_isolate); | 364 Isolate* isolate = reinterpret_cast<Isolate*>(internal_isolate); |
365 StartupData result = {NULL, 0}; | 365 StartupData result = {NULL, 0}; |
366 { | 366 { |
367 base::ElapsedTimer timer; | 367 base::ElapsedTimer timer; |
368 timer.Start(); | 368 timer.Start(); |
369 Isolate::Scope isolate_scope(isolate); | 369 Isolate::Scope isolate_scope(isolate); |
| 370 internal_isolate->set_creating_default_snapshot(true); |
370 internal_isolate->Init(NULL); | 371 internal_isolate->Init(NULL); |
371 Persistent<Context> context; | 372 Persistent<Context> context; |
372 i::Snapshot::Metadata metadata; | 373 i::Snapshot::Metadata metadata; |
373 { | 374 { |
374 HandleScope handle_scope(isolate); | 375 HandleScope handle_scope(isolate); |
375 Local<Context> new_context = Context::New(isolate); | 376 Local<Context> new_context = Context::New(isolate); |
| 377 internal_isolate->set_creating_default_snapshot(false); |
376 context.Reset(isolate, new_context); | 378 context.Reset(isolate, new_context); |
377 if (custom_source != NULL) { | 379 if (custom_source != NULL) { |
378 metadata.set_embeds_script(true); | 380 metadata.set_embeds_script(true); |
379 Context::Scope context_scope(new_context); | 381 Context::Scope context_scope(new_context); |
380 if (!RunExtraCode(isolate, new_context, custom_source)) context.Reset(); | 382 if (!RunExtraCode(isolate, new_context, custom_source)) context.Reset(); |
381 } | 383 } |
382 } | 384 } |
383 if (!context.IsEmpty()) { | 385 if (!context.IsEmpty()) { |
384 // Make sure all builtin scripts are cached. | 386 // Make sure all builtin scripts are cached. |
385 { | 387 { |
(...skipping 8015 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8401 Address callback_address = | 8403 Address callback_address = |
8402 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8404 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8403 VMState<EXTERNAL> state(isolate); | 8405 VMState<EXTERNAL> state(isolate); |
8404 ExternalCallbackScope call_scope(isolate, callback_address); | 8406 ExternalCallbackScope call_scope(isolate, callback_address); |
8405 callback(info); | 8407 callback(info); |
8406 } | 8408 } |
8407 | 8409 |
8408 | 8410 |
8409 } // namespace internal | 8411 } // namespace internal |
8410 } // namespace v8 | 8412 } // namespace v8 |
OLD | NEW |