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

Side by Side Diff: src/isolate.cc

Issue 898663005: Add a flag to track detached contexts. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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 unified diff | Download patch
« no previous file with comments | « src/isolate.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stdlib.h> 5 #include <stdlib.h>
6 6
7 #include <fstream> // NOLINT(readability/streams) 7 #include <fstream> // NOLINT(readability/streams)
8 #include <sstream> 8 #include <sstream>
9 9
10 #include "src/v8.h" 10 #include "src/v8.h"
(...skipping 2550 matching lines...) Expand 10 before | Expand all | Expand 10 after
2561 if (FLAG_trace_turbo_cfg_file == NULL) { 2561 if (FLAG_trace_turbo_cfg_file == NULL) {
2562 std::ostringstream os; 2562 std::ostringstream os;
2563 os << "turbo-" << base::OS::GetCurrentProcessId() << "-" << id() << ".cfg"; 2563 os << "turbo-" << base::OS::GetCurrentProcessId() << "-" << id() << ".cfg";
2564 return os.str(); 2564 return os.str();
2565 } else { 2565 } else {
2566 return FLAG_trace_turbo_cfg_file; 2566 return FLAG_trace_turbo_cfg_file;
2567 } 2567 }
2568 } 2568 }
2569 2569
2570 2570
2571 // Heap::detached_contexts tracks detached contexts as pairs
2572 // (number of GC since the context was detached, the context).
2573 void Isolate::AddDetachedContext(Handle<Context> context) {
2574 HandleScope scope(this);
2575 Handle<WeakCell> cell = factory()->NewWeakCell(context);
2576 Handle<FixedArray> detached_contexts(heap()->detached_contexts());
2577 int length = detached_contexts->length();
2578 detached_contexts = FixedArray::CopySize(detached_contexts, length + 2);
2579 detached_contexts->set(length, Smi::FromInt(0));
2580 detached_contexts->set(length + 1, *cell);
2581 heap()->set_detached_contexts(*detached_contexts);
2582 }
2583
2584
2585 void Isolate::CheckDetachedContextsAfterGC() {
2586 HandleScope scope(this);
2587 Handle<FixedArray> detached_contexts(heap()->detached_contexts());
2588 int length = detached_contexts->length();
2589 if (length == 0) return;
2590 int new_length = 0;
2591 for (int i = 0; i < length; i += 2) {
2592 int mark_sweeps = Smi::cast(detached_contexts->get(i))->value();
2593 WeakCell* cell = WeakCell::cast(detached_contexts->get(i + 1));
2594 if (!cell->cleared()) {
2595 detached_contexts->set(new_length, Smi::FromInt(mark_sweeps + 1));
2596 detached_contexts->set(new_length + 1, cell);
2597 new_length += 2;
2598 }
2599 }
2600 PrintF("%d detached contexts are collected out of %d\n", length - new_length,
2601 length);
2602 for (int i = 0; i < new_length; i += 2) {
2603 int mark_sweeps = Smi::cast(detached_contexts->get(i))->value();
2604 WeakCell* cell = WeakCell::cast(detached_contexts->get(i + 1));
2605 if (mark_sweeps > 3) {
2606 PrintF("detached context 0x%p\n survived %d GCs (leak?)\n",
2607 static_cast<void*>(cell->value()), mark_sweeps);
2608 }
2609 }
2610 if (length == new_length) {
2611 heap()->set_detached_contexts(heap()->empty_fixed_array());
2612 } else {
2613 heap()->RightTrimFixedArray<Heap::FROM_GC>(*detached_contexts,
2614 length - new_length);
2615 }
2616 }
2617
2618
2571 bool StackLimitCheck::JsHasOverflowed() const { 2619 bool StackLimitCheck::JsHasOverflowed() const {
2572 StackGuard* stack_guard = isolate_->stack_guard(); 2620 StackGuard* stack_guard = isolate_->stack_guard();
2573 #ifdef USE_SIMULATOR 2621 #ifdef USE_SIMULATOR
2574 // The simulator uses a separate JS stack. 2622 // The simulator uses a separate JS stack.
2575 Address jssp_address = Simulator::current(isolate_)->get_sp(); 2623 Address jssp_address = Simulator::current(isolate_)->get_sp();
2576 uintptr_t jssp = reinterpret_cast<uintptr_t>(jssp_address); 2624 uintptr_t jssp = reinterpret_cast<uintptr_t>(jssp_address);
2577 if (jssp < stack_guard->real_jslimit()) return true; 2625 if (jssp < stack_guard->real_jslimit()) return true;
2578 #endif // USE_SIMULATOR 2626 #endif // USE_SIMULATOR
2579 return GetCurrentStackPosition() < stack_guard->real_climit(); 2627 return GetCurrentStackPosition() < stack_guard->real_climit();
2580 } 2628 }
2581 2629
2582 2630
2583 bool PostponeInterruptsScope::Intercept(StackGuard::InterruptFlag flag) { 2631 bool PostponeInterruptsScope::Intercept(StackGuard::InterruptFlag flag) {
2584 // First check whether the previous scope intercepts. 2632 // First check whether the previous scope intercepts.
2585 if (prev_ && prev_->Intercept(flag)) return true; 2633 if (prev_ && prev_->Intercept(flag)) return true;
2586 // Then check whether this scope intercepts. 2634 // Then check whether this scope intercepts.
2587 if ((flag & intercept_mask_)) { 2635 if ((flag & intercept_mask_)) {
2588 intercepted_flags_ |= flag; 2636 intercepted_flags_ |= flag;
2589 return true; 2637 return true;
2590 } 2638 }
2591 return false; 2639 return false;
2592 } 2640 }
2593 2641
2594 } } // namespace v8::internal 2642 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/isolate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698