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

Side by Side Diff: src/objects-inl.h

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, 4 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 | « src/objects.cc ('k') | src/runtime.cc » ('j') | no next file with comments »
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 // Review notes: 5 // Review notes:
6 // 6 //
7 // - The use of macros in these inline functions may seem superfluous 7 // - The use of macros in these inline functions may seem superfluous
8 // but it is absolutely needed to make sure gcc generates optimal 8 // but it is absolutely needed to make sure gcc generates optimal
9 // code. gcc is not happy when attempting to inline too deep. 9 // code. gcc is not happy when attempting to inline too deep.
10 // 10 //
(...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1159 Handle<JSReceiver> receiver, 1159 Handle<JSReceiver> receiver,
1160 uint32_t index, 1160 uint32_t index,
1161 Handle<Object> value, 1161 Handle<Object> value,
1162 StrictMode strict_mode) { 1162 StrictMode strict_mode) {
1163 Isolate* isolate = proxy->GetIsolate(); 1163 Isolate* isolate = proxy->GetIsolate();
1164 Handle<String> name = isolate->factory()->Uint32ToString(index); 1164 Handle<String> name = isolate->factory()->Uint32ToString(index);
1165 return SetPropertyWithHandler(proxy, receiver, name, value, strict_mode); 1165 return SetPropertyWithHandler(proxy, receiver, name, value, strict_mode);
1166 } 1166 }
1167 1167
1168 1168
1169 bool JSProxy::HasElementWithHandler(Handle<JSProxy> proxy, uint32_t index) { 1169 Maybe<bool> JSProxy::HasElementWithHandler(Handle<JSProxy> proxy,
1170 uint32_t index) {
1170 Isolate* isolate = proxy->GetIsolate(); 1171 Isolate* isolate = proxy->GetIsolate();
1171 Handle<String> name = isolate->factory()->Uint32ToString(index); 1172 Handle<String> name = isolate->factory()->Uint32ToString(index);
1172 return HasPropertyWithHandler(proxy, name); 1173 return HasPropertyWithHandler(proxy, name);
1173 } 1174 }
1174 1175
1175 1176
1176 #define FIELD_ADDR(p, offset) \ 1177 #define FIELD_ADDR(p, offset) \
1177 (reinterpret_cast<byte*>(p) + offset - kHeapObjectTag) 1178 (reinterpret_cast<byte*>(p) + offset - kHeapObjectTag)
1178 1179
1179 #define FIELD_ADDR_CONST(p, offset) \ 1180 #define FIELD_ADDR_CONST(p, offset) \
(...skipping 5442 matching lines...) Expand 10 before | Expand all | Expand 10 after
6622 ASSERT(canonical->HasHashCode()); 6623 ASSERT(canonical->HasHashCode());
6623 return canonical; 6624 return canonical;
6624 } 6625 }
6625 6626
6626 6627
6627 Object* JSReceiver::GetConstructor() { 6628 Object* JSReceiver::GetConstructor() {
6628 return map()->constructor(); 6629 return map()->constructor();
6629 } 6630 }
6630 6631
6631 6632
6632 bool JSReceiver::HasProperty(Handle<JSReceiver> object, 6633 Maybe<bool> JSReceiver::HasProperty(Handle<JSReceiver> object,
6633 Handle<Name> name) { 6634 Handle<Name> name) {
6634 if (object->IsJSProxy()) { 6635 if (object->IsJSProxy()) {
6635 Handle<JSProxy> proxy = Handle<JSProxy>::cast(object); 6636 Handle<JSProxy> proxy = Handle<JSProxy>::cast(object);
6636 return JSProxy::HasPropertyWithHandler(proxy, name); 6637 return JSProxy::HasPropertyWithHandler(proxy, name);
6637 } 6638 }
6638 return GetPropertyAttributes(object, name) != ABSENT; 6639 Maybe<PropertyAttributes> result = GetPropertyAttributes(object, name);
6640 if (!result.has_value) return Maybe<bool>();
Igor Sheludko 2014/07/25 18:31:41 It would probably be nicer to create a macros for
6641 return maybe(result.value != ABSENT);
6639 } 6642 }
6640 6643
6641 6644
6642 bool JSReceiver::HasOwnProperty(Handle<JSReceiver> object, Handle<Name> name) { 6645 Maybe<bool> JSReceiver::HasOwnProperty(Handle<JSReceiver> object,
6646 Handle<Name> name) {
6643 if (object->IsJSProxy()) { 6647 if (object->IsJSProxy()) {
6644 Handle<JSProxy> proxy = Handle<JSProxy>::cast(object); 6648 Handle<JSProxy> proxy = Handle<JSProxy>::cast(object);
6645 return JSProxy::HasPropertyWithHandler(proxy, name); 6649 return JSProxy::HasPropertyWithHandler(proxy, name);
6646 } 6650 }
6647 return GetOwnPropertyAttributes(object, name) != ABSENT; 6651 Maybe<PropertyAttributes> result = GetOwnPropertyAttributes(object, name);
6652 if (!result.has_value) return Maybe<bool>();
6653 return maybe(result.value != ABSENT);
6648 } 6654 }
6649 6655
6650 6656
6651 PropertyAttributes JSReceiver::GetPropertyAttributes(Handle<JSReceiver> object, 6657 Maybe<PropertyAttributes> JSReceiver::GetPropertyAttributes(
6652 Handle<Name> key) { 6658 Handle<JSReceiver> object, Handle<Name> key) {
6653 uint32_t index; 6659 uint32_t index;
6654 if (object->IsJSObject() && key->AsArrayIndex(&index)) { 6660 if (object->IsJSObject() && key->AsArrayIndex(&index)) {
6655 return GetElementAttribute(object, index); 6661 return GetElementAttribute(object, index);
6656 } 6662 }
6657 LookupIterator it(object, key); 6663 LookupIterator it(object, key);
6658 return GetPropertyAttributes(&it); 6664 return GetPropertyAttributes(&it);
6659 } 6665 }
6660 6666
6661 6667
6662 PropertyAttributes JSReceiver::GetElementAttribute(Handle<JSReceiver> object, 6668 Maybe<PropertyAttributes> JSReceiver::GetElementAttribute(
6663 uint32_t index) { 6669 Handle<JSReceiver> object, uint32_t index) {
6664 if (object->IsJSProxy()) { 6670 if (object->IsJSProxy()) {
6665 return JSProxy::GetElementAttributeWithHandler( 6671 return JSProxy::GetElementAttributeWithHandler(
6666 Handle<JSProxy>::cast(object), object, index); 6672 Handle<JSProxy>::cast(object), object, index);
6667 } 6673 }
6668 return JSObject::GetElementAttributeWithReceiver( 6674 return JSObject::GetElementAttributeWithReceiver(
6669 Handle<JSObject>::cast(object), object, index, true); 6675 Handle<JSObject>::cast(object), object, index, true);
6670 } 6676 }
6671 6677
6672 6678
6673 bool JSGlobalObject::IsDetached() { 6679 bool JSGlobalObject::IsDetached() {
(...skipping 15 matching lines...) Expand all
6689 } 6695 }
6690 6696
6691 6697
6692 Object* JSReceiver::GetIdentityHash() { 6698 Object* JSReceiver::GetIdentityHash() {
6693 return IsJSProxy() 6699 return IsJSProxy()
6694 ? JSProxy::cast(this)->GetIdentityHash() 6700 ? JSProxy::cast(this)->GetIdentityHash()
6695 : JSObject::cast(this)->GetIdentityHash(); 6701 : JSObject::cast(this)->GetIdentityHash();
6696 } 6702 }
6697 6703
6698 6704
6699 bool JSReceiver::HasElement(Handle<JSReceiver> object, uint32_t index) { 6705 Maybe<bool> JSReceiver::HasElement(Handle<JSReceiver> object, uint32_t index) {
6700 if (object->IsJSProxy()) { 6706 if (object->IsJSProxy()) {
6701 Handle<JSProxy> proxy = Handle<JSProxy>::cast(object); 6707 Handle<JSProxy> proxy = Handle<JSProxy>::cast(object);
6702 return JSProxy::HasElementWithHandler(proxy, index); 6708 return JSProxy::HasElementWithHandler(proxy, index);
6703 } 6709 }
6704 return JSObject::GetElementAttributeWithReceiver( 6710 Maybe<PropertyAttributes> result = JSObject::GetElementAttributeWithReceiver(
6705 Handle<JSObject>::cast(object), object, index, true) != ABSENT; 6711 Handle<JSObject>::cast(object), object, index, true);
6712 if (!result.has_value) return Maybe<bool>();
6713 return maybe(result.value != ABSENT);
6706 } 6714 }
6707 6715
6708 6716
6709 bool JSReceiver::HasOwnElement(Handle<JSReceiver> object, uint32_t index) { 6717 Maybe<bool> JSReceiver::HasOwnElement(Handle<JSReceiver> object,
6718 uint32_t index) {
6710 if (object->IsJSProxy()) { 6719 if (object->IsJSProxy()) {
6711 Handle<JSProxy> proxy = Handle<JSProxy>::cast(object); 6720 Handle<JSProxy> proxy = Handle<JSProxy>::cast(object);
6712 return JSProxy::HasElementWithHandler(proxy, index); 6721 return JSProxy::HasElementWithHandler(proxy, index);
6713 } 6722 }
6714 return JSObject::GetElementAttributeWithReceiver( 6723 Maybe<PropertyAttributes> result = JSObject::GetElementAttributeWithReceiver(
6715 Handle<JSObject>::cast(object), object, index, false) != ABSENT; 6724 Handle<JSObject>::cast(object), object, index, false);
6725 if (!result.has_value) return Maybe<bool>();
6726 return maybe(result.value != ABSENT);
6716 } 6727 }
6717 6728
6718 6729
6719 PropertyAttributes JSReceiver::GetOwnElementAttribute( 6730 Maybe<PropertyAttributes> JSReceiver::GetOwnElementAttribute(
6720 Handle<JSReceiver> object, uint32_t index) { 6731 Handle<JSReceiver> object, uint32_t index) {
6721 if (object->IsJSProxy()) { 6732 if (object->IsJSProxy()) {
6722 return JSProxy::GetElementAttributeWithHandler( 6733 return JSProxy::GetElementAttributeWithHandler(
6723 Handle<JSProxy>::cast(object), object, index); 6734 Handle<JSProxy>::cast(object), object, index);
6724 } 6735 }
6725 return JSObject::GetElementAttributeWithReceiver( 6736 return JSObject::GetElementAttributeWithReceiver(
6726 Handle<JSObject>::cast(object), object, index, false); 6737 Handle<JSObject>::cast(object), object, index, false);
6727 } 6738 }
6728 6739
6729 6740
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
7214 #undef READ_SHORT_FIELD 7225 #undef READ_SHORT_FIELD
7215 #undef WRITE_SHORT_FIELD 7226 #undef WRITE_SHORT_FIELD
7216 #undef READ_BYTE_FIELD 7227 #undef READ_BYTE_FIELD
7217 #undef WRITE_BYTE_FIELD 7228 #undef WRITE_BYTE_FIELD
7218 #undef NOBARRIER_READ_BYTE_FIELD 7229 #undef NOBARRIER_READ_BYTE_FIELD
7219 #undef NOBARRIER_WRITE_BYTE_FIELD 7230 #undef NOBARRIER_WRITE_BYTE_FIELD
7220 7231
7221 } } // namespace v8::internal 7232 } } // namespace v8::internal
7222 7233
7223 #endif // V8_OBJECTS_INL_H_ 7234 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698