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 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 FixedArray* elms = NULL; | 479 FixedArray* elms = NULL; |
480 if (!IsJSArrayWithFastElements(receiver, &elms) | 480 if (!IsJSArrayWithFastElements(receiver, &elms) |
481 || !ArrayPrototypeHasNoElements()) { | 481 || !ArrayPrototypeHasNoElements()) { |
482 return CallJsBuiltin("ArrayUnshift", args); | 482 return CallJsBuiltin("ArrayUnshift", args); |
483 } | 483 } |
484 JSArray* array = JSArray::cast(receiver); | 484 JSArray* array = JSArray::cast(receiver); |
485 ASSERT(array->HasFastElements()); | 485 ASSERT(array->HasFastElements()); |
486 | 486 |
487 int len = Smi::cast(array->length())->value(); | 487 int len = Smi::cast(array->length())->value(); |
488 int to_add = args.length() - 1; | 488 int to_add = args.length() - 1; |
489 // Note that we cannot quit early if to_add == 0 as | |
490 // values should be lifted from prototype into | |
491 // the array. | |
492 | |
493 int new_length = len + to_add; | 489 int new_length = len + to_add; |
494 // Currently fixed arrays cannot grow too big, so | 490 // Currently fixed arrays cannot grow too big, so |
495 // we should never hit this case. | 491 // we should never hit this case. |
496 ASSERT(to_add <= (Smi::kMaxValue - len)); | 492 ASSERT(to_add <= (Smi::kMaxValue - len)); |
497 | 493 |
498 if (new_length > elms->length()) { | 494 if (new_length > elms->length()) { |
499 // New backing storage is needed. | 495 // New backing storage is needed. |
500 int capacity = new_length + (new_length >> 1) + 16; | 496 int capacity = new_length + (new_length >> 1) + 16; |
501 Object* obj = Heap::AllocateUninitializedFixedArray(capacity); | 497 Object* obj = Heap::AllocateUninitializedFixedArray(capacity); |
502 if (obj->IsFailure()) return obj; | 498 if (obj->IsFailure()) return obj; |
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1374 if (entry->contains(pc)) { | 1370 if (entry->contains(pc)) { |
1375 return names_[i]; | 1371 return names_[i]; |
1376 } | 1372 } |
1377 } | 1373 } |
1378 } | 1374 } |
1379 return NULL; | 1375 return NULL; |
1380 } | 1376 } |
1381 | 1377 |
1382 | 1378 |
1383 } } // namespace v8::internal | 1379 } } // namespace v8::internal |
OLD | NEW |