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

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

Issue 2934893002: [builtins] Properly optimize Object.prototype.isPrototypeOf. (Closed)
Patch Set: Address feedback. Created 3 years, 6 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/debug/debug-evaluate.cc ('k') | src/objects.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 GlobalObject = global.Object; 12 var GlobalObject = global.Object;
13 var iteratorSymbol = utils.ImportNow("iterator_symbol"); 13 var iteratorSymbol = utils.ImportNow("iterator_symbol");
14 14
15 // ---------------------------------------------------------------------------- 15 // ----------------------------------------------------------------------------
16 // Object 16 // Object
17 17
18 // ES6 19.1.3.5 Object.prototype.toLocaleString([reserved1 [,reserved2]]) 18 // ES6 19.1.3.5 Object.prototype.toLocaleString([reserved1 [,reserved2]])
19 function ObjectToLocaleString() { 19 function ObjectToLocaleString() {
20 CHECK_OBJECT_COERCIBLE(this, "Object.prototype.toLocaleString"); 20 CHECK_OBJECT_COERCIBLE(this, "Object.prototype.toLocaleString");
21 return this.toString(); 21 return this.toString();
22 } 22 }
23 23
24
25 // ES6 19.1.3.3 Object.prototype.isPrototypeOf(V)
26 function ObjectIsPrototypeOf(V) {
27 if (!IS_RECEIVER(V)) return false;
28 var O = TO_OBJECT(this);
29 return %HasInPrototypeChain(V, O);
30 }
31
32
33 // ES6 7.3.9 24 // ES6 7.3.9
34 function GetMethod(obj, p) { 25 function GetMethod(obj, p) {
35 var func = obj[p]; 26 var func = obj[p];
36 if (IS_NULL_OR_UNDEFINED(func)) return UNDEFINED; 27 if (IS_NULL_OR_UNDEFINED(func)) return UNDEFINED;
37 if (IS_CALLABLE(func)) return func; 28 if (IS_CALLABLE(func)) return func;
38 throw %make_type_error(kCalledNonCallable, typeof func); 29 throw %make_type_error(kCalledNonCallable, typeof func);
39 } 30 }
40 31
41 // ES6 19.1.1.1 32 // ES6 19.1.1.1
42 function ObjectConstructor(x) { 33 function ObjectConstructor(x) {
(...skipping 12 matching lines...) Expand all
55 %SetCode(GlobalObject, ObjectConstructor); 46 %SetCode(GlobalObject, ObjectConstructor);
56 47
57 %AddNamedProperty(GlobalObject.prototype, "constructor", GlobalObject, 48 %AddNamedProperty(GlobalObject.prototype, "constructor", GlobalObject,
58 DONT_ENUM); 49 DONT_ENUM);
59 50
60 // Set up non-enumerable functions on the Object.prototype object. 51 // Set up non-enumerable functions on the Object.prototype object.
61 utils.InstallFunctions(GlobalObject.prototype, DONT_ENUM, [ 52 utils.InstallFunctions(GlobalObject.prototype, DONT_ENUM, [
62 // toString is added in bootstrapper.cc 53 // toString is added in bootstrapper.cc
63 "toLocaleString", ObjectToLocaleString, 54 "toLocaleString", ObjectToLocaleString,
64 // valueOf is added in bootstrapper.cc. 55 // valueOf is added in bootstrapper.cc.
65 "isPrototypeOf", ObjectIsPrototypeOf, 56 // isPrototypeOf is added in bootstrapper.cc.
66 // propertyIsEnumerable is added in bootstrapper.cc. 57 // propertyIsEnumerable is added in bootstrapper.cc.
67 // __defineGetter__ is added in bootstrapper.cc. 58 // __defineGetter__ is added in bootstrapper.cc.
68 // __lookupGetter__ is added in bootstrapper.cc. 59 // __lookupGetter__ is added in bootstrapper.cc.
69 // __defineSetter__ is added in bootstrapper.cc. 60 // __defineSetter__ is added in bootstrapper.cc.
70 // __lookupSetter__ is added in bootstrapper.cc. 61 // __lookupSetter__ is added in bootstrapper.cc.
71 ]); 62 ]);
72 63
73 64
74 // ---------------------------------------------------------------------------- 65 // ----------------------------------------------------------------------------
75 // Iterator related spec functions. 66 // Iterator related spec functions.
(...skipping 15 matching lines...) Expand all
91 82
92 // ---------------------------------------------------------------------------- 83 // ----------------------------------------------------------------------------
93 // Exports 84 // Exports
94 85
95 utils.Export(function(to) { 86 utils.Export(function(to) {
96 to.GetIterator = GetIterator; 87 to.GetIterator = GetIterator;
97 to.GetMethod = GetMethod; 88 to.GetMethod = GetMethod;
98 }); 89 });
99 90
100 }) 91 })
OLDNEW
« no previous file with comments | « src/debug/debug-evaluate.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698