Chromium Code Reviews| 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 2764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2775 | 2775 |
| 2776 | 2776 |
| 2777 template<typename T> | 2777 template<typename T> |
| 2778 class ReturnValue { | 2778 class ReturnValue { |
| 2779 public: | 2779 public: |
| 2780 V8_INLINE(explicit ReturnValue(internal::Object** slot)); | 2780 V8_INLINE(explicit ReturnValue(internal::Object** slot)); |
| 2781 // Handle setters | 2781 // Handle setters |
| 2782 V8_INLINE(void Set(const Persistent<T>& handle)); | 2782 V8_INLINE(void Set(const Persistent<T>& handle)); |
| 2783 V8_INLINE(void Set(const Handle<T> handle)); | 2783 V8_INLINE(void Set(const Handle<T> handle)); |
| 2784 // Fast primitive setters | 2784 // Fast primitive setters |
| 2785 V8_INLINE(void Set(Isolate* isolate, bool value)); | 2785 V8_INLINE(void Set(bool value)); |
| 2786 V8_INLINE(void Set(Isolate* isolate, double i)); | 2786 V8_INLINE(void Set(double i)); |
| 2787 V8_INLINE(void Set(Isolate* isolate, int32_t i)); | 2787 V8_INLINE(void Set(int32_t i)); |
| 2788 V8_INLINE(void Set(Isolate* isolate, uint32_t i)); | 2788 V8_INLINE(void Set(uint32_t i)); |
| 2789 // Fast JS primitive setters | 2789 // Fast JS primitive setters |
| 2790 V8_INLINE(void SetNull(Isolate* isolate)); | 2790 V8_INLINE(void SetNull()); |
| 2791 V8_INLINE(void SetUndefined(Isolate* isolate)); | 2791 V8_INLINE(void SetUndefined()); |
| 2792 // Convenience getter for Isolate | |
| 2793 V8_INLINE(Isolate* GetIsolate()); | |
|
Sven Panne
2013/05/27 11:35:36
Do we really want to expose GetIsolate() or would
| |
| 2792 private: | 2794 private: |
| 2793 V8_INLINE(void SetTrue(Isolate* isolate)); | |
| 2794 V8_INLINE(void SetFalse(Isolate* isolate)); | |
| 2795 internal::Object** value_; | 2795 internal::Object** value_; |
| 2796 }; | 2796 }; |
| 2797 | 2797 |
| 2798 | 2798 |
| 2799 /** | 2799 /** |
| 2800 * The argument information given to function call callbacks. This | 2800 * The argument information given to function call callbacks. This |
| 2801 * class provides access to information about the context of the call, | 2801 * class provides access to information about the context of the call, |
| 2802 * including the receiver, the number and values of arguments, and | 2802 * including the receiver, the number and values of arguments, and |
| 2803 * the holder of the function. | 2803 * the holder of the function. |
| 2804 */ | 2804 */ |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2861 // This shouldn't be public, but the arm compiler needs it. | 2861 // This shouldn't be public, but the arm compiler needs it. |
| 2862 static const int kArgsLength = 5; | 2862 static const int kArgsLength = 5; |
| 2863 | 2863 |
| 2864 protected: | 2864 protected: |
| 2865 friend class MacroAssembler; | 2865 friend class MacroAssembler; |
| 2866 friend class internal::PropertyCallbackArguments; | 2866 friend class internal::PropertyCallbackArguments; |
| 2867 friend class internal::CustomArguments<PropertyCallbackInfo>; | 2867 friend class internal::CustomArguments<PropertyCallbackInfo>; |
| 2868 static const int kThisIndex = 0; | 2868 static const int kThisIndex = 0; |
| 2869 static const int kHolderIndex = -1; | 2869 static const int kHolderIndex = -1; |
| 2870 static const int kDataIndex = -2; | 2870 static const int kDataIndex = -2; |
| 2871 static const int kIsolateIndex = -3; | 2871 static const int kReturnValueIndex = -3; |
| 2872 static const int kReturnValueIndex = -4; | 2872 static const int kIsolateIndex = -4; |
| 2873 | 2873 |
| 2874 V8_INLINE(PropertyCallbackInfo(internal::Object** args)) | 2874 V8_INLINE(PropertyCallbackInfo(internal::Object** args)) |
| 2875 : args_(args) { } | 2875 : args_(args) { } |
| 2876 internal::Object** args_; | 2876 internal::Object** args_; |
| 2877 }; | 2877 }; |
| 2878 | 2878 |
| 2879 | 2879 |
| 2880 class V8EXPORT AccessorInfo : public PropertyCallbackInfo<Value> { | 2880 class V8EXPORT AccessorInfo : public PropertyCallbackInfo<Value> { |
| 2881 private: | 2881 private: |
| 2882 friend class internal::PropertyCallbackArguments; | 2882 friend class internal::PropertyCallbackArguments; |
| (...skipping 2804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5687 void ReturnValue<T>::Set(const Persistent<T>& handle) { | 5687 void ReturnValue<T>::Set(const Persistent<T>& handle) { |
| 5688 *value_ = *reinterpret_cast<internal::Object**>(*handle); | 5688 *value_ = *reinterpret_cast<internal::Object**>(*handle); |
| 5689 } | 5689 } |
| 5690 | 5690 |
| 5691 template<typename T> | 5691 template<typename T> |
| 5692 void ReturnValue<T>::Set(const Handle<T> handle) { | 5692 void ReturnValue<T>::Set(const Handle<T> handle) { |
| 5693 *value_ = *reinterpret_cast<internal::Object**>(*handle); | 5693 *value_ = *reinterpret_cast<internal::Object**>(*handle); |
| 5694 } | 5694 } |
| 5695 | 5695 |
| 5696 template<typename T> | 5696 template<typename T> |
| 5697 void ReturnValue<T>::Set(Isolate* isolate, double i) { | 5697 void ReturnValue<T>::Set(double i) { |
| 5698 Set(Number::New(isolate, i)); | 5698 Set(Number::New(GetIsolate(), i)); |
| 5699 } | 5699 } |
| 5700 | 5700 |
| 5701 template<typename T> | 5701 template<typename T> |
| 5702 void ReturnValue<T>::Set(Isolate* isolate, int32_t i) { | 5702 void ReturnValue<T>::Set(int32_t i) { |
| 5703 typedef internal::Internals I; | 5703 typedef internal::Internals I; |
| 5704 if (V8_LIKELY(I::IsValidSmi(i))) { | 5704 if (V8_LIKELY(I::IsValidSmi(i))) { |
| 5705 *value_ = I::IntToSmi(i); | 5705 *value_ = I::IntToSmi(i); |
| 5706 return; | 5706 return; |
| 5707 } | 5707 } |
| 5708 Set(Integer::New(i, isolate)); | 5708 Set(Integer::New(i, GetIsolate())); |
| 5709 } | 5709 } |
| 5710 | 5710 |
| 5711 template<typename T> | 5711 template<typename T> |
| 5712 void ReturnValue<T>::Set(Isolate* isolate, uint32_t i) { | 5712 void ReturnValue<T>::Set(uint32_t i) { |
| 5713 typedef internal::Internals I; | 5713 typedef internal::Internals I; |
| 5714 if (V8_LIKELY(I::IsValidSmi(i))) { | 5714 if (V8_LIKELY(I::IsValidSmi(i))) { |
| 5715 *value_ = I::IntToSmi(i); | 5715 *value_ = I::IntToSmi(i); |
| 5716 return; | 5716 return; |
| 5717 } | 5717 } |
| 5718 Set(Integer::NewFromUnsigned(i, isolate)); | 5718 Set(Integer::NewFromUnsigned(i, GetIsolate())); |
| 5719 } | 5719 } |
| 5720 | 5720 |
| 5721 template<typename T> | 5721 template<typename T> |
| 5722 void ReturnValue<T>::Set(Isolate* isolate, bool value) { | 5722 void ReturnValue<T>::Set(bool value) { |
| 5723 typedef internal::Internals I; | |
| 5724 int root_index; | |
| 5723 if (value) { | 5725 if (value) { |
| 5724 SetTrue(isolate); | 5726 root_index = I::kTrueValueRootIndex; |
| 5725 } else { | 5727 } else { |
| 5726 SetFalse(isolate); | 5728 root_index = I::kFalseValueRootIndex; |
| 5727 } | 5729 } |
| 5730 *value_ = *I::GetRoot(GetIsolate(), root_index); | |
| 5728 } | 5731 } |
| 5729 | 5732 |
| 5730 template<typename T> | 5733 template<typename T> |
| 5731 void ReturnValue<T>::SetTrue(Isolate* isolate) { | 5734 void ReturnValue<T>::SetNull() { |
| 5732 typedef internal::Internals I; | 5735 typedef internal::Internals I; |
| 5733 *value_ = *I::GetRoot(isolate, I::kTrueValueRootIndex); | 5736 *value_ = *I::GetRoot(GetIsolate(), I::kNullValueRootIndex); |
| 5734 } | 5737 } |
| 5735 | 5738 |
| 5736 template<typename T> | 5739 template<typename T> |
| 5737 void ReturnValue<T>::SetFalse(Isolate* isolate) { | 5740 void ReturnValue<T>::SetUndefined() { |
| 5738 typedef internal::Internals I; | 5741 typedef internal::Internals I; |
| 5739 *value_ = *I::GetRoot(isolate, I::kFalseValueRootIndex); | 5742 *value_ = *I::GetRoot(GetIsolate(), I::kUndefinedValueRootIndex); |
| 5740 } | 5743 } |
| 5741 | 5744 |
| 5742 template<typename T> | 5745 template<typename T> |
| 5743 void ReturnValue<T>::SetNull(Isolate* isolate) { | 5746 Isolate* ReturnValue<T>::GetIsolate() { |
| 5744 typedef internal::Internals I; | 5747 // Isolate is always the pointer below value_ on the stack. |
| 5745 *value_ = *I::GetRoot(isolate, I::kNullValueRootIndex); | 5748 return *reinterpret_cast<Isolate**>(&value_[-1]); |
| 5746 } | |
| 5747 | |
| 5748 template<typename T> | |
| 5749 void ReturnValue<T>::SetUndefined(Isolate* isolate) { | |
| 5750 typedef internal::Internals I; | |
| 5751 *value_ = *I::GetRoot(isolate, I::kUndefinedValueRootIndex); | |
| 5752 } | 5749 } |
| 5753 | 5750 |
| 5754 | 5751 |
| 5755 template<typename T> | 5752 template<typename T> |
| 5756 FunctionCallbackInfo<T>::FunctionCallbackInfo(internal::Object** implicit_args, | 5753 FunctionCallbackInfo<T>::FunctionCallbackInfo(internal::Object** implicit_args, |
| 5757 internal::Object** values, | 5754 internal::Object** values, |
| 5758 int length, | 5755 int length, |
| 5759 bool is_construct_call) | 5756 bool is_construct_call) |
| 5760 : implicit_args_(implicit_args), | 5757 : implicit_args_(implicit_args), |
| 5761 values_(values), | 5758 values_(values), |
| (...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6324 | 6321 |
| 6325 | 6322 |
| 6326 } // namespace v8 | 6323 } // namespace v8 |
| 6327 | 6324 |
| 6328 | 6325 |
| 6329 #undef V8EXPORT | 6326 #undef V8EXPORT |
| 6330 #undef TYPE_CHECK | 6327 #undef TYPE_CHECK |
| 6331 | 6328 |
| 6332 | 6329 |
| 6333 #endif // V8_H_ | 6330 #endif // V8_H_ |
| OLD | NEW |