Chromium Code Reviews| 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 <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 Loading... | |
| 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); | |
|
ulan
2015/02/04 15:39:05
Would be nice to print the retaining path for the
| |
| 2608 } | |
| 2609 } | |
| 2610 } | |
| 2611 | |
| 2612 | |
| 2571 bool StackLimitCheck::JsHasOverflowed() const { | 2613 bool StackLimitCheck::JsHasOverflowed() const { |
| 2572 StackGuard* stack_guard = isolate_->stack_guard(); | 2614 StackGuard* stack_guard = isolate_->stack_guard(); |
| 2573 #ifdef USE_SIMULATOR | 2615 #ifdef USE_SIMULATOR |
| 2574 // The simulator uses a separate JS stack. | 2616 // The simulator uses a separate JS stack. |
| 2575 Address jssp_address = Simulator::current(isolate_)->get_sp(); | 2617 Address jssp_address = Simulator::current(isolate_)->get_sp(); |
| 2576 uintptr_t jssp = reinterpret_cast<uintptr_t>(jssp_address); | 2618 uintptr_t jssp = reinterpret_cast<uintptr_t>(jssp_address); |
| 2577 if (jssp < stack_guard->real_jslimit()) return true; | 2619 if (jssp < stack_guard->real_jslimit()) return true; |
| 2578 #endif // USE_SIMULATOR | 2620 #endif // USE_SIMULATOR |
| 2579 return GetCurrentStackPosition() < stack_guard->real_climit(); | 2621 return GetCurrentStackPosition() < stack_guard->real_climit(); |
| 2580 } | 2622 } |
| 2581 | 2623 |
| 2582 | 2624 |
| 2583 bool PostponeInterruptsScope::Intercept(StackGuard::InterruptFlag flag) { | 2625 bool PostponeInterruptsScope::Intercept(StackGuard::InterruptFlag flag) { |
| 2584 // First check whether the previous scope intercepts. | 2626 // First check whether the previous scope intercepts. |
| 2585 if (prev_ && prev_->Intercept(flag)) return true; | 2627 if (prev_ && prev_->Intercept(flag)) return true; |
| 2586 // Then check whether this scope intercepts. | 2628 // Then check whether this scope intercepts. |
| 2587 if ((flag & intercept_mask_)) { | 2629 if ((flag & intercept_mask_)) { |
| 2588 intercepted_flags_ |= flag; | 2630 intercepted_flags_ |= flag; |
| 2589 return true; | 2631 return true; |
| 2590 } | 2632 } |
| 2591 return false; | 2633 return false; |
| 2592 } | 2634 } |
| 2593 | 2635 |
| 2594 } } // namespace v8::internal | 2636 } } // namespace v8::internal |
| OLD | NEW |