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