| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 1971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1982 cache->Update(descriptors, name, number); | 1982 cache->Update(descriptors, name, number); |
| 1983 } | 1983 } |
| 1984 if (number != DescriptorArray::kNotFound) { | 1984 if (number != DescriptorArray::kNotFound) { |
| 1985 result->DescriptorResult(holder, descriptors->GetDetails(number), number); | 1985 result->DescriptorResult(holder, descriptors->GetDetails(number), number); |
| 1986 } else { | 1986 } else { |
| 1987 result->NotFound(); | 1987 result->NotFound(); |
| 1988 } | 1988 } |
| 1989 } | 1989 } |
| 1990 | 1990 |
| 1991 | 1991 |
| 1992 static JSObject::ElementsKind GetElementsKindFromExternalArrayType( | 1992 static ElementsKind GetElementsKindFromExternalArrayType( |
| 1993 ExternalArrayType array_type) { | 1993 ExternalArrayType array_type) { |
| 1994 switch (array_type) { | 1994 switch (array_type) { |
| 1995 case kExternalByteArray: | 1995 case kExternalByteArray: |
| 1996 return JSObject::EXTERNAL_BYTE_ELEMENTS; | 1996 return EXTERNAL_BYTE_ELEMENTS; |
| 1997 break; | 1997 break; |
| 1998 case kExternalUnsignedByteArray: | 1998 case kExternalUnsignedByteArray: |
| 1999 return JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS; | 1999 return EXTERNAL_UNSIGNED_BYTE_ELEMENTS; |
| 2000 break; | 2000 break; |
| 2001 case kExternalShortArray: | 2001 case kExternalShortArray: |
| 2002 return JSObject::EXTERNAL_SHORT_ELEMENTS; | 2002 return EXTERNAL_SHORT_ELEMENTS; |
| 2003 break; | 2003 break; |
| 2004 case kExternalUnsignedShortArray: | 2004 case kExternalUnsignedShortArray: |
| 2005 return JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS; | 2005 return EXTERNAL_UNSIGNED_SHORT_ELEMENTS; |
| 2006 break; | 2006 break; |
| 2007 case kExternalIntArray: | 2007 case kExternalIntArray: |
| 2008 return JSObject::EXTERNAL_INT_ELEMENTS; | 2008 return EXTERNAL_INT_ELEMENTS; |
| 2009 break; | 2009 break; |
| 2010 case kExternalUnsignedIntArray: | 2010 case kExternalUnsignedIntArray: |
| 2011 return JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS; | 2011 return EXTERNAL_UNSIGNED_INT_ELEMENTS; |
| 2012 break; | 2012 break; |
| 2013 case kExternalFloatArray: | 2013 case kExternalFloatArray: |
| 2014 return JSObject::EXTERNAL_FLOAT_ELEMENTS; | 2014 return EXTERNAL_FLOAT_ELEMENTS; |
| 2015 break; | 2015 break; |
| 2016 case kExternalDoubleArray: | 2016 case kExternalDoubleArray: |
| 2017 return JSObject::EXTERNAL_DOUBLE_ELEMENTS; | 2017 return EXTERNAL_DOUBLE_ELEMENTS; |
| 2018 break; | 2018 break; |
| 2019 case kExternalPixelArray: | 2019 case kExternalPixelArray: |
| 2020 return JSObject::EXTERNAL_PIXEL_ELEMENTS; | 2020 return EXTERNAL_PIXEL_ELEMENTS; |
| 2021 break; | 2021 break; |
| 2022 } | 2022 } |
| 2023 UNREACHABLE(); | 2023 UNREACHABLE(); |
| 2024 return JSObject::DICTIONARY_ELEMENTS; | 2024 return DICTIONARY_ELEMENTS; |
| 2025 } | 2025 } |
| 2026 | 2026 |
| 2027 | 2027 |
| 2028 MaybeObject* Map::GetExternalArrayElementsMap(ExternalArrayType array_type, | 2028 MaybeObject* Map::GetExternalArrayElementsMap(ExternalArrayType array_type, |
| 2029 bool safe_to_add_transition) { | 2029 bool safe_to_add_transition) { |
| 2030 Heap* current_heap = heap(); | 2030 Heap* current_heap = heap(); |
| 2031 DescriptorArray* descriptors = instance_descriptors(); | 2031 DescriptorArray* descriptors = instance_descriptors(); |
| 2032 String* external_array_sentinel_name = current_heap->empty_symbol(); | 2032 String* external_array_sentinel_name = current_heap->empty_symbol(); |
| 2033 | 2033 |
| 2034 if (safe_to_add_transition) { | 2034 if (safe_to_add_transition) { |
| (...skipping 5481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7516 | 7516 |
| 7517 MaybeObject* JSObject::SetElementsLength(Object* len) { | 7517 MaybeObject* JSObject::SetElementsLength(Object* len) { |
| 7518 // We should never end in here with a pixel or external array. | 7518 // We should never end in here with a pixel or external array. |
| 7519 ASSERT(AllowsSetElementsLength()); | 7519 ASSERT(AllowsSetElementsLength()); |
| 7520 | 7520 |
| 7521 MaybeObject* maybe_smi_length = len->ToSmi(); | 7521 MaybeObject* maybe_smi_length = len->ToSmi(); |
| 7522 Object* smi_length = Smi::FromInt(0); | 7522 Object* smi_length = Smi::FromInt(0); |
| 7523 if (maybe_smi_length->ToObject(&smi_length) && smi_length->IsSmi()) { | 7523 if (maybe_smi_length->ToObject(&smi_length) && smi_length->IsSmi()) { |
| 7524 const int value = Smi::cast(smi_length)->value(); | 7524 const int value = Smi::cast(smi_length)->value(); |
| 7525 if (value < 0) return ArrayLengthRangeError(GetHeap()); | 7525 if (value < 0) return ArrayLengthRangeError(GetHeap()); |
| 7526 JSObject::ElementsKind elements_kind = GetElementsKind(); | 7526 ElementsKind elements_kind = GetElementsKind(); |
| 7527 switch (elements_kind) { | 7527 switch (elements_kind) { |
| 7528 case FAST_ELEMENTS: | 7528 case FAST_ELEMENTS: |
| 7529 case FAST_DOUBLE_ELEMENTS: { | 7529 case FAST_DOUBLE_ELEMENTS: { |
| 7530 int old_capacity = FixedArrayBase::cast(elements())->length(); | 7530 int old_capacity = FixedArrayBase::cast(elements())->length(); |
| 7531 if (value <= old_capacity) { | 7531 if (value <= old_capacity) { |
| 7532 if (IsJSArray()) { | 7532 if (IsJSArray()) { |
| 7533 Object* obj; | 7533 Object* obj; |
| 7534 if (elements_kind == FAST_ELEMENTS) { | 7534 if (elements_kind == FAST_ELEMENTS) { |
| 7535 MaybeObject* maybe_obj = EnsureWritableFastElements(); | 7535 MaybeObject* maybe_obj = EnsureWritableFastElements(); |
| 7536 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 7536 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| (...skipping 4061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11598 if (break_point_objects()->IsUndefined()) return 0; | 11598 if (break_point_objects()->IsUndefined()) return 0; |
| 11599 // Single break point. | 11599 // Single break point. |
| 11600 if (!break_point_objects()->IsFixedArray()) return 1; | 11600 if (!break_point_objects()->IsFixedArray()) return 1; |
| 11601 // Multiple break points. | 11601 // Multiple break points. |
| 11602 return FixedArray::cast(break_point_objects())->length(); | 11602 return FixedArray::cast(break_point_objects())->length(); |
| 11603 } | 11603 } |
| 11604 #endif | 11604 #endif |
| 11605 | 11605 |
| 11606 | 11606 |
| 11607 } } // namespace v8::internal | 11607 } } // namespace v8::internal |
| OLD | NEW |