| OLD | NEW |
| 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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 set_limits(kInterruptLimit, access); | 230 set_limits(kInterruptLimit, access); |
| 231 } | 231 } |
| 232 } | 232 } |
| 233 | 233 |
| 234 | 234 |
| 235 void StackGuard::SetStackLimit(uintptr_t limit) { | 235 void StackGuard::SetStackLimit(uintptr_t limit) { |
| 236 ExecutionAccess access; | 236 ExecutionAccess access; |
| 237 // If the current limits are special (eg due to a pending interrupt) then | 237 // If the current limits are special (eg due to a pending interrupt) then |
| 238 // leave them alone. | 238 // leave them alone. |
| 239 uintptr_t jslimit = SimulatorStack::JsLimitFromCLimit(limit); | 239 uintptr_t jslimit = SimulatorStack::JsLimitFromCLimit(limit); |
| 240 if (thread_local_.jslimit_ == thread_local_.initial_jslimit_) { | 240 if (thread_local_.jslimit_ == thread_local_.real_jslimit_) { |
| 241 thread_local_.jslimit_ = jslimit; | 241 thread_local_.jslimit_ = jslimit; |
| 242 Heap::SetStackLimit(jslimit); | |
| 243 } | 242 } |
| 244 if (thread_local_.climit_ == thread_local_.initial_climit_) { | 243 if (thread_local_.climit_ == thread_local_.real_climit_) { |
| 245 thread_local_.climit_ = limit; | 244 thread_local_.climit_ = limit; |
| 246 } | 245 } |
| 247 thread_local_.initial_climit_ = limit; | 246 thread_local_.real_climit_ = limit; |
| 248 thread_local_.initial_jslimit_ = jslimit; | 247 thread_local_.real_jslimit_ = jslimit; |
| 249 } | 248 } |
| 250 | 249 |
| 251 | 250 |
| 252 void StackGuard::DisableInterrupts() { | 251 void StackGuard::DisableInterrupts() { |
| 253 ExecutionAccess access; | 252 ExecutionAccess access; |
| 254 reset_limits(access); | 253 reset_limits(access); |
| 255 } | 254 } |
| 256 | 255 |
| 257 | 256 |
| 258 bool StackGuard::IsSet(const ExecutionAccess& lock) { | 257 bool StackGuard::IsSet(const ExecutionAccess& lock) { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 memcpy(to, reinterpret_cast<char*>(&thread_local_), sizeof(ThreadLocal)); | 346 memcpy(to, reinterpret_cast<char*>(&thread_local_), sizeof(ThreadLocal)); |
| 348 ThreadLocal blank; | 347 ThreadLocal blank; |
| 349 thread_local_ = blank; | 348 thread_local_ = blank; |
| 350 return to + sizeof(ThreadLocal); | 349 return to + sizeof(ThreadLocal); |
| 351 } | 350 } |
| 352 | 351 |
| 353 | 352 |
| 354 char* StackGuard::RestoreStackGuard(char* from) { | 353 char* StackGuard::RestoreStackGuard(char* from) { |
| 355 ExecutionAccess access; | 354 ExecutionAccess access; |
| 356 memcpy(reinterpret_cast<char*>(&thread_local_), from, sizeof(ThreadLocal)); | 355 memcpy(reinterpret_cast<char*>(&thread_local_), from, sizeof(ThreadLocal)); |
| 357 Heap::SetStackLimit(thread_local_.jslimit_); | 356 Heap::SetStackLimits(); |
| 358 return from + sizeof(ThreadLocal); | 357 return from + sizeof(ThreadLocal); |
| 359 } | 358 } |
| 360 | 359 |
| 361 | 360 |
| 362 static internal::Thread::LocalStorageKey stack_limit_key = | 361 static internal::Thread::LocalStorageKey stack_limit_key = |
| 363 internal::Thread::CreateThreadLocalKey(); | 362 internal::Thread::CreateThreadLocalKey(); |
| 364 | 363 |
| 365 | 364 |
| 366 void StackGuard::FreeThreadResources() { | 365 void StackGuard::FreeThreadResources() { |
| 367 Thread::SetThreadLocal( | 366 Thread::SetThreadLocal( |
| 368 stack_limit_key, | 367 stack_limit_key, |
| 369 reinterpret_cast<void*>(thread_local_.initial_climit_)); | 368 reinterpret_cast<void*>(thread_local_.real_climit_)); |
| 370 } | 369 } |
| 371 | 370 |
| 372 | 371 |
| 373 void StackGuard::ThreadLocal::Clear() { | 372 void StackGuard::ThreadLocal::Clear() { |
| 374 initial_jslimit_ = kIllegalLimit; | 373 real_jslimit_ = kIllegalLimit; |
| 375 jslimit_ = kIllegalLimit; | 374 jslimit_ = kIllegalLimit; |
| 376 initial_climit_ = kIllegalLimit; | 375 real_climit_ = kIllegalLimit; |
| 377 climit_ = kIllegalLimit; | 376 climit_ = kIllegalLimit; |
| 378 nesting_ = 0; | 377 nesting_ = 0; |
| 379 postpone_interrupts_nesting_ = 0; | 378 postpone_interrupts_nesting_ = 0; |
| 380 interrupt_flags_ = 0; | 379 interrupt_flags_ = 0; |
| 381 Heap::SetStackLimit(kIllegalLimit); | 380 Heap::SetStackLimits(); |
| 382 } | 381 } |
| 383 | 382 |
| 384 | 383 |
| 385 void StackGuard::ThreadLocal::Initialize() { | 384 void StackGuard::ThreadLocal::Initialize() { |
| 386 if (initial_climit_ == kIllegalLimit) { | 385 if (real_climit_ == kIllegalLimit) { |
| 387 // Takes the address of the limit variable in order to find out where | 386 // Takes the address of the limit variable in order to find out where |
| 388 // the top of stack is right now. | 387 // the top of stack is right now. |
| 389 uintptr_t limit = reinterpret_cast<uintptr_t>(&limit) - kLimitSize; | 388 uintptr_t limit = reinterpret_cast<uintptr_t>(&limit) - kLimitSize; |
| 390 ASSERT(reinterpret_cast<uintptr_t>(&limit) > kLimitSize); | 389 ASSERT(reinterpret_cast<uintptr_t>(&limit) > kLimitSize); |
| 391 initial_jslimit_ = SimulatorStack::JsLimitFromCLimit(limit); | 390 real_jslimit_ = SimulatorStack::JsLimitFromCLimit(limit); |
| 392 jslimit_ = SimulatorStack::JsLimitFromCLimit(limit); | 391 jslimit_ = SimulatorStack::JsLimitFromCLimit(limit); |
| 393 initial_climit_ = limit; | 392 real_climit_ = limit; |
| 394 climit_ = limit; | 393 climit_ = limit; |
| 395 Heap::SetStackLimit(SimulatorStack::JsLimitFromCLimit(limit)); | 394 Heap::SetStackLimits(); |
| 396 } | 395 } |
| 397 nesting_ = 0; | 396 nesting_ = 0; |
| 398 postpone_interrupts_nesting_ = 0; | 397 postpone_interrupts_nesting_ = 0; |
| 399 interrupt_flags_ = 0; | 398 interrupt_flags_ = 0; |
| 400 } | 399 } |
| 401 | 400 |
| 402 | 401 |
| 403 void StackGuard::ClearThread(const ExecutionAccess& lock) { | 402 void StackGuard::ClearThread(const ExecutionAccess& lock) { |
| 404 thread_local_.Clear(); | 403 thread_local_.Clear(); |
| 405 } | 404 } |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 // All allocation spaces other than NEW_SPACE have the same effect. | 692 // All allocation spaces other than NEW_SPACE have the same effect. |
| 694 Heap::CollectAllGarbage(false); | 693 Heap::CollectAllGarbage(false); |
| 695 return v8::Undefined(); | 694 return v8::Undefined(); |
| 696 } | 695 } |
| 697 | 696 |
| 698 | 697 |
| 699 static GCExtension kGCExtension; | 698 static GCExtension kGCExtension; |
| 700 v8::DeclareExtension kGCExtensionDeclaration(&kGCExtension); | 699 v8::DeclareExtension kGCExtensionDeclaration(&kGCExtension); |
| 701 | 700 |
| 702 } } // namespace v8::internal | 701 } } // namespace v8::internal |
| OLD | NEW |