| 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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 } | 185 } |
| 186 return %_StringAdd(x, y); | 186 return %_StringAdd(x, y); |
| 187 } | 187 } |
| 188 | 188 |
| 189 | 189 |
| 190 /* ----------------------------- | 190 /* ----------------------------- |
| 191 - - - H e l p e r s - - - | 191 - - - H e l p e r s - - - |
| 192 ----------------------------- | 192 ----------------------------- |
| 193 */ | 193 */ |
| 194 | 194 |
| 195 function CALL_NON_FUNCTION_AS_CONSTRUCTOR() { | |
| 196 var delegate = %GetConstructorDelegate(this); | |
| 197 return %Apply(delegate, this, arguments, 0, %_ArgumentsLength()); | |
| 198 } | |
| 199 | |
| 200 | |
| 201 function CALL_FUNCTION_PROXY_AS_CONSTRUCTOR () { | |
| 202 var proxy = this; | |
| 203 var trap = %GetConstructTrap(proxy); | |
| 204 return %Apply(trap, this, arguments, 0, %_ArgumentsLength()); | |
| 205 } | |
| 206 | |
| 207 | |
| 208 function APPLY_PREPARE(args) { | 195 function APPLY_PREPARE(args) { |
| 209 var length; | 196 var length; |
| 210 | 197 |
| 211 // First check that the receiver is callable. | 198 // First check that the receiver is callable. |
| 212 if (!IS_CALLABLE(this)) { | 199 if (!IS_CALLABLE(this)) { |
| 213 throw %make_type_error(kApplyNonFunction, %to_string_fun(this), | 200 throw %make_type_error(kApplyNonFunction, %to_string_fun(this), |
| 214 typeof this); | 201 typeof this); |
| 215 } | 202 } |
| 216 | 203 |
| 217 // First check whether length is a positive Smi and args is an | 204 // First check whether length is a positive Smi and args is an |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 $sameValueZero = SameValueZero; | 530 $sameValueZero = SameValueZero; |
| 544 $toInteger = ToInteger; | 531 $toInteger = ToInteger; |
| 545 $toLength = ToLength; | 532 $toLength = ToLength; |
| 546 $toNumber = ToNumber; | 533 $toNumber = ToNumber; |
| 547 $toPositiveInteger = ToPositiveInteger; | 534 $toPositiveInteger = ToPositiveInteger; |
| 548 $toPrimitive = ToPrimitive; | 535 $toPrimitive = ToPrimitive; |
| 549 $toString = ToString; | 536 $toString = ToString; |
| 550 | 537 |
| 551 %InstallToContext([ | 538 %InstallToContext([ |
| 552 "apply_prepare_builtin", APPLY_PREPARE, | 539 "apply_prepare_builtin", APPLY_PREPARE, |
| 553 "call_function_proxy_as_constructor_builtin", CALL_FUNCTION_PROXY_AS_CONSTRUCT
OR, | |
| 554 "call_non_function_as_constructor_builtin", CALL_NON_FUNCTION_AS_CONSTRUCTOR, | |
| 555 "compare_builtin", COMPARE, | 540 "compare_builtin", COMPARE, |
| 556 "compare_strong_builtin", COMPARE_STRONG, | 541 "compare_strong_builtin", COMPARE_STRONG, |
| 557 "concat_iterable_to_array_builtin", CONCAT_ITERABLE_TO_ARRAY, | 542 "concat_iterable_to_array_builtin", CONCAT_ITERABLE_TO_ARRAY, |
| 558 "equals_builtin", EQUALS, | 543 "equals_builtin", EQUALS, |
| 559 "reflect_apply_prepare_builtin", REFLECT_APPLY_PREPARE, | 544 "reflect_apply_prepare_builtin", REFLECT_APPLY_PREPARE, |
| 560 "reflect_construct_prepare_builtin", REFLECT_CONSTRUCT_PREPARE, | 545 "reflect_construct_prepare_builtin", REFLECT_CONSTRUCT_PREPARE, |
| 561 "stack_overflow_builtin", STACK_OVERFLOW, | 546 "stack_overflow_builtin", STACK_OVERFLOW, |
| 562 "string_add_left_builtin", STRING_ADD_LEFT, | 547 "string_add_left_builtin", STRING_ADD_LEFT, |
| 563 "string_add_right_builtin", STRING_ADD_RIGHT, | 548 "string_add_right_builtin", STRING_ADD_RIGHT, |
| 564 ]); | 549 ]); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 576 | 561 |
| 577 utils.Export(function(to) { | 562 utils.Export(function(to) { |
| 578 to.ToBoolean = ToBoolean; | 563 to.ToBoolean = ToBoolean; |
| 579 to.ToLength = ToLength; | 564 to.ToLength = ToLength; |
| 580 to.ToNumber = ToNumber; | 565 to.ToNumber = ToNumber; |
| 581 to.ToPrimitive = ToPrimitive; | 566 to.ToPrimitive = ToPrimitive; |
| 582 to.ToString = ToString; | 567 to.ToString = ToString; |
| 583 }); | 568 }); |
| 584 | 569 |
| 585 }) | 570 }) |
| OLD | NEW |