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 // Check if the property is overridden on the instance. | |
113 DescriptorArray* descriptors = map->instance_descriptors(); | |
Jakob Kummerow
2015/09/10 11:33:56
Before this is safe, you need to bail out for dict
fedor.indutny
2015/09/10 11:56:28
I knew I should do this! :) Thanks!
| |
114 int descriptor = descriptors->SearchWithCache(*name, *map); | |
115 if (descriptor != DescriptorArray::kNotFound) return false; | |
116 | |
117 Handle<Object> proto = Handle<Object>(map->prototype(), isolate); | |
118 if (!proto->IsJSReceiver()) return false; | |
119 | |
120 // Check if the property is overridden in the prototype chain. | |
Jakob Kummerow
2015/09/10 11:33:56
s/overridden/defined/
fedor.indutny
2015/09/10 11:56:28
Acknowledged.
| |
121 LookupIterator it(proto, name); | |
122 if (it.state() == LookupIterator::NOT_FOUND) return false; | |
Jakob Kummerow
2015/09/10 11:33:56
if (!it.IsFound()) return false;
fedor.indutny
2015/09/10 11:56:28
Acknowledged.
| |
123 | |
124 Object* original_proto = | |
125 JSFunction::cast(map->GetConstructor())->prototype(); | |
126 | |
127 // Property is not configurable. It is enough to verify that | |
128 // the holder is the same. | |
129 return *it.GetHolder<Object>() == original_proto; | |
130 } | |
118 case JS_DATA_VIEW_TYPE: | 131 case JS_DATA_VIEW_TYPE: |
119 return CheckForName(name, isolate->factory()->byte_length_string(), | 132 return CheckForName(name, isolate->factory()->byte_length_string(), |
120 JSDataView::kByteLengthOffset, object_offset) || | 133 JSDataView::kByteLengthOffset, object_offset) || |
121 CheckForName(name, isolate->factory()->byte_offset_string(), | 134 CheckForName(name, isolate->factory()->byte_offset_string(), |
122 JSDataView::kByteOffsetOffset, object_offset); | 135 JSDataView::kByteOffsetOffset, object_offset); |
123 default: | 136 default: |
124 return false; | 137 return false; |
125 } | 138 } |
126 } | 139 } |
127 | 140 |
(...skipping 1361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1489 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport); | 1502 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport); |
1490 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport); | 1503 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport); |
1491 info->set_getter(*getter); | 1504 info->set_getter(*getter); |
1492 if (!(attributes & ReadOnly)) info->set_setter(*setter); | 1505 if (!(attributes & ReadOnly)) info->set_setter(*setter); |
1493 return info; | 1506 return info; |
1494 } | 1507 } |
1495 | 1508 |
1496 | 1509 |
1497 } // namespace internal | 1510 } // namespace internal |
1498 } // namespace v8 | 1511 } // namespace v8 |
OLD | NEW |