| 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 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 HandleScope handle_scope(isolate); | 376 HandleScope handle_scope(isolate); |
| 377 Local<Context> new_context = Context::New(isolate); | 377 Local<Context> new_context = Context::New(isolate); |
| 378 context.Reset(isolate, new_context); | 378 context.Reset(isolate, new_context); |
| 379 if (custom_source != NULL) { | 379 if (custom_source != NULL) { |
| 380 metadata.set_embeds_script(true); | 380 metadata.set_embeds_script(true); |
| 381 Context::Scope context_scope(new_context); | 381 Context::Scope context_scope(new_context); |
| 382 if (!RunExtraCode(isolate, new_context, custom_source)) context.Reset(); | 382 if (!RunExtraCode(isolate, new_context, custom_source)) context.Reset(); |
| 383 } | 383 } |
| 384 } | 384 } |
| 385 if (!context.IsEmpty()) { | 385 if (!context.IsEmpty()) { |
| 386 // Make sure all builtin scripts are cached. | |
| 387 { | 386 { |
| 388 HandleScope scope(isolate); | 387 HandleScope scope(isolate); |
| 388 |
| 389 // Make sure all builtin scripts are cached. |
| 389 for (int i = 0; i < i::Natives::GetBuiltinsCount(); i++) { | 390 for (int i = 0; i < i::Natives::GetBuiltinsCount(); i++) { |
| 390 internal_isolate->bootstrapper()->SourceLookup<i::Natives>(i); | 391 internal_isolate->bootstrapper()->SourceLookup<i::Natives>(i); |
| 391 } | 392 } |
| 393 |
| 394 // Make sure all extra scripts are cached. |
| 395 for (int i = 0; i < i::ExtraNatives::GetBuiltinsCount(); i++) { |
| 396 internal_isolate->bootstrapper()->SourceLookup<i::ExtraNatives>(i); |
| 397 } |
| 392 } | 398 } |
| 393 // If we don't do this then we end up with a stray root pointing at the | 399 // If we don't do this then we end up with a stray root pointing at the |
| 394 // context even after we have disposed of the context. | 400 // context even after we have disposed of the context. |
| 395 internal_isolate->heap()->CollectAllAvailableGarbage("mksnapshot"); | 401 internal_isolate->heap()->CollectAllAvailableGarbage("mksnapshot"); |
| 396 i::Object* raw_context = *v8::Utils::OpenPersistent(context); | 402 i::Object* raw_context = *v8::Utils::OpenPersistent(context); |
| 397 context.Reset(); | 403 context.Reset(); |
| 398 | 404 |
| 399 i::SnapshotByteSink snapshot_sink; | 405 i::SnapshotByteSink snapshot_sink; |
| 400 i::StartupSerializer ser(internal_isolate, &snapshot_sink); | 406 i::StartupSerializer ser(internal_isolate, &snapshot_sink); |
| 401 ser.SerializeStrongReferences(); | 407 ser.SerializeStrongReferences(); |
| (...skipping 8016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8418 Address callback_address = | 8424 Address callback_address = |
| 8419 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8425 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 8420 VMState<EXTERNAL> state(isolate); | 8426 VMState<EXTERNAL> state(isolate); |
| 8421 ExternalCallbackScope call_scope(isolate, callback_address); | 8427 ExternalCallbackScope call_scope(isolate, callback_address); |
| 8422 callback(info); | 8428 callback(info); |
| 8423 } | 8429 } |
| 8424 | 8430 |
| 8425 | 8431 |
| 8426 } // namespace internal | 8432 } // namespace internal |
| 8427 } // namespace v8 | 8433 } // namespace v8 |
| OLD | NEW |