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

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

Issue 2724833002: Migrate Object.prototype.valueOf to CSA (Closed)
Patch Set: Delete NaN Created 3 years, 9 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
« src/bootstrapper.cc ('K') | « src/builtins/builtins-object.cc ('k') | no next file » | 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 GlobalObject = global.Object; 12 var GlobalObject = global.Object;
13 var iteratorSymbol = utils.ImportNow("iterator_symbol"); 13 var iteratorSymbol = utils.ImportNow("iterator_symbol");
14 var NaN = %GetRootNaN();
15 var ObjectToString = utils.ImportNow("object_to_string"); 14 var ObjectToString = utils.ImportNow("object_to_string");
16 15
17 // ---------------------------------------------------------------------------- 16 // ----------------------------------------------------------------------------
18 17
19 18
20 // Set up global object. 19 // Set up global object.
21 var attributes = DONT_ENUM | DONT_DELETE | READ_ONLY; 20 var attributes = DONT_ENUM | DONT_DELETE | READ_ONLY;
22 21
23 22
24 // ---------------------------------------------------------------------------- 23 // ----------------------------------------------------------------------------
25 // Object 24 // Object
26 25
27 // ES6 19.1.3.5 Object.prototype.toLocaleString([reserved1 [,reserved2]]) 26 // ES6 19.1.3.5 Object.prototype.toLocaleString([reserved1 [,reserved2]])
28 function ObjectToLocaleString() { 27 function ObjectToLocaleString() {
29 CHECK_OBJECT_COERCIBLE(this, "Object.prototype.toLocaleString"); 28 CHECK_OBJECT_COERCIBLE(this, "Object.prototype.toLocaleString");
30 return this.toString(); 29 return this.toString();
31 } 30 }
32 31
33 32
34 // ES6 19.1.3.7 Object.prototype.valueOf()
35 function ObjectValueOf() {
36 return TO_OBJECT(this);
37 }
38
39
40 // ES6 19.1.3.3 Object.prototype.isPrototypeOf(V) 33 // ES6 19.1.3.3 Object.prototype.isPrototypeOf(V)
41 function ObjectIsPrototypeOf(V) { 34 function ObjectIsPrototypeOf(V) {
42 if (!IS_RECEIVER(V)) return false; 35 if (!IS_RECEIVER(V)) return false;
43 var O = TO_OBJECT(this); 36 var O = TO_OBJECT(this);
44 return %HasInPrototypeChain(V, O); 37 return %HasInPrototypeChain(V, O);
45 } 38 }
46 39
47 40
48 // ES6 7.3.9 41 // ES6 7.3.9
49 function GetMethod(obj, p) { 42 function GetMethod(obj, p) {
(...skipping 19 matching lines...) Expand all
69 %SetNativeFlag(GlobalObject); 62 %SetNativeFlag(GlobalObject);
70 %SetCode(GlobalObject, ObjectConstructor); 63 %SetCode(GlobalObject, ObjectConstructor);
71 64
72 %AddNamedProperty(GlobalObject.prototype, "constructor", GlobalObject, 65 %AddNamedProperty(GlobalObject.prototype, "constructor", GlobalObject,
73 DONT_ENUM); 66 DONT_ENUM);
74 67
75 // Set up non-enumerable functions on the Object.prototype object. 68 // Set up non-enumerable functions on the Object.prototype object.
76 utils.InstallFunctions(GlobalObject.prototype, DONT_ENUM, [ 69 utils.InstallFunctions(GlobalObject.prototype, DONT_ENUM, [
77 "toString", ObjectToString, 70 "toString", ObjectToString,
78 "toLocaleString", ObjectToLocaleString, 71 "toLocaleString", ObjectToLocaleString,
79 "valueOf", ObjectValueOf, 72 // valueOf is added in bootstrapper.cc.
80 "isPrototypeOf", ObjectIsPrototypeOf, 73 "isPrototypeOf", ObjectIsPrototypeOf,
81 // propertyIsEnumerable is added in bootstrapper.cc. 74 // propertyIsEnumerable is added in bootstrapper.cc.
82 // __defineGetter__ is added in bootstrapper.cc. 75 // __defineGetter__ is added in bootstrapper.cc.
83 // __lookupGetter__ is added in bootstrapper.cc. 76 // __lookupGetter__ is added in bootstrapper.cc.
84 // __defineSetter__ is added in bootstrapper.cc. 77 // __defineSetter__ is added in bootstrapper.cc.
85 // __lookupSetter__ is added in bootstrapper.cc. 78 // __lookupSetter__ is added in bootstrapper.cc.
86 ]); 79 ]);
87 80
88 81
89 // ---------------------------------------------------------------------------- 82 // ----------------------------------------------------------------------------
(...skipping 16 matching lines...) Expand all
106 99
107 // ---------------------------------------------------------------------------- 100 // ----------------------------------------------------------------------------
108 // Exports 101 // Exports
109 102
110 utils.Export(function(to) { 103 utils.Export(function(to) {
111 to.GetIterator = GetIterator; 104 to.GetIterator = GetIterator;
112 to.GetMethod = GetMethod; 105 to.GetMethod = GetMethod;
113 to.ObjectHasOwnProperty = GlobalObject.prototype.hasOwnProperty; 106 to.ObjectHasOwnProperty = GlobalObject.prototype.hasOwnProperty;
114 }); 107 });
115 108
116 %InstallToContext([
117 "object_value_of", ObjectValueOf,
Benedikt Meurer 2017/03/01 19:57:16 Does this pass the test suite?
118 ]);
119
120 }) 109 })
OLDNEW
« src/bootstrapper.cc ('K') | « src/builtins/builtins-object.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698