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

Side by Side Diff: src/execution.cc

Issue 13783: * Made preemption work in Irregexp-native-ia32 (Closed)
Patch Set: Addressed review comments Created 12 years 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/execution.h ('k') | src/jsregexp.cc » ('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 20 matching lines...) Expand all
31 31
32 #include "api.h" 32 #include "api.h"
33 #include "codegen-inl.h" 33 #include "codegen-inl.h"
34 34
35 #ifdef ARM 35 #ifdef ARM
36 #include "simulator-arm.h" 36 #include "simulator-arm.h"
37 #else // ia32 37 #else // ia32
38 #include "simulator-ia32.h" 38 #include "simulator-ia32.h"
39 #endif 39 #endif
40 40
41 #include "debug.h"
42 #include "v8threads.h"
43
41 namespace v8 { namespace internal { 44 namespace v8 { namespace internal {
42 45
43 46
44 static Handle<Object> Invoke(bool construct, 47 static Handle<Object> Invoke(bool construct,
45 Handle<JSFunction> func, 48 Handle<JSFunction> func,
46 Handle<Object> receiver, 49 Handle<Object> receiver,
47 int argc, 50 int argc,
48 Object*** args, 51 Object*** args,
49 bool* has_pending_exception) { 52 bool* has_pending_exception) {
50 // Make sure we have a real function, not a boilerplate function. 53 // Make sure we have a real function, not a boilerplate function.
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 is_global.location() }; 496 is_global.location() };
494 bool caught_exception = false; 497 bool caught_exception = false;
495 Handle<Object> result = TryCall(Top::get_stack_trace_line_fun(), 498 Handle<Object> result = TryCall(Top::get_stack_trace_line_fun(),
496 Top::builtins(), argc, args, 499 Top::builtins(), argc, args,
497 &caught_exception); 500 &caught_exception);
498 if (caught_exception || !result->IsString()) return Factory::empty_symbol(); 501 if (caught_exception || !result->IsString()) return Factory::empty_symbol();
499 return Handle<String>::cast(result); 502 return Handle<String>::cast(result);
500 } 503 }
501 504
502 505
506 static Object* RuntimePreempt() {
507 // Clear the preempt request flag.
508 StackGuard::Continue(PREEMPT);
509
510 ContextSwitcher::PreemptionReceived();
511
512 {
513 v8::Unlocker unlocker;
514 Thread::YieldCPU();
515 }
516
517 return Heap::undefined_value();
518 }
519
520
521 Object* Execution::DebugBreakHelper() {
522 // Just continue if breaks are disabled.
523 if (Debug::disable_break()) {
524 return Heap::undefined_value();
525 }
526
527 // Don't break in system functions. If the current function is
528 // either in the builtins object of some context or is in the debug
529 // context just return with the debug break stack guard active.
530 JavaScriptFrameIterator it;
531 JavaScriptFrame* frame = it.frame();
532 Object* fun = frame->function();
533 if (fun->IsJSFunction()) {
534 GlobalObject* global = JSFunction::cast(fun)->context()->global();
535 if (global->IsJSBuiltinsObject() || Debug::IsDebugGlobal(global)) {
536 return Heap::undefined_value();
537 }
538 }
539
540 // Clear the debug request flag.
541 StackGuard::Continue(DEBUGBREAK);
542
543 HandleScope scope;
544 // Enter the debugger. Just continue if we fail to enter the debugger.
545 EnterDebugger debugger;
546 if (debugger.FailedToEnter()) {
547 return Heap::undefined_value();
548 }
549
550 // Notify the debug event listeners.
551 Debugger::OnDebugBreak(Factory::undefined_value());
552
553 // Return to continue execution.
554 return Heap::undefined_value();
555 }
556
557
558 Object* Execution::HandleStackGuardInterrupt() {
559 if (StackGuard::IsDebugBreak()) DebugBreakHelper();
560 if (StackGuard::IsPreempted()) RuntimePreempt();
561 if (StackGuard::IsInterrupted()) {
562 // interrupt
563 StackGuard::Continue(INTERRUPT);
564 return Top::StackOverflow();
565 }
566 return Heap::undefined_value();
567 }
568
503 // --- G C E x t e n s i o n --- 569 // --- G C E x t e n s i o n ---
504 570
505 const char* GCExtension::kSource = "native function gc();"; 571 const char* GCExtension::kSource = "native function gc();";
506 572
507 573
508 v8::Handle<v8::FunctionTemplate> GCExtension::GetNativeFunction( 574 v8::Handle<v8::FunctionTemplate> GCExtension::GetNativeFunction(
509 v8::Handle<v8::String> str) { 575 v8::Handle<v8::String> str) {
510 return v8::FunctionTemplate::New(GCExtension::GC); 576 return v8::FunctionTemplate::New(GCExtension::GC);
511 } 577 }
512 578
513 579
514 v8::Handle<v8::Value> GCExtension::GC(const v8::Arguments& args) { 580 v8::Handle<v8::Value> GCExtension::GC(const v8::Arguments& args) {
515 // All allocation spaces other than NEW_SPACE have the same effect. 581 // All allocation spaces other than NEW_SPACE have the same effect.
516 Heap::CollectGarbage(0, OLD_DATA_SPACE); 582 Heap::CollectGarbage(0, OLD_DATA_SPACE);
517 return v8::Undefined(); 583 return v8::Undefined();
518 } 584 }
519 585
520 586
521 static GCExtension kGCExtension; 587 static GCExtension kGCExtension;
522 v8::DeclareExtension kGCExtensionDeclaration(&kGCExtension); 588 v8::DeclareExtension kGCExtensionDeclaration(&kGCExtension);
523 589
524 } } // namespace v8::internal 590 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/execution.h ('k') | src/jsregexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698