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

Side by Side Diff: include/v8.h

Issue 240013004: Prevent calls to ReturnValue::Set with pointer-valued types. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 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 | « no previous file | 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 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 2440 matching lines...) Expand 10 before | Expand all | Expand 10 after
2451 V8_INLINE void Set(double i); 2451 V8_INLINE void Set(double i);
2452 V8_INLINE void Set(int32_t i); 2452 V8_INLINE void Set(int32_t i);
2453 V8_INLINE void Set(uint32_t i); 2453 V8_INLINE void Set(uint32_t i);
2454 // Fast JS primitive setters 2454 // Fast JS primitive setters
2455 V8_INLINE void SetNull(); 2455 V8_INLINE void SetNull();
2456 V8_INLINE void SetUndefined(); 2456 V8_INLINE void SetUndefined();
2457 V8_INLINE void SetEmptyString(); 2457 V8_INLINE void SetEmptyString();
2458 // Convenience getter for Isolate 2458 // Convenience getter for Isolate
2459 V8_INLINE Isolate* GetIsolate(); 2459 V8_INLINE Isolate* GetIsolate();
2460 2460
2461 // Pointer setter: Uncompilable to prevent inadvertent misuse.
2462 void Set(void* whatever);
2463
2461 private: 2464 private:
2462 template<class F> friend class ReturnValue; 2465 template<class F> friend class ReturnValue;
2463 template<class F> friend class FunctionCallbackInfo; 2466 template<class F> friend class FunctionCallbackInfo;
2464 template<class F> friend class PropertyCallbackInfo; 2467 template<class F> friend class PropertyCallbackInfo;
2465 template<class F, class G, class H> friend class PersistentValueMap; 2468 template<class F, class G, class H> friend class PersistentValueMap;
2466 V8_INLINE void SetInternal(internal::Object* value) { *value_ = value; } 2469 V8_INLINE void SetInternal(internal::Object* value) { *value_ = value; }
2467 V8_INLINE internal::Object* GetDefaultValue(); 2470 V8_INLINE internal::Object* GetDefaultValue();
2468 V8_INLINE explicit ReturnValue(internal::Object** slot); 2471 V8_INLINE explicit ReturnValue(internal::Object** slot);
2469 internal::Object** value_; 2472 internal::Object** value_;
2470 }; 2473 };
(...skipping 3503 matching lines...) Expand 10 before | Expand all | Expand 10 after
5974 *value_ = *I::GetRoot(GetIsolate(), I::kEmptyStringRootIndex); 5977 *value_ = *I::GetRoot(GetIsolate(), I::kEmptyStringRootIndex);
5975 } 5978 }
5976 5979
5977 template<typename T> 5980 template<typename T>
5978 Isolate* ReturnValue<T>::GetIsolate() { 5981 Isolate* ReturnValue<T>::GetIsolate() {
5979 // Isolate is always the pointer below the default value on the stack. 5982 // Isolate is always the pointer below the default value on the stack.
5980 return *reinterpret_cast<Isolate**>(&value_[-2]); 5983 return *reinterpret_cast<Isolate**>(&value_[-2]);
5981 } 5984 }
5982 5985
5983 template<typename T> 5986 template<typename T>
5987 void ReturnValue<T>::Set(void* whatever) {
5988 // Uncompilable to prevent inadvertent misuse.
5989 TYPE_CHECK(void*, Primitive);
5990 }
5991
5992 template<typename T>
5984 internal::Object* ReturnValue<T>::GetDefaultValue() { 5993 internal::Object* ReturnValue<T>::GetDefaultValue() {
5985 // Default value is always the pointer below value_ on the stack. 5994 // Default value is always the pointer below value_ on the stack.
5986 return value_[-1]; 5995 return value_[-1];
5987 } 5996 }
5988 5997
5989 5998
5990 template<typename T> 5999 template<typename T>
5991 FunctionCallbackInfo<T>::FunctionCallbackInfo(internal::Object** implicit_args, 6000 FunctionCallbackInfo<T>::FunctionCallbackInfo(internal::Object** implicit_args,
5992 internal::Object** values, 6001 internal::Object** values,
5993 int length, 6002 int length,
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
6630 */ 6639 */
6631 6640
6632 6641
6633 } // namespace v8 6642 } // namespace v8
6634 6643
6635 6644
6636 #undef TYPE_CHECK 6645 #undef TYPE_CHECK
6637 6646
6638 6647
6639 #endif // V8_H_ 6648 #endif // V8_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698