| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/accessors.h" | 5 #include "src/accessors.h" |
| 6 | 6 |
| 7 #include "src/api.h" | 7 #include "src/api.h" |
| 8 #include "src/contexts.h" | 8 #include "src/contexts.h" |
| 9 #include "src/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
| 10 #include "src/execution.h" | 10 #include "src/execution.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 } | 92 } |
| 93 } | 93 } |
| 94 | 94 |
| 95 | 95 |
| 96 bool Accessors::IsJSArrayBufferViewFieldAccessor(Handle<Map> map, | 96 bool Accessors::IsJSArrayBufferViewFieldAccessor(Handle<Map> map, |
| 97 Handle<Name> name, | 97 Handle<Name> name, |
| 98 int* object_offset) { | 98 int* object_offset) { |
| 99 Isolate* isolate = name->GetIsolate(); | 99 Isolate* isolate = name->GetIsolate(); |
| 100 | 100 |
| 101 switch (map->instance_type()) { | 101 switch (map->instance_type()) { |
| 102 case JS_TYPED_ARRAY_TYPE: | 102 case JS_TYPED_ARRAY_TYPE: { |
| 103 // %TypedArray%.prototype is non-configurable, and so are the following | 103 if (!CheckForName(name, isolate->factory()->length_string(), |
| 104 // named properties on %TypedArray%.prototype, so we can directly inline | 104 JSTypedArray::kLengthOffset, object_offset) && |
| 105 // the field-load for typed array maps that still use their | 105 !CheckForName(name, isolate->factory()->byte_length_string(), |
| 106 // %TypedArray%.prototype. | 106 JSTypedArray::kByteLengthOffset, object_offset) && |
| 107 if (JSFunction::cast(map->GetConstructor())->prototype() != | 107 !CheckForName(name, isolate->factory()->byte_offset_string(), |
| 108 map->prototype()) { | 108 JSTypedArray::kByteOffsetOffset, object_offset)) { |
| 109 return false; | 109 return false; |
| 110 } | 110 } |
| 111 return CheckForName(name, isolate->factory()->length_string(), | |
| 112 JSTypedArray::kLengthOffset, object_offset) || | |
| 113 CheckForName(name, isolate->factory()->byte_length_string(), | |
| 114 JSTypedArray::kByteLengthOffset, object_offset) || | |
| 115 CheckForName(name, isolate->factory()->byte_offset_string(), | |
| 116 JSTypedArray::kByteOffsetOffset, object_offset); | |
| 117 | 111 |
| 112 if (map->is_dictionary_map()) return false; |
| 113 |
| 114 // Check if the property is overridden on the instance. |
| 115 DescriptorArray* descriptors = map->instance_descriptors(); |
| 116 int descriptor = descriptors->SearchWithCache(*name, *map); |
| 117 if (descriptor != DescriptorArray::kNotFound) return false; |
| 118 |
| 119 Handle<Object> proto = Handle<Object>(map->prototype(), isolate); |
| 120 if (!proto->IsJSReceiver()) return false; |
| 121 |
| 122 // Check if the property is defined in the prototype chain. |
| 123 LookupIterator it(proto, name); |
| 124 if (!it.IsFound()) return false; |
| 125 |
| 126 Object* original_proto = |
| 127 JSFunction::cast(map->GetConstructor())->prototype(); |
| 128 |
| 129 // Property is not configurable. It is enough to verify that |
| 130 // the holder is the same. |
| 131 return *it.GetHolder<Object>() == original_proto; |
| 132 } |
| 118 case JS_DATA_VIEW_TYPE: | 133 case JS_DATA_VIEW_TYPE: |
| 119 return CheckForName(name, isolate->factory()->byte_length_string(), | 134 return CheckForName(name, isolate->factory()->byte_length_string(), |
| 120 JSDataView::kByteLengthOffset, object_offset) || | 135 JSDataView::kByteLengthOffset, object_offset) || |
| 121 CheckForName(name, isolate->factory()->byte_offset_string(), | 136 CheckForName(name, isolate->factory()->byte_offset_string(), |
| 122 JSDataView::kByteOffsetOffset, object_offset); | 137 JSDataView::kByteOffsetOffset, object_offset); |
| 123 default: | 138 default: |
| 124 return false; | 139 return false; |
| 125 } | 140 } |
| 126 } | 141 } |
| 127 | 142 |
| (...skipping 1361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1489 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport); | 1504 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport); |
| 1490 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport); | 1505 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport); |
| 1491 info->set_getter(*getter); | 1506 info->set_getter(*getter); |
| 1492 if (!(attributes & ReadOnly)) info->set_setter(*setter); | 1507 if (!(attributes & ReadOnly)) info->set_setter(*setter); |
| 1493 return info; | 1508 return info; |
| 1494 } | 1509 } |
| 1495 | 1510 |
| 1496 | 1511 |
| 1497 } // namespace internal | 1512 } // namespace internal |
| 1498 } // namespace v8 | 1513 } // namespace v8 |
| OLD | NEW |