OLD | NEW |
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 5260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5271 | 5271 |
5272 static Object* ArrayLengthRangeError() { | 5272 static Object* ArrayLengthRangeError() { |
5273 HandleScope scope; | 5273 HandleScope scope; |
5274 return Top::Throw(*Factory::NewRangeError("invalid_array_length", | 5274 return Top::Throw(*Factory::NewRangeError("invalid_array_length", |
5275 HandleVector<Object>(NULL, 0))); | 5275 HandleVector<Object>(NULL, 0))); |
5276 } | 5276 } |
5277 | 5277 |
5278 | 5278 |
5279 Object* JSObject::SetElementsLength(Object* len) { | 5279 Object* JSObject::SetElementsLength(Object* len) { |
5280 // We should never end in here with a pixel or external array. | 5280 // We should never end in here with a pixel or external array. |
5281 ASSERT(!HasPixelElements() && !HasExternalArrayElements()); | 5281 ASSERT(AllowsSetElementsLength()); |
5282 | 5282 |
5283 Object* smi_length = len->ToSmi(); | 5283 Object* smi_length = len->ToSmi(); |
5284 if (smi_length->IsSmi()) { | 5284 if (smi_length->IsSmi()) { |
5285 int value = Smi::cast(smi_length)->value(); | 5285 int value = Smi::cast(smi_length)->value(); |
5286 if (value < 0) return ArrayLengthRangeError(); | 5286 if (value < 0) return ArrayLengthRangeError(); |
5287 switch (GetElementsKind()) { | 5287 switch (GetElementsKind()) { |
5288 case FAST_ELEMENTS: { | 5288 case FAST_ELEMENTS: { |
5289 int old_capacity = FixedArray::cast(elements())->length(); | 5289 int old_capacity = FixedArray::cast(elements())->length(); |
5290 if (value <= old_capacity) { | 5290 if (value <= old_capacity) { |
5291 if (IsJSArray()) { | 5291 if (IsJSArray()) { |
(...skipping 3110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8402 if (break_point_objects()->IsUndefined()) return 0; | 8402 if (break_point_objects()->IsUndefined()) return 0; |
8403 // Single beak point. | 8403 // Single beak point. |
8404 if (!break_point_objects()->IsFixedArray()) return 1; | 8404 if (!break_point_objects()->IsFixedArray()) return 1; |
8405 // Multiple break points. | 8405 // Multiple break points. |
8406 return FixedArray::cast(break_point_objects())->length(); | 8406 return FixedArray::cast(break_point_objects())->length(); |
8407 } | 8407 } |
8408 #endif | 8408 #endif |
8409 | 8409 |
8410 | 8410 |
8411 } } // namespace v8::internal | 8411 } } // namespace v8::internal |
OLD | NEW |