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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/contexts.h" | 9 #include "src/contexts.h" |
10 #include "src/deoptimizer.h" | 10 #include "src/deoptimizer.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 // If true, *object_offset contains offset of object field. | 71 // If true, *object_offset contains offset of object field. |
72 bool Accessors::IsJSObjectFieldAccessor(Handle<Map> map, Handle<Name> name, | 72 bool Accessors::IsJSObjectFieldAccessor(Handle<Map> map, Handle<Name> name, |
73 int* object_offset) { | 73 int* object_offset) { |
74 Isolate* isolate = name->GetIsolate(); | 74 Isolate* isolate = name->GetIsolate(); |
75 | 75 |
76 switch (map->instance_type()) { | 76 switch (map->instance_type()) { |
77 case JS_ARRAY_TYPE: | 77 case JS_ARRAY_TYPE: |
78 return | 78 return |
79 CheckForName(name, isolate->factory()->length_string(), | 79 CheckForName(name, isolate->factory()->length_string(), |
80 JSArray::kLengthOffset, object_offset); | 80 JSArray::kLengthOffset, object_offset); |
81 case JS_ARRAY_BUFFER_TYPE: | |
82 return CheckForName(name, isolate->factory()->byte_length_string(), | |
83 JSArrayBuffer::kByteLengthOffset, object_offset); | |
84 default: | |
85 if (map->instance_type() < FIRST_NONSTRING_TYPE) { | |
86 return CheckForName(name, isolate->factory()->length_string(), | |
87 String::kLengthOffset, object_offset); | |
88 } | |
89 | |
90 return false; | |
91 } | |
92 } | |
93 | |
94 | |
95 bool Accessors::IsJSArrayBufferViewFieldAccessor(Handle<Map> map, | |
96 Handle<Name> name, | |
97 int* object_offset) { | |
98 Isolate* isolate = name->GetIsolate(); | |
99 | |
100 switch (map->instance_type()) { | |
101 case JS_TYPED_ARRAY_TYPE: | 81 case JS_TYPED_ARRAY_TYPE: |
102 // %TypedArray%.prototype is non-configurable, and so are the following | 82 // %TypedArray%.prototype is non-configurable, and so are the following |
103 // named properties on %TypedArray%.prototype, so we can directly inline | 83 // named properties on %TypedArray%.prototype, so we can directly inline |
104 // the field-load for typed array maps that still use their | 84 // the field-load for typed array maps that still use their |
105 // %TypedArray%.prototype. | 85 // %TypedArray%.prototype. |
106 if (JSFunction::cast(map->GetConstructor())->prototype() != | 86 if (JSFunction::cast(map->GetConstructor())->prototype() != |
107 map->prototype()) { | 87 map->prototype()) { |
108 return false; | 88 return false; |
109 } | 89 } |
110 return CheckForName(name, isolate->factory()->length_string(), | 90 return |
111 JSTypedArray::kLengthOffset, object_offset) || | 91 CheckForName(name, isolate->factory()->length_string(), |
112 CheckForName(name, isolate->factory()->byte_length_string(), | 92 JSTypedArray::kLengthOffset, object_offset) || |
113 JSTypedArray::kByteLengthOffset, object_offset) || | 93 CheckForName(name, isolate->factory()->byte_length_string(), |
114 CheckForName(name, isolate->factory()->byte_offset_string(), | 94 JSTypedArray::kByteLengthOffset, object_offset) || |
115 JSTypedArray::kByteOffsetOffset, object_offset); | 95 CheckForName(name, isolate->factory()->byte_offset_string(), |
| 96 JSTypedArray::kByteOffsetOffset, object_offset); |
| 97 case JS_ARRAY_BUFFER_TYPE: |
| 98 return |
| 99 CheckForName(name, isolate->factory()->byte_length_string(), |
| 100 JSArrayBuffer::kByteLengthOffset, object_offset); |
| 101 case JS_DATA_VIEW_TYPE: |
| 102 return |
| 103 CheckForName(name, isolate->factory()->byte_length_string(), |
| 104 JSDataView::kByteLengthOffset, object_offset) || |
| 105 CheckForName(name, isolate->factory()->byte_offset_string(), |
| 106 JSDataView::kByteOffsetOffset, object_offset); |
| 107 default: |
| 108 if (map->instance_type() < FIRST_NONSTRING_TYPE) { |
| 109 return CheckForName(name, isolate->factory()->length_string(), |
| 110 String::kLengthOffset, object_offset); |
| 111 } |
116 | 112 |
117 case JS_DATA_VIEW_TYPE: | |
118 return CheckForName(name, isolate->factory()->byte_length_string(), | |
119 JSDataView::kByteLengthOffset, object_offset) || | |
120 CheckForName(name, isolate->factory()->byte_offset_string(), | |
121 JSDataView::kByteOffsetOffset, object_offset); | |
122 default: | |
123 return false; | 113 return false; |
124 } | 114 } |
125 } | 115 } |
126 | 116 |
127 | 117 |
128 bool SetPropertyOnInstanceIfInherited( | 118 bool SetPropertyOnInstanceIfInherited( |
129 Isolate* isolate, const v8::PropertyCallbackInfo<void>& info, | 119 Isolate* isolate, const v8::PropertyCallbackInfo<void>& info, |
130 v8::Local<v8::Name> name, Handle<Object> value) { | 120 v8::Local<v8::Name> name, Handle<Object> value) { |
131 Handle<Object> holder = Utils::OpenHandle(*info.Holder()); | 121 Handle<Object> holder = Utils::OpenHandle(*info.Holder()); |
132 Handle<Object> receiver = Utils::OpenHandle(*info.This()); | 122 Handle<Object> receiver = Utils::OpenHandle(*info.This()); |
(...skipping 1353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1486 info->set_data(Smi::FromInt(index)); | 1476 info->set_data(Smi::FromInt(index)); |
1487 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport); | 1477 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport); |
1488 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport); | 1478 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport); |
1489 info->set_getter(*getter); | 1479 info->set_getter(*getter); |
1490 if (!(attributes & ReadOnly)) info->set_setter(*setter); | 1480 if (!(attributes & ReadOnly)) info->set_setter(*setter); |
1491 return info; | 1481 return info; |
1492 } | 1482 } |
1493 | 1483 |
1494 | 1484 |
1495 } } // namespace v8::internal | 1485 } } // namespace v8::internal |
OLD | NEW |