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 int offset; | |
104 | |
105 if (Name::Equals(name, isolate->factory()->length_string())) { | |
Jakob Kummerow
2015/09/09 11:51:06
Let's keep using the existing CheckForName helper:
fedor.indutny
2015/09/09 21:20:36
Acknowledged.
| |
106 offset = JSTypedArray::kLengthOffset; | |
107 } else if (Name::Equals(name, isolate->factory()->byte_length_string())) { | |
108 offset = JSTypedArray::kByteLengthOffset; | |
109 } else if (Name::Equals(name, isolate->factory()->byte_offset_string())) { | |
110 offset = JSTypedArray::kByteOffsetOffset; | |
111 } else { | |
112 return false; | |
113 } | |
114 | |
115 Object* proto = map->prototype(); | |
116 Object* original_proto = | |
117 JSFunction::cast(map->GetConstructor())->prototype(); | |
118 | |
103 // %TypedArray%.prototype is non-configurable, and so are the following | 119 // %TypedArray%.prototype is non-configurable, and so are the following |
Jakob Kummerow
2015/09/09 11:51:06
outdated comment (there are no "following named pr
fedor.indutny
2015/09/09 21:20:36
Acknowledged.
| |
104 // named properties on %TypedArray%.prototype, so we can directly inline | 120 // named properties on %TypedArray%.prototype, so we can directly inline |
105 // the field-load for typed array maps that still use their | 121 // the field-load for typed array maps that still use their |
106 // %TypedArray%.prototype. | 122 // %TypedArray%.prototype. |
107 if (JSFunction::cast(map->GetConstructor())->prototype() != | 123 if (original_proto == proto) { |
108 map->prototype()) { | 124 *object_offset = offset; |
125 return true; | |
126 } | |
127 | |
128 if (!proto->IsJSObject()) return false; | |
129 | |
130 JSObject* js_proto = JSObject::cast(proto); | |
131 | |
132 // Check if the typed array is a second order child of the original | |
133 // constructor | |
Jakob Kummerow
2015/09/09 11:51:07
nit: trailing full stop
fedor.indutny
2015/09/09 21:20:36
Remove the comment.
| |
134 if (js_proto->map()->prototype() != original_proto) return false; | |
135 | |
136 // If the middle-prototype does not override the fast property - | |
Jakob Kummerow
2015/09/09 11:51:06
s/ -/, then/
s/it's/its/
s/offset/offset./
fedor.indutny
2015/09/09 21:20:35
Removed the comment, added the dot.
| |
137 // return it's offset | |
138 Maybe<PropertyAttributes> maybe_attr = | |
139 JSReceiver::GetOwnPropertyAttributes(Handle<JSObject>(js_proto), | |
Jakob Kummerow
2015/09/09 11:51:06
This should use JSReceiver::HasOwnProperty(), but
fedor.indutny
2015/09/09 21:20:35
I did it in a slightly different way... Hope it is
| |
140 name); | |
141 if (maybe_attr.IsJust() && maybe_attr.FromJust() != ABSENT) { | |
109 return false; | 142 return false; |
110 } | 143 } |
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 | 144 |
145 *object_offset = offset; | |
146 return true; | |
147 } | |
118 case JS_DATA_VIEW_TYPE: | 148 case JS_DATA_VIEW_TYPE: |
119 return CheckForName(name, isolate->factory()->byte_length_string(), | 149 return CheckForName(name, isolate->factory()->byte_length_string(), |
120 JSDataView::kByteLengthOffset, object_offset) || | 150 JSDataView::kByteLengthOffset, object_offset) || |
121 CheckForName(name, isolate->factory()->byte_offset_string(), | 151 CheckForName(name, isolate->factory()->byte_offset_string(), |
122 JSDataView::kByteOffsetOffset, object_offset); | 152 JSDataView::kByteOffsetOffset, object_offset); |
123 default: | 153 default: |
124 return false; | 154 return false; |
125 } | 155 } |
126 } | 156 } |
127 | 157 |
(...skipping 1361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1489 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport); | 1519 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport); |
1490 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport); | 1520 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport); |
1491 info->set_getter(*getter); | 1521 info->set_getter(*getter); |
1492 if (!(attributes & ReadOnly)) info->set_setter(*setter); | 1522 if (!(attributes & ReadOnly)) info->set_setter(*setter); |
1493 return info; | 1523 return info; |
1494 } | 1524 } |
1495 | 1525 |
1496 | 1526 |
1497 } // namespace internal | 1527 } // namespace internal |
1498 } // namespace v8 | 1528 } // namespace v8 |
OLD | NEW |