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 1925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1936 v8::Local<Value> v8::TryCatch::StackTrace() const { | 1936 v8::Local<Value> v8::TryCatch::StackTrace() const { |
1937 if (HasCaught()) { | 1937 if (HasCaught()) { |
1938 i::Object* raw_obj = reinterpret_cast<i::Object*>(exception_); | 1938 i::Object* raw_obj = reinterpret_cast<i::Object*>(exception_); |
1939 if (!raw_obj->IsJSObject()) return v8::Local<Value>(); | 1939 if (!raw_obj->IsJSObject()) return v8::Local<Value>(); |
1940 i::HandleScope scope(isolate_); | 1940 i::HandleScope scope(isolate_); |
1941 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_obj), isolate_); | 1941 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_obj), isolate_); |
1942 i::Handle<i::String> name = isolate_->factory()->stack_string(); | 1942 i::Handle<i::String> name = isolate_->factory()->stack_string(); |
1943 { | 1943 { |
1944 EXCEPTION_PREAMBLE(isolate_); | 1944 EXCEPTION_PREAMBLE(isolate_); |
1945 Maybe<bool> maybe = i::JSReceiver::HasProperty(obj, name); | 1945 Maybe<bool> maybe = i::JSReceiver::HasProperty(obj, name); |
1946 has_pending_exception = !maybe.has_value; | 1946 has_pending_exception = !maybe.IsJust(); |
1947 EXCEPTION_BAILOUT_CHECK(isolate_, v8::Local<Value>()); | 1947 EXCEPTION_BAILOUT_CHECK(isolate_, v8::Local<Value>()); |
1948 if (!maybe.value) return v8::Local<Value>(); | 1948 if (!maybe.FromJust()) return v8::Local<Value>(); |
1949 } | 1949 } |
1950 i::Handle<i::Object> value; | 1950 i::Handle<i::Object> value; |
1951 EXCEPTION_PREAMBLE(isolate_); | 1951 EXCEPTION_PREAMBLE(isolate_); |
1952 has_pending_exception = !i::Object::GetProperty(obj, name).ToHandle(&value); | 1952 has_pending_exception = !i::Object::GetProperty(obj, name).ToHandle(&value); |
1953 EXCEPTION_BAILOUT_CHECK(isolate_, v8::Local<Value>()); | 1953 EXCEPTION_BAILOUT_CHECK(isolate_, v8::Local<Value>()); |
1954 return v8::Utils::ToLocal(scope.CloseAndEscape(value)); | 1954 return v8::Utils::ToLocal(scope.CloseAndEscape(value)); |
1955 } else { | 1955 } else { |
1956 return v8::Local<Value>(); | 1956 return v8::Local<Value>(); |
1957 } | 1957 } |
1958 } | 1958 } |
(...skipping 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3351 if (!key_obj->IsName()) { | 3351 if (!key_obj->IsName()) { |
3352 EXCEPTION_PREAMBLE(isolate); | 3352 EXCEPTION_PREAMBLE(isolate); |
3353 has_pending_exception = !i::Execution::ToString( | 3353 has_pending_exception = !i::Execution::ToString( |
3354 isolate, key_obj).ToHandle(&key_obj); | 3354 isolate, key_obj).ToHandle(&key_obj); |
3355 EXCEPTION_BAILOUT_CHECK(isolate, static_cast<PropertyAttribute>(NONE)); | 3355 EXCEPTION_BAILOUT_CHECK(isolate, static_cast<PropertyAttribute>(NONE)); |
3356 } | 3356 } |
3357 i::Handle<i::Name> key_name = i::Handle<i::Name>::cast(key_obj); | 3357 i::Handle<i::Name> key_name = i::Handle<i::Name>::cast(key_obj); |
3358 EXCEPTION_PREAMBLE(isolate); | 3358 EXCEPTION_PREAMBLE(isolate); |
3359 Maybe<PropertyAttributes> result = | 3359 Maybe<PropertyAttributes> result = |
3360 i::JSReceiver::GetPropertyAttributes(self, key_name); | 3360 i::JSReceiver::GetPropertyAttributes(self, key_name); |
3361 has_pending_exception = !result.has_value; | 3361 has_pending_exception = !result.IsJust(); |
3362 EXCEPTION_BAILOUT_CHECK(isolate, static_cast<PropertyAttribute>(NONE)); | 3362 EXCEPTION_BAILOUT_CHECK(isolate, static_cast<PropertyAttribute>(NONE)); |
3363 if (result.value == ABSENT) return static_cast<PropertyAttribute>(NONE); | 3363 if (result.FromJust() == ABSENT) return static_cast<PropertyAttribute>(NONE); |
3364 return static_cast<PropertyAttribute>(result.value); | 3364 return static_cast<PropertyAttribute>(result.FromJust()); |
3365 } | 3365 } |
3366 | 3366 |
3367 | 3367 |
3368 Local<Value> v8::Object::GetOwnPropertyDescriptor(Local<String> key) { | 3368 Local<Value> v8::Object::GetOwnPropertyDescriptor(Local<String> key) { |
3369 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3369 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
3370 ON_BAILOUT(isolate, "v8::Object::GetOwnPropertyDescriptor()", | 3370 ON_BAILOUT(isolate, "v8::Object::GetOwnPropertyDescriptor()", |
3371 return Local<Value>()); | 3371 return Local<Value>()); |
3372 ENTER_V8(isolate); | 3372 ENTER_V8(isolate); |
3373 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); | 3373 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); |
3374 i::Handle<i::Name> key_name = Utils::OpenHandle(*key); | 3374 i::Handle<i::Name> key_name = Utils::OpenHandle(*key); |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3590 uint32_t index; | 3590 uint32_t index; |
3591 if (key_obj->ToArrayIndex(&index)) { | 3591 if (key_obj->ToArrayIndex(&index)) { |
3592 maybe = i::JSReceiver::HasElement(self, index); | 3592 maybe = i::JSReceiver::HasElement(self, index); |
3593 } else { | 3593 } else { |
3594 // Convert the key to a name - possibly by calling back into JavaScript. | 3594 // Convert the key to a name - possibly by calling back into JavaScript. |
3595 i::Handle<i::Name> name; | 3595 i::Handle<i::Name> name; |
3596 if (i::Runtime::ToName(isolate, key_obj).ToHandle(&name)) { | 3596 if (i::Runtime::ToName(isolate, key_obj).ToHandle(&name)) { |
3597 maybe = i::JSReceiver::HasProperty(self, name); | 3597 maybe = i::JSReceiver::HasProperty(self, name); |
3598 } | 3598 } |
3599 } | 3599 } |
3600 if (!maybe.has_value) has_pending_exception = true; | 3600 if (!maybe.IsJust()) has_pending_exception = true; |
3601 EXCEPTION_BAILOUT_CHECK(isolate, false); | 3601 EXCEPTION_BAILOUT_CHECK(isolate, false); |
3602 DCHECK(maybe.has_value); | 3602 DCHECK(maybe.IsJust()); |
3603 return maybe.value; | 3603 return maybe.FromJust(); |
3604 } | 3604 } |
3605 | 3605 |
3606 | 3606 |
3607 bool v8::Object::HasPrivate(v8::Handle<Private> key) { | 3607 bool v8::Object::HasPrivate(v8::Handle<Private> key) { |
3608 // TODO(rossberg): this should use HasOwnProperty, but we'd need to | 3608 // TODO(rossberg): this should use HasOwnProperty, but we'd need to |
3609 // generalise that to a (noy yet existant) Name argument first. | 3609 // generalise that to a (noy yet existant) Name argument first. |
3610 return Has(v8::Handle<Value>(reinterpret_cast<Value*>(*key))); | 3610 return Has(v8::Handle<Value>(reinterpret_cast<Value*>(*key))); |
3611 } | 3611 } |
3612 | 3612 |
3613 | 3613 |
(...skipping 13 matching lines...) Expand all Loading... |
3627 return obj->IsTrue(); | 3627 return obj->IsTrue(); |
3628 } | 3628 } |
3629 | 3629 |
3630 | 3630 |
3631 bool v8::Object::Has(uint32_t index) { | 3631 bool v8::Object::Has(uint32_t index) { |
3632 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3632 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
3633 ON_BAILOUT(isolate, "v8::Object::HasProperty()", return false); | 3633 ON_BAILOUT(isolate, "v8::Object::HasProperty()", return false); |
3634 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 3634 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
3635 EXCEPTION_PREAMBLE(isolate); | 3635 EXCEPTION_PREAMBLE(isolate); |
3636 Maybe<bool> maybe = i::JSReceiver::HasElement(self, index); | 3636 Maybe<bool> maybe = i::JSReceiver::HasElement(self, index); |
3637 has_pending_exception = !maybe.has_value; | 3637 has_pending_exception = !maybe.IsJust(); |
3638 EXCEPTION_BAILOUT_CHECK(isolate, false); | 3638 EXCEPTION_BAILOUT_CHECK(isolate, false); |
3639 return maybe.value; | 3639 return maybe.FromJust(); |
3640 } | 3640 } |
3641 | 3641 |
3642 | 3642 |
3643 template<typename Getter, typename Setter, typename Data> | 3643 template<typename Getter, typename Setter, typename Data> |
3644 static inline bool ObjectSetAccessor(Object* obj, | 3644 static inline bool ObjectSetAccessor(Object* obj, |
3645 Handle<Name> name, | 3645 Handle<Name> name, |
3646 Getter getter, | 3646 Getter getter, |
3647 Setter setter, | 3647 Setter setter, |
3648 Data data, | 3648 Data data, |
3649 AccessControl settings, | 3649 AccessControl settings, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3714 } | 3714 } |
3715 | 3715 |
3716 | 3716 |
3717 bool v8::Object::HasOwnProperty(Handle<String> key) { | 3717 bool v8::Object::HasOwnProperty(Handle<String> key) { |
3718 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3718 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
3719 ON_BAILOUT(isolate, "v8::Object::HasOwnProperty()", | 3719 ON_BAILOUT(isolate, "v8::Object::HasOwnProperty()", |
3720 return false); | 3720 return false); |
3721 EXCEPTION_PREAMBLE(isolate); | 3721 EXCEPTION_PREAMBLE(isolate); |
3722 Maybe<bool> maybe = i::JSReceiver::HasOwnProperty(Utils::OpenHandle(this), | 3722 Maybe<bool> maybe = i::JSReceiver::HasOwnProperty(Utils::OpenHandle(this), |
3723 Utils::OpenHandle(*key)); | 3723 Utils::OpenHandle(*key)); |
3724 has_pending_exception = !maybe.has_value; | 3724 has_pending_exception = !maybe.IsJust(); |
3725 EXCEPTION_BAILOUT_CHECK(isolate, false); | 3725 EXCEPTION_BAILOUT_CHECK(isolate, false); |
3726 return maybe.value; | 3726 return maybe.FromJust(); |
3727 } | 3727 } |
3728 | 3728 |
3729 | 3729 |
3730 bool v8::Object::HasRealNamedProperty(Handle<String> key) { | 3730 bool v8::Object::HasRealNamedProperty(Handle<String> key) { |
3731 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3731 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
3732 ON_BAILOUT(isolate, "v8::Object::HasRealNamedProperty()", | 3732 ON_BAILOUT(isolate, "v8::Object::HasRealNamedProperty()", |
3733 return false); | 3733 return false); |
3734 EXCEPTION_PREAMBLE(isolate); | 3734 EXCEPTION_PREAMBLE(isolate); |
3735 Maybe<bool> maybe = i::JSObject::HasRealNamedProperty( | 3735 Maybe<bool> maybe = i::JSObject::HasRealNamedProperty( |
3736 Utils::OpenHandle(this), Utils::OpenHandle(*key)); | 3736 Utils::OpenHandle(this), Utils::OpenHandle(*key)); |
3737 has_pending_exception = !maybe.has_value; | 3737 has_pending_exception = !maybe.IsJust(); |
3738 EXCEPTION_BAILOUT_CHECK(isolate, false); | 3738 EXCEPTION_BAILOUT_CHECK(isolate, false); |
3739 return maybe.value; | 3739 return maybe.FromJust(); |
3740 } | 3740 } |
3741 | 3741 |
3742 | 3742 |
3743 bool v8::Object::HasRealIndexedProperty(uint32_t index) { | 3743 bool v8::Object::HasRealIndexedProperty(uint32_t index) { |
3744 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3744 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
3745 ON_BAILOUT(isolate, "v8::Object::HasRealIndexedProperty()", | 3745 ON_BAILOUT(isolate, "v8::Object::HasRealIndexedProperty()", |
3746 return false); | 3746 return false); |
3747 EXCEPTION_PREAMBLE(isolate); | 3747 EXCEPTION_PREAMBLE(isolate); |
3748 Maybe<bool> maybe = | 3748 Maybe<bool> maybe = |
3749 i::JSObject::HasRealElementProperty(Utils::OpenHandle(this), index); | 3749 i::JSObject::HasRealElementProperty(Utils::OpenHandle(this), index); |
3750 has_pending_exception = !maybe.has_value; | 3750 has_pending_exception = !maybe.IsJust(); |
3751 EXCEPTION_BAILOUT_CHECK(isolate, false); | 3751 EXCEPTION_BAILOUT_CHECK(isolate, false); |
3752 return maybe.value; | 3752 return maybe.FromJust(); |
3753 } | 3753 } |
3754 | 3754 |
3755 | 3755 |
3756 bool v8::Object::HasRealNamedCallbackProperty(Handle<String> key) { | 3756 bool v8::Object::HasRealNamedCallbackProperty(Handle<String> key) { |
3757 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3757 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
3758 ON_BAILOUT(isolate, | 3758 ON_BAILOUT(isolate, |
3759 "v8::Object::HasRealNamedCallbackProperty()", | 3759 "v8::Object::HasRealNamedCallbackProperty()", |
3760 return false); | 3760 return false); |
3761 ENTER_V8(isolate); | 3761 ENTER_V8(isolate); |
3762 EXCEPTION_PREAMBLE(isolate); | 3762 EXCEPTION_PREAMBLE(isolate); |
3763 Maybe<bool> maybe = i::JSObject::HasRealNamedCallbackProperty( | 3763 Maybe<bool> maybe = i::JSObject::HasRealNamedCallbackProperty( |
3764 Utils::OpenHandle(this), Utils::OpenHandle(*key)); | 3764 Utils::OpenHandle(this), Utils::OpenHandle(*key)); |
3765 has_pending_exception = !maybe.has_value; | 3765 has_pending_exception = !maybe.IsJust(); |
3766 EXCEPTION_BAILOUT_CHECK(isolate, false); | 3766 EXCEPTION_BAILOUT_CHECK(isolate, false); |
3767 return maybe.value; | 3767 return maybe.FromJust(); |
3768 } | 3768 } |
3769 | 3769 |
3770 | 3770 |
3771 bool v8::Object::HasNamedLookupInterceptor() { | 3771 bool v8::Object::HasNamedLookupInterceptor() { |
3772 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3772 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
3773 ON_BAILOUT(isolate, "v8::Object::HasNamedLookupInterceptor()", | 3773 ON_BAILOUT(isolate, "v8::Object::HasNamedLookupInterceptor()", |
3774 return false); | 3774 return false); |
3775 return Utils::OpenHandle(this)->HasNamedInterceptor(); | 3775 return Utils::OpenHandle(this)->HasNamedInterceptor(); |
3776 } | 3776 } |
3777 | 3777 |
(...skipping 15 matching lines...) Expand all Loading... |
3793 | 3793 |
3794 if (it->IsFound()) return Utils::ToLocal(result); | 3794 if (it->IsFound()) return Utils::ToLocal(result); |
3795 return Local<Value>(); | 3795 return Local<Value>(); |
3796 } | 3796 } |
3797 | 3797 |
3798 | 3798 |
3799 static Maybe<PropertyAttribute> GetPropertyAttributesByLookup( | 3799 static Maybe<PropertyAttribute> GetPropertyAttributesByLookup( |
3800 i::LookupIterator* it) { | 3800 i::LookupIterator* it) { |
3801 Maybe<PropertyAttributes> attr = i::JSReceiver::GetPropertyAttributes(it); | 3801 Maybe<PropertyAttributes> attr = i::JSReceiver::GetPropertyAttributes(it); |
3802 return it->IsFound() ? Just<PropertyAttribute>( | 3802 return it->IsFound() ? Just<PropertyAttribute>( |
3803 static_cast<PropertyAttribute>(attr.value)) | 3803 static_cast<PropertyAttribute>(attr.FromJust())) |
3804 : Nothing<PropertyAttribute>(); | 3804 : Nothing<PropertyAttribute>(); |
3805 } | 3805 } |
3806 | 3806 |
3807 | 3807 |
3808 Local<Value> v8::Object::GetRealNamedPropertyInPrototypeChain( | 3808 Local<Value> v8::Object::GetRealNamedPropertyInPrototypeChain( |
3809 Handle<String> key) { | 3809 Handle<String> key) { |
3810 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3810 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
3811 ON_BAILOUT(isolate, | 3811 ON_BAILOUT(isolate, |
3812 "v8::Object::GetRealNamedPropertyInPrototypeChain()", | 3812 "v8::Object::GetRealNamedPropertyInPrototypeChain()", |
3813 return Local<Value>()); | 3813 return Local<Value>()); |
(...skipping 4055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7869 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7869 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7870 Address callback_address = | 7870 Address callback_address = |
7871 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7871 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7872 VMState<EXTERNAL> state(isolate); | 7872 VMState<EXTERNAL> state(isolate); |
7873 ExternalCallbackScope call_scope(isolate, callback_address); | 7873 ExternalCallbackScope call_scope(isolate, callback_address); |
7874 callback(info); | 7874 callback(info); |
7875 } | 7875 } |
7876 | 7876 |
7877 | 7877 |
7878 } } // namespace v8::internal | 7878 } } // namespace v8::internal |
OLD | NEW |