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 6869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6880 } | 6880 } |
6881 ENTER_V8(internal_isolate); | 6881 ENTER_V8(internal_isolate); |
6882 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value); | 6882 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value); |
6883 return Utils::IntegerToLocal(result); | 6883 return Utils::IntegerToLocal(result); |
6884 } | 6884 } |
6885 | 6885 |
6886 | 6886 |
6887 void Isolate::CollectAllGarbage(const char* gc_reason) { | 6887 void Isolate::CollectAllGarbage(const char* gc_reason) { |
6888 i::Heap* heap = reinterpret_cast<i::Isolate*>(this)->heap(); | 6888 i::Heap* heap = reinterpret_cast<i::Isolate*>(this)->heap(); |
6889 if (heap->incremental_marking()->IsStopped()) { | 6889 if (heap->incremental_marking()->IsStopped()) { |
6890 heap->StartIncrementalMarking(i::Heap::kNoGCFlags, kGCCallbackFlagForced, | 6890 if (heap->incremental_marking()->CanBeActivated()) { |
6891 gc_reason); | 6891 heap->StartIncrementalMarking(i::Heap::kNoGCFlags, kGCCallbackFlagForced, |
| 6892 gc_reason); |
| 6893 } else { |
| 6894 heap->CollectAllGarbage(i::Heap::kNoGCFlags, gc_reason, |
| 6895 kGCCallbackFlagForced); |
| 6896 } |
| 6897 } else { |
| 6898 // Incremental marking is turned on an has already been started. |
| 6899 |
| 6900 // TODO(mlippautz): Compute the time slice for incremental marking based on |
| 6901 // memory pressure. |
| 6902 double deadline = heap->MonotonicallyIncreasingTimeInMs() + |
| 6903 i::FLAG_external_allocation_limit_incremental_time; |
| 6904 heap->AdvanceIncrementalMarking( |
| 6905 0, deadline, i::IncrementalMarking::StepActions( |
| 6906 i::IncrementalMarking::GC_VIA_STACK_GUARD, |
| 6907 i::IncrementalMarking::FORCE_MARKING, |
| 6908 i::IncrementalMarking::FORCE_COMPLETION)); |
6892 } | 6909 } |
6893 // TODO(mlippautz): Compute the time slice for incremental marking based on | |
6894 // memory pressure. | |
6895 double deadline = heap->MonotonicallyIncreasingTimeInMs() + | |
6896 i::FLAG_external_allocation_limit_incremental_time; | |
6897 heap->AdvanceIncrementalMarking(0, deadline, | |
6898 i::IncrementalMarking::StepActions( | |
6899 i::IncrementalMarking::GC_VIA_STACK_GUARD, | |
6900 i::IncrementalMarking::FORCE_MARKING, | |
6901 i::IncrementalMarking::FORCE_COMPLETION)); | |
6902 } | 6910 } |
6903 | 6911 |
6904 | 6912 |
6905 HeapProfiler* Isolate::GetHeapProfiler() { | 6913 HeapProfiler* Isolate::GetHeapProfiler() { |
6906 i::HeapProfiler* heap_profiler = | 6914 i::HeapProfiler* heap_profiler = |
6907 reinterpret_cast<i::Isolate*>(this)->heap_profiler(); | 6915 reinterpret_cast<i::Isolate*>(this)->heap_profiler(); |
6908 return reinterpret_cast<HeapProfiler*>(heap_profiler); | 6916 return reinterpret_cast<HeapProfiler*>(heap_profiler); |
6909 } | 6917 } |
6910 | 6918 |
6911 | 6919 |
(...skipping 1504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8416 Address callback_address = | 8424 Address callback_address = |
8417 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8425 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8418 VMState<EXTERNAL> state(isolate); | 8426 VMState<EXTERNAL> state(isolate); |
8419 ExternalCallbackScope call_scope(isolate, callback_address); | 8427 ExternalCallbackScope call_scope(isolate, callback_address); |
8420 callback(info); | 8428 callback(info); |
8421 } | 8429 } |
8422 | 8430 |
8423 | 8431 |
8424 } // namespace internal | 8432 } // namespace internal |
8425 } // namespace v8 | 8433 } // namespace v8 |
OLD | NEW |