OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 F(IndexedPropertyGetter, IndexedPropertyGetterCallback) \ | 145 F(IndexedPropertyGetter, IndexedPropertyGetterCallback) \ |
146 F(IndexedPropertySetter, IndexedPropertySetterCallback) \ | 146 F(IndexedPropertySetter, IndexedPropertySetterCallback) \ |
147 F(IndexedPropertyQuery, IndexedPropertyQueryCallback) \ | 147 F(IndexedPropertyQuery, IndexedPropertyQueryCallback) \ |
148 F(IndexedPropertyDeleter, IndexedPropertyDeleterCallback) \ | 148 F(IndexedPropertyDeleter, IndexedPropertyDeleterCallback) \ |
149 F(IndexedPropertyEnumerator, IndexedPropertyEnumeratorCallback) \ | 149 F(IndexedPropertyEnumerator, IndexedPropertyEnumeratorCallback) \ |
150 | 150 |
151 | 151 |
152 // TODO(dcarney): Remove this class when old callbacks are gone. | 152 // TODO(dcarney): Remove this class when old callbacks are gone. |
153 class CallbackTable { | 153 class CallbackTable { |
154 public: | 154 public: |
155 // TODO(dcarney): Flip this when it makes sense for performance. | 155 static const bool kStoreVoidFunctions = false; |
156 static const bool kStoreVoidFunctions = true; | |
157 static inline bool ReturnsVoid(Isolate* isolate, void* function) { | 156 static inline bool ReturnsVoid(Isolate* isolate, void* function) { |
158 CallbackTable* table = isolate->callback_table(); | 157 CallbackTable* table = isolate->callback_table(); |
159 bool contains = | 158 bool contains = |
160 table != NULL && | 159 table != NULL && |
161 table->map_.occupancy() != 0 && | 160 table->map_.occupancy() != 0 && |
162 table->Contains(function); | 161 table->Contains(function); |
163 return contains == kStoreVoidFunctions; | 162 return contains == kStoreVoidFunctions; |
164 } | 163 } |
165 | 164 |
166 STATIC_ASSERT(sizeof(intptr_t) == sizeof(AccessorGetterCallback)); | 165 STATIC_ASSERT(sizeof(intptr_t) == sizeof(AccessorGetterCallback)); |
167 | 166 |
168 template<typename F> | 167 template<typename F> |
169 static inline void* FunctionToVoidPtr(F function) { | 168 static inline void* FunctionToVoidPtr(F function) { |
170 return reinterpret_cast<void*>(reinterpret_cast<intptr_t>(function)); | 169 return reinterpret_cast<void*>(reinterpret_cast<intptr_t>(function)); |
171 } | 170 } |
172 | 171 |
173 #define WRITE_REGISTER(OldFunction, NewFunction) \ | 172 #define WRITE_REGISTER(OldFunction, NewFunction) \ |
174 static OldFunction Register(Isolate* isolate, NewFunction f) { \ | 173 static NewFunction Register(Isolate* isolate, OldFunction f) { \ |
175 InsertCallback(isolate, FunctionToVoidPtr(f), true); \ | 174 InsertCallback(isolate, FunctionToVoidPtr(f), false); \ |
176 return reinterpret_cast<OldFunction>(f); \ | 175 return reinterpret_cast<NewFunction>(f); \ |
177 } \ | 176 } \ |
178 \ | 177 \ |
179 static OldFunction Register(Isolate* isolate, OldFunction f) { \ | 178 static NewFunction Register(Isolate* isolate, NewFunction f) { \ |
180 InsertCallback(isolate, FunctionToVoidPtr(f), false); \ | 179 InsertCallback(isolate, FunctionToVoidPtr(f), true); \ |
181 return f; \ | 180 return f; \ |
182 } | 181 } |
183 FOR_EACH_CALLBACK_TABLE_MAPPING(WRITE_REGISTER) | 182 FOR_EACH_CALLBACK_TABLE_MAPPING(WRITE_REGISTER) |
184 #undef WRITE_REGISTER | 183 #undef WRITE_REGISTER |
185 | 184 |
186 private: | 185 private: |
187 CallbackTable(); | 186 CallbackTable(); |
188 bool Contains(void* function); | 187 bool Contains(void* function); |
189 static void InsertCallback(Isolate* isolate, | 188 static void InsertCallback(Isolate* isolate, |
190 void* function, | 189 void* function, |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 return __RT_impl_##Name(args, isolate); \ | 346 return __RT_impl_##Name(args, isolate); \ |
348 } \ | 347 } \ |
349 static Type __RT_impl_##Name(Arguments args, Isolate* isolate) | 348 static Type __RT_impl_##Name(Arguments args, Isolate* isolate) |
350 | 349 |
351 #define RUNTIME_ARGUMENTS(isolate, args) \ | 350 #define RUNTIME_ARGUMENTS(isolate, args) \ |
352 args.length(), args.arguments(), isolate | 351 args.length(), args.arguments(), isolate |
353 | 352 |
354 } } // namespace v8::internal | 353 } } // namespace v8::internal |
355 | 354 |
356 #endif // V8_ARGUMENTS_H_ | 355 #endif // V8_ARGUMENTS_H_ |
OLD | NEW |