| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 int offset, | 84 int offset, |
| 85 int* object_offset) { | 85 int* object_offset) { |
| 86 if (name->Equals(property_name)) { | 86 if (name->Equals(property_name)) { |
| 87 *object_offset = offset; | 87 *object_offset = offset; |
| 88 return true; | 88 return true; |
| 89 } | 89 } |
| 90 return false; | 90 return false; |
| 91 } | 91 } |
| 92 | 92 |
| 93 | 93 |
| 94 bool Accessors::IsJSObjectFieldAccessor( | 94 bool Accessors::IsJSObjectFieldAccessor(Handle<HeapType> type, |
| 95 Handle<Map> map, Handle<String> name, | 95 Handle<String> name, |
| 96 int* object_offset) { | 96 int* object_offset) { |
| 97 Isolate* isolate = map->GetIsolate(); | 97 Isolate* isolate = name->GetIsolate(); |
| 98 |
| 99 if (type->Is(HeapType::String())) { |
| 100 return CheckForName(name, isolate->heap()->length_string(), |
| 101 String::kLengthOffset, object_offset); |
| 102 } |
| 103 |
| 104 if (!type->IsClass()) return false; |
| 105 Handle<Map> map = type->AsClass(); |
| 106 |
| 98 switch (map->instance_type()) { | 107 switch (map->instance_type()) { |
| 99 case JS_ARRAY_TYPE: | 108 case JS_ARRAY_TYPE: |
| 100 return | 109 return |
| 101 CheckForName(name, isolate->heap()->length_string(), | 110 CheckForName(name, isolate->heap()->length_string(), |
| 102 JSArray::kLengthOffset, object_offset); | 111 JSArray::kLengthOffset, object_offset); |
| 103 case JS_TYPED_ARRAY_TYPE: | 112 case JS_TYPED_ARRAY_TYPE: |
| 104 return | 113 return |
| 105 CheckForName(name, isolate->heap()->length_string(), | 114 CheckForName(name, isolate->heap()->length_string(), |
| 106 JSTypedArray::kLengthOffset, object_offset) || | 115 JSTypedArray::kLengthOffset, object_offset) || |
| 107 CheckForName(name, isolate->heap()->byte_length_string(), | 116 CheckForName(name, isolate->heap()->byte_length_string(), |
| 108 JSTypedArray::kByteLengthOffset, object_offset) || | 117 JSTypedArray::kByteLengthOffset, object_offset) || |
| 109 CheckForName(name, isolate->heap()->byte_offset_string(), | 118 CheckForName(name, isolate->heap()->byte_offset_string(), |
| 110 JSTypedArray::kByteOffsetOffset, object_offset) || | 119 JSTypedArray::kByteOffsetOffset, object_offset) || |
| 111 CheckForName(name, isolate->heap()->buffer_string(), | 120 CheckForName(name, isolate->heap()->buffer_string(), |
| 112 JSTypedArray::kBufferOffset, object_offset); | 121 JSTypedArray::kBufferOffset, object_offset); |
| 113 case JS_ARRAY_BUFFER_TYPE: | 122 case JS_ARRAY_BUFFER_TYPE: |
| 114 return | 123 return |
| 115 CheckForName(name, isolate->heap()->byte_length_string(), | 124 CheckForName(name, isolate->heap()->byte_length_string(), |
| 116 JSArrayBuffer::kByteLengthOffset, object_offset); | 125 JSArrayBuffer::kByteLengthOffset, object_offset); |
| 117 case JS_DATA_VIEW_TYPE: | 126 case JS_DATA_VIEW_TYPE: |
| 118 return | 127 return |
| 119 CheckForName(name, isolate->heap()->byte_length_string(), | 128 CheckForName(name, isolate->heap()->byte_length_string(), |
| 120 JSDataView::kByteLengthOffset, object_offset) || | 129 JSDataView::kByteLengthOffset, object_offset) || |
| 121 CheckForName(name, isolate->heap()->byte_offset_string(), | 130 CheckForName(name, isolate->heap()->byte_offset_string(), |
| 122 JSDataView::kByteOffsetOffset, object_offset) || | 131 JSDataView::kByteOffsetOffset, object_offset) || |
| 123 CheckForName(name, isolate->heap()->buffer_string(), | 132 CheckForName(name, isolate->heap()->buffer_string(), |
| 124 JSDataView::kBufferOffset, object_offset); | 133 JSDataView::kBufferOffset, object_offset); |
| 125 default: { | 134 default: |
| 126 if (map->instance_type() < FIRST_NONSTRING_TYPE) { | |
| 127 return | |
| 128 CheckForName(name, isolate->heap()->length_string(), | |
| 129 String::kLengthOffset, object_offset); | |
| 130 } | |
| 131 return false; | 135 return false; |
| 132 } | |
| 133 } | 136 } |
| 134 } | 137 } |
| 135 | 138 |
| 136 | 139 |
| 137 // | 140 // |
| 138 // Accessors::ArrayLength | 141 // Accessors::ArrayLength |
| 139 // | 142 // |
| 140 | 143 |
| 141 | 144 |
| 142 MaybeObject* Accessors::ArrayGetLength(Isolate* isolate, | 145 MaybeObject* Accessors::ArrayGetLength(Isolate* isolate, |
| (...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 970 info->set_data(Smi::FromInt(index)); | 973 info->set_data(Smi::FromInt(index)); |
| 971 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport); | 974 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport); |
| 972 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport); | 975 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport); |
| 973 info->set_getter(*getter); | 976 info->set_getter(*getter); |
| 974 if (!(attributes & ReadOnly)) info->set_setter(*setter); | 977 if (!(attributes & ReadOnly)) info->set_setter(*setter); |
| 975 return info; | 978 return info; |
| 976 } | 979 } |
| 977 | 980 |
| 978 | 981 |
| 979 } } // namespace v8::internal | 982 } } // namespace v8::internal |
| OLD | NEW |