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

Side by Side Diff: src/objects.cc

Issue 3462005: Fix getOwnPropertyDescriptor() support for index properties. (Closed)
Patch Set: Created 10 years, 3 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
« no previous file with comments | « src/objects.h ('k') | src/runtime.cc » ('j') | src/runtime.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 5912 matching lines...) Expand 10 before | Expand all | Expand 10 after
5923 // Leaving JavaScript. 5923 // Leaving JavaScript.
5924 VMState state(EXTERNAL); 5924 VMState state(EXTERNAL);
5925 result = getter(index, info); 5925 result = getter(index, info);
5926 } 5926 }
5927 if (!result.IsEmpty()) return true; 5927 if (!result.IsEmpty()) return true;
5928 } 5928 }
5929 return holder_handle->HasElementPostInterceptor(*receiver_handle, index); 5929 return holder_handle->HasElementPostInterceptor(*receiver_handle, index);
5930 } 5930 }
5931 5931
5932 5932
5933 bool JSObject::HasLocalElement(uint32_t index) { 5933 JSObject::LocalElementType JSObject::HasLocalElement(uint32_t index) {
5934 // Check access rights if needed. 5934 // Check access rights if needed.
5935 if (IsAccessCheckNeeded() && 5935 if (IsAccessCheckNeeded() &&
5936 !Top::MayIndexedAccess(this, index, v8::ACCESS_HAS)) { 5936 !Top::MayIndexedAccess(this, index, v8::ACCESS_HAS)) {
5937 Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS); 5937 Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS);
5938 return false; 5938 return UNDEFINED_ELEMENT;
5939 } 5939 }
5940 5940
5941 // Check for lookup interceptor 5941 // Check for lookup interceptor
5942 if (HasIndexedInterceptor()) { 5942 if (HasIndexedInterceptor()) {
5943 return HasElementWithInterceptor(this, index); 5943 return HasElementWithInterceptor(this, index) ? INTERCEPTED_ELEMENT
5944 : UNDEFINED_ELEMENT;
5944 } 5945 }
5945 5946
5946 // Handle [] on String objects. 5947 // Handle [] on String objects.
5947 if (this->IsStringObjectWithCharacterAt(index)) return true; 5948 if (this->IsStringObjectWithCharacterAt(index)) {
5949 return STRING_CHARACTER_ELEMENT;
5950 }
5948 5951
5949 switch (GetElementsKind()) { 5952 switch (GetElementsKind()) {
5950 case FAST_ELEMENTS: { 5953 case FAST_ELEMENTS: {
5951 uint32_t length = IsJSArray() ? 5954 uint32_t length = IsJSArray() ?
5952 static_cast<uint32_t> 5955 static_cast<uint32_t>
5953 (Smi::cast(JSArray::cast(this)->length())->value()) : 5956 (Smi::cast(JSArray::cast(this)->length())->value()) :
5954 static_cast<uint32_t>(FixedArray::cast(elements())->length()); 5957 static_cast<uint32_t>(FixedArray::cast(elements())->length());
5955 return (index < length) && 5958 if ((index < length) &&
5956 !FixedArray::cast(elements())->get(index)->IsTheHole(); 5959 !FixedArray::cast(elements())->get(index)->IsTheHole()) {
5960 return FAST_ELEMENT;
5961 }
5962
Rico 2010/09/22 15:23:56 remove blank line?
5963 break;
5957 } 5964 }
5958 case PIXEL_ELEMENTS: { 5965 case PIXEL_ELEMENTS: {
5959 PixelArray* pixels = PixelArray::cast(elements()); 5966 PixelArray* pixels = PixelArray::cast(elements());
5960 return (index < static_cast<uint32_t>(pixels->length())); 5967 if (index < static_cast<uint32_t>(pixels->length())) return FAST_ELEMENT;
5968 break;
5961 } 5969 }
5962 case EXTERNAL_BYTE_ELEMENTS: 5970 case EXTERNAL_BYTE_ELEMENTS:
5963 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: 5971 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS:
5964 case EXTERNAL_SHORT_ELEMENTS: 5972 case EXTERNAL_SHORT_ELEMENTS:
5965 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: 5973 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS:
5966 case EXTERNAL_INT_ELEMENTS: 5974 case EXTERNAL_INT_ELEMENTS:
5967 case EXTERNAL_UNSIGNED_INT_ELEMENTS: 5975 case EXTERNAL_UNSIGNED_INT_ELEMENTS:
5968 case EXTERNAL_FLOAT_ELEMENTS: { 5976 case EXTERNAL_FLOAT_ELEMENTS: {
5969 ExternalArray* array = ExternalArray::cast(elements()); 5977 ExternalArray* array = ExternalArray::cast(elements());
5970 return (index < static_cast<uint32_t>(array->length())); 5978 if (index < static_cast<uint32_t>(array->length())) return FAST_ELEMENT;
5979 break;
5971 } 5980 }
5972 case DICTIONARY_ELEMENTS: { 5981 case DICTIONARY_ELEMENTS: {
5973 return element_dictionary()->FindEntry(index) 5982 if (element_dictionary()->FindEntry(index) !=
5974 != NumberDictionary::kNotFound; 5983 NumberDictionary::kNotFound) {
5984 return DICTIONARY_ELEMENT;
5985 }
5986 break;
5975 } 5987 }
5976 default: 5988 default:
5977 UNREACHABLE(); 5989 UNREACHABLE();
5978 break; 5990 break;
5979 } 5991 }
5980 UNREACHABLE(); 5992
5981 return Heap::null_value(); 5993 return UNDEFINED_ELEMENT;
5982 } 5994 }
5983 5995
5984 5996
5985 bool JSObject::HasElementWithReceiver(JSObject* receiver, uint32_t index) { 5997 bool JSObject::HasElementWithReceiver(JSObject* receiver, uint32_t index) {
5986 // Check access rights if needed. 5998 // Check access rights if needed.
5987 if (IsAccessCheckNeeded() && 5999 if (IsAccessCheckNeeded() &&
5988 !Top::MayIndexedAccess(this, index, v8::ACCESS_HAS)) { 6000 !Top::MayIndexedAccess(this, index, v8::ACCESS_HAS)) {
5989 Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS); 6001 Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS);
5990 return false; 6002 return false;
5991 } 6003 }
(...skipping 2908 matching lines...) Expand 10 before | Expand all | Expand 10 after
8900 if (break_point_objects()->IsUndefined()) return 0; 8912 if (break_point_objects()->IsUndefined()) return 0;
8901 // Single beak point. 8913 // Single beak point.
8902 if (!break_point_objects()->IsFixedArray()) return 1; 8914 if (!break_point_objects()->IsFixedArray()) return 1;
8903 // Multiple break points. 8915 // Multiple break points.
8904 return FixedArray::cast(break_point_objects())->length(); 8916 return FixedArray::cast(break_point_objects())->length();
8905 } 8917 }
8906 #endif 8918 #endif
8907 8919
8908 8920
8909 } } // namespace v8::internal 8921 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/runtime.cc » ('j') | src/runtime.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698