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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 // Make sure all builtin scripts are cached. | 386 // Make sure all builtin scripts are cached. |
387 { | 387 { |
388 HandleScope scope(isolate); | 388 HandleScope scope(isolate); |
389 for (int i = 0; i < i::Natives::GetBuiltinsCount(); i++) { | 389 for (int i = 0; i < i::Natives::GetBuiltinsCount(); i++) { |
390 internal_isolate->bootstrapper()->SourceLookup<i::Natives>(i); | 390 internal_isolate->bootstrapper()->SourceLookup<i::Natives>(i); |
391 } | 391 } |
392 } | 392 } |
393 // If we don't do this then we end up with a stray root pointing at the | 393 // 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. | 394 // context even after we have disposed of the context. |
395 internal_isolate->heap()->CollectAllAvailableGarbage("mksnapshot"); | 395 internal_isolate->heap()->CollectAllAvailableGarbage("mksnapshot"); |
| 396 |
| 397 // GC may have cleared weak cells, so compact any WeakFixedArrays |
| 398 // found on the heap. |
| 399 i::HeapIterator iterator(internal_isolate->heap(), |
| 400 i::HeapIterator::kFilterUnreachable); |
| 401 for (i::HeapObject* o = iterator.next(); o != NULL; o = iterator.next()) { |
| 402 if (o->IsPrototypeInfo()) { |
| 403 i::Object* prototype_users = |
| 404 i::PrototypeInfo::cast(o)->prototype_users(); |
| 405 if (prototype_users->IsWeakFixedArray()) { |
| 406 i::WeakFixedArray* array = i::WeakFixedArray::cast(prototype_users); |
| 407 array->Compact<i::JSObject::PrototypeRegistryCompactionCallback>(); |
| 408 } |
| 409 } else if (o->IsScript()) { |
| 410 i::Object* shared_list = i::Script::cast(o)->shared_function_infos(); |
| 411 if (shared_list->IsWeakFixedArray()) { |
| 412 i::WeakFixedArray* array = i::WeakFixedArray::cast(shared_list); |
| 413 array->Compact<i::WeakFixedArray::NullCallback>(); |
| 414 } |
| 415 } |
| 416 } |
| 417 |
396 i::Object* raw_context = *v8::Utils::OpenPersistent(context); | 418 i::Object* raw_context = *v8::Utils::OpenPersistent(context); |
397 context.Reset(); | 419 context.Reset(); |
398 | 420 |
399 i::SnapshotByteSink snapshot_sink; | 421 i::SnapshotByteSink snapshot_sink; |
400 i::StartupSerializer ser(internal_isolate, &snapshot_sink); | 422 i::StartupSerializer ser(internal_isolate, &snapshot_sink); |
401 ser.SerializeStrongReferences(); | 423 ser.SerializeStrongReferences(); |
402 | 424 |
403 i::SnapshotByteSink context_sink; | 425 i::SnapshotByteSink context_sink; |
404 i::PartialSerializer context_ser(internal_isolate, &ser, &context_sink); | 426 i::PartialSerializer context_ser(internal_isolate, &ser, &context_sink); |
405 context_ser.Serialize(&raw_context); | 427 context_ser.Serialize(&raw_context); |
(...skipping 8014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8420 Address callback_address = | 8442 Address callback_address = |
8421 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8443 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8422 VMState<EXTERNAL> state(isolate); | 8444 VMState<EXTERNAL> state(isolate); |
8423 ExternalCallbackScope call_scope(isolate, callback_address); | 8445 ExternalCallbackScope call_scope(isolate, callback_address); |
8424 callback(info); | 8446 callback(info); |
8425 } | 8447 } |
8426 | 8448 |
8427 | 8449 |
8428 } // namespace internal | 8450 } // namespace internal |
8429 } // namespace v8 | 8451 } // namespace v8 |
OLD | NEW |