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

Side by Side Diff: src/js/v8natives.js

Issue 1909433003: Remove support for Object.observe (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased Created 4 years, 8 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
« no previous file with comments | « src/js/object-observe.js ('k') | src/messages.h » ('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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 (function(global, utils) { 5 (function(global, utils) {
6 6
7 %CheckIsBootstrapping(); 7 %CheckIsBootstrapping();
8 8
9 // ---------------------------------------------------------------------------- 9 // ----------------------------------------------------------------------------
10 // Imports 10 // Imports
11 11
12 var GlobalArray = global.Array; 12 var GlobalArray = global.Array;
13 var GlobalNumber = global.Number; 13 var GlobalNumber = global.Number;
14 var GlobalObject = global.Object; 14 var GlobalObject = global.Object;
15 var InternalArray = utils.InternalArray; 15 var InternalArray = utils.InternalArray;
16 var iteratorSymbol = utils.ImportNow("iterator_symbol"); 16 var iteratorSymbol = utils.ImportNow("iterator_symbol");
17 var MakeRangeError; 17 var MakeRangeError;
18 var MakeSyntaxError; 18 var MakeSyntaxError;
19 var MakeTypeError; 19 var MakeTypeError;
20 var MathAbs; 20 var MathAbs;
21 var NaN = %GetRootNaN(); 21 var NaN = %GetRootNaN();
22 var ObjectToString = utils.ImportNow("object_to_string"); 22 var ObjectToString = utils.ImportNow("object_to_string");
23 var ObserveBeginPerformSplice;
24 var ObserveEndPerformSplice;
25 var ObserveEnqueueSpliceRecord;
26 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); 23 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
27 24
28 utils.Import(function(from) { 25 utils.Import(function(from) {
29 MakeRangeError = from.MakeRangeError; 26 MakeRangeError = from.MakeRangeError;
30 MakeSyntaxError = from.MakeSyntaxError; 27 MakeSyntaxError = from.MakeSyntaxError;
31 MakeTypeError = from.MakeTypeError; 28 MakeTypeError = from.MakeTypeError;
32 MathAbs = from.MathAbs; 29 MathAbs = from.MathAbs;
33 ObserveBeginPerformSplice = from.ObserveBeginPerformSplice;
34 ObserveEndPerformSplice = from.ObserveEndPerformSplice;
35 ObserveEnqueueSpliceRecord = from.ObserveEnqueueSpliceRecord;
36 }); 30 });
37 31
38 // ---------------------------------------------------------------------------- 32 // ----------------------------------------------------------------------------
39 33
40 34
41 // ES6 18.2.3 isNaN(number) 35 // ES6 18.2.3 isNaN(number)
42 function GlobalIsNaN(number) { 36 function GlobalIsNaN(number) {
43 number = TO_NUMBER(number); 37 number = TO_NUMBER(number);
44 return NUMBER_IS_NAN(number); 38 return NUMBER_IS_NAN(number);
45 } 39 }
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 } 675 }
682 return true; 676 return true;
683 } 677 }
684 678
685 679
686 // ES5 section 15.4.5.1. 680 // ES5 section 15.4.5.1.
687 function DefineArrayProperty(obj, p, desc, should_throw) { 681 function DefineArrayProperty(obj, p, desc, should_throw) {
688 // Step 3 - Special handling for array index. 682 // Step 3 - Special handling for array index.
689 if (!IS_SYMBOL(p)) { 683 if (!IS_SYMBOL(p)) {
690 var index = TO_UINT32(p); 684 var index = TO_UINT32(p);
691 var emit_splice = false;
692 if (TO_STRING(index) == p && index != 4294967295) { 685 if (TO_STRING(index) == p && index != 4294967295) {
693 var length = obj.length; 686 var length = obj.length;
694 if (index >= length && %IsObserved(obj)) {
695 emit_splice = true;
696 ObserveBeginPerformSplice(obj);
697 }
698
699 var length_desc = GetOwnPropertyJS(obj, "length"); 687 var length_desc = GetOwnPropertyJS(obj, "length");
700 if ((index >= length && !length_desc.isWritable()) || 688 if ((index >= length && !length_desc.isWritable()) ||
701 !DefineObjectProperty(obj, p, desc, true)) { 689 !DefineObjectProperty(obj, p, desc, true)) {
702 if (emit_splice)
703 ObserveEndPerformSplice(obj);
704 if (should_throw) { 690 if (should_throw) {
705 throw MakeTypeError(kDefineDisallowed, p); 691 throw MakeTypeError(kDefineDisallowed, p);
706 } else { 692 } else {
707 return false; 693 return false;
708 } 694 }
709 } 695 }
710 if (index >= length) { 696 if (index >= length) {
711 obj.length = index + 1; 697 obj.length = index + 1;
712 } 698 }
713 if (emit_splice) {
714 ObserveEndPerformSplice(obj);
715 ObserveEnqueueSpliceRecord(obj, length, [], index + 1 - length);
716 }
717 return true; 699 return true;
718 } 700 }
719 } 701 }
720 702
721 // Step 5 - Fallback to default implementation. 703 // Step 5 - Fallback to default implementation.
722 return DefineObjectProperty(obj, p, desc, should_throw); 704 return DefineObjectProperty(obj, p, desc, should_throw);
723 } 705 }
724 706
725 707
726 // ES5 section 8.12.9, ES5 section 15.4.5.1 and Harmony proxies. 708 // ES5 section 8.12.9, ES5 section 15.4.5.1 and Harmony proxies.
(...skipping 30 matching lines...) Expand all
757 } 739 }
758 740
759 return obj; 741 return obj;
760 } 742 }
761 743
762 744
763 // ES5 section 15.2.3.6. 745 // ES5 section 15.2.3.6.
764 function ObjectDefineProperty(obj, p, attributes) { 746 function ObjectDefineProperty(obj, p, attributes) {
765 // The new pure-C++ implementation doesn't support O.o. 747 // The new pure-C++ implementation doesn't support O.o.
766 // TODO(jkummerow): Implement missing features and remove fallback path. 748 // TODO(jkummerow): Implement missing features and remove fallback path.
767 if (%IsObserved(obj)) {
768 if (!IS_RECEIVER(obj)) {
769 throw MakeTypeError(kCalledOnNonObject, "Object.defineProperty");
770 }
771 var name = TO_NAME(p);
772 var desc = ToPropertyDescriptor(attributes);
773 DefineOwnProperty(obj, name, desc, true);
774 return obj;
775 }
776 return %ObjectDefineProperty(obj, p, attributes); 749 return %ObjectDefineProperty(obj, p, attributes);
777 } 750 }
778 751
779 752
780 // ES5 section 15.2.3.7. 753 // ES5 section 15.2.3.7.
781 function ObjectDefineProperties(obj, properties) { 754 function ObjectDefineProperties(obj, properties) {
782 // The new pure-C++ implementation doesn't support O.o. 755 // The new pure-C++ implementation doesn't support O.o.
783 // TODO(jkummerow): Implement missing features and remove fallback path. 756 // TODO(jkummerow): Implement missing features and remove fallback path.
784 if (%IsObserved(obj)) {
785 if (!IS_RECEIVER(obj)) {
786 throw MakeTypeError(kCalledOnNonObject, "Object.defineProperties");
787 }
788 var props = TO_OBJECT(properties);
789 var names = %GetOwnPropertyKeys(props, PROPERTY_FILTER_ONLY_ENUMERABLE);
790 var descriptors = new InternalArray();
791 for (var i = 0; i < names.length; i++) {
792 descriptors.push(ToPropertyDescriptor(props[names[i]]));
793 }
794 for (var i = 0; i < names.length; i++) {
795 DefineOwnProperty(obj, names[i], descriptors[i], true);
796 }
797 return obj;
798 }
799 return %ObjectDefineProperties(obj, properties); 757 return %ObjectDefineProperties(obj, properties);
800 } 758 }
801 759
802 760
803 // ES6 B.2.2.1.1 761 // ES6 B.2.2.1.1
804 function ObjectGetProto() { 762 function ObjectGetProto() {
805 return %_GetPrototype(TO_OBJECT(this)); 763 return %_GetPrototype(TO_OBJECT(this));
806 } 764 }
807 765
808 766
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 // Set up non-enumerable functions in the Object object. 811 // Set up non-enumerable functions in the Object object.
854 utils.InstallFunctions(GlobalObject, DONT_ENUM, [ 812 utils.InstallFunctions(GlobalObject, DONT_ENUM, [
855 // assign is added in bootstrapper.cc. 813 // assign is added in bootstrapper.cc.
856 // keys is added in bootstrapper.cc. 814 // keys is added in bootstrapper.cc.
857 "defineProperty", ObjectDefineProperty, 815 "defineProperty", ObjectDefineProperty,
858 "defineProperties", ObjectDefineProperties, 816 "defineProperties", ObjectDefineProperties,
859 "getPrototypeOf", ObjectGetPrototypeOf, 817 "getPrototypeOf", ObjectGetPrototypeOf,
860 "setPrototypeOf", ObjectSetPrototypeOf, 818 "setPrototypeOf", ObjectSetPrototypeOf,
861 // getOwnPropertySymbols is added in symbol.js. 819 // getOwnPropertySymbols is added in symbol.js.
862 // is is added in bootstrapper.cc. 820 // is is added in bootstrapper.cc.
863 // deliverChangeRecords, getNotifier, observe and unobserve are added
864 // in object-observe.js.
865 ]); 821 ]);
866 822
867 823
868 824
869 // ---------------------------------------------------------------------------- 825 // ----------------------------------------------------------------------------
870 // Number 826 // Number
871 827
872 // ES6 Number.prototype.toString([ radix ]) 828 // ES6 Number.prototype.toString([ radix ])
873 function NumberToStringJS(radix) { 829 function NumberToStringJS(radix) {
874 // NOTE: Both Number objects and values can enter here as 830 // NOTE: Both Number objects and values can enter here as
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1099 to.ObjectDefineProperties = ObjectDefineProperties; 1055 to.ObjectDefineProperties = ObjectDefineProperties;
1100 to.ObjectDefineProperty = ObjectDefineProperty; 1056 to.ObjectDefineProperty = ObjectDefineProperty;
1101 to.ObjectHasOwnProperty = GlobalObject.prototype.hasOwnProperty; 1057 to.ObjectHasOwnProperty = GlobalObject.prototype.hasOwnProperty;
1102 }); 1058 });
1103 1059
1104 %InstallToContext([ 1060 %InstallToContext([
1105 "object_value_of", ObjectValueOf, 1061 "object_value_of", ObjectValueOf,
1106 ]); 1062 ]);
1107 1063
1108 }) 1064 })
OLDNEW
« no previous file with comments | « src/js/object-observe.js ('k') | src/messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698