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.h

Issue 164498: Fix strict aliasing crash on x64. (Closed)
Patch Set: remove todo. Created 11 years, 4 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/compilation-cache.cc ('k') | src/handles-inl.h » ('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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 reinterpret_cast<Address>(*location_) != kZapValue); 75 reinterpret_cast<Address>(*location_) != kZapValue);
76 return location_; 76 return location_;
77 } 77 }
78 78
79 template <class S> static Handle<T> cast(Handle<S> that) { 79 template <class S> static Handle<T> cast(Handle<S> that) {
80 T::cast(*that); 80 T::cast(*that);
81 return Handle<T>(reinterpret_cast<T**>(that.location())); 81 return Handle<T>(reinterpret_cast<T**>(that.location()));
82 } 82 }
83 83
84 static Handle<T> null() { return Handle<T>(); } 84 static Handle<T> null() { return Handle<T>(); }
85 bool is_null() {return location_ == NULL; } 85 bool is_null() { return location_ == NULL; }
86 86
87 // Closes the given scope, but lets this handle escape. See 87 // Closes the given scope, but lets this handle escape. See
88 // implementation in api.h. 88 // implementation in api.h.
89 inline Handle<T> EscapeFrom(v8::HandleScope* scope); 89 inline Handle<T> EscapeFrom(v8::HandleScope* scope);
90 90
91 private: 91 private:
92 T** location_; 92 T** location_;
93 }; 93 };
94 94
95 95
(...skipping 16 matching lines...) Expand all
112 } 112 }
113 113
114 ~HandleScope() { 114 ~HandleScope() {
115 Leave(&previous_); 115 Leave(&previous_);
116 } 116 }
117 117
118 // Counts the number of allocated handles. 118 // Counts the number of allocated handles.
119 static int NumberOfHandles(); 119 static int NumberOfHandles();
120 120
121 // Creates a new handle with the given value. 121 // Creates a new handle with the given value.
122 static inline Object** CreateHandle(Object* value) { 122 template <typename T>
123 void** result = current_.next; 123 static inline T** CreateHandle(T* value) {
124 if (result == current_.limit) result = Extend(); 124 void** cur = current_.next;
125 if (cur == current_.limit) cur = Extend();
125 // Update the current next field, set the value in the created 126 // Update the current next field, set the value in the created
126 // handle, and return the result. 127 // handle, and return the result.
127 ASSERT(result < current_.limit); 128 ASSERT(cur < current_.limit);
128 current_.next = result + 1; 129 current_.next = cur + 1;
129 *reinterpret_cast<Object**>(result) = value; 130
130 return reinterpret_cast<Object**>(result); 131 T** result = reinterpret_cast<T**>(cur);
132 *result = value;
133 return result;
131 } 134 }
132 135
133 private: 136 private:
134 // Prevent heap allocation or illegal handle scopes. 137 // Prevent heap allocation or illegal handle scopes.
135 HandleScope(const HandleScope&); 138 HandleScope(const HandleScope&);
136 void operator=(const HandleScope&); 139 void operator=(const HandleScope&);
137 void* operator new(size_t size); 140 void* operator new(size_t size);
138 void operator delete(void* size_t); 141 void operator delete(void* size_t);
139 142
140 static v8::ImplementationUtilities::HandleScopeData current_; 143 static v8::ImplementationUtilities::HandleScopeData current_;
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 private: 346 private:
344 bool has_been_transformed_; // Tells whether the object has been transformed. 347 bool has_been_transformed_; // Tells whether the object has been transformed.
345 int unused_property_fields_; // Captures the unused number of field. 348 int unused_property_fields_; // Captures the unused number of field.
346 Handle<JSObject> object_; // The object being optimized. 349 Handle<JSObject> object_; // The object being optimized.
347 }; 350 };
348 351
349 352
350 } } // namespace v8::internal 353 } } // namespace v8::internal
351 354
352 #endif // V8_HANDLES_H_ 355 #endif // V8_HANDLES_H_
OLDNEW
« no previous file with comments | « src/compilation-cache.cc ('k') | src/handles-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698