OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 if (has_pending_interrupts(access)) { | 289 if (has_pending_interrupts(access)) { |
290 set_interrupt_limits(access); | 290 set_interrupt_limits(access); |
291 } | 291 } |
292 } | 292 } |
293 | 293 |
294 | 294 |
295 void StackGuard::SetStackLimit(uintptr_t limit) { | 295 void StackGuard::SetStackLimit(uintptr_t limit) { |
296 ExecutionAccess access(isolate_); | 296 ExecutionAccess access(isolate_); |
297 // If the current limits are special (eg due to a pending interrupt) then | 297 // If the current limits are special (eg due to a pending interrupt) then |
298 // leave them alone. | 298 // leave them alone. |
299 uintptr_t jslimit = SimulatorStack::JsLimitFromCLimit(limit); | 299 uintptr_t jslimit = SimulatorStack::JsLimitFromCLimit(isolate_, limit); |
300 if (thread_local_.jslimit_ == thread_local_.real_jslimit_) { | 300 if (thread_local_.jslimit_ == thread_local_.real_jslimit_) { |
301 thread_local_.jslimit_ = jslimit; | 301 thread_local_.jslimit_ = jslimit; |
302 } | 302 } |
303 if (thread_local_.climit_ == thread_local_.real_climit_) { | 303 if (thread_local_.climit_ == thread_local_.real_climit_) { |
304 thread_local_.climit_ = limit; | 304 thread_local_.climit_ = limit; |
305 } | 305 } |
306 thread_local_.real_climit_ = limit; | 306 thread_local_.real_climit_ = limit; |
307 thread_local_.real_jslimit_ = jslimit; | 307 thread_local_.real_jslimit_ = jslimit; |
308 } | 308 } |
309 | 309 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 real_jslimit_ = kIllegalLimit; | 445 real_jslimit_ = kIllegalLimit; |
446 jslimit_ = kIllegalLimit; | 446 jslimit_ = kIllegalLimit; |
447 real_climit_ = kIllegalLimit; | 447 real_climit_ = kIllegalLimit; |
448 climit_ = kIllegalLimit; | 448 climit_ = kIllegalLimit; |
449 nesting_ = 0; | 449 nesting_ = 0; |
450 postpone_interrupts_nesting_ = 0; | 450 postpone_interrupts_nesting_ = 0; |
451 interrupt_flags_ = 0; | 451 interrupt_flags_ = 0; |
452 } | 452 } |
453 | 453 |
454 | 454 |
455 bool StackGuard::ThreadLocal::Initialize() { | 455 bool StackGuard::ThreadLocal::Initialize(Isolate* isolate) { |
456 bool should_set_stack_limits = false; | 456 bool should_set_stack_limits = false; |
457 if (real_climit_ == kIllegalLimit) { | 457 if (real_climit_ == kIllegalLimit) { |
458 // Takes the address of the limit variable in order to find out where | 458 // Takes the address of the limit variable in order to find out where |
459 // the top of stack is right now. | 459 // the top of stack is right now. |
460 const uintptr_t kLimitSize = FLAG_stack_size * KB; | 460 const uintptr_t kLimitSize = FLAG_stack_size * KB; |
461 uintptr_t limit = reinterpret_cast<uintptr_t>(&limit) - kLimitSize; | 461 uintptr_t limit = reinterpret_cast<uintptr_t>(&limit) - kLimitSize; |
462 ASSERT(reinterpret_cast<uintptr_t>(&limit) > kLimitSize); | 462 ASSERT(reinterpret_cast<uintptr_t>(&limit) > kLimitSize); |
463 real_jslimit_ = SimulatorStack::JsLimitFromCLimit(limit); | 463 real_jslimit_ = SimulatorStack::JsLimitFromCLimit(isolate, limit); |
464 jslimit_ = SimulatorStack::JsLimitFromCLimit(limit); | 464 jslimit_ = SimulatorStack::JsLimitFromCLimit(isolate, limit); |
465 real_climit_ = limit; | 465 real_climit_ = limit; |
466 climit_ = limit; | 466 climit_ = limit; |
467 should_set_stack_limits = true; | 467 should_set_stack_limits = true; |
468 } | 468 } |
469 nesting_ = 0; | 469 nesting_ = 0; |
470 postpone_interrupts_nesting_ = 0; | 470 postpone_interrupts_nesting_ = 0; |
471 interrupt_flags_ = 0; | 471 interrupt_flags_ = 0; |
472 return should_set_stack_limits; | 472 return should_set_stack_limits; |
473 } | 473 } |
474 | 474 |
475 | 475 |
476 void StackGuard::ClearThread(const ExecutionAccess& lock) { | 476 void StackGuard::ClearThread(const ExecutionAccess& lock) { |
477 thread_local_.Clear(); | 477 thread_local_.Clear(); |
478 isolate_->heap()->SetStackLimits(); | 478 isolate_->heap()->SetStackLimits(); |
479 } | 479 } |
480 | 480 |
481 | 481 |
482 void StackGuard::InitThread(const ExecutionAccess& lock) { | 482 void StackGuard::InitThread(const ExecutionAccess& lock) { |
483 if (thread_local_.Initialize()) isolate_->heap()->SetStackLimits(); | 483 if (thread_local_.Initialize(isolate_)) isolate_->heap()->SetStackLimits(); |
484 uintptr_t stored_limit = | 484 Isolate::PerIsolateThreadData* per_thread = |
485 Isolate::CurrentPerIsolateThreadData()->stack_limit(); | 485 isolate_->FindOrAllocatePerThreadDataForThisThread(); |
| 486 uintptr_t stored_limit = per_thread->stack_limit(); |
486 // You should hold the ExecutionAccess lock when you call this. | 487 // You should hold the ExecutionAccess lock when you call this. |
487 if (stored_limit != 0) { | 488 if (stored_limit != 0) { |
488 StackGuard::SetStackLimit(stored_limit); | 489 StackGuard::SetStackLimit(stored_limit); |
489 } | 490 } |
490 } | 491 } |
491 | 492 |
492 | 493 |
493 // --- C a l l s t o n a t i v e s --- | 494 // --- C a l l s t o n a t i v e s --- |
494 | 495 |
495 #define RETURN_NATIVE_CALL(name, argc, argv, has_pending_exception) \ | 496 #define RETURN_NATIVE_CALL(name, argc, argv, has_pending_exception) \ |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 | 699 |
699 ContextSwitcher::PreemptionReceived(); | 700 ContextSwitcher::PreemptionReceived(); |
700 | 701 |
701 #ifdef ENABLE_DEBUGGER_SUPPORT | 702 #ifdef ENABLE_DEBUGGER_SUPPORT |
702 if (isolate->debug()->InDebugger()) { | 703 if (isolate->debug()->InDebugger()) { |
703 // If currently in the debugger don't do any actual preemption but record | 704 // If currently in the debugger don't do any actual preemption but record |
704 // that preemption occoured while in the debugger. | 705 // that preemption occoured while in the debugger. |
705 isolate->debug()->PreemptionWhileInDebugger(); | 706 isolate->debug()->PreemptionWhileInDebugger(); |
706 } else { | 707 } else { |
707 // Perform preemption. | 708 // Perform preemption. |
708 v8::Unlocker unlocker; | 709 v8::Unlocker unlocker(reinterpret_cast<v8::Isolate*>(isolate)); |
709 Thread::YieldCPU(); | 710 Thread::YieldCPU(); |
710 } | 711 } |
711 #else | 712 #else |
712 { // NOLINT | 713 { // NOLINT |
713 // Perform preemption. | 714 // Perform preemption. |
714 v8::Unlocker unlocker; | 715 v8::Unlocker unlocker(reinterpret_cast<v8::Isolate*>(isolate)); |
715 Thread::YieldCPU(); | 716 Thread::YieldCPU(); |
716 } | 717 } |
717 #endif | 718 #endif |
718 | 719 |
719 return isolate->heap()->undefined_value(); | 720 return isolate->heap()->undefined_value(); |
720 } | 721 } |
721 | 722 |
722 | 723 |
723 #ifdef ENABLE_DEBUGGER_SUPPORT | 724 #ifdef ENABLE_DEBUGGER_SUPPORT |
724 Object* Execution::DebugBreakHelper() { | 725 Object* Execution::DebugBreakHelper() { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 return isolate->TerminateExecution(); | 807 return isolate->TerminateExecution(); |
807 } | 808 } |
808 if (stack_guard->IsInterrupted()) { | 809 if (stack_guard->IsInterrupted()) { |
809 stack_guard->Continue(INTERRUPT); | 810 stack_guard->Continue(INTERRUPT); |
810 return isolate->StackOverflow(); | 811 return isolate->StackOverflow(); |
811 } | 812 } |
812 return isolate->heap()->undefined_value(); | 813 return isolate->heap()->undefined_value(); |
813 } | 814 } |
814 | 815 |
815 } } // namespace v8::internal | 816 } } // namespace v8::internal |
OLD | NEW |