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

Side by Side Diff: src/v8natives.js

Issue 7060010: Merge bleeding edge into the GC branch up to 7948. The asserts (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: Created 9 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 | « src/v8globals.h ('k') | src/v8threads.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 function InstallFunctions(object, attributes, functions) { 49 function InstallFunctions(object, attributes, functions) {
50 if (functions.length >= 8) { 50 if (functions.length >= 8) {
51 %OptimizeObjectForAddingMultipleProperties(object, functions.length >> 1); 51 %OptimizeObjectForAddingMultipleProperties(object, functions.length >> 1);
52 } 52 }
53 for (var i = 0; i < functions.length; i += 2) { 53 for (var i = 0; i < functions.length; i += 2) {
54 var key = functions[i]; 54 var key = functions[i];
55 var f = functions[i + 1]; 55 var f = functions[i + 1];
56 %FunctionSetName(f, key); 56 %FunctionSetName(f, key);
57 %FunctionRemovePrototype(f); 57 %FunctionRemovePrototype(f);
58 %SetProperty(object, key, f, attributes); 58 %SetProperty(object, key, f, attributes);
59 %SetES5Flag(f);
59 } 60 }
60 %ToFastProperties(object); 61 %ToFastProperties(object);
61 } 62 }
62 63
63 // Emulates JSC by installing functions on a hidden prototype that 64 // Emulates JSC by installing functions on a hidden prototype that
64 // lies above the current object/prototype. This lets you override 65 // lies above the current object/prototype. This lets you override
65 // functions on String.prototype etc. and then restore the old function 66 // functions on String.prototype etc. and then restore the old function
66 // with delete. See http://code.google.com/p/chromium/issues/detail?id=1717 67 // with delete. See http://code.google.com/p/chromium/issues/detail?id=1717
67 function InstallFunctionsOnHiddenPrototype(object, attributes, functions) { 68 function InstallFunctionsOnHiddenPrototype(object, attributes, functions) {
68 var hidden_prototype = new $Object(); 69 var hidden_prototype = new $Object();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 'be the global object from which eval originated'); 141 'be the global object from which eval originated');
141 } 142 }
142 143
143 var f = %CompileString(x); 144 var f = %CompileString(x);
144 if (!IS_FUNCTION(f)) return f; 145 if (!IS_FUNCTION(f)) return f;
145 146
146 return %_CallFunction(this, f); 147 return %_CallFunction(this, f);
147 } 148 }
148 149
149 150
150 // execScript for IE compatibility.
151 function GlobalExecScript(expr, lang) {
152 // NOTE: We don't care about the character casing.
153 if (!lang || /javascript/i.test(lang)) {
154 var f = %CompileString(ToString(expr));
155 %_CallFunction(%GlobalReceiver(global), f);
156 }
157 return null;
158 }
159
160
161 // ---------------------------------------------------------------------------- 151 // ----------------------------------------------------------------------------
162 152
163 153
164 function SetupGlobal() { 154 function SetupGlobal() {
165 // ECMA 262 - 15.1.1.1. 155 // ECMA 262 - 15.1.1.1.
166 %SetProperty(global, "NaN", $NaN, DONT_ENUM | DONT_DELETE); 156 %SetProperty(global, "NaN", $NaN, DONT_ENUM | DONT_DELETE);
167 157
168 // ECMA-262 - 15.1.1.2. 158 // ECMA-262 - 15.1.1.2.
169 %SetProperty(global, "Infinity", 1/0, DONT_ENUM | DONT_DELETE); 159 %SetProperty(global, "Infinity", 1/0, DONT_ENUM | DONT_DELETE);
170 160
171 // ECMA-262 - 15.1.1.3. 161 // ECMA-262 - 15.1.1.3.
172 %SetProperty(global, "undefined", void 0, DONT_ENUM | DONT_DELETE); 162 %SetProperty(global, "undefined", void 0, DONT_ENUM | DONT_DELETE);
173 163
174 // Setup non-enumerable function on the global object. 164 // Setup non-enumerable function on the global object.
175 InstallFunctions(global, DONT_ENUM, $Array( 165 InstallFunctions(global, DONT_ENUM, $Array(
176 "isNaN", GlobalIsNaN, 166 "isNaN", GlobalIsNaN,
177 "isFinite", GlobalIsFinite, 167 "isFinite", GlobalIsFinite,
178 "parseInt", GlobalParseInt, 168 "parseInt", GlobalParseInt,
179 "parseFloat", GlobalParseFloat, 169 "parseFloat", GlobalParseFloat,
180 "eval", GlobalEval, 170 "eval", GlobalEval
181 "execScript", GlobalExecScript
182 )); 171 ));
183 } 172 }
184 173
185 SetupGlobal(); 174 SetupGlobal();
186 175
187 176
188 // ---------------------------------------------------------------------------- 177 // ----------------------------------------------------------------------------
189 // Boolean (first part of definition) 178 // Boolean (first part of definition)
190 179
191 180
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 216
228 217
229 // ECMA-262 - 15.2.4.4 218 // ECMA-262 - 15.2.4.4
230 function ObjectValueOf() { 219 function ObjectValueOf() {
231 return ToObject(this); 220 return ToObject(this);
232 } 221 }
233 222
234 223
235 // ECMA-262 - 15.2.4.5 224 // ECMA-262 - 15.2.4.5
236 function ObjectHasOwnProperty(V) { 225 function ObjectHasOwnProperty(V) {
237 return %HasLocalProperty(ToObject(this), ToString(V)); 226 return %HasLocalProperty(TO_OBJECT_INLINE(this), TO_STRING_INLINE(V));
238 } 227 }
239 228
240 229
241 // ECMA-262 - 15.2.4.6 230 // ECMA-262 - 15.2.4.6
242 function ObjectIsPrototypeOf(V) { 231 function ObjectIsPrototypeOf(V) {
243 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { 232 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
244 throw MakeTypeError("called_on_null_or_undefined", 233 throw MakeTypeError("called_on_null_or_undefined",
245 ["Object.prototype.isPrototypeOf"]); 234 ["Object.prototype.isPrototypeOf"]);
246 } 235 }
247 if (!IS_SPEC_OBJECT(V)) return false; 236 if (!IS_SPEC_OBJECT(V)) return false;
(...skipping 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after
1312 // ---------------------------------------------------------------------------- 1301 // ----------------------------------------------------------------------------
1313 1302
1314 function SetupFunction() { 1303 function SetupFunction() {
1315 InstallFunctions($Function.prototype, DONT_ENUM, $Array( 1304 InstallFunctions($Function.prototype, DONT_ENUM, $Array(
1316 "bind", FunctionBind, 1305 "bind", FunctionBind,
1317 "toString", FunctionToString 1306 "toString", FunctionToString
1318 )); 1307 ));
1319 } 1308 }
1320 1309
1321 SetupFunction(); 1310 SetupFunction();
OLDNEW
« no previous file with comments | « src/v8globals.h ('k') | src/v8threads.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698