Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1094)

Side by Side Diff: src/api.cc

Issue 418383002: Change Has* and Get*Attributes to return Maybe<*>, indicating possible exceptions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « include/v8.h ('k') | src/contexts.cc » ('j') | src/objects-inl.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1887 matching lines...) Expand 10 before | Expand all | Expand 10 after
1898 1898
1899 1899
1900 v8::Local<Value> v8::TryCatch::StackTrace() const { 1900 v8::Local<Value> v8::TryCatch::StackTrace() const {
1901 ASSERT(isolate_ == i::Isolate::Current()); 1901 ASSERT(isolate_ == i::Isolate::Current());
1902 if (HasCaught()) { 1902 if (HasCaught()) {
1903 i::Object* raw_obj = reinterpret_cast<i::Object*>(exception_); 1903 i::Object* raw_obj = reinterpret_cast<i::Object*>(exception_);
1904 if (!raw_obj->IsJSObject()) return v8::Local<Value>(); 1904 if (!raw_obj->IsJSObject()) return v8::Local<Value>();
1905 i::HandleScope scope(isolate_); 1905 i::HandleScope scope(isolate_);
1906 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_obj), isolate_); 1906 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_obj), isolate_);
1907 i::Handle<i::String> name = isolate_->factory()->stack_string(); 1907 i::Handle<i::String> name = isolate_->factory()->stack_string();
1908 if (!i::JSReceiver::HasProperty(obj, name)) return v8::Local<Value>(); 1908 EXCEPTION_PREAMBLE(isolate_);
1909 Maybe<bool> maybe = i::JSReceiver::HasProperty(obj, name);
1910 has_pending_exception = !maybe.has_value;
1911 EXCEPTION_BAILOUT_CHECK(isolate_, v8::Local<Value>());
1912 if (!maybe.value) return v8::Local<Value>();
1909 i::Handle<i::Object> value; 1913 i::Handle<i::Object> value;
1910 if (!i::Object::GetProperty(obj, name).ToHandle(&value)) { 1914 if (!i::Object::GetProperty(obj, name).ToHandle(&value)) {
1911 return v8::Local<Value>(); 1915 return v8::Local<Value>();
1912 } 1916 }
1913 return v8::Utils::ToLocal(scope.CloseAndEscape(value)); 1917 return v8::Utils::ToLocal(scope.CloseAndEscape(value));
1914 } else { 1918 } else {
1915 return v8::Local<Value>(); 1919 return v8::Local<Value>();
1916 } 1920 }
1917 } 1921 }
1918 1922
(...skipping 1213 matching lines...) Expand 10 before | Expand all | Expand 10 after
3132 i::HandleScope scope(isolate); 3136 i::HandleScope scope(isolate);
3133 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3137 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3134 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); 3138 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
3135 if (!key_obj->IsName()) { 3139 if (!key_obj->IsName()) {
3136 EXCEPTION_PREAMBLE(isolate); 3140 EXCEPTION_PREAMBLE(isolate);
3137 has_pending_exception = !i::Execution::ToString( 3141 has_pending_exception = !i::Execution::ToString(
3138 isolate, key_obj).ToHandle(&key_obj); 3142 isolate, key_obj).ToHandle(&key_obj);
3139 EXCEPTION_BAILOUT_CHECK(isolate, static_cast<PropertyAttribute>(NONE)); 3143 EXCEPTION_BAILOUT_CHECK(isolate, static_cast<PropertyAttribute>(NONE));
3140 } 3144 }
3141 i::Handle<i::Name> key_name = i::Handle<i::Name>::cast(key_obj); 3145 i::Handle<i::Name> key_name = i::Handle<i::Name>::cast(key_obj);
3142 PropertyAttributes result = 3146 EXCEPTION_PREAMBLE(isolate);
3147 Maybe<PropertyAttributes> result =
3143 i::JSReceiver::GetPropertyAttributes(self, key_name); 3148 i::JSReceiver::GetPropertyAttributes(self, key_name);
3144 if (result == ABSENT) return static_cast<PropertyAttribute>(NONE); 3149 has_pending_exception = !result.has_value;
3145 return static_cast<PropertyAttribute>(result); 3150 EXCEPTION_BAILOUT_CHECK(isolate, static_cast<PropertyAttribute>(NONE));
3151 if (result.value == ABSENT) return static_cast<PropertyAttribute>(NONE);
3152 return static_cast<PropertyAttribute>(result.value);
3146 } 3153 }
3147 3154
3148 3155
3149 Local<Value> v8::Object::GetOwnPropertyDescriptor(Local<String> key) { 3156 Local<Value> v8::Object::GetOwnPropertyDescriptor(Local<String> key) {
3150 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3157 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3151 ON_BAILOUT(isolate, "v8::Object::GetOwnPropertyDescriptor()", 3158 ON_BAILOUT(isolate, "v8::Object::GetOwnPropertyDescriptor()",
3152 return Local<Value>()); 3159 return Local<Value>());
3153 ENTER_V8(isolate); 3160 ENTER_V8(isolate);
3154 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); 3161 i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
3155 i::Handle<i::Name> key_name = Utils::OpenHandle(*key); 3162 i::Handle<i::Name> key_name = Utils::OpenHandle(*key);
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
3392 !i::JSReceiver::DeleteElement(self, index).ToHandle(&obj); 3399 !i::JSReceiver::DeleteElement(self, index).ToHandle(&obj);
3393 EXCEPTION_BAILOUT_CHECK(isolate, false); 3400 EXCEPTION_BAILOUT_CHECK(isolate, false);
3394 return obj->IsTrue(); 3401 return obj->IsTrue();
3395 } 3402 }
3396 3403
3397 3404
3398 bool v8::Object::Has(uint32_t index) { 3405 bool v8::Object::Has(uint32_t index) {
3399 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3406 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3400 ON_BAILOUT(isolate, "v8::Object::HasProperty()", return false); 3407 ON_BAILOUT(isolate, "v8::Object::HasProperty()", return false);
3401 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3408 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3402 return i::JSReceiver::HasElement(self, index); 3409 EXCEPTION_PREAMBLE(isolate);
3410 Maybe<bool> maybe = i::JSReceiver::HasElement(self, index);
3411 has_pending_exception = !maybe.has_value;
3412 EXCEPTION_BAILOUT_CHECK(isolate, false);
3413 return maybe.value;
3403 } 3414 }
3404 3415
3405 3416
3406 template<typename Setter, typename Getter, typename Data> 3417 template<typename Setter, typename Getter, typename Data>
3407 static inline bool ObjectSetAccessor(Object* obj, 3418 static inline bool ObjectSetAccessor(Object* obj,
3408 Handle<String> name, 3419 Handle<String> name,
3409 Setter getter, 3420 Setter getter,
3410 Getter setter, 3421 Getter setter,
3411 Data data, 3422 Data data,
3412 AccessControl settings, 3423 AccessControl settings,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
3471 getter_i, 3482 getter_i,
3472 setter_i, 3483 setter_i,
3473 static_cast<PropertyAttributes>(attribute)); 3484 static_cast<PropertyAttributes>(attribute));
3474 } 3485 }
3475 3486
3476 3487
3477 bool v8::Object::HasOwnProperty(Handle<String> key) { 3488 bool v8::Object::HasOwnProperty(Handle<String> key) {
3478 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3489 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3479 ON_BAILOUT(isolate, "v8::Object::HasOwnProperty()", 3490 ON_BAILOUT(isolate, "v8::Object::HasOwnProperty()",
3480 return false); 3491 return false);
3481 return i::JSReceiver::HasOwnProperty( 3492 EXCEPTION_PREAMBLE(isolate);
3482 Utils::OpenHandle(this), Utils::OpenHandle(*key)); 3493 Maybe<bool> maybe = i::JSReceiver::HasOwnProperty(Utils::OpenHandle(this),
3494 Utils::OpenHandle(*key));
3495 has_pending_exception = !maybe.has_value;
3496 EXCEPTION_BAILOUT_CHECK(isolate, false);
3497 return maybe.value;
3483 } 3498 }
3484 3499
3485 3500
3486 bool v8::Object::HasRealNamedProperty(Handle<String> key) { 3501 bool v8::Object::HasRealNamedProperty(Handle<String> key) {
3487 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3502 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3488 ON_BAILOUT(isolate, "v8::Object::HasRealNamedProperty()", 3503 ON_BAILOUT(isolate, "v8::Object::HasRealNamedProperty()",
3489 return false); 3504 return false);
3490 return i::JSObject::HasRealNamedProperty(Utils::OpenHandle(this), 3505 EXCEPTION_PREAMBLE(isolate);
3491 Utils::OpenHandle(*key)); 3506 Maybe<bool> maybe = i::JSObject::HasRealNamedProperty(
3507 Utils::OpenHandle(this), Utils::OpenHandle(*key));
3508 has_pending_exception = !maybe.has_value;
3509 EXCEPTION_BAILOUT_CHECK(isolate, false);
3510 return maybe.value;
3492 } 3511 }
3493 3512
3494 3513
3495 bool v8::Object::HasRealIndexedProperty(uint32_t index) { 3514 bool v8::Object::HasRealIndexedProperty(uint32_t index) {
3496 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3515 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3497 ON_BAILOUT(isolate, "v8::Object::HasRealIndexedProperty()", 3516 ON_BAILOUT(isolate, "v8::Object::HasRealIndexedProperty()",
3498 return false); 3517 return false);
3499 return i::JSObject::HasRealElementProperty(Utils::OpenHandle(this), index); 3518 EXCEPTION_PREAMBLE(isolate);
3519 Maybe<bool> maybe =
3520 i::JSObject::HasRealElementProperty(Utils::OpenHandle(this), index);
3521 has_pending_exception = !maybe.has_value;
3522 EXCEPTION_BAILOUT_CHECK(isolate, false);
3523 return maybe.value;
3500 } 3524 }
3501 3525
3502 3526
3503 bool v8::Object::HasRealNamedCallbackProperty(Handle<String> key) { 3527 bool v8::Object::HasRealNamedCallbackProperty(Handle<String> key) {
3504 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3528 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3505 ON_BAILOUT(isolate, 3529 ON_BAILOUT(isolate,
3506 "v8::Object::HasRealNamedCallbackProperty()", 3530 "v8::Object::HasRealNamedCallbackProperty()",
3507 return false); 3531 return false);
3508 ENTER_V8(isolate); 3532 ENTER_V8(isolate);
3509 return i::JSObject::HasRealNamedCallbackProperty(Utils::OpenHandle(this), 3533 EXCEPTION_PREAMBLE(isolate);
3510 Utils::OpenHandle(*key)); 3534 Maybe<bool> maybe = i::JSObject::HasRealNamedCallbackProperty(
3535 Utils::OpenHandle(this), Utils::OpenHandle(*key));
3536 has_pending_exception = !maybe.has_value;
3537 EXCEPTION_BAILOUT_CHECK(isolate, false);
3538 return maybe.value;
3511 } 3539 }
3512 3540
3513 3541
3514 bool v8::Object::HasNamedLookupInterceptor() { 3542 bool v8::Object::HasNamedLookupInterceptor() {
3515 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3543 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3516 ON_BAILOUT(isolate, "v8::Object::HasNamedLookupInterceptor()", 3544 ON_BAILOUT(isolate, "v8::Object::HasNamedLookupInterceptor()",
3517 return false); 3545 return false);
3518 return Utils::OpenHandle(this)->HasNamedInterceptor(); 3546 return Utils::OpenHandle(this)->HasNamedInterceptor();
3519 } 3547 }
3520 3548
(...skipping 4113 matching lines...) Expand 10 before | Expand all | Expand 10 after
7634 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7662 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7635 Address callback_address = 7663 Address callback_address =
7636 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7664 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7637 VMState<EXTERNAL> state(isolate); 7665 VMState<EXTERNAL> state(isolate);
7638 ExternalCallbackScope call_scope(isolate, callback_address); 7666 ExternalCallbackScope call_scope(isolate, callback_address);
7639 callback(info); 7667 callback(info);
7640 } 7668 }
7641 7669
7642 7670
7643 } } // namespace v8::internal 7671 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/contexts.cc » ('j') | src/objects-inl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698