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); | |
371 internal_isolate->Init(NULL); | 370 internal_isolate->Init(NULL); |
372 Persistent<Context> context; | 371 Persistent<Context> context; |
373 i::Snapshot::Metadata metadata; | 372 i::Snapshot::Metadata metadata; |
374 { | 373 { |
375 HandleScope handle_scope(isolate); | 374 HandleScope handle_scope(isolate); |
376 Local<Context> new_context = Context::New(isolate); | 375 Local<Context> new_context = Context::New(isolate); |
377 internal_isolate->set_creating_default_snapshot(false); | |
378 context.Reset(isolate, new_context); | 376 context.Reset(isolate, new_context); |
379 if (custom_source != NULL) { | 377 if (custom_source != NULL) { |
380 metadata.set_embeds_script(true); | 378 metadata.set_embeds_script(true); |
381 Context::Scope context_scope(new_context); | 379 Context::Scope context_scope(new_context); |
382 if (!RunExtraCode(isolate, new_context, custom_source)) context.Reset(); | 380 if (!RunExtraCode(isolate, new_context, custom_source)) context.Reset(); |
383 } | 381 } |
384 } | 382 } |
385 if (!context.IsEmpty()) { | 383 if (!context.IsEmpty()) { |
386 // Make sure all builtin scripts are cached. | 384 // Make sure all builtin scripts are cached. |
387 { | 385 { |
(...skipping 8017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8405 Address callback_address = | 8403 Address callback_address = |
8406 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8404 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8407 VMState<EXTERNAL> state(isolate); | 8405 VMState<EXTERNAL> state(isolate); |
8408 ExternalCallbackScope call_scope(isolate, callback_address); | 8406 ExternalCallbackScope call_scope(isolate, callback_address); |
8409 callback(info); | 8407 callback(info); |
8410 } | 8408 } |
8411 | 8409 |
8412 | 8410 |
8413 } // namespace internal | 8411 } // namespace internal |
8414 } // namespace v8 | 8412 } // namespace v8 |
OLD | NEW |