Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: src/handles-inl.h

Issue 3473024: [Isolates] More handle improvements: (Closed)
Patch Set: Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/handles.cc ('k') | src/ic.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 25 matching lines...) Expand all
36 36
37 namespace v8 { 37 namespace v8 {
38 namespace internal { 38 namespace internal {
39 39
40 template<class T> 40 template<class T>
41 Handle<T>::Handle(T* obj) { 41 Handle<T>::Handle(T* obj) {
42 ASSERT(!obj->IsFailure()); 42 ASSERT(!obj->IsFailure());
43 location_ = HandleScope::CreateHandle(obj, Isolate::Current()); 43 location_ = HandleScope::CreateHandle(obj, Isolate::Current());
44 } 44 }
45 45
46 template<class T>
47 Handle<T>::Handle(HeapObject* obj) {
48 location_ = HandleScope::CreateHandle<T>(obj, obj->GetIsolate());
49 }
50
46 51
47 template<class T> 52 template<class T>
48 Handle<T>::Handle(T* obj, Isolate* isolate) { 53 Handle<T>::Handle(T* obj, Isolate* isolate) {
49 ASSERT(!obj->IsFailure()); 54 ASSERT(!obj->IsFailure());
50 location_ = HandleScope::CreateHandle(obj, isolate); 55 location_ = HandleScope::CreateHandle(obj, isolate);
51 } 56 }
52 57
53 58
54 template <class T> 59 template <class T>
55 inline T* Handle<T>::operator*() const { 60 inline T* Handle<T>::operator*() const {
56 ASSERT(location_ != NULL); 61 ASSERT(location_ != NULL);
57 ASSERT(reinterpret_cast<Address>(*location_) != kHandleZapValue); 62 ASSERT(reinterpret_cast<Address>(*location_) != kHandleZapValue);
58 return *BitCast<T**>(location_); 63 return *BitCast<T**>(location_);
59 } 64 }
60 65
61 66
67 // Helper class to zero out the number of extensions in the handle
68 // scope data after it has been saved.
69 // This is only necessary for HandleScope constructor to get the right
70 // order of effects.
71 class HandleScopeDataTransfer {
72 public:
73 typedef v8::ImplementationUtilities::HandleScopeData Data;
74
75 explicit HandleScopeDataTransfer(Data* data) : data_(data) {}
76 ~HandleScopeDataTransfer() { data_->extensions = 0; }
77
78 // Called before the destructor to get the data to save.
79 Data* data() { return data_; }
80
81 private:
82 Data* data_;
83
84 DISALLOW_COPY_AND_ASSIGN(HandleScopeDataTransfer);
85 };
86
87
62 HandleScope::HandleScope() 88 HandleScope::HandleScope()
63 : previous_(*Isolate::Current()->handle_scope_data()) { 89 : previous_(*HandleScopeDataTransfer(
64 Isolate::Current()->handle_scope_data()->extensions = 0; 90 Isolate::Current()->handle_scope_data()).data()) {
65 } 91 }
66 92
67 93
94 HandleScope::HandleScope(Isolate* isolate)
95 : previous_(*HandleScopeDataTransfer(isolate->handle_scope_data()).data()) {
96 ASSERT(isolate == Isolate::Current());
97 }
98
99
68 template <typename T> 100 template <typename T>
69 T** HandleScope::CreateHandle(T* value, Isolate* isolate) { 101 T** HandleScope::CreateHandle(T* value, Isolate* isolate) {
70 ASSERT(isolate == Isolate::Current()); 102 ASSERT(isolate == Isolate::Current());
71 v8::ImplementationUtilities::HandleScopeData* current = 103 v8::ImplementationUtilities::HandleScopeData* current =
72 isolate->handle_scope_data(); 104 isolate->handle_scope_data();
73 105
74 internal::Object** cur = current->next; 106 internal::Object** cur = current->next;
75 if (cur == current->limit) cur = Extend(); 107 if (cur == current->limit) cur = Extend();
76 // Update the current next field, set the value in the created 108 // Update the current next field, set the value in the created
77 // handle, and return the result. 109 // handle, and return the result.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 // Restore state in current handle scope to re-enable handle 156 // Restore state in current handle scope to re-enable handle
125 // allocations. 157 // allocations.
126 Isolate::Current()->handle_scope_data()->extensions = extensions_; 158 Isolate::Current()->handle_scope_data()->extensions = extensions_;
127 } 159 }
128 #endif 160 #endif
129 161
130 162
131 } } // namespace v8::internal 163 } } // namespace v8::internal
132 164
133 #endif // V8_HANDLES_INL_H_ 165 #endif // V8_HANDLES_INL_H_
OLDNEW
« no previous file with comments | « src/handles.cc ('k') | src/ic.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698