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 11 matching lines...) Expand all Loading... | |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef V8_ACCESSORS_H_ | 28 #ifndef V8_ACCESSORS_H_ |
| 29 #define V8_ACCESSORS_H_ | 29 #define V8_ACCESSORS_H_ |
| 30 | 30 |
| 31 #include "allocation.h" | 31 #include "allocation.h" |
| 32 #include "types.h" | |
| 32 #include "v8globals.h" | 33 #include "v8globals.h" |
| 33 | 34 |
| 34 namespace v8 { | 35 namespace v8 { |
| 35 namespace internal { | 36 namespace internal { |
| 36 | 37 |
| 37 // The list of accessor descriptors. This is a second-order macro | 38 // The list of accessor descriptors. This is a second-order macro |
| 38 // taking a macro to be applied to all accessor descriptor names. | 39 // taking a macro to be applied to all accessor descriptor names. |
| 39 #define ACCESSOR_DESCRIPTOR_LIST(V) \ | 40 #define ACCESSOR_DESCRIPTOR_LIST(V) \ |
| 40 V(FunctionPrototype) \ | 41 V(FunctionPrototype) \ |
| 41 V(FunctionLength) \ | 42 V(FunctionLength) \ |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 79 // Accessor functions called directly from the runtime system. | 80 // Accessor functions called directly from the runtime system. |
| 80 static Handle<Object> FunctionSetPrototype(Handle<JSFunction> object, | 81 static Handle<Object> FunctionSetPrototype(Handle<JSFunction> object, |
| 81 Handle<Object> value); | 82 Handle<Object> value); |
| 82 static Handle<Object> FunctionGetPrototype(Handle<JSFunction> object); | 83 static Handle<Object> FunctionGetPrototype(Handle<JSFunction> object); |
| 83 static Handle<Object> FunctionGetArguments(Handle<JSFunction> object); | 84 static Handle<Object> FunctionGetArguments(Handle<JSFunction> object); |
| 84 | 85 |
| 85 // Accessor infos. | 86 // Accessor infos. |
| 86 static Handle<AccessorInfo> MakeModuleExport( | 87 static Handle<AccessorInfo> MakeModuleExport( |
| 87 Handle<String> name, int index, PropertyAttributes attributes); | 88 Handle<String> name, int index, PropertyAttributes attributes); |
| 88 | 89 |
| 90 static V8_INLINE bool CheckForName(Handle<String> name, | |
| 91 String* property_name, | |
| 92 int offset, | |
| 93 int* object_offset) { | |
| 94 if (name->Equals(property_name)) { | |
| 95 *object_offset = offset; | |
| 96 return true; | |
| 97 } | |
| 98 return false; | |
| 99 } | |
| 100 | |
| 89 // Returns true for properties that are accessors to object fields. | 101 // Returns true for properties that are accessors to object fields. |
| 90 // If true, *object_offset contains offset of object field. | 102 // If true, *object_offset contains offset of object field. |
| 91 static bool IsJSObjectFieldAccessor( | 103 template <class T> |
|
rossberg
2014/02/03 16:54:05
You don't necessarily need to move this to the hea
| |
| 92 Handle<HeapType> map, Handle<String> name, int* object_offset); | 104 static bool IsJSObjectFieldAccessor(typename T::TypeHandle type, |
| 105 Handle<String> name, | |
| 106 int* object_offset) { | |
| 107 Isolate* isolate = name->GetIsolate(); | |
| 93 | 108 |
| 109 if (type->Is(T::String())) { | |
| 110 return CheckForName(name, isolate->heap()->length_string(), | |
| 111 String::kLengthOffset, object_offset); | |
| 112 } | |
| 113 | |
| 114 if (!type->IsClass()) return false; | |
| 115 Handle<Map> map = type->AsClass(); | |
| 116 | |
| 117 switch (map->instance_type()) { | |
| 118 case JS_ARRAY_TYPE: | |
| 119 return | |
| 120 CheckForName(name, isolate->heap()->length_string(), | |
| 121 JSArray::kLengthOffset, object_offset); | |
| 122 case JS_TYPED_ARRAY_TYPE: | |
| 123 return | |
| 124 CheckForName(name, isolate->heap()->length_string(), | |
| 125 JSTypedArray::kLengthOffset, object_offset) || | |
| 126 CheckForName(name, isolate->heap()->byte_length_string(), | |
| 127 JSTypedArray::kByteLengthOffset, object_offset) || | |
| 128 CheckForName(name, isolate->heap()->byte_offset_string(), | |
| 129 JSTypedArray::kByteOffsetOffset, object_offset) || | |
| 130 CheckForName(name, isolate->heap()->buffer_string(), | |
| 131 JSTypedArray::kBufferOffset, object_offset); | |
| 132 case JS_ARRAY_BUFFER_TYPE: | |
| 133 return | |
| 134 CheckForName(name, isolate->heap()->byte_length_string(), | |
| 135 JSArrayBuffer::kByteLengthOffset, object_offset); | |
| 136 case JS_DATA_VIEW_TYPE: | |
| 137 return | |
| 138 CheckForName(name, isolate->heap()->byte_length_string(), | |
| 139 JSDataView::kByteLengthOffset, object_offset) || | |
| 140 CheckForName(name, isolate->heap()->byte_offset_string(), | |
| 141 JSDataView::kByteOffsetOffset, object_offset) || | |
| 142 CheckForName(name, isolate->heap()->buffer_string(), | |
| 143 JSDataView::kBufferOffset, object_offset); | |
| 144 default: | |
| 145 return false; | |
| 146 } | |
| 147 } | |
| 94 | 148 |
| 95 private: | 149 private: |
| 96 // Accessor functions only used through the descriptor. | 150 // Accessor functions only used through the descriptor. |
| 97 static MaybeObject* FunctionSetPrototype(Isolate* isolate, | 151 static MaybeObject* FunctionSetPrototype(Isolate* isolate, |
| 98 JSObject* object, | 152 JSObject* object, |
| 99 Object*, | 153 Object*, |
| 100 void*); | 154 void*); |
| 101 static MaybeObject* FunctionGetPrototype(Isolate* isolate, | 155 static MaybeObject* FunctionGetPrototype(Isolate* isolate, |
| 102 Object* object, | 156 Object* object, |
| 103 void*); | 157 void*); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 156 static Object* IllegalGetAccessor(Isolate* isolate, Object* object, void*); | 210 static Object* IllegalGetAccessor(Isolate* isolate, Object* object, void*); |
| 157 static MaybeObject* ReadOnlySetAccessor(Isolate* isolate, | 211 static MaybeObject* ReadOnlySetAccessor(Isolate* isolate, |
| 158 JSObject*, | 212 JSObject*, |
| 159 Object* value, | 213 Object* value, |
| 160 void*); | 214 void*); |
| 161 }; | 215 }; |
| 162 | 216 |
| 163 } } // namespace v8::internal | 217 } } // namespace v8::internal |
| 164 | 218 |
| 165 #endif // V8_ACCESSORS_H_ | 219 #endif // V8_ACCESSORS_H_ |
| OLD | NEW |