| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 ReadOnlySetAccessor, | 642 ReadOnlySetAccessor, |
| 643 0 | 643 0 |
| 644 }; | 644 }; |
| 645 | 645 |
| 646 | 646 |
| 647 // | 647 // |
| 648 // Accessors::FunctionCaller | 648 // Accessors::FunctionCaller |
| 649 // | 649 // |
| 650 | 650 |
| 651 | 651 |
| 652 static MaybeObject* CheckNonStrictCallerOrThrow( | |
| 653 Isolate* isolate, | |
| 654 JSFunction* caller) { | |
| 655 DisableAssertNoAllocation enable_allocation; | |
| 656 if (!caller->shared()->is_classic_mode()) { | |
| 657 return isolate->Throw( | |
| 658 *isolate->factory()->NewTypeError("strict_caller", | |
| 659 HandleVector<Object>(NULL, 0))); | |
| 660 } | |
| 661 return caller; | |
| 662 } | |
| 663 | |
| 664 | |
| 665 class FrameFunctionIterator { | 652 class FrameFunctionIterator { |
| 666 public: | 653 public: |
| 667 FrameFunctionIterator(Isolate* isolate, const AssertNoAllocation& promise) | 654 FrameFunctionIterator(Isolate* isolate, const AssertNoAllocation& promise) |
| 668 : frame_iterator_(isolate), | 655 : frame_iterator_(isolate), |
| 669 functions_(2), | 656 functions_(2), |
| 670 index_(0) { | 657 index_(0) { |
| 671 GetFunctions(); | 658 GetFunctions(); |
| 672 } | 659 } |
| 673 JSFunction* next() { | 660 JSFunction* next() { |
| 674 if (functions_.length() == 0) return NULL; | 661 if (functions_.length() == 0) return NULL; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 } | 728 } |
| 742 if (!caller->shared()->native() && potential_caller != NULL) { | 729 if (!caller->shared()->native() && potential_caller != NULL) { |
| 743 caller = potential_caller; | 730 caller = potential_caller; |
| 744 } | 731 } |
| 745 // If caller is bound, return null. This is compatible with JSC, and | 732 // If caller is bound, return null. This is compatible with JSC, and |
| 746 // allows us to make bound functions use the strict function map | 733 // allows us to make bound functions use the strict function map |
| 747 // and its associated throwing caller and arguments. | 734 // and its associated throwing caller and arguments. |
| 748 if (caller->shared()->bound()) { | 735 if (caller->shared()->bound()) { |
| 749 return isolate->heap()->null_value(); | 736 return isolate->heap()->null_value(); |
| 750 } | 737 } |
| 751 return CheckNonStrictCallerOrThrow(isolate, caller); | 738 // Censor if the caller is not a classic mode function. |
| 739 // Change from ES5, which used to throw, see: |
| 740 // https://bugs.ecmascript.org/show_bug.cgi?id=310 |
| 741 if (!caller->shared()->is_classic_mode()) { |
| 742 return isolate->heap()->null_value(); |
| 743 } |
| 744 |
| 745 return caller; |
| 752 } | 746 } |
| 753 | 747 |
| 754 | 748 |
| 755 const AccessorDescriptor Accessors::FunctionCaller = { | 749 const AccessorDescriptor Accessors::FunctionCaller = { |
| 756 FunctionGetCaller, | 750 FunctionGetCaller, |
| 757 ReadOnlySetAccessor, | 751 ReadOnlySetAccessor, |
| 758 0 | 752 0 |
| 759 }; | 753 }; |
| 760 | 754 |
| 761 | 755 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 848 info->set_data(Smi::FromInt(index)); | 842 info->set_data(Smi::FromInt(index)); |
| 849 Handle<Object> getter = v8::FromCData(&ModuleGetExport); | 843 Handle<Object> getter = v8::FromCData(&ModuleGetExport); |
| 850 Handle<Object> setter = v8::FromCData(&ModuleSetExport); | 844 Handle<Object> setter = v8::FromCData(&ModuleSetExport); |
| 851 info->set_getter(*getter); | 845 info->set_getter(*getter); |
| 852 if (!(attributes & ReadOnly)) info->set_setter(*setter); | 846 if (!(attributes & ReadOnly)) info->set_setter(*setter); |
| 853 return info; | 847 return info; |
| 854 } | 848 } |
| 855 | 849 |
| 856 | 850 |
| 857 } } // namespace v8::internal | 851 } } // namespace v8::internal |
| OLD | NEW |