OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 // Constructor for the Locker object. Once the Locker is constructed the | 50 // Constructor for the Locker object. Once the Locker is constructed the |
51 // current thread will be guaranteed to have the big V8 lock. | 51 // current thread will be guaranteed to have the big V8 lock. |
52 Locker::Locker() : has_lock_(false), top_level_(true) { | 52 Locker::Locker() : has_lock_(false), top_level_(true) { |
53 // Record that the Locker has been used at least once. | 53 // Record that the Locker has been used at least once. |
54 active_ = true; | 54 active_ = true; |
55 // Get the big lock if necessary. | 55 // Get the big lock if necessary. |
56 if (!internal::ThreadManager::IsLockedByCurrentThread()) { | 56 if (!internal::ThreadManager::IsLockedByCurrentThread()) { |
57 internal::ThreadManager::Lock(); | 57 internal::ThreadManager::Lock(); |
58 has_lock_ = true; | 58 has_lock_ = true; |
| 59 // Make sure that V8 is initialized. Archiving of threads interferes |
| 60 // with deserialization by adding additional root pointers, so we must |
| 61 // initialize here, before anyone can call ~Locker() or Unlocker(). |
| 62 if (!internal::V8::IsRunning()) { |
| 63 V8::Initialize(); |
| 64 } |
59 // This may be a locker within an unlocker in which case we have to | 65 // This may be a locker within an unlocker in which case we have to |
60 // get the saved state for this thread and restore it. | 66 // get the saved state for this thread and restore it. |
61 if (internal::ThreadManager::RestoreThread()) { | 67 if (internal::ThreadManager::RestoreThread()) { |
62 top_level_ = false; | 68 top_level_ = false; |
63 } else { | 69 } else { |
64 internal::ExecutionAccess access; | 70 internal::ExecutionAccess access; |
65 internal::StackGuard::ClearThread(access); | 71 internal::StackGuard::ClearThread(access); |
66 internal::StackGuard::InitThread(access); | 72 internal::StackGuard::InitThread(access); |
67 } | 73 } |
68 } | 74 } |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 // Acknowledge the preemption by the receiving thread. | 441 // Acknowledge the preemption by the receiving thread. |
436 void ContextSwitcher::PreemptionReceived() { | 442 void ContextSwitcher::PreemptionReceived() { |
437 ASSERT(Locker::IsLocked()); | 443 ASSERT(Locker::IsLocked()); |
438 // There is currently no accounting being done for this. But could be in the | 444 // There is currently no accounting being done for this. But could be in the |
439 // future, which is why we leave this in. | 445 // future, which is why we leave this in. |
440 } | 446 } |
441 | 447 |
442 | 448 |
443 } // namespace internal | 449 } // namespace internal |
444 } // namespace v8 | 450 } // namespace v8 |
OLD | NEW |