| 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/api.h" | 5 #include "src/api.h" |
| 6 | 6 |
| 7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
| 8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
| 9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
| 10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
| (...skipping 3729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3740 auto isolate = Utils::OpenHandle(this)->GetIsolate(); | 3740 auto isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 3741 i::PrototypeIterator iter(isolate, *Utils::OpenHandle(this), | 3741 i::PrototypeIterator iter(isolate, *Utils::OpenHandle(this), |
| 3742 i::PrototypeIterator::START_AT_RECEIVER); | 3742 i::PrototypeIterator::START_AT_RECEIVER); |
| 3743 auto tmpl_info = *Utils::OpenHandle(*tmpl); | 3743 auto tmpl_info = *Utils::OpenHandle(*tmpl); |
| 3744 while (!tmpl_info->IsTemplateFor(iter.GetCurrent())) { | 3744 while (!tmpl_info->IsTemplateFor(iter.GetCurrent())) { |
| 3745 iter.Advance(); | 3745 iter.Advance(); |
| 3746 if (iter.IsAtEnd()) { | 3746 if (iter.IsAtEnd()) { |
| 3747 return Local<Object>(); | 3747 return Local<Object>(); |
| 3748 } | 3748 } |
| 3749 } | 3749 } |
| 3750 // IsTemplateFor() ensures that iter.GetCurrent() can't be a Proxy here. |
| 3750 return Utils::ToLocal(i::handle(iter.GetCurrent<i::JSObject>(), isolate)); | 3751 return Utils::ToLocal(i::handle(iter.GetCurrent<i::JSObject>(), isolate)); |
| 3751 } | 3752 } |
| 3752 | 3753 |
| 3753 | 3754 |
| 3754 MaybeLocal<Array> v8::Object::GetPropertyNames(Local<Context> context) { | 3755 MaybeLocal<Array> v8::Object::GetPropertyNames(Local<Context> context) { |
| 3755 PREPARE_FOR_EXECUTION(context, "v8::Object::GetPropertyNames()", Array); | 3756 PREPARE_FOR_EXECUTION(context, "v8::Object::GetPropertyNames()", Array); |
| 3756 auto self = Utils::OpenHandle(this); | 3757 auto self = Utils::OpenHandle(this); |
| 3757 i::Handle<i::FixedArray> value; | 3758 i::Handle<i::FixedArray> value; |
| 3758 has_pending_exception = !i::JSReceiver::GetKeys( | 3759 has_pending_exception = !i::JSReceiver::GetKeys( |
| 3759 self, i::JSReceiver::INCLUDE_PROTOS).ToHandle(&value); | 3760 self, i::JSReceiver::INCLUDE_PROTOS).ToHandle(&value); |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4118 bool v8::Object::HasIndexedLookupInterceptor() { | 4119 bool v8::Object::HasIndexedLookupInterceptor() { |
| 4119 auto self = Utils::OpenHandle(this); | 4120 auto self = Utils::OpenHandle(this); |
| 4120 return self->HasIndexedInterceptor(); | 4121 return self->HasIndexedInterceptor(); |
| 4121 } | 4122 } |
| 4122 | 4123 |
| 4123 | 4124 |
| 4124 MaybeLocal<Value> v8::Object::GetRealNamedPropertyInPrototypeChain( | 4125 MaybeLocal<Value> v8::Object::GetRealNamedPropertyInPrototypeChain( |
| 4125 Local<Context> context, Local<Name> key) { | 4126 Local<Context> context, Local<Name> key) { |
| 4126 PREPARE_FOR_EXECUTION( | 4127 PREPARE_FOR_EXECUTION( |
| 4127 context, "v8::Object::GetRealNamedPropertyInPrototypeChain()", Value); | 4128 context, "v8::Object::GetRealNamedPropertyInPrototypeChain()", Value); |
| 4128 auto self = Utils::OpenHandle(this); | 4129 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
| 4129 auto key_obj = Utils::OpenHandle(*key); | 4130 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); |
| 4130 i::PrototypeIterator iter(isolate, self); | 4131 i::PrototypeIterator iter(isolate, self); |
| 4131 if (iter.IsAtEnd()) return MaybeLocal<Value>(); | 4132 if (iter.IsAtEnd()) return MaybeLocal<Value>(); |
| 4132 auto proto = i::PrototypeIterator::GetCurrent(iter); | 4133 i::Handle<i::JSReceiver> proto = |
| 4134 i::PrototypeIterator::GetCurrent<i::JSReceiver>(iter); |
| 4133 i::LookupIterator it = i::LookupIterator::PropertyOrElement( | 4135 i::LookupIterator it = i::LookupIterator::PropertyOrElement( |
| 4134 isolate, self, key_obj, i::Handle<i::JSReceiver>::cast(proto), | 4136 isolate, self, key_obj, proto, |
| 4135 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); | 4137 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); |
| 4136 Local<Value> result; | 4138 Local<Value> result; |
| 4137 has_pending_exception = !ToLocal<Value>(i::Object::GetProperty(&it), &result); | 4139 has_pending_exception = !ToLocal<Value>(i::Object::GetProperty(&it), &result); |
| 4138 RETURN_ON_FAILED_EXECUTION(Value); | 4140 RETURN_ON_FAILED_EXECUTION(Value); |
| 4139 if (!it.IsFound()) return MaybeLocal<Value>(); | 4141 if (!it.IsFound()) return MaybeLocal<Value>(); |
| 4140 RETURN_ESCAPED(result); | 4142 RETURN_ESCAPED(result); |
| 4141 } | 4143 } |
| 4142 | 4144 |
| 4143 | 4145 |
| 4144 Local<Value> v8::Object::GetRealNamedPropertyInPrototypeChain( | 4146 Local<Value> v8::Object::GetRealNamedPropertyInPrototypeChain( |
| 4145 Local<String> key) { | 4147 Local<String> key) { |
| 4146 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4148 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 4147 RETURN_TO_LOCAL_UNCHECKED(GetRealNamedPropertyInPrototypeChain(context, key), | 4149 RETURN_TO_LOCAL_UNCHECKED(GetRealNamedPropertyInPrototypeChain(context, key), |
| 4148 Value); | 4150 Value); |
| 4149 } | 4151 } |
| 4150 | 4152 |
| 4151 | 4153 |
| 4152 Maybe<PropertyAttribute> | 4154 Maybe<PropertyAttribute> |
| 4153 v8::Object::GetRealNamedPropertyAttributesInPrototypeChain( | 4155 v8::Object::GetRealNamedPropertyAttributesInPrototypeChain( |
| 4154 Local<Context> context, Local<Name> key) { | 4156 Local<Context> context, Local<Name> key) { |
| 4155 PREPARE_FOR_EXECUTION_PRIMITIVE( | 4157 PREPARE_FOR_EXECUTION_PRIMITIVE( |
| 4156 context, "v8::Object::GetRealNamedPropertyAttributesInPrototypeChain()", | 4158 context, "v8::Object::GetRealNamedPropertyAttributesInPrototypeChain()", |
| 4157 PropertyAttribute); | 4159 PropertyAttribute); |
| 4158 auto self = Utils::OpenHandle(this); | 4160 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
| 4159 auto key_obj = Utils::OpenHandle(*key); | 4161 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); |
| 4160 i::PrototypeIterator iter(isolate, self); | 4162 i::PrototypeIterator iter(isolate, self); |
| 4161 if (iter.IsAtEnd()) return Nothing<PropertyAttribute>(); | 4163 if (iter.IsAtEnd()) return Nothing<PropertyAttribute>(); |
| 4162 auto proto = i::PrototypeIterator::GetCurrent(iter); | 4164 i::Handle<i::JSReceiver> proto = |
| 4165 i::PrototypeIterator::GetCurrent<i::JSReceiver>(iter); |
| 4163 i::LookupIterator it = i::LookupIterator::PropertyOrElement( | 4166 i::LookupIterator it = i::LookupIterator::PropertyOrElement( |
| 4164 isolate, self, key_obj, i::Handle<i::JSReceiver>::cast(proto), | 4167 isolate, self, key_obj, proto, |
| 4165 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); | 4168 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); |
| 4166 auto result = i::JSReceiver::GetPropertyAttributes(&it); | 4169 Maybe<PropertyAttributes> result = i::JSReceiver::GetPropertyAttributes(&it); |
| 4167 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute); | 4170 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute); |
| 4168 if (!it.IsFound()) return Nothing<PropertyAttribute>(); | 4171 if (!it.IsFound()) return Nothing<PropertyAttribute>(); |
| 4169 if (result.FromJust() == ABSENT) { | 4172 if (result.FromJust() == ABSENT) return Just(None); |
| 4170 return Just(static_cast<PropertyAttribute>(NONE)); | 4173 return Just(static_cast<PropertyAttribute>(result.FromJust())); |
| 4171 } | |
| 4172 return Just<PropertyAttribute>( | |
| 4173 static_cast<PropertyAttribute>(result.FromJust())); | |
| 4174 } | 4174 } |
| 4175 | 4175 |
| 4176 | 4176 |
| 4177 Maybe<PropertyAttribute> | 4177 Maybe<PropertyAttribute> |
| 4178 v8::Object::GetRealNamedPropertyAttributesInPrototypeChain(Local<String> key) { | 4178 v8::Object::GetRealNamedPropertyAttributesInPrototypeChain(Local<String> key) { |
| 4179 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4179 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 4180 return GetRealNamedPropertyAttributesInPrototypeChain(context, key); | 4180 return GetRealNamedPropertyAttributesInPrototypeChain(context, key); |
| 4181 } | 4181 } |
| 4182 | 4182 |
| 4183 | 4183 |
| (...skipping 4332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8516 Address callback_address = | 8516 Address callback_address = |
| 8517 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8517 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 8518 VMState<EXTERNAL> state(isolate); | 8518 VMState<EXTERNAL> state(isolate); |
| 8519 ExternalCallbackScope call_scope(isolate, callback_address); | 8519 ExternalCallbackScope call_scope(isolate, callback_address); |
| 8520 callback(info); | 8520 callback(info); |
| 8521 } | 8521 } |
| 8522 | 8522 |
| 8523 | 8523 |
| 8524 } // namespace internal | 8524 } // namespace internal |
| 8525 } // namespace v8 | 8525 } // namespace v8 |
| OLD | NEW |