Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(719)

Unified Diff: src/isolate.cc

Issue 2857633002: Make Isolate::AddDetachedContext GC safe (Closed)
Patch Set: fix typo Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/isolate.cc
diff --git a/src/isolate.cc b/src/isolate.cc
index ed30d84cf1fa3fb9421f68326953ebff7458c71f..13b4c38a4588676149e63d0f9de489e10494ea91 100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -3509,6 +3509,7 @@ void Isolate::RunMicrotasksInternal() {
while (pending_microtask_count() > 0) {
HandleScope scope(this);
int num_tasks = pending_microtask_count();
+ // Do not use factory()->microtask_queue() here; we need a fresh handle!
Handle<FixedArray> queue(heap()->microtask_queue(), this);
DCHECK(num_tasks <= queue->length());
set_pending_microtask_count(0);
@@ -3652,11 +3653,11 @@ void Isolate::SetTailCallEliminationEnabled(bool enabled) {
void Isolate::AddDetachedContext(Handle<Context> context) {
HandleScope scope(this);
Handle<WeakCell> cell = factory()->NewWeakCell(context);
- Handle<FixedArray> detached_contexts = factory()->detached_contexts();
- int length = detached_contexts->length();
- detached_contexts = factory()->CopyFixedArrayAndGrow(detached_contexts, 2);
- detached_contexts->set(length, Smi::kZero);
- detached_contexts->set(length + 1, *cell);
+ Handle<FixedArray> detached_contexts =
+ factory()->CopyFixedArrayAndGrow(factory()->detached_contexts(), 2);
+ int new_length = detached_contexts->length();
+ detached_contexts->set(new_length - 2, Smi::kZero);
+ detached_contexts->set(new_length - 1, *cell);
heap()->set_detached_contexts(*detached_contexts);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698