| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| 11 // with the distribution. | 11 // with the distribution. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 42 namespace v8 { | 42 namespace v8 { |
| 43 namespace internal { | 43 namespace internal { |
| 44 | 44 |
| 45 | 45 |
| 46 StackGuard::StackGuard() | 46 StackGuard::StackGuard() |
| 47 : isolate_(NULL) { | 47 : isolate_(NULL) { |
| 48 } | 48 } |
| 49 | 49 |
| 50 | 50 |
| 51 void StackGuard::set_interrupt_limits(const ExecutionAccess& lock) { | 51 void StackGuard::set_interrupt_limits(const ExecutionAccess& lock) { |
| 52 if (FLAG_count_based_interrupts) return; |
| 52 ASSERT(isolate_ != NULL); | 53 ASSERT(isolate_ != NULL); |
| 53 // Ignore attempts to interrupt when interrupts are postponed. | 54 // Ignore attempts to interrupt when interrupts are postponed. |
| 54 if (should_postpone_interrupts(lock)) return; | 55 if (should_postpone_interrupts(lock)) return; |
| 55 thread_local_.jslimit_ = kInterruptLimit; | 56 thread_local_.jslimit_ = kInterruptLimit; |
| 56 thread_local_.climit_ = kInterruptLimit; | 57 thread_local_.climit_ = kInterruptLimit; |
| 57 isolate_->heap()->SetStackLimits(); | 58 isolate_->heap()->SetStackLimits(); |
| 58 } | 59 } |
| 59 | 60 |
| 60 | 61 |
| 61 void StackGuard::reset_limits(const ExecutionAccess& lock) { | 62 void StackGuard::reset_limits(const ExecutionAccess& lock) { |
| 63 if (FLAG_count_based_interrupts) return; |
| 62 ASSERT(isolate_ != NULL); | 64 ASSERT(isolate_ != NULL); |
| 63 thread_local_.jslimit_ = thread_local_.real_jslimit_; | 65 thread_local_.jslimit_ = thread_local_.real_jslimit_; |
| 64 thread_local_.climit_ = thread_local_.real_climit_; | 66 thread_local_.climit_ = thread_local_.real_climit_; |
| 65 isolate_->heap()->SetStackLimits(); | 67 isolate_->heap()->SetStackLimits(); |
| 66 } | 68 } |
| 67 | 69 |
| 68 | 70 |
| 69 static Handle<Object> Invoke(bool is_construct, | 71 static Handle<Object> Invoke(bool is_construct, |
| 70 Handle<JSFunction> function, | 72 Handle<JSFunction> function, |
| 71 Handle<Object> receiver, | 73 Handle<Object> receiver, |
| (...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 875 MaybeObject* Execution::HandleStackGuardInterrupt() { | 877 MaybeObject* Execution::HandleStackGuardInterrupt() { |
| 876 Isolate* isolate = Isolate::Current(); | 878 Isolate* isolate = Isolate::Current(); |
| 877 StackGuard* stack_guard = isolate->stack_guard(); | 879 StackGuard* stack_guard = isolate->stack_guard(); |
| 878 | 880 |
| 879 if (stack_guard->IsGCRequest()) { | 881 if (stack_guard->IsGCRequest()) { |
| 880 isolate->heap()->CollectAllGarbage(false, "StackGuard GC request"); | 882 isolate->heap()->CollectAllGarbage(false, "StackGuard GC request"); |
| 881 stack_guard->Continue(GC_REQUEST); | 883 stack_guard->Continue(GC_REQUEST); |
| 882 } | 884 } |
| 883 | 885 |
| 884 isolate->counters()->stack_interrupts()->Increment(); | 886 isolate->counters()->stack_interrupts()->Increment(); |
| 885 if (stack_guard->IsRuntimeProfilerTick()) { | 887 // If FLAG_count_based_interrupts, every interrupt is a profiler interrupt. |
| 888 if (FLAG_count_based_interrupts || |
| 889 stack_guard->IsRuntimeProfilerTick()) { |
| 886 isolate->counters()->runtime_profiler_ticks()->Increment(); | 890 isolate->counters()->runtime_profiler_ticks()->Increment(); |
| 887 stack_guard->Continue(RUNTIME_PROFILER_TICK); | 891 stack_guard->Continue(RUNTIME_PROFILER_TICK); |
| 888 isolate->runtime_profiler()->OptimizeNow(); | 892 isolate->runtime_profiler()->OptimizeNow(); |
| 889 } | 893 } |
| 890 #ifdef ENABLE_DEBUGGER_SUPPORT | 894 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 891 if (stack_guard->IsDebugBreak() || stack_guard->IsDebugCommand()) { | 895 if (stack_guard->IsDebugBreak() || stack_guard->IsDebugCommand()) { |
| 892 DebugBreakHelper(); | 896 DebugBreakHelper(); |
| 893 } | 897 } |
| 894 #endif | 898 #endif |
| 895 if (stack_guard->IsPreempted()) RuntimePreempt(); | 899 if (stack_guard->IsPreempted()) RuntimePreempt(); |
| 896 if (stack_guard->IsTerminateExecution()) { | 900 if (stack_guard->IsTerminateExecution()) { |
| 897 stack_guard->Continue(TERMINATE); | 901 stack_guard->Continue(TERMINATE); |
| 898 return isolate->TerminateExecution(); | 902 return isolate->TerminateExecution(); |
| 899 } | 903 } |
| 900 if (stack_guard->IsInterrupted()) { | 904 if (stack_guard->IsInterrupted()) { |
| 901 stack_guard->Continue(INTERRUPT); | 905 stack_guard->Continue(INTERRUPT); |
| 902 return isolate->StackOverflow(); | 906 return isolate->StackOverflow(); |
| 903 } | 907 } |
| 904 return isolate->heap()->undefined_value(); | 908 return isolate->heap()->undefined_value(); |
| 905 } | 909 } |
| 906 | 910 |
| 911 |
| 907 } } // namespace v8::internal | 912 } } // namespace v8::internal |
| OLD | NEW |