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

Side by Side Diff: src/harmony-array.js

Issue 132333019: Use `CHECK_OBJECT_COERCIBLE` macro where possible (Closed) Base URL: git@github.com:v8/v8.git@master
Patch Set: Don’t update copyright year Created 6 years, 10 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/array.js ('k') | src/v8natives.js » ('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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 17 matching lines...) Expand all
28 'use strict'; 28 'use strict';
29 29
30 // This file relies on the fact that the following declaration has been made 30 // This file relies on the fact that the following declaration has been made
31 // in runtime.js: 31 // in runtime.js:
32 // var $Array = global.Array; 32 // var $Array = global.Array;
33 33
34 // ------------------------------------------------------------------- 34 // -------------------------------------------------------------------
35 35
36 // ES6 draft 07-15-13, section 15.4.3.23 36 // ES6 draft 07-15-13, section 15.4.3.23
37 function ArrayFind(predicate /* thisArg */) { // length == 1 37 function ArrayFind(predicate /* thisArg */) { // length == 1
38 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { 38 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.find");
39 throw MakeTypeError("called_on_null_or_undefined",
40 ["Array.prototype.find"]);
41 }
42 39
43 var array = ToObject(this); 40 var array = ToObject(this);
44 var length = ToInteger(array.length); 41 var length = ToInteger(array.length);
45 42
46 if (!IS_SPEC_FUNCTION(predicate)) { 43 if (!IS_SPEC_FUNCTION(predicate)) {
47 throw MakeTypeError('called_non_callable', [predicate]); 44 throw MakeTypeError('called_non_callable', [predicate]);
48 } 45 }
49 46
50 var thisArg; 47 var thisArg;
51 if (%_ArgumentsLength() > 1) { 48 if (%_ArgumentsLength() > 1) {
(...skipping 14 matching lines...) Expand all
66 } 63 }
67 } 64 }
68 } 65 }
69 66
70 return; 67 return;
71 } 68 }
72 69
73 70
74 // ES6 draft 07-15-13, section 15.4.3.24 71 // ES6 draft 07-15-13, section 15.4.3.24
75 function ArrayFindIndex(predicate /* thisArg */) { // length == 1 72 function ArrayFindIndex(predicate /* thisArg */) { // length == 1
76 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { 73 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.findIndex");
77 throw MakeTypeError("called_on_null_or_undefined",
78 ["Array.prototype.findIndex"]);
79 }
80 74
81 var array = ToObject(this); 75 var array = ToObject(this);
82 var length = ToInteger(array.length); 76 var length = ToInteger(array.length);
83 77
84 if (!IS_SPEC_FUNCTION(predicate)) { 78 if (!IS_SPEC_FUNCTION(predicate)) {
85 throw MakeTypeError('called_non_callable', [predicate]); 79 throw MakeTypeError('called_non_callable', [predicate]);
86 } 80 }
87 81
88 var thisArg; 82 var thisArg;
89 if (%_ArgumentsLength() > 1) { 83 if (%_ArgumentsLength() > 1) {
(...skipping 25 matching lines...) Expand all
115 %CheckIsBootstrapping(); 109 %CheckIsBootstrapping();
116 110
117 // Set up the non-enumerable functions on the Array prototype object. 111 // Set up the non-enumerable functions on the Array prototype object.
118 InstallFunctions($Array.prototype, DONT_ENUM, $Array( 112 InstallFunctions($Array.prototype, DONT_ENUM, $Array(
119 "find", ArrayFind, 113 "find", ArrayFind,
120 "findIndex", ArrayFindIndex 114 "findIndex", ArrayFindIndex
121 )); 115 ));
122 } 116 }
123 117
124 HarmonyArrayExtendArrayPrototype(); 118 HarmonyArrayExtendArrayPrototype();
OLDNEW
« no previous file with comments | « src/array.js ('k') | src/v8natives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698