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 } finally { |
| 433 EndPerformSplice(this); |
| 434 } |
| 435 |
| 436 return this.length; |
| 437 } |
| 438 |
419 // Appends the arguments to the end of the array and returns the new | 439 // 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. | 440 // length of the array. See ECMA-262, section 15.4.4.7. |
421 function ArrayPush() { | 441 function ArrayPush() { |
422 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { | 442 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { |
423 throw MakeTypeError("called_on_null_or_undefined", | 443 throw MakeTypeError("called_on_null_or_undefined", |
424 ["Array.prototype.push"]); | 444 ["Array.prototype.push"]); |
425 } | 445 } |
426 | 446 |
| 447 if (%IsObserved(this)) |
| 448 return ObservedArrayPush.apply(this, arguments); |
| 449 |
427 var n = TO_UINT32(this.length); | 450 var n = TO_UINT32(this.length); |
428 var m = %_ArgumentsLength(); | 451 var m = %_ArgumentsLength(); |
429 for (var i = 0; i < m; i++) { | 452 for (var i = 0; i < m; i++) { |
430 this[i+n] = %_Arguments(i); | 453 this[i+n] = %_Arguments(i); |
431 } | 454 } |
432 this.length = n + m; | 455 this.length = n + m; |
433 return this.length; | 456 return this.length; |
434 } | 457 } |
435 | 458 |
436 | 459 |
(...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1523 )); | 1546 )); |
1524 | 1547 |
1525 SetUpLockedPrototype(InternalPackedArray, $Array(), $Array( | 1548 SetUpLockedPrototype(InternalPackedArray, $Array(), $Array( |
1526 "join", getFunction("join", ArrayJoin), | 1549 "join", getFunction("join", ArrayJoin), |
1527 "pop", getFunction("pop", ArrayPop), | 1550 "pop", getFunction("pop", ArrayPop), |
1528 "push", getFunction("push", ArrayPush) | 1551 "push", getFunction("push", ArrayPush) |
1529 )); | 1552 )); |
1530 } | 1553 } |
1531 | 1554 |
1532 SetUpArray(); | 1555 SetUpArray(); |
OLD | NEW |