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

Side by Side Diff: src/handles.h

Issue 119177: Change handle creation to use Object*, to comply with strict aliasing rules. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « src/api.cc ('k') | no next file » | 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 void** CreateHandle(void* value) { 122 static inline Object** CreateHandle(Object* value) {
123 void** result = current_.next; 123 void** result = current_.next;
124 if (result == current_.limit) result = Extend(); 124 if (result == current_.limit) result = Extend();
125 // Update the current next field, set the value in the created 125 // Update the current next field, set the value in the created
126 // handle, and return the result. 126 // handle, and return the result.
127 ASSERT(result < current_.limit); 127 ASSERT(result < current_.limit);
128 current_.next = result + 1; 128 current_.next = result + 1;
129 *result = value; 129 *reinterpret_cast<Object**>(result) = value;
130 return result; 130 return reinterpret_cast<Object**>(result);
131 } 131 }
132 132
133 private: 133 private:
134 // Prevent heap allocation or illegal handle scopes. 134 // Prevent heap allocation or illegal handle scopes.
135 HandleScope(const HandleScope&); 135 HandleScope(const HandleScope&);
136 void operator=(const HandleScope&); 136 void operator=(const HandleScope&);
137 void* operator new(size_t size); 137 void* operator new(size_t size);
138 void operator delete(void* size_t); 138 void operator delete(void* size_t);
139 139
140 static v8::ImplementationUtilities::HandleScopeData current_; 140 static v8::ImplementationUtilities::HandleScopeData current_;
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 private: 338 private:
339 bool has_been_transformed_; // Tells whether the object has been transformed. 339 bool has_been_transformed_; // Tells whether the object has been transformed.
340 int unused_property_fields_; // Captures the unused number of field. 340 int unused_property_fields_; // Captures the unused number of field.
341 Handle<JSObject> object_; // The object being optimized. 341 Handle<JSObject> object_; // The object being optimized.
342 }; 342 };
343 343
344 344
345 } } // namespace v8::internal 345 } } // namespace v8::internal
346 346
347 #endif // V8_HANDLES_H_ 347 #endif // V8_HANDLES_H_
OLDNEW
« no previous file with comments | « src/api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698