Reviewers: jochen,
Description:
Version 4.5.103.2 (cherry-pick)
Merged a5616e5d4
Disable the pending task if the memory reducer is torn down.
BUG=chromium:508584
LOG=N
[email protected]
Please review this at https://codereview.chromium.org/1235543005/
Base URL: https://chromium.googlesource.com/v8/[email protected]
Affected files (+25, -6 lines):
M include/v8-version.h
M src/heap/heap.cc
M src/heap/memory-reducer.h
M src/heap/memory-reducer.cc
Index: include/v8-version.h
diff --git a/include/v8-version.h b/include/v8-version.h
index
1d0c0b4e0aefb1cc2fa55ed90648fc47327cc8c2..379f688c9517c7767575e3560bdda3af190eddb9
100644
--- a/include/v8-version.h
+++ b/include/v8-version.h
@@ -11,7 +11,7 @@
#define V8_MAJOR_VERSION 4
#define V8_MINOR_VERSION 5
#define V8_BUILD_NUMBER 103
-#define V8_PATCH_LEVEL 1
+#define V8_PATCH_LEVEL 2
// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index
4660a67dd2847e668ca305a780bc8e80a2482488..86b546940a40e13674804efa90e58d49ada01738
100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -5886,6 +5886,8 @@ void Heap::TearDown() {
PrintAlloctionsHash();
}
+ memory_reducer_.TearDown();
+
TearDownArrayBuffers();
isolate_->global_handles()->TearDown();
Index: src/heap/memory-reducer.cc
diff --git a/src/heap/memory-reducer.cc b/src/heap/memory-reducer.cc
index
aa3abd0f21919cb5459e2125244082caef80b8a0..2e0ccb9de6a07ebac1ea37141af7e25c7586f487
100644
--- a/src/heap/memory-reducer.cc
+++ b/src/heap/memory-reducer.cc
@@ -18,6 +18,7 @@ const int MemoryReducer::kMaxNumberOfGCs = 3;
void MemoryReducer::TimerTask::Run() {
+ if (heap_is_torn_down_) return;
Heap* heap = memory_reducer_->heap();
Event event;
event.type = kTimer;
@@ -31,8 +32,10 @@ void MemoryReducer::TimerTask::Run() {
void MemoryReducer::NotifyTimer(const Event& event) {
+ DCHECK(nullptr != pending_task_);
DCHECK_EQ(kTimer, event.type);
DCHECK_EQ(kWait, state_.action);
+ pending_task_ = nullptr;
state_ = Step(state_, event);
if (state_.action == kRun) {
DCHECK(heap()->incremental_marking()->IsStopped());
@@ -167,9 +170,19 @@ void MemoryReducer::ScheduleTimer(double delay_ms) {
// Leave some room for precision error in task scheduler.
const double kSlackMs = 100;
v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(heap()->isolate());
+ DCHECK(nullptr == pending_task_);
+ pending_task_ = new MemoryReducer::TimerTask(this);
V8::GetCurrentPlatform()->CallDelayedOnForegroundThread(
- isolate, new MemoryReducer::TimerTask(this),
- (delay_ms + kSlackMs) / 1000.0);
+ isolate, pending_task_, (delay_ms + kSlackMs) / 1000.0);
+}
+
+
+void MemoryReducer::TearDown() {
+ if (pending_task_ != nullptr) {
+ pending_task_->NotifyHeapTearDown();
+ pending_task_ = nullptr;
+ }
+ state_ = State(kDone, 0, 0);
}
} // internal
Index: src/heap/memory-reducer.h
diff --git a/src/heap/memory-reducer.h b/src/heap/memory-reducer.h
index
fc7b2eaee569b34add4501d2874fde953d5b3c6f..4d15afa2e2dc5eee75680b820796da1b5a78c74c
100644
--- a/src/heap/memory-reducer.h
+++ b/src/heap/memory-reducer.h
@@ -101,7 +101,8 @@ class MemoryReducer {
bool can_start_incremental_gc;
};
- explicit MemoryReducer(Heap* heap) : heap_(heap), state_(kDone, 0, 0.0)
{}
+ explicit MemoryReducer(Heap* heap)
+ : heap_(heap), state_(kDone, 0, 0.0), pending_task_(nullptr) {}
// Callbacks.
void NotifyTimer(const Event& event);
void NotifyMarkCompact(const Event& event);
@@ -112,6 +113,7 @@ class MemoryReducer {
static State Step(const State& state, const Event& event);
// Posts a timer task that will call NotifyTimer after the given delay.
void ScheduleTimer(double delay_ms);
+ void TearDown();
static const int kLongDelayMs;
static const int kShortDelayMs;
@@ -123,18 +125,20 @@ class MemoryReducer {
class TimerTask : public v8::Task {
public:
explicit TimerTask(MemoryReducer* memory_reducer)
- : memory_reducer_(memory_reducer) {}
+ : memory_reducer_(memory_reducer), heap_is_torn_down_(false) {}
virtual ~TimerTask() {}
+ void NotifyHeapTearDown() { heap_is_torn_down_ = true; }
private:
// v8::Task overrides.
void Run() override;
MemoryReducer* memory_reducer_;
+ bool heap_is_torn_down_;
DISALLOW_COPY_AND_ASSIGN(TimerTask);
};
-
Heap* heap_;
State state_;
+ TimerTask* pending_task_;
DISALLOW_COPY_AND_ASSIGN(MemoryReducer);
};
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.