Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: src/array.js

Issue 15837006: Make (Object.)observed Arrays use SafeRemoveArrayHoles during sort (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 983 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 // the prototype chain on non-Array objects. 994 // the prototype chain on non-Array objects.
995 // We do this by copying them to this object and sorting only 995 // We do this by copying them to this object and sorting only
996 // local elements. This is not very efficient, but sorting with 996 // local elements. This is not very efficient, but sorting with
997 // inherited elements happens very, very rarely, if at all. 997 // inherited elements happens very, very rarely, if at all.
998 // The specification allows "implementation dependent" behavior 998 // The specification allows "implementation dependent" behavior
999 // if an element on the prototype chain has an element that 999 // if an element on the prototype chain has an element that
1000 // might interact with sorting. 1000 // might interact with sorting.
1001 max_prototype_element = CopyFromPrototype(this, length); 1001 max_prototype_element = CopyFromPrototype(this, length);
1002 } 1002 }
1003 1003
1004 var num_non_undefined = %RemoveArrayHoles(this, length); 1004 var num_non_undefined = %IsObserved(this) ?
1005 -1 : %RemoveArrayHoles(this, length);
1006
1005 if (num_non_undefined == -1) { 1007 if (num_non_undefined == -1) {
1006 // There were indexed accessors in the array. Move array holes and 1008 // The array is observed, or there were indexed accessors in the array.
1007 // undefineds to the end using a Javascript function that is safe 1009 // Move array holes and undefineds to the end using a Javascript function
1008 // in the presence of accessors. 1010 // that is safe in the presence of accessors and is observable.
1009 num_non_undefined = SafeRemoveArrayHoles(this); 1011 num_non_undefined = SafeRemoveArrayHoles(this);
1010 } 1012 }
1011 1013
1012 QuickSort(this, 0, num_non_undefined); 1014 QuickSort(this, 0, num_non_undefined);
1013 1015
1014 if (!is_array && (num_non_undefined + 1 < max_prototype_element)) { 1016 if (!is_array && (num_non_undefined + 1 < max_prototype_element)) {
1015 // For compatibility with JSC, we shadow any elements in the prototype 1017 // For compatibility with JSC, we shadow any elements in the prototype
1016 // chain that has become exposed by sort moving a hole to its position. 1018 // chain that has become exposed by sort moving a hole to its position.
1017 ShadowPrototypeElements(this, num_non_undefined, max_prototype_element); 1019 ShadowPrototypeElements(this, num_non_undefined, max_prototype_element);
1018 } 1020 }
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
1546 )); 1548 ));
1547 1549
1548 SetUpLockedPrototype(InternalPackedArray, $Array(), $Array( 1550 SetUpLockedPrototype(InternalPackedArray, $Array(), $Array(
1549 "join", getFunction("join", ArrayJoin), 1551 "join", getFunction("join", ArrayJoin),
1550 "pop", getFunction("pop", ArrayPop), 1552 "pop", getFunction("pop", ArrayPop),
1551 "push", getFunction("push", ArrayPush) 1553 "push", getFunction("push", ArrayPush)
1552 )); 1554 ));
1553 } 1555 }
1554 1556
1555 SetUpArray(); 1557 SetUpArray();
OLDNEW
« no previous file with comments | « no previous file | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698