OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 // This files contains runtime support implemented in JavaScript. | 5 // This files contains runtime support implemented in JavaScript. |
6 | 6 |
7 // CAUTION: Some of the functions specified in this file are called | 7 // CAUTION: Some of the functions specified in this file are called |
8 // directly from compiled code. These are the functions with names in | 8 // directly from compiled code. These are the functions with names in |
9 // ALL CAPS. The compiled code passes the first argument in 'this'. | 9 // ALL CAPS. The compiled code passes the first argument in 'this'. |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... |
37 var BIT_AND; | 37 var BIT_AND; |
38 var BIT_AND_STRONG; | 38 var BIT_AND_STRONG; |
39 var BIT_XOR; | 39 var BIT_XOR; |
40 var BIT_XOR_STRONG; | 40 var BIT_XOR_STRONG; |
41 var SHL; | 41 var SHL; |
42 var SHL_STRONG; | 42 var SHL_STRONG; |
43 var SAR; | 43 var SAR; |
44 var SAR_STRONG; | 44 var SAR_STRONG; |
45 var SHR; | 45 var SHR; |
46 var SHR_STRONG; | 46 var SHR_STRONG; |
| 47 var IN; |
47 var INSTANCE_OF; | 48 var INSTANCE_OF; |
48 var CALL_NON_FUNCTION; | 49 var CALL_NON_FUNCTION; |
49 var CALL_NON_FUNCTION_AS_CONSTRUCTOR; | 50 var CALL_NON_FUNCTION_AS_CONSTRUCTOR; |
50 var CALL_FUNCTION_PROXY; | 51 var CALL_FUNCTION_PROXY; |
51 var CALL_FUNCTION_PROXY_AS_CONSTRUCTOR; | 52 var CALL_FUNCTION_PROXY_AS_CONSTRUCTOR; |
52 var CONCAT_ITERABLE_TO_ARRAY; | 53 var CONCAT_ITERABLE_TO_ARRAY; |
53 var APPLY_PREPARE; | 54 var APPLY_PREPARE; |
54 var REFLECT_APPLY_PREPARE; | 55 var REFLECT_APPLY_PREPARE; |
55 var REFLECT_CONSTRUCT_PREPARE; | 56 var REFLECT_CONSTRUCT_PREPARE; |
56 var STACK_OVERFLOW; | 57 var STACK_OVERFLOW; |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 } | 476 } |
476 throw %MakeTypeError(kStrongImplicitConversion); | 477 throw %MakeTypeError(kStrongImplicitConversion); |
477 } | 478 } |
478 | 479 |
479 | 480 |
480 /* ----------------------------- | 481 /* ----------------------------- |
481 - - - H e l p e r s - - - | 482 - - - H e l p e r s - - - |
482 ----------------------------- | 483 ----------------------------- |
483 */ | 484 */ |
484 | 485 |
| 486 // ECMA-262, section 11.8.7, page 54. |
| 487 IN = function IN(x) { |
| 488 if (!IS_SPEC_OBJECT(x)) { |
| 489 throw %MakeTypeError(kInvalidInOperatorUse, this, x); |
| 490 } |
| 491 if (%_IsNonNegativeSmi(this)) { |
| 492 if (IS_ARRAY(x) && %_HasFastPackedElements(x)) { |
| 493 return this < x.length; |
| 494 } |
| 495 return %HasElement(x, this); |
| 496 } |
| 497 return %HasProperty(x, %$toName(this)); |
| 498 } |
| 499 |
| 500 |
485 // ECMA-262, section 11.8.6, page 54. To make the implementation more | 501 // ECMA-262, section 11.8.6, page 54. To make the implementation more |
486 // efficient, the return value should be zero if the 'this' is an | 502 // efficient, the return value should be zero if the 'this' is an |
487 // instance of F, and non-zero if not. This makes it possible to avoid | 503 // instance of F, and non-zero if not. This makes it possible to avoid |
488 // an expensive ToBoolean conversion in the generated code. | 504 // an expensive ToBoolean conversion in the generated code. |
489 INSTANCE_OF = function INSTANCE_OF(F) { | 505 INSTANCE_OF = function INSTANCE_OF(F) { |
490 var V = this; | 506 var V = this; |
491 if (!IS_SPEC_FUNCTION(F)) { | 507 if (!IS_SPEC_FUNCTION(F)) { |
492 throw %MakeTypeError(kInstanceofFunctionExpected, F); | 508 throw %MakeTypeError(kInstanceofFunctionExpected, F); |
493 } | 509 } |
494 | 510 |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
912 $toBoolean = ToBoolean; | 928 $toBoolean = ToBoolean; |
913 $toInteger = ToInteger; | 929 $toInteger = ToInteger; |
914 $toLength = ToLength; | 930 $toLength = ToLength; |
915 $toName = ToName; | 931 $toName = ToName; |
916 $toNumber = ToNumber; | 932 $toNumber = ToNumber; |
917 $toPositiveInteger = ToPositiveInteger; | 933 $toPositiveInteger = ToPositiveInteger; |
918 $toPrimitive = ToPrimitive; | 934 $toPrimitive = ToPrimitive; |
919 $toString = ToString; | 935 $toString = ToString; |
920 | 936 |
921 }) | 937 }) |
OLD | NEW |