Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 409 return; | 409 return; |
| 410 } | 410 } |
| 411 n--; | 411 n--; |
| 412 var value = this[n]; | 412 var value = this[n]; |
| 413 delete this[n]; | 413 delete this[n]; |
| 414 this.length = n; | 414 this.length = n; |
| 415 return value; | 415 return value; |
| 416 } | 416 } |
| 417 | 417 |
| 418 | 418 |
| 419 function ObservedArrayPush() { | |
| 420 var n = TO_UINT32(this.length); | |
| 421 var m = %_ArgumentsLength(); | |
| 422 | |
| 423 EnqueueSpliceRecord(this, n, [], 0, m); | |
| 424 | |
| 425 try { | |
| 426 BeginPerformSplice(this); | |
| 427 | |
| 428 for (var i = 0; i < m; i++) { | |
| 429 this[i+n] = %_Arguments(i); | |
| 430 } | |
| 431 this.length = n + m; | |
| 432 | |
|
adamk
2013/05/16 00:45:30
Nit: no need for this blank line
rafaelw
2013/05/16 01:10:48
Done.
| |
| 433 } finally { | |
| 434 EndPerformSplice(this); | |
| 435 } | |
| 436 | |
| 437 return this.length; | |
| 438 } | |
| 439 | |
| 419 // Appends the arguments to the end of the array and returns the new | 440 // Appends the arguments to the end of the array and returns the new |
| 420 // length of the array. See ECMA-262, section 15.4.4.7. | 441 // length of the array. See ECMA-262, section 15.4.4.7. |
| 421 function ArrayPush() { | 442 function ArrayPush() { |
| 422 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { | 443 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { |
| 423 throw MakeTypeError("called_on_null_or_undefined", | 444 throw MakeTypeError("called_on_null_or_undefined", |
| 424 ["Array.prototype.push"]); | 445 ["Array.prototype.push"]); |
| 425 } | 446 } |
| 426 | 447 |
| 448 if (%IsObserved(this)) | |
| 449 return ObservedArrayPush.apply(this, arguments); | |
| 450 | |
| 427 var n = TO_UINT32(this.length); | 451 var n = TO_UINT32(this.length); |
| 428 var m = %_ArgumentsLength(); | 452 var m = %_ArgumentsLength(); |
| 429 for (var i = 0; i < m; i++) { | 453 for (var i = 0; i < m; i++) { |
| 430 this[i+n] = %_Arguments(i); | 454 this[i+n] = %_Arguments(i); |
| 431 } | 455 } |
| 432 this.length = n + m; | 456 this.length = n + m; |
| 433 return this.length; | 457 return this.length; |
| 434 } | 458 } |
| 435 | 459 |
| 436 | 460 |
| (...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1523 )); | 1547 )); |
| 1524 | 1548 |
| 1525 SetUpLockedPrototype(InternalPackedArray, $Array(), $Array( | 1549 SetUpLockedPrototype(InternalPackedArray, $Array(), $Array( |
| 1526 "join", getFunction("join", ArrayJoin), | 1550 "join", getFunction("join", ArrayJoin), |
| 1527 "pop", getFunction("pop", ArrayPop), | 1551 "pop", getFunction("pop", ArrayPop), |
| 1528 "push", getFunction("push", ArrayPush) | 1552 "push", getFunction("push", ArrayPush) |
| 1529 )); | 1553 )); |
| 1530 } | 1554 } |
| 1531 | 1555 |
| 1532 SetUpArray(); | 1556 SetUpArray(); |
| OLD | NEW |