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

Side by Side Diff: src/runtime.js

Issue 660095: Merge revision 3813 to 3930 from bleeding_edge to partial snapshots branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/partial_snapshots/
Patch Set: '' Created 10 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 | Annotate | Revision Log
« no previous file with comments | « src/runtime.cc ('k') | src/scopeinfo.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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 } 171 }
172 172
173 173
174 // Left operand (this) is already a string. 174 // Left operand (this) is already a string.
175 function STRING_ADD_LEFT(y) { 175 function STRING_ADD_LEFT(y) {
176 if (!IS_STRING(y)) { 176 if (!IS_STRING(y)) {
177 if (IS_STRING_WRAPPER(y)) { 177 if (IS_STRING_WRAPPER(y)) {
178 y = %_ValueOf(y); 178 y = %_ValueOf(y);
179 } else { 179 } else {
180 y = IS_NUMBER(y) 180 y = IS_NUMBER(y)
181 ? %NumberToString(y) 181 ? %_NumberToString(y)
182 : %ToString(%ToPrimitive(y, NO_HINT)); 182 : %ToString(%ToPrimitive(y, NO_HINT));
183 } 183 }
184 } 184 }
185 return %_StringAdd(this, y); 185 return %_StringAdd(this, y);
186 } 186 }
187 187
188 188
189 // Right operand (y) is already a string. 189 // Right operand (y) is already a string.
190 function STRING_ADD_RIGHT(y) { 190 function STRING_ADD_RIGHT(y) {
191 var x = this; 191 var x = this;
192 if (!IS_STRING(x)) { 192 if (!IS_STRING(x)) {
193 if (IS_STRING_WRAPPER(x)) { 193 if (IS_STRING_WRAPPER(x)) {
194 x = %_ValueOf(x); 194 x = %_ValueOf(x);
195 } else { 195 } else {
196 x = IS_NUMBER(x) 196 x = IS_NUMBER(x)
197 ? %NumberToString(x) 197 ? %_NumberToString(x)
198 : %ToString(%ToPrimitive(x, NO_HINT)); 198 : %ToString(%ToPrimitive(x, NO_HINT));
199 } 199 }
200 } 200 }
201 return %_StringAdd(x, y); 201 return %_StringAdd(x, y);
202 } 202 }
203 203
204 204
205 // ECMA-262, section 11.6.2, page 50. 205 // ECMA-262, section 11.6.2, page 50.
206 function SUB(y) { 206 function SUB(y) {
207 var x = IS_NUMBER(this) ? this : %ToNumber(this); 207 var x = IS_NUMBER(this) ? this : %ToNumber(this);
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 // has a property with the given key; return the key as a string if 388 // has a property with the given key; return the key as a string if
389 // it has. Otherwise returns null. Used in for-in statements. 389 // it has. Otherwise returns null. Used in for-in statements.
390 function FILTER_KEY(key) { 390 function FILTER_KEY(key) {
391 var string = %ToString(key); 391 var string = %ToString(key);
392 if (%HasProperty(this, string)) return string; 392 if (%HasProperty(this, string)) return string;
393 return null; 393 return null;
394 } 394 }
395 395
396 396
397 function CALL_NON_FUNCTION() { 397 function CALL_NON_FUNCTION() {
398 var callee = %GetCalledFunction(); 398 var delegate = %GetFunctionDelegate(this);
399 var delegate = %GetFunctionDelegate(callee);
400 if (!IS_FUNCTION(delegate)) { 399 if (!IS_FUNCTION(delegate)) {
401 throw %MakeTypeError('called_non_callable', [typeof callee]); 400 throw %MakeTypeError('called_non_callable', [typeof this]);
402 } 401 }
403 402 return delegate.apply(this, arguments);
404 var parameters = %NewArguments(delegate);
405 return delegate.apply(callee, parameters);
406 } 403 }
407 404
408 405
409 function CALL_NON_FUNCTION_AS_CONSTRUCTOR() { 406 function CALL_NON_FUNCTION_AS_CONSTRUCTOR() {
410 var callee = %GetCalledFunction(); 407 var delegate = %GetConstructorDelegate(this);
411 var delegate = %GetConstructorDelegate(callee);
412 if (!IS_FUNCTION(delegate)) { 408 if (!IS_FUNCTION(delegate)) {
413 throw %MakeTypeError('called_non_callable', [typeof callee]); 409 throw %MakeTypeError('called_non_callable', [typeof this]);
414 } 410 }
415 411 return delegate.apply(this, arguments);
416 var parameters = %NewArguments(delegate);
417 return delegate.apply(callee, parameters);
418 } 412 }
419 413
420 414
421 function APPLY_PREPARE(args) { 415 function APPLY_PREPARE(args) {
422 var length; 416 var length;
423 // First check whether length is a positive Smi and args is an 417 // First check whether length is a positive Smi and args is an
424 // array. This is the fast case. If this fails, we do the slow case 418 // array. This is the fast case. If this fails, we do the slow case
425 // that takes care of more eventualities. 419 // that takes care of more eventualities.
426 if (IS_ARRAY(args)) { 420 if (IS_ARRAY(args)) {
427 length = args.length; 421 length = args.length;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 if (IS_STRING(x)) return %StringToNumber(x); 516 if (IS_STRING(x)) return %StringToNumber(x);
523 if (IS_BOOLEAN(x)) return x ? 1 : 0; 517 if (IS_BOOLEAN(x)) return x ? 1 : 0;
524 if (IS_UNDEFINED(x)) return $NaN; 518 if (IS_UNDEFINED(x)) return $NaN;
525 return (IS_NULL(x)) ? 0 : ToNumber(%DefaultNumber(x)); 519 return (IS_NULL(x)) ? 0 : ToNumber(%DefaultNumber(x));
526 } 520 }
527 521
528 522
529 // ECMA-262, section 9.8, page 35. 523 // ECMA-262, section 9.8, page 35.
530 function ToString(x) { 524 function ToString(x) {
531 if (IS_STRING(x)) return x; 525 if (IS_STRING(x)) return x;
526 if (IS_NUMBER(x)) return %_NumberToString(x);
527 if (IS_BOOLEAN(x)) return x ? 'true' : 'false';
528 if (IS_UNDEFINED(x)) return 'undefined';
529 return (IS_NULL(x)) ? 'null' : %ToString(%DefaultString(x));
530 }
531
532 function NonStringToString(x) {
532 if (IS_NUMBER(x)) return %NumberToString(x); 533 if (IS_NUMBER(x)) return %NumberToString(x);
533 if (IS_BOOLEAN(x)) return x ? 'true' : 'false'; 534 if (IS_BOOLEAN(x)) return x ? 'true' : 'false';
534 if (IS_UNDEFINED(x)) return 'undefined'; 535 if (IS_UNDEFINED(x)) return 'undefined';
535 return (IS_NULL(x)) ? 'null' : %ToString(%DefaultString(x)); 536 return (IS_NULL(x)) ? 'null' : %ToString(%DefaultString(x));
536 } 537 }
537 538
538 539
539 // ECMA-262, section 9.9, page 36. 540 // ECMA-262, section 9.9, page 36.
540 function ToObject(x) { 541 function ToObject(x) {
541 if (IS_STRING(x)) return new $String(x); 542 if (IS_STRING(x)) return new $String(x);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 throw %MakeTypeError('cannot_convert_to_primitive', []); 639 throw %MakeTypeError('cannot_convert_to_primitive', []);
639 } 640 }
640 641
641 642
642 // NOTE: Setting the prototype for Array must take place as early as 643 // NOTE: Setting the prototype for Array must take place as early as
643 // possible due to code generation for array literals. When 644 // possible due to code generation for array literals. When
644 // generating code for a array literal a boilerplate array is created 645 // generating code for a array literal a boilerplate array is created
645 // that is cloned when running the code. It is essiential that the 646 // that is cloned when running the code. It is essiential that the
646 // boilerplate gets the right prototype. 647 // boilerplate gets the right prototype.
647 %FunctionSetPrototype($Array, new $Array(0)); 648 %FunctionSetPrototype($Array, new $Array(0));
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | src/scopeinfo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698