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

Side by Side Diff: src/objects.cc

Issue 3446028: Merge r5509, r5512, r5530 to 2.3 branch ... (Closed) Base URL: http://v8.googlecode.com/svn/branches/2.3/
Patch Set: '' Created 10 years, 2 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.h ('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 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 5899 matching lines...) Expand 10 before | Expand all | Expand 10 after
5910 // Leaving JavaScript. 5910 // Leaving JavaScript.
5911 VMState state(EXTERNAL); 5911 VMState state(EXTERNAL);
5912 result = getter(index, info); 5912 result = getter(index, info);
5913 } 5913 }
5914 if (!result.IsEmpty()) return true; 5914 if (!result.IsEmpty()) return true;
5915 } 5915 }
5916 return holder_handle->HasElementPostInterceptor(*receiver_handle, index); 5916 return holder_handle->HasElementPostInterceptor(*receiver_handle, index);
5917 } 5917 }
5918 5918
5919 5919
5920 bool JSObject::HasLocalElement(uint32_t index) { 5920 JSObject::LocalElementType JSObject::HasLocalElement(uint32_t index) {
5921 // Check access rights if needed. 5921 // Check access rights if needed.
5922 if (IsAccessCheckNeeded() && 5922 if (IsAccessCheckNeeded() &&
5923 !Top::MayIndexedAccess(this, index, v8::ACCESS_HAS)) { 5923 !Top::MayIndexedAccess(this, index, v8::ACCESS_HAS)) {
5924 Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS); 5924 Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS);
5925 return false; 5925 return UNDEFINED_ELEMENT;
5926 } 5926 }
5927 5927
5928 // Check for lookup interceptor 5928 // Check for lookup interceptor
5929 if (HasIndexedInterceptor()) { 5929 if (HasIndexedInterceptor()) {
5930 return HasElementWithInterceptor(this, index); 5930 return HasElementWithInterceptor(this, index) ? INTERCEPTED_ELEMENT
5931 : UNDEFINED_ELEMENT;
5931 } 5932 }
5932 5933
5933 // Handle [] on String objects. 5934 // Handle [] on String objects.
5934 if (this->IsStringObjectWithCharacterAt(index)) return true; 5935 if (this->IsStringObjectWithCharacterAt(index)) {
5936 return STRING_CHARACTER_ELEMENT;
5937 }
5935 5938
5936 switch (GetElementsKind()) { 5939 switch (GetElementsKind()) {
5937 case FAST_ELEMENTS: { 5940 case FAST_ELEMENTS: {
5938 uint32_t length = IsJSArray() ? 5941 uint32_t length = IsJSArray() ?
5939 static_cast<uint32_t> 5942 static_cast<uint32_t>
5940 (Smi::cast(JSArray::cast(this)->length())->value()) : 5943 (Smi::cast(JSArray::cast(this)->length())->value()) :
5941 static_cast<uint32_t>(FixedArray::cast(elements())->length()); 5944 static_cast<uint32_t>(FixedArray::cast(elements())->length());
5942 return (index < length) && 5945 if ((index < length) &&
5943 !FixedArray::cast(elements())->get(index)->IsTheHole(); 5946 !FixedArray::cast(elements())->get(index)->IsTheHole()) {
5947 return FAST_ELEMENT;
5948 }
5949 break;
5944 } 5950 }
5945 case PIXEL_ELEMENTS: { 5951 case PIXEL_ELEMENTS: {
5946 PixelArray* pixels = PixelArray::cast(elements()); 5952 PixelArray* pixels = PixelArray::cast(elements());
5947 return (index < static_cast<uint32_t>(pixels->length())); 5953 if (index < static_cast<uint32_t>(pixels->length())) return FAST_ELEMENT;
5954 break;
5948 } 5955 }
5949 case EXTERNAL_BYTE_ELEMENTS: 5956 case EXTERNAL_BYTE_ELEMENTS:
5950 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: 5957 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS:
5951 case EXTERNAL_SHORT_ELEMENTS: 5958 case EXTERNAL_SHORT_ELEMENTS:
5952 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: 5959 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS:
5953 case EXTERNAL_INT_ELEMENTS: 5960 case EXTERNAL_INT_ELEMENTS:
5954 case EXTERNAL_UNSIGNED_INT_ELEMENTS: 5961 case EXTERNAL_UNSIGNED_INT_ELEMENTS:
5955 case EXTERNAL_FLOAT_ELEMENTS: { 5962 case EXTERNAL_FLOAT_ELEMENTS: {
5956 ExternalArray* array = ExternalArray::cast(elements()); 5963 ExternalArray* array = ExternalArray::cast(elements());
5957 return (index < static_cast<uint32_t>(array->length())); 5964 if (index < static_cast<uint32_t>(array->length())) return FAST_ELEMENT;
5965 break;
5958 } 5966 }
5959 case DICTIONARY_ELEMENTS: { 5967 case DICTIONARY_ELEMENTS: {
5960 return element_dictionary()->FindEntry(index) 5968 if (element_dictionary()->FindEntry(index) !=
5961 != NumberDictionary::kNotFound; 5969 NumberDictionary::kNotFound) {
5970 return DICTIONARY_ELEMENT;
5971 }
5972 break;
5962 } 5973 }
5963 default: 5974 default:
5964 UNREACHABLE(); 5975 UNREACHABLE();
5965 break; 5976 break;
5966 } 5977 }
5967 UNREACHABLE(); 5978
5968 return Heap::null_value(); 5979 return UNDEFINED_ELEMENT;
5969 } 5980 }
5970 5981
5971 5982
5972 bool JSObject::HasElementWithReceiver(JSObject* receiver, uint32_t index) { 5983 bool JSObject::HasElementWithReceiver(JSObject* receiver, uint32_t index) {
5973 // Check access rights if needed. 5984 // Check access rights if needed.
5974 if (IsAccessCheckNeeded() && 5985 if (IsAccessCheckNeeded() &&
5975 !Top::MayIndexedAccess(this, index, v8::ACCESS_HAS)) { 5986 !Top::MayIndexedAccess(this, index, v8::ACCESS_HAS)) {
5976 Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS); 5987 Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS);
5977 return false; 5988 return false;
5978 } 5989 }
(...skipping 2722 matching lines...) Expand 10 before | Expand all | Expand 10 after
8701 for (int i = 0; i < debug_info->break_points()->length(); i++) { 8712 for (int i = 0; i < debug_info->break_points()->length(); i++) {
8702 if (debug_info->break_points()->get(i)->IsUndefined()) { 8713 if (debug_info->break_points()->get(i)->IsUndefined()) {
8703 index = i; 8714 index = i;
8704 break; 8715 break;
8705 } 8716 }
8706 } 8717 }
8707 if (index == kNoBreakPointInfo) { 8718 if (index == kNoBreakPointInfo) {
8708 // No free slot - extend break point info array. 8719 // No free slot - extend break point info array.
8709 Handle<FixedArray> old_break_points = 8720 Handle<FixedArray> old_break_points =
8710 Handle<FixedArray>(FixedArray::cast(debug_info->break_points())); 8721 Handle<FixedArray>(FixedArray::cast(debug_info->break_points()));
8711 debug_info->set_break_points(*Factory::NewFixedArray(
8712 old_break_points->length() +
8713 Debug::kEstimatedNofBreakPointsInFunction));
8714 Handle<FixedArray> new_break_points = 8722 Handle<FixedArray> new_break_points =
8715 Handle<FixedArray>(FixedArray::cast(debug_info->break_points())); 8723 Factory::NewFixedArray(old_break_points->length() +
8724 Debug::kEstimatedNofBreakPointsInFunction);
8725
8726 debug_info->set_break_points(*new_break_points);
8716 for (int i = 0; i < old_break_points->length(); i++) { 8727 for (int i = 0; i < old_break_points->length(); i++) {
8717 new_break_points->set(i, old_break_points->get(i)); 8728 new_break_points->set(i, old_break_points->get(i));
8718 } 8729 }
8719 index = old_break_points->length(); 8730 index = old_break_points->length();
8720 } 8731 }
8721 ASSERT(index != kNoBreakPointInfo); 8732 ASSERT(index != kNoBreakPointInfo);
8722 8733
8723 // Allocate new BreakPointInfo object and set the break point. 8734 // Allocate new BreakPointInfo object and set the break point.
8724 Handle<BreakPointInfo> new_break_point_info = 8735 Handle<BreakPointInfo> new_break_point_info =
8725 Handle<BreakPointInfo>::cast(Factory::NewStruct(BREAK_POINT_INFO_TYPE)); 8736 Handle<BreakPointInfo>::cast(Factory::NewStruct(BREAK_POINT_INFO_TYPE));
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
8887 if (break_point_objects()->IsUndefined()) return 0; 8898 if (break_point_objects()->IsUndefined()) return 0;
8888 // Single beak point. 8899 // Single beak point.
8889 if (!break_point_objects()->IsFixedArray()) return 1; 8900 if (!break_point_objects()->IsFixedArray()) return 1;
8890 // Multiple break points. 8901 // Multiple break points.
8891 return FixedArray::cast(break_point_objects())->length(); 8902 return FixedArray::cast(break_point_objects())->length();
8892 } 8903 }
8893 #endif 8904 #endif
8894 8905
8895 8906
8896 } } // namespace v8::internal 8907 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698