OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 4363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4374 } else { | 4374 } else { |
4375 Object* obj = Heap::AllocateFixedArrayWithHoles(capacity); | 4375 Object* obj = Heap::AllocateFixedArrayWithHoles(capacity); |
4376 if (obj->IsFailure()) return obj; | 4376 if (obj->IsFailure()) return obj; |
4377 new_elements = FixedArray::cast(obj); | 4377 new_elements = FixedArray::cast(obj); |
4378 } | 4378 } |
4379 set_elements(new_elements); | 4379 set_elements(new_elements); |
4380 return this; | 4380 return this; |
4381 } | 4381 } |
4382 | 4382 |
4383 | 4383 |
4384 void JSArray::SetContent(FixedArray* storage) { | |
4385 set_length(Smi::FromInt(storage->length())); | |
4386 set_elements(storage); | |
4387 } | |
4388 | |
4389 | |
4390 // Computes the new capacity when expanding the elements of a JSObject. | 4384 // Computes the new capacity when expanding the elements of a JSObject. |
4391 static int NewElementsCapacity(int old_capacity) { | 4385 static int NewElementsCapacity(int old_capacity) { |
4392 // (old_capacity + 50%) + 16 | 4386 // (old_capacity + 50%) + 16 |
4393 return old_capacity + (old_capacity >> 1) + 16; | 4387 return old_capacity + (old_capacity >> 1) + 16; |
4394 } | 4388 } |
4395 | 4389 |
4396 | 4390 |
4397 static Object* ArrayLengthRangeError() { | 4391 static Object* ArrayLengthRangeError() { |
4398 HandleScope scope; | 4392 HandleScope scope; |
4399 return Top::Throw(*Factory::NewRangeError("invalid_array_length", | 4393 return Top::Throw(*Factory::NewRangeError("invalid_array_length", |
(...skipping 2042 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6442 // No break point. | 6436 // No break point. |
6443 if (break_point_objects()->IsUndefined()) return 0; | 6437 if (break_point_objects()->IsUndefined()) return 0; |
6444 // Single beak point. | 6438 // Single beak point. |
6445 if (!break_point_objects()->IsFixedArray()) return 1; | 6439 if (!break_point_objects()->IsFixedArray()) return 1; |
6446 // Multiple break points. | 6440 // Multiple break points. |
6447 return FixedArray::cast(break_point_objects())->length(); | 6441 return FixedArray::cast(break_point_objects())->length(); |
6448 } | 6442 } |
6449 | 6443 |
6450 | 6444 |
6451 } } // namespace v8::internal | 6445 } } // namespace v8::internal |
OLD | NEW |