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

Side by Side Diff: src/execution.cc

Issue 174056: Add support for forceful termination of JavaScript execution. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « src/execution.h ('k') | src/heap.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 catcher.SetVerbose(false); 149 catcher.SetVerbose(false);
150 catcher.SetCaptureMessage(false); 150 catcher.SetCaptureMessage(false);
151 151
152 Handle<Object> result = Invoke(false, func, receiver, argc, args, 152 Handle<Object> result = Invoke(false, func, receiver, argc, args,
153 caught_exception); 153 caught_exception);
154 154
155 if (*caught_exception) { 155 if (*caught_exception) {
156 ASSERT(catcher.HasCaught()); 156 ASSERT(catcher.HasCaught());
157 ASSERT(Top::has_pending_exception()); 157 ASSERT(Top::has_pending_exception());
158 ASSERT(Top::external_caught_exception()); 158 ASSERT(Top::external_caught_exception());
159 Top::optional_reschedule_exception(true); 159 bool is_bottom_call = HandleScopeImplementer::instance()->CallDepthIsZero();
160 Top::OptionalRescheduleException(is_bottom_call, true);
160 result = v8::Utils::OpenHandle(*catcher.Exception()); 161 result = v8::Utils::OpenHandle(*catcher.Exception());
161 } 162 }
162 163
163 ASSERT(!Top::has_pending_exception()); 164 ASSERT(!Top::has_pending_exception());
164 ASSERT(!Top::external_caught_exception()); 165 ASSERT(!Top::external_caught_exception());
165 return result; 166 return result;
166 } 167 }
167 168
168 169
169 Handle<Object> Execution::GetFunctionDelegate(Handle<Object> object) { 170 Handle<Object> Execution::GetFunctionDelegate(Handle<Object> object) {
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 } 322 }
322 323
323 324
324 void StackGuard::Preempt() { 325 void StackGuard::Preempt() {
325 ExecutionAccess access; 326 ExecutionAccess access;
326 thread_local_.interrupt_flags_ |= PREEMPT; 327 thread_local_.interrupt_flags_ |= PREEMPT;
327 set_limits(kInterruptLimit, access); 328 set_limits(kInterruptLimit, access);
328 } 329 }
329 330
330 331
332 bool StackGuard::IsTerminateExecution() {
333 ExecutionAccess access;
334 return thread_local_.interrupt_flags_ & TERMINATE;
335 }
336
337
338 void StackGuard::TerminateExecution() {
339 ExecutionAccess access;
340 thread_local_.interrupt_flags_ |= TERMINATE;
341 set_limits(kInterruptLimit, access);
342 }
343
344
331 #ifdef ENABLE_DEBUGGER_SUPPORT 345 #ifdef ENABLE_DEBUGGER_SUPPORT
332 bool StackGuard::IsDebugBreak() { 346 bool StackGuard::IsDebugBreak() {
333 ExecutionAccess access; 347 ExecutionAccess access;
334 return thread_local_.interrupt_flags_ & DEBUGBREAK; 348 return thread_local_.interrupt_flags_ & DEBUGBREAK;
335 } 349 }
336 350
337 351
338 void StackGuard::DebugBreak() { 352 void StackGuard::DebugBreak() {
339 ExecutionAccess access; 353 ExecutionAccess access;
340 thread_local_.interrupt_flags_ |= DEBUGBREAK; 354 thread_local_.interrupt_flags_ |= DEBUGBREAK;
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 } 645 }
632 #endif 646 #endif
633 647
634 Object* Execution::HandleStackGuardInterrupt() { 648 Object* Execution::HandleStackGuardInterrupt() {
635 #ifdef ENABLE_DEBUGGER_SUPPORT 649 #ifdef ENABLE_DEBUGGER_SUPPORT
636 if (StackGuard::IsDebugBreak() || StackGuard::IsDebugCommand()) { 650 if (StackGuard::IsDebugBreak() || StackGuard::IsDebugCommand()) {
637 DebugBreakHelper(); 651 DebugBreakHelper();
638 } 652 }
639 #endif 653 #endif
640 if (StackGuard::IsPreempted()) RuntimePreempt(); 654 if (StackGuard::IsPreempted()) RuntimePreempt();
655 if (StackGuard::IsTerminateExecution()) {
656 StackGuard::Continue(TERMINATE);
657 return Top::TerminateExecution();
658 }
641 if (StackGuard::IsInterrupted()) { 659 if (StackGuard::IsInterrupted()) {
642 // interrupt 660 // interrupt
643 StackGuard::Continue(INTERRUPT); 661 StackGuard::Continue(INTERRUPT);
644 return Top::StackOverflow(); 662 return Top::StackOverflow();
645 } 663 }
646 return Heap::undefined_value(); 664 return Heap::undefined_value();
647 } 665 }
648 666
649 // --- G C E x t e n s i o n --- 667 // --- G C E x t e n s i o n ---
650 668
(...skipping 10 matching lines...) Expand all
661 // All allocation spaces other than NEW_SPACE have the same effect. 679 // All allocation spaces other than NEW_SPACE have the same effect.
662 Heap::CollectAllGarbage(); 680 Heap::CollectAllGarbage();
663 return v8::Undefined(); 681 return v8::Undefined();
664 } 682 }
665 683
666 684
667 static GCExtension kGCExtension; 685 static GCExtension kGCExtension;
668 v8::DeclareExtension kGCExtensionDeclaration(&kGCExtension); 686 v8::DeclareExtension kGCExtensionDeclaration(&kGCExtension);
669 687
670 } } // namespace v8::internal 688 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/execution.h ('k') | src/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698