| 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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 // they indicate a pending interruption. The interrupt limit will be | 227 // they indicate a pending interruption. The interrupt limit will be |
| 228 // temporarily reset through the code below and reestablished if the | 228 // temporarily reset through the code below and reestablished if the |
| 229 // interrupt flags indicate that an interrupt is pending. | 229 // interrupt flags indicate that an interrupt is pending. |
| 230 ASSERT(thread_local_.jslimit_ == kIllegalLimit || | 230 ASSERT(thread_local_.jslimit_ == kIllegalLimit || |
| 231 (thread_local_.jslimit_ == kInterruptLimit && | 231 (thread_local_.jslimit_ == kInterruptLimit && |
| 232 thread_local_.interrupt_flags_ != 0)); | 232 thread_local_.interrupt_flags_ != 0)); |
| 233 ASSERT(thread_local_.climit_ == kIllegalLimit || | 233 ASSERT(thread_local_.climit_ == kIllegalLimit || |
| 234 (thread_local_.climit_ == kInterruptLimit && | 234 (thread_local_.climit_ == kInterruptLimit && |
| 235 thread_local_.interrupt_flags_ != 0)); | 235 thread_local_.interrupt_flags_ != 0)); |
| 236 | 236 |
| 237 thread_local_.initial_jslimit_ = thread_local_.jslimit_ = | 237 uintptr_t limit = GENERATED_CODE_STACK_LIMIT(kLimitSize); |
| 238 GENERATED_CODE_STACK_LIMIT(kLimitSize); | 238 thread_local_.initial_jslimit_ = thread_local_.jslimit_ = limit; |
| 239 Heap::SetStackLimit(limit); |
| 239 // NOTE: The check for overflow is not safe as there is no guarantee that | 240 // NOTE: The check for overflow is not safe as there is no guarantee that |
| 240 // the running thread has its stack in all memory up to address 0x00000000. | 241 // the running thread has its stack in all memory up to address 0x00000000. |
| 241 thread_local_.initial_climit_ = thread_local_.climit_ = | 242 thread_local_.initial_climit_ = thread_local_.climit_ = |
| 242 reinterpret_cast<uintptr_t>(this) >= kLimitSize ? | 243 reinterpret_cast<uintptr_t>(this) >= kLimitSize ? |
| 243 reinterpret_cast<uintptr_t>(this) - kLimitSize : 0; | 244 reinterpret_cast<uintptr_t>(this) - kLimitSize : 0; |
| 244 | 245 |
| 245 if (thread_local_.interrupt_flags_ != 0) { | 246 if (thread_local_.interrupt_flags_ != 0) { |
| 246 set_limits(kInterruptLimit, access); | 247 set_limits(kInterruptLimit, access); |
| 247 } | 248 } |
| 248 } | 249 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 276 } | 277 } |
| 277 } | 278 } |
| 278 | 279 |
| 279 | 280 |
| 280 void StackGuard::SetStackLimit(uintptr_t limit) { | 281 void StackGuard::SetStackLimit(uintptr_t limit) { |
| 281 ExecutionAccess access; | 282 ExecutionAccess access; |
| 282 // If the current limits are special (eg due to a pending interrupt) then | 283 // If the current limits are special (eg due to a pending interrupt) then |
| 283 // leave them alone. | 284 // leave them alone. |
| 284 if (thread_local_.jslimit_ == thread_local_.initial_jslimit_) { | 285 if (thread_local_.jslimit_ == thread_local_.initial_jslimit_) { |
| 285 thread_local_.jslimit_ = limit; | 286 thread_local_.jslimit_ = limit; |
| 287 Heap::SetStackLimit(limit); |
| 286 } | 288 } |
| 287 if (thread_local_.climit_ == thread_local_.initial_climit_) { | 289 if (thread_local_.climit_ == thread_local_.initial_climit_) { |
| 288 thread_local_.climit_ = limit; | 290 thread_local_.climit_ = limit; |
| 289 } | 291 } |
| 290 thread_local_.initial_climit_ = limit; | 292 thread_local_.initial_climit_ = limit; |
| 291 thread_local_.initial_jslimit_ = limit; | 293 thread_local_.initial_jslimit_ = limit; |
| 292 } | 294 } |
| 293 | 295 |
| 294 | 296 |
| 295 void StackGuard::DisableInterrupts() { | 297 void StackGuard::DisableInterrupts() { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 memcpy(to, reinterpret_cast<char*>(&thread_local_), sizeof(ThreadLocal)); | 392 memcpy(to, reinterpret_cast<char*>(&thread_local_), sizeof(ThreadLocal)); |
| 391 ThreadLocal blank; | 393 ThreadLocal blank; |
| 392 thread_local_ = blank; | 394 thread_local_ = blank; |
| 393 return to + sizeof(ThreadLocal); | 395 return to + sizeof(ThreadLocal); |
| 394 } | 396 } |
| 395 | 397 |
| 396 | 398 |
| 397 char* StackGuard::RestoreStackGuard(char* from) { | 399 char* StackGuard::RestoreStackGuard(char* from) { |
| 398 ExecutionAccess access; | 400 ExecutionAccess access; |
| 399 memcpy(reinterpret_cast<char*>(&thread_local_), from, sizeof(ThreadLocal)); | 401 memcpy(reinterpret_cast<char*>(&thread_local_), from, sizeof(ThreadLocal)); |
| 402 Heap::SetStackLimit(thread_local_.jslimit_); |
| 400 return from + sizeof(ThreadLocal); | 403 return from + sizeof(ThreadLocal); |
| 401 } | 404 } |
| 402 | 405 |
| 403 | 406 |
| 404 // --- C a l l s t o n a t i v e s --- | 407 // --- C a l l s t o n a t i v e s --- |
| 405 | 408 |
| 406 #define RETURN_NATIVE_CALL(name, argc, argv, has_pending_exception) \ | 409 #define RETURN_NATIVE_CALL(name, argc, argv, has_pending_exception) \ |
| 407 do { \ | 410 do { \ |
| 408 Object** args[argc] = argv; \ | 411 Object** args[argc] = argv; \ |
| 409 ASSERT(has_pending_exception != NULL); \ | 412 ASSERT(has_pending_exception != NULL); \ |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 // All allocation spaces other than NEW_SPACE have the same effect. | 682 // All allocation spaces other than NEW_SPACE have the same effect. |
| 680 Heap::CollectAllGarbage(false); | 683 Heap::CollectAllGarbage(false); |
| 681 return v8::Undefined(); | 684 return v8::Undefined(); |
| 682 } | 685 } |
| 683 | 686 |
| 684 | 687 |
| 685 static GCExtension kGCExtension; | 688 static GCExtension kGCExtension; |
| 686 v8::DeclareExtension kGCExtensionDeclaration(&kGCExtension); | 689 v8::DeclareExtension kGCExtensionDeclaration(&kGCExtension); |
| 687 | 690 |
| 688 } } // namespace v8::internal | 691 } } // namespace v8::internal |
| OLD | NEW |