 Chromium Code Reviews
 Chromium Code Reviews Issue 12049012:
  Avoid handle dereference during graph optimization.  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
    
  
    Issue 12049012:
  Avoid handle dereference during graph optimization.  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 Handle<T>::Handle(T* obj, Isolate* isolate) { | 56 Handle<T>::Handle(T* obj, Isolate* isolate) { | 
| 57 ASSERT(!obj->IsFailure()); | 57 ASSERT(!obj->IsFailure()); | 
| 58 location_ = HandleScope::CreateHandle(obj, isolate); | 58 location_ = HandleScope::CreateHandle(obj, isolate); | 
| 59 } | 59 } | 
| 60 | 60 | 
| 61 | 61 | 
| 62 template <typename T> | 62 template <typename T> | 
| 63 inline T* Handle<T>::operator*() const { | 63 inline T* Handle<T>::operator*() const { | 
| 64 ASSERT(location_ != NULL); | 64 ASSERT(location_ != NULL); | 
| 65 ASSERT(reinterpret_cast<Address>(*location_) != kHandleZapValue); | 65 ASSERT(reinterpret_cast<Address>(*location_) != kHandleZapValue); | 
| 66 SLOW_ASSERT(ISOLATE->allow_handle_deref()); | |
| 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(); | 
| 72 v8::ImplementationUtilities::HandleScopeData* current = | 73 v8::ImplementationUtilities::HandleScopeData* current = | 
| 73 isolate->handle_scope_data(); | 74 isolate->handle_scope_data(); | 
| 74 isolate_ = isolate; | 75 isolate_ = isolate; | 
| 75 prev_next_ = current->next; | 76 prev_next_ = current->next; | 
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 168 inline NoHandleAllocation::~NoHandleAllocation() { | 169 inline NoHandleAllocation::~NoHandleAllocation() { | 
| 169 if (active_) { | 170 if (active_) { | 
| 170 // Restore state in current handle scope to re-enable handle | 171 // Restore state in current handle scope to re-enable handle | 
| 171 // allocations. | 172 // allocations. | 
| 172 v8::ImplementationUtilities::HandleScopeData* data = | 173 v8::ImplementationUtilities::HandleScopeData* data = | 
| 173 Isolate::Current()->handle_scope_data(); | 174 Isolate::Current()->handle_scope_data(); | 
| 174 ASSERT_EQ(0, data->level); | 175 ASSERT_EQ(0, data->level); | 
| 175 data->level = level_; | 176 data->level = level_; | 
| 176 } | 177 } | 
| 177 } | 178 } | 
| 179 | |
| 180 | |
| 181 NoHandleDereference::NoHandleDereference() { | |
| 182 Isolate* isolate = Isolate::Current(); | |
| 183 active_ = !isolate->optimizing_compiler_thread()->IsOptimizerThread(); | |
| 
Jakob Kummerow
2013/01/23 12:09:18
I'd appreciate a comment here, something along the
 
Yang
2013/01/23 13:34:25
Done.
 | |
| 184 if (active_) { | |
| 185 old_state_ = isolate->allow_handle_deref(); | |
| 186 isolate->set_allow_handle_deref(false); | |
| 187 } | |
| 188 } | |
| 189 | |
| 190 | |
| 191 NoHandleDereference::~NoHandleDereference() { | |
| 192 if (active_) Isolate::Current()->set_allow_handle_deref(old_state_); | |
| 193 } | |
| 194 | |
| 195 | |
| 196 AllowHandleDereference::AllowHandleDereference() { | |
| 197 Isolate* isolate = Isolate::Current(); | |
| 198 active_ = !isolate->optimizing_compiler_thread()->IsOptimizerThread(); | |
| 199 if (active_) { | |
| 200 old_state_ = isolate->allow_handle_deref(); | |
| 201 isolate->set_allow_handle_deref(true); | |
| 202 } | |
| 203 } | |
| 204 | |
| 205 | |
| 206 AllowHandleDereference::~AllowHandleDereference() { | |
| 207 if (active_) Isolate::Current()->set_allow_handle_deref(old_state_); | |
| 208 } | |
| 178 #endif | 209 #endif | 
| 179 | 210 | 
| 180 | 211 | 
| 181 } } // namespace v8::internal | 212 } } // namespace v8::internal | 
| 182 | 213 | 
| 183 #endif // V8_HANDLES_INL_H_ | 214 #endif // V8_HANDLES_INL_H_ | 
| OLD | NEW |