| 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 15 matching lines...) Expand all Loading... |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 // | 27 // |
| 28 | 28 |
| 29 #ifndef V8_HANDLES_INL_H_ | 29 #ifndef V8_HANDLES_INL_H_ |
| 30 #define V8_HANDLES_INL_H_ | 30 #define V8_HANDLES_INL_H_ |
| 31 | 31 |
| 32 #include "api.h" | 32 #include "api.h" |
| 33 #include "apiutils.h" | 33 #include "apiutils.h" |
| 34 #include "handles.h" | 34 #include "handles.h" |
| 35 #include "isolate.h" | 35 #include "isolate.h" |
| 36 #include "v8threads.h" |
| 36 | 37 |
| 37 namespace v8 { | 38 namespace v8 { |
| 38 namespace internal { | 39 namespace internal { |
| 39 | 40 |
| 40 inline Isolate* GetIsolateForHandle(Object* obj) { | 41 inline Isolate* GetIsolateForHandle(Object* obj) { |
| 41 return Isolate::Current(); | 42 return Isolate::Current(); |
| 42 } | 43 } |
| 43 | 44 |
| 44 inline Isolate* GetIsolateForHandle(HeapObject* obj) { | 45 inline Isolate* GetIsolateForHandle(HeapObject* obj) { |
| 45 return obj->GetIsolate(); | 46 return obj->GetIsolate(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 62 template <typename T> | 63 template <typename T> |
| 63 inline T* Handle<T>::operator*() const { | 64 inline T* Handle<T>::operator*() const { |
| 64 ASSERT(location_ != NULL); | 65 ASSERT(location_ != NULL); |
| 65 ASSERT(reinterpret_cast<Address>(*location_) != kHandleZapValue); | 66 ASSERT(reinterpret_cast<Address>(*location_) != kHandleZapValue); |
| 66 return *BitCast<T**>(location_); | 67 return *BitCast<T**>(location_); |
| 67 } | 68 } |
| 68 | 69 |
| 69 | 70 |
| 70 HandleScope::HandleScope() { | 71 HandleScope::HandleScope() { |
| 71 Isolate* isolate = Isolate::Current(); | 72 Isolate* isolate = Isolate::Current(); |
| 73 |
| 74 if (FLAG_optimize_in_parallel && |
| 75 !isolate->thread_manager()->IsLockedByCurrentThread()) { |
| 76 has_isolate_lock_ = true; |
| 77 isolate->thread_manager()->Lock(); |
| 78 } else { |
| 79 has_isolate_lock_ = false; |
| 80 } |
| 81 |
| 72 v8::ImplementationUtilities::HandleScopeData* current = | 82 v8::ImplementationUtilities::HandleScopeData* current = |
| 73 isolate->handle_scope_data(); | 83 isolate->handle_scope_data(); |
| 74 isolate_ = isolate; | 84 isolate_ = isolate; |
| 75 prev_next_ = current->next; | 85 prev_next_ = current->next; |
| 76 prev_limit_ = current->limit; | 86 prev_limit_ = current->limit; |
| 77 current->level++; | 87 current->level++; |
| 78 } | 88 } |
| 79 | 89 |
| 80 | 90 |
| 81 HandleScope::HandleScope(Isolate* isolate) { | 91 HandleScope::HandleScope(Isolate* isolate) { |
| 82 ASSERT(isolate == Isolate::Current()); | 92 ASSERT(isolate == Isolate::Current()); |
| 83 v8::ImplementationUtilities::HandleScopeData* current = | 93 v8::ImplementationUtilities::HandleScopeData* current = |
| 84 isolate->handle_scope_data(); | 94 isolate->handle_scope_data(); |
| 95 |
| 96 if (FLAG_optimize_in_parallel && |
| 97 !isolate->thread_manager()->IsLockedByCurrentThread()) { |
| 98 has_isolate_lock_ = true; |
| 99 isolate->thread_manager()->Lock(); |
| 100 } else { |
| 101 has_isolate_lock_ = false; |
| 102 } |
| 103 |
| 85 isolate_ = isolate; | 104 isolate_ = isolate; |
| 86 prev_next_ = current->next; | 105 prev_next_ = current->next; |
| 87 prev_limit_ = current->limit; | 106 prev_limit_ = current->limit; |
| 88 current->level++; | 107 current->level++; |
| 89 } | 108 } |
| 90 | 109 |
| 91 | 110 |
| 92 HandleScope::~HandleScope() { | 111 HandleScope::~HandleScope() { |
| 93 CloseScope(); | 112 CloseScope(); |
| 113 if (has_isolate_lock_) { |
| 114 isolate_->thread_manager()->Unlock(); |
| 115 } |
| 94 } | 116 } |
| 95 | 117 |
| 96 void HandleScope::CloseScope() { | 118 void HandleScope::CloseScope() { |
| 97 ASSERT(isolate_ == Isolate::Current()); | 119 ASSERT(isolate_ == Isolate::Current()); |
| 98 v8::ImplementationUtilities::HandleScopeData* current = | 120 v8::ImplementationUtilities::HandleScopeData* current = |
| 99 isolate_->handle_scope_data(); | 121 isolate_->handle_scope_data(); |
| 100 current->next = prev_next_; | 122 current->next = prev_next_; |
| 101 current->level--; | 123 current->level--; |
| 102 if (current->limit != prev_limit_) { | 124 if (current->limit != prev_limit_) { |
| 103 current->limit = prev_limit_; | 125 current->limit = prev_limit_; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 Isolate::Current()->handle_scope_data(); | 190 Isolate::Current()->handle_scope_data(); |
| 169 ASSERT_EQ(0, data->level); | 191 ASSERT_EQ(0, data->level); |
| 170 data->level = level_; | 192 data->level = level_; |
| 171 } | 193 } |
| 172 #endif | 194 #endif |
| 173 | 195 |
| 174 | 196 |
| 175 } } // namespace v8::internal | 197 } } // namespace v8::internal |
| 176 | 198 |
| 177 #endif // V8_HANDLES_INL_H_ | 199 #endif // V8_HANDLES_INL_H_ |
| OLD | NEW |