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 // 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 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 function DELETE(key, strict) { | 348 function DELETE(key, strict) { |
349 return %DeleteProperty(%ToObject(this), %ToString(key), strict); | 349 return %DeleteProperty(%ToObject(this), %ToString(key), strict); |
350 } | 350 } |
351 | 351 |
352 | 352 |
353 // ECMA-262, section 11.8.7, page 54. | 353 // ECMA-262, section 11.8.7, page 54. |
354 function IN(x) { | 354 function IN(x) { |
355 if (!IS_SPEC_OBJECT(x)) { | 355 if (!IS_SPEC_OBJECT(x)) { |
356 throw %MakeTypeError('invalid_in_operator_use', [this, x]); | 356 throw %MakeTypeError('invalid_in_operator_use', [this, x]); |
357 } | 357 } |
358 return %_IsNonNegativeSmi(this) && !%IsJSProxy(x) ? | 358 return %_IsNonNegativeSmi(this) ? |
359 %HasElement(x, this) : %HasProperty(x, %ToString(this)); | 359 %HasElement(x, this) : %HasProperty(x, %ToString(this)); |
360 } | 360 } |
361 | 361 |
362 | 362 |
363 // ECMA-262, section 11.8.6, page 54. To make the implementation more | 363 // ECMA-262, section 11.8.6, page 54. To make the implementation more |
364 // efficient, the return value should be zero if the 'this' is an | 364 // efficient, the return value should be zero if the 'this' is an |
365 // instance of F, and non-zero if not. This makes it possible to avoid | 365 // instance of F, and non-zero if not. This makes it possible to avoid |
366 // an expensive ToBoolean conversion in the generated code. | 366 // an expensive ToBoolean conversion in the generated code. |
367 function INSTANCE_OF(F) { | 367 function INSTANCE_OF(F) { |
368 var V = this; | 368 var V = this; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 | 422 |
423 | 423 |
424 function CALL_FUNCTION_PROXY() { | 424 function CALL_FUNCTION_PROXY() { |
425 var arity = %_ArgumentsLength() - 1; | 425 var arity = %_ArgumentsLength() - 1; |
426 var proxy = %_Arguments(arity); // The proxy comes in as an additional arg. | 426 var proxy = %_Arguments(arity); // The proxy comes in as an additional arg. |
427 var trap = %GetCallTrap(proxy); | 427 var trap = %GetCallTrap(proxy); |
428 return %Apply(trap, this, arguments, 0, arity); | 428 return %Apply(trap, this, arguments, 0, arity); |
429 } | 429 } |
430 | 430 |
431 | 431 |
432 function CALL_FUNCTION_PROXY_AS_CONSTRUCTOR(proxy) { | 432 function CALL_FUNCTION_PROXY_AS_CONSTRUCTOR() { |
433 var arity = %_ArgumentsLength() - 1; | 433 var proxy = this; |
434 var trap = %GetConstructTrap(proxy); | 434 var trap = %GetConstructTrap(proxy); |
435 var receiver = void 0; | 435 return %Apply(trap, this, arguments, 0, %_ArgumentsLength()); |
436 if (!IS_UNDEFINED(trap)) { | |
437 trap = %GetCallTrap(proxy); | |
438 var proto = proxy.prototype; | |
439 if (!IS_SPEC_OBJECT(proto) && proto !== null) { | |
440 throw MakeTypeError("proto_object_or_null", [proto]); | |
441 } | |
442 receiver = new global.Object(); | |
443 receiver.__proto__ = proto; | |
444 } | |
445 return %Apply(trap, this, arguments, 1, arity); | |
446 } | 436 } |
447 | 437 |
448 | 438 |
449 function APPLY_PREPARE(args) { | 439 function APPLY_PREPARE(args) { |
450 var length; | 440 var length; |
451 // First check whether length is a positive Smi and args is an | 441 // First check whether length is a positive Smi and args is an |
452 // array. This is the fast case. If this fails, we do the slow case | 442 // array. This is the fast case. If this fails, we do the slow case |
453 // that takes care of more eventualities. | 443 // that takes care of more eventualities. |
454 if (IS_ARRAY(args)) { | 444 if (IS_ARRAY(args)) { |
455 length = args.length; | 445 length = args.length; |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 throw %MakeTypeError('cannot_convert_to_primitive', []); | 658 throw %MakeTypeError('cannot_convert_to_primitive', []); |
669 } | 659 } |
670 | 660 |
671 | 661 |
672 // NOTE: Setting the prototype for Array must take place as early as | 662 // NOTE: Setting the prototype for Array must take place as early as |
673 // possible due to code generation for array literals. When | 663 // possible due to code generation for array literals. When |
674 // generating code for a array literal a boilerplate array is created | 664 // generating code for a array literal a boilerplate array is created |
675 // that is cloned when running the code. It is essential that the | 665 // that is cloned when running the code. It is essential that the |
676 // boilerplate gets the right prototype. | 666 // boilerplate gets the right prototype. |
677 %FunctionSetPrototype($Array, new $Array(0)); | 667 %FunctionSetPrototype($Array, new $Array(0)); |
OLD | NEW |