| 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 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 isolate->factory()->NewFixedArray(num_templates, i::TENURED); | 505 isolate->factory()->NewFixedArray(num_templates, i::TENURED); |
| 506 for (int i = 0; i < num_templates; i++) { | 506 for (int i = 0; i < num_templates; i++) { |
| 507 templates->set(i, *v8::Utils::OpenHandle(*data->templates_.Get(i))); | 507 templates->set(i, *v8::Utils::OpenHandle(*data->templates_.Get(i))); |
| 508 } | 508 } |
| 509 isolate->heap()->SetSerializedTemplates(*templates); | 509 isolate->heap()->SetSerializedTemplates(*templates); |
| 510 data->templates_.Clear(); | 510 data->templates_.Clear(); |
| 511 } | 511 } |
| 512 | 512 |
| 513 // If we don't do this then we end up with a stray root pointing at the | 513 // If we don't do this then we end up with a stray root pointing at the |
| 514 // context even after we have disposed of the context. | 514 // context even after we have disposed of the context. |
| 515 isolate->heap()->CollectAllAvailableGarbage("mksnapshot"); | 515 isolate->heap()->CollectAllAvailableGarbage( |
| 516 i::GarbageCollectionReason::kSnapshotCreator); |
| 516 isolate->heap()->CompactWeakFixedArrays(); | 517 isolate->heap()->CompactWeakFixedArrays(); |
| 517 | 518 |
| 518 i::DisallowHeapAllocation no_gc_from_here_on; | 519 i::DisallowHeapAllocation no_gc_from_here_on; |
| 519 | 520 |
| 520 int num_contexts = static_cast<int>(data->contexts_.Size()); | 521 int num_contexts = static_cast<int>(data->contexts_.Size()); |
| 521 i::List<i::Object*> contexts(num_contexts); | 522 i::List<i::Object*> contexts(num_contexts); |
| 522 for (int i = 0; i < num_contexts; i++) { | 523 for (int i = 0; i < num_contexts; i++) { |
| 523 i::HandleScope scope(isolate); | 524 i::HandleScope scope(isolate); |
| 524 i::Handle<i::Context> context = | 525 i::Handle<i::Context> context = |
| 525 v8::Utils::OpenHandle(*data->contexts_.Get(i)); | 526 v8::Utils::OpenHandle(*data->contexts_.Get(i)); |
| (...skipping 6944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7470 } | 7471 } |
| 7471 ENTER_V8(internal_isolate); | 7472 ENTER_V8(internal_isolate); |
| 7472 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value); | 7473 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value); |
| 7473 return Utils::IntegerToLocal(result); | 7474 return Utils::IntegerToLocal(result); |
| 7474 } | 7475 } |
| 7475 | 7476 |
| 7476 | 7477 |
| 7477 void Isolate::ReportExternalAllocationLimitReached() { | 7478 void Isolate::ReportExternalAllocationLimitReached() { |
| 7478 i::Heap* heap = reinterpret_cast<i::Isolate*>(this)->heap(); | 7479 i::Heap* heap = reinterpret_cast<i::Isolate*>(this)->heap(); |
| 7479 if (heap->gc_state() != i::Heap::NOT_IN_GC) return; | 7480 if (heap->gc_state() != i::Heap::NOT_IN_GC) return; |
| 7480 heap->ReportExternalMemoryPressure( | 7481 heap->ReportExternalMemoryPressure(); |
| 7481 "external memory allocation limit reached."); | |
| 7482 } | 7482 } |
| 7483 | 7483 |
| 7484 | 7484 |
| 7485 HeapProfiler* Isolate::GetHeapProfiler() { | 7485 HeapProfiler* Isolate::GetHeapProfiler() { |
| 7486 i::HeapProfiler* heap_profiler = | 7486 i::HeapProfiler* heap_profiler = |
| 7487 reinterpret_cast<i::Isolate*>(this)->heap_profiler(); | 7487 reinterpret_cast<i::Isolate*>(this)->heap_profiler(); |
| 7488 return reinterpret_cast<HeapProfiler*>(heap_profiler); | 7488 return reinterpret_cast<HeapProfiler*>(heap_profiler); |
| 7489 } | 7489 } |
| 7490 | 7490 |
| 7491 | 7491 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7631 void Isolate::RequestInterrupt(InterruptCallback callback, void* data) { | 7631 void Isolate::RequestInterrupt(InterruptCallback callback, void* data) { |
| 7632 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | 7632 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
| 7633 isolate->RequestInterrupt(callback, data); | 7633 isolate->RequestInterrupt(callback, data); |
| 7634 } | 7634 } |
| 7635 | 7635 |
| 7636 | 7636 |
| 7637 void Isolate::RequestGarbageCollectionForTesting(GarbageCollectionType type) { | 7637 void Isolate::RequestGarbageCollectionForTesting(GarbageCollectionType type) { |
| 7638 CHECK(i::FLAG_expose_gc); | 7638 CHECK(i::FLAG_expose_gc); |
| 7639 if (type == kMinorGarbageCollection) { | 7639 if (type == kMinorGarbageCollection) { |
| 7640 reinterpret_cast<i::Isolate*>(this)->heap()->CollectGarbage( | 7640 reinterpret_cast<i::Isolate*>(this)->heap()->CollectGarbage( |
| 7641 i::NEW_SPACE, "Isolate::RequestGarbageCollection", | 7641 i::NEW_SPACE, i::GarbageCollectionReason::kTesting, |
| 7642 kGCCallbackFlagForced); | 7642 kGCCallbackFlagForced); |
| 7643 } else { | 7643 } else { |
| 7644 DCHECK_EQ(kFullGarbageCollection, type); | 7644 DCHECK_EQ(kFullGarbageCollection, type); |
| 7645 reinterpret_cast<i::Isolate*>(this)->heap()->CollectAllGarbage( | 7645 reinterpret_cast<i::Isolate*>(this)->heap()->CollectAllGarbage( |
| 7646 i::Heap::kAbortIncrementalMarkingMask, | 7646 i::Heap::kAbortIncrementalMarkingMask, |
| 7647 "Isolate::RequestGarbageCollection", kGCCallbackFlagForced); | 7647 i::GarbageCollectionReason::kTesting, kGCCallbackFlagForced); |
| 7648 } | 7648 } |
| 7649 } | 7649 } |
| 7650 | 7650 |
| 7651 | 7651 |
| 7652 Isolate* Isolate::GetCurrent() { | 7652 Isolate* Isolate::GetCurrent() { |
| 7653 i::Isolate* isolate = i::Isolate::Current(); | 7653 i::Isolate* isolate = i::Isolate::Current(); |
| 7654 return reinterpret_cast<Isolate*>(isolate); | 7654 return reinterpret_cast<Isolate*>(isolate); |
| 7655 } | 7655 } |
| 7656 | 7656 |
| 7657 | 7657 |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8066 return isolate->heap()->IdleNotification(deadline_in_seconds); | 8066 return isolate->heap()->IdleNotification(deadline_in_seconds); |
| 8067 } | 8067 } |
| 8068 | 8068 |
| 8069 | 8069 |
| 8070 void Isolate::LowMemoryNotification() { | 8070 void Isolate::LowMemoryNotification() { |
| 8071 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | 8071 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
| 8072 { | 8072 { |
| 8073 i::HistogramTimerScope idle_notification_scope( | 8073 i::HistogramTimerScope idle_notification_scope( |
| 8074 isolate->counters()->gc_low_memory_notification()); | 8074 isolate->counters()->gc_low_memory_notification()); |
| 8075 TRACE_EVENT0("v8", "V8.GCLowMemoryNotification"); | 8075 TRACE_EVENT0("v8", "V8.GCLowMemoryNotification"); |
| 8076 isolate->heap()->CollectAllAvailableGarbage("low memory notification"); | 8076 isolate->heap()->CollectAllAvailableGarbage( |
| 8077 i::GarbageCollectionReason::kLowMemoryNotification); |
| 8077 } | 8078 } |
| 8078 } | 8079 } |
| 8079 | 8080 |
| 8080 | 8081 |
| 8081 int Isolate::ContextDisposedNotification(bool dependant_context) { | 8082 int Isolate::ContextDisposedNotification(bool dependant_context) { |
| 8082 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | 8083 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
| 8083 return isolate->heap()->NotifyContextDisposed(dependant_context); | 8084 return isolate->heap()->NotifyContextDisposed(dependant_context); |
| 8084 } | 8085 } |
| 8085 | 8086 |
| 8086 | 8087 |
| (...skipping 1135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9222 Address callback_address = | 9223 Address callback_address = |
| 9223 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 9224 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 9224 VMState<EXTERNAL> state(isolate); | 9225 VMState<EXTERNAL> state(isolate); |
| 9225 ExternalCallbackScope call_scope(isolate, callback_address); | 9226 ExternalCallbackScope call_scope(isolate, callback_address); |
| 9226 callback(info); | 9227 callback(info); |
| 9227 } | 9228 } |
| 9228 | 9229 |
| 9229 | 9230 |
| 9230 } // namespace internal | 9231 } // namespace internal |
| 9231 } // namespace v8 | 9232 } // namespace v8 |
| OLD | NEW |