| 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 { | |
| 388 HandleScope scope(isolate); | |
| 389 for (int i = 0; i < i::Natives::GetBuiltinsCount(); i++) { | |
| 390 internal_isolate->bootstrapper()->SourceLookup<i::Natives>(i); | |
| 391 } | |
| 392 } | |
| 393 // If we don't do this then we end up with a stray root pointing at the | 386 // 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. | 387 // context even after we have disposed of the context. |
| 395 internal_isolate->heap()->CollectAllAvailableGarbage("mksnapshot"); | 388 internal_isolate->heap()->CollectAllAvailableGarbage("mksnapshot"); |
| 396 i::Object* raw_context = *v8::Utils::OpenPersistent(context); | 389 i::Object* raw_context = *v8::Utils::OpenPersistent(context); |
| 397 context.Reset(); | 390 context.Reset(); |
| 398 | 391 |
| 399 i::SnapshotByteSink snapshot_sink; | 392 i::SnapshotByteSink snapshot_sink; |
| 400 i::StartupSerializer ser(internal_isolate, &snapshot_sink); | 393 i::StartupSerializer ser(internal_isolate, &snapshot_sink); |
| 401 ser.SerializeStrongReferences(); | 394 ser.SerializeStrongReferences(); |
| 402 | 395 |
| (...skipping 8015 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8418 Address callback_address = | 8411 Address callback_address = |
| 8419 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8412 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 8420 VMState<EXTERNAL> state(isolate); | 8413 VMState<EXTERNAL> state(isolate); |
| 8421 ExternalCallbackScope call_scope(isolate, callback_address); | 8414 ExternalCallbackScope call_scope(isolate, callback_address); |
| 8422 callback(info); | 8415 callback(info); |
| 8423 } | 8416 } |
| 8424 | 8417 |
| 8425 | 8418 |
| 8426 } // namespace internal | 8419 } // namespace internal |
| 8427 } // namespace v8 | 8420 } // namespace v8 |
| OLD | NEW |