| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 2739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2750 // Restore the context and overwrite the function on the stack with | 2750 // Restore the context and overwrite the function on the stack with |
| 2751 // the result. | 2751 // the result. |
| 2752 frame_->RestoreContextRegister(); | 2752 frame_->RestoreContextRegister(); |
| 2753 frame_->SetElementAt(0, &result); | 2753 frame_->SetElementAt(0, &result); |
| 2754 | 2754 |
| 2755 } else if (var != NULL && !var->is_this() && var->is_global()) { | 2755 } else if (var != NULL && !var->is_this() && var->is_global()) { |
| 2756 // ---------------------------------- | 2756 // ---------------------------------- |
| 2757 // JavaScript example: 'foo(1, 2, 3)' // foo is global | 2757 // JavaScript example: 'foo(1, 2, 3)' // foo is global |
| 2758 // ---------------------------------- | 2758 // ---------------------------------- |
| 2759 | 2759 |
| 2760 // Push the name of the function and the receiver onto the stack. | |
| 2761 frame_->Push(var->name()); | |
| 2762 | |
| 2763 // Pass the global object as the receiver and let the IC stub | 2760 // Pass the global object as the receiver and let the IC stub |
| 2764 // patch the stack to use the global proxy as 'this' in the | 2761 // patch the stack to use the global proxy as 'this' in the |
| 2765 // invoked function. | 2762 // invoked function. |
| 2766 LoadGlobal(); | 2763 LoadGlobal(); |
| 2767 | 2764 |
| 2768 // Load the arguments. | 2765 // Load the arguments. |
| 2769 int arg_count = args->length(); | 2766 int arg_count = args->length(); |
| 2770 for (int i = 0; i < arg_count; i++) { | 2767 for (int i = 0; i < arg_count; i++) { |
| 2771 Load(args->at(i)); | 2768 Load(args->at(i)); |
| 2772 } | 2769 } |
| 2773 | 2770 |
| 2771 // Push the name of the function on the frame. |
| 2772 frame_->Push(var->name()); |
| 2773 |
| 2774 // Call the IC initialization code. | 2774 // Call the IC initialization code. |
| 2775 CodeForSourcePosition(node->position()); | 2775 CodeForSourcePosition(node->position()); |
| 2776 Result result = frame_->CallCallIC(RelocInfo::CODE_TARGET_CONTEXT, | 2776 Result result = frame_->CallCallIC(RelocInfo::CODE_TARGET_CONTEXT, |
| 2777 arg_count, | 2777 arg_count, |
| 2778 loop_nesting()); | 2778 loop_nesting()); |
| 2779 frame_->RestoreContextRegister(); | 2779 frame_->RestoreContextRegister(); |
| 2780 // Replace the function on the stack with the result. | 2780 // Replace the function on the stack with the result. |
| 2781 frame_->SetElementAt(0, &result); | 2781 frame_->Push(&result); |
| 2782 | 2782 |
| 2783 } else if (var != NULL && var->slot() != NULL && | 2783 } else if (var != NULL && var->slot() != NULL && |
| 2784 var->slot()->type() == Slot::LOOKUP) { | 2784 var->slot()->type() == Slot::LOOKUP) { |
| 2785 // ---------------------------------- | 2785 // ---------------------------------- |
| 2786 // JavaScript example: 'with (obj) foo(1, 2, 3)' // foo is in obj | 2786 // JavaScript example: 'with (obj) foo(1, 2, 3)' // foo is in obj |
| 2787 // ---------------------------------- | 2787 // ---------------------------------- |
| 2788 | 2788 |
| 2789 // Load the function from the context. Sync the frame so we can | 2789 // Load the function from the context. Sync the frame so we can |
| 2790 // push the arguments directly into place. | 2790 // push the arguments directly into place. |
| 2791 frame_->SyncRange(0, frame_->element_count() - 1); | 2791 frame_->SyncRange(0, frame_->element_count() - 1); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2824 args->at(1)->AsVariableProxy() != NULL && | 2824 args->at(1)->AsVariableProxy() != NULL && |
| 2825 args->at(1)->AsVariableProxy()->IsArguments()) { | 2825 args->at(1)->AsVariableProxy()->IsArguments()) { |
| 2826 // Use the optimized Function.prototype.apply that avoids | 2826 // Use the optimized Function.prototype.apply that avoids |
| 2827 // allocating lazily allocated arguments objects. | 2827 // allocating lazily allocated arguments objects. |
| 2828 CallApplyLazy(property->obj(), | 2828 CallApplyLazy(property->obj(), |
| 2829 args->at(0), | 2829 args->at(0), |
| 2830 args->at(1)->AsVariableProxy(), | 2830 args->at(1)->AsVariableProxy(), |
| 2831 node->position()); | 2831 node->position()); |
| 2832 | 2832 |
| 2833 } else { | 2833 } else { |
| 2834 // Push the name of the function and the receiver onto the stack. | 2834 // Push the receiver onto the frame. |
| 2835 frame_->Push(name); | |
| 2836 Load(property->obj()); | 2835 Load(property->obj()); |
| 2837 | 2836 |
| 2838 // Load the arguments. | 2837 // Load the arguments. |
| 2839 int arg_count = args->length(); | 2838 int arg_count = args->length(); |
| 2840 for (int i = 0; i < arg_count; i++) { | 2839 for (int i = 0; i < arg_count; i++) { |
| 2841 Load(args->at(i)); | 2840 Load(args->at(i)); |
| 2842 } | 2841 } |
| 2843 | 2842 |
| 2843 // Push the name of the function onto the frame. |
| 2844 frame_->Push(name); |
| 2845 |
| 2844 // Call the IC initialization code. | 2846 // Call the IC initialization code. |
| 2845 CodeForSourcePosition(node->position()); | 2847 CodeForSourcePosition(node->position()); |
| 2846 Result result = frame_->CallCallIC(RelocInfo::CODE_TARGET, | 2848 Result result = frame_->CallCallIC(RelocInfo::CODE_TARGET, |
| 2847 arg_count, | 2849 arg_count, |
| 2848 loop_nesting()); | 2850 loop_nesting()); |
| 2849 frame_->RestoreContextRegister(); | 2851 frame_->RestoreContextRegister(); |
| 2850 // Replace the function on the stack with the result. | 2852 frame_->Push(&result); |
| 2851 frame_->SetElementAt(0, &result); | |
| 2852 } | 2853 } |
| 2853 | 2854 |
| 2854 } else { | 2855 } else { |
| 2855 // ------------------------------------------- | 2856 // ------------------------------------------- |
| 2856 // JavaScript example: 'array[index](1, 2, 3)' | 2857 // JavaScript example: 'array[index](1, 2, 3)' |
| 2857 // ------------------------------------------- | 2858 // ------------------------------------------- |
| 2858 | 2859 |
| 2859 // Load the function to call from the property through a reference. | 2860 // Load the function to call from the property through a reference. |
| 2860 if (property->is_synthetic()) { | 2861 if (property->is_synthetic()) { |
| 2861 Reference ref(this, property, false); | 2862 Reference ref(this, property, false); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2932 void CodeGenerator::VisitCallRuntime(CallRuntime* node) { | 2933 void CodeGenerator::VisitCallRuntime(CallRuntime* node) { |
| 2933 if (CheckForInlineRuntimeCall(node)) { | 2934 if (CheckForInlineRuntimeCall(node)) { |
| 2934 return; | 2935 return; |
| 2935 } | 2936 } |
| 2936 | 2937 |
| 2937 ZoneList<Expression*>* args = node->arguments(); | 2938 ZoneList<Expression*>* args = node->arguments(); |
| 2938 Comment cmnt(masm_, "[ CallRuntime"); | 2939 Comment cmnt(masm_, "[ CallRuntime"); |
| 2939 Runtime::Function* function = node->function(); | 2940 Runtime::Function* function = node->function(); |
| 2940 | 2941 |
| 2941 if (function == NULL) { | 2942 if (function == NULL) { |
| 2942 // Prepare stack for calling JS runtime function. | |
| 2943 frame_->Push(node->name()); | |
| 2944 // Push the builtins object found in the current global object. | 2943 // Push the builtins object found in the current global object. |
| 2945 Result temp = allocator()->Allocate(); | 2944 Result temp = allocator()->Allocate(); |
| 2946 ASSERT(temp.is_valid()); | 2945 ASSERT(temp.is_valid()); |
| 2947 __ movq(temp.reg(), GlobalObject()); | 2946 __ movq(temp.reg(), GlobalObject()); |
| 2948 __ movq(temp.reg(), | 2947 __ movq(temp.reg(), |
| 2949 FieldOperand(temp.reg(), GlobalObject::kBuiltinsOffset)); | 2948 FieldOperand(temp.reg(), GlobalObject::kBuiltinsOffset)); |
| 2950 frame_->Push(&temp); | 2949 frame_->Push(&temp); |
| 2951 } | 2950 } |
| 2952 | 2951 |
| 2953 // Push the arguments ("left-to-right"). | 2952 // Push the arguments ("left-to-right"). |
| 2954 int arg_count = args->length(); | 2953 int arg_count = args->length(); |
| 2955 for (int i = 0; i < arg_count; i++) { | 2954 for (int i = 0; i < arg_count; i++) { |
| 2956 Load(args->at(i)); | 2955 Load(args->at(i)); |
| 2957 } | 2956 } |
| 2958 | 2957 |
| 2959 if (function == NULL) { | 2958 if (function == NULL) { |
| 2960 // Call the JS runtime function. | 2959 // Call the JS runtime function. |
| 2960 frame_->Push(node->name()); |
| 2961 Result answer = frame_->CallCallIC(RelocInfo::CODE_TARGET, | 2961 Result answer = frame_->CallCallIC(RelocInfo::CODE_TARGET, |
| 2962 arg_count, | 2962 arg_count, |
| 2963 loop_nesting_); | 2963 loop_nesting_); |
| 2964 frame_->RestoreContextRegister(); | 2964 frame_->RestoreContextRegister(); |
| 2965 frame_->SetElementAt(0, &answer); | 2965 frame_->Push(&answer); |
| 2966 } else { | 2966 } else { |
| 2967 // Call the C runtime function. | 2967 // Call the C runtime function. |
| 2968 Result answer = frame_->CallRuntime(function, arg_count); | 2968 Result answer = frame_->CallRuntime(function, arg_count); |
| 2969 frame_->Push(&answer); | 2969 frame_->Push(&answer); |
| 2970 } | 2970 } |
| 2971 } | 2971 } |
| 2972 | 2972 |
| 2973 | 2973 |
| 2974 void CodeGenerator::VisitUnaryOperation(UnaryOperation* node) { | 2974 void CodeGenerator::VisitUnaryOperation(UnaryOperation* node) { |
| 2975 Comment cmnt(masm_, "[ UnaryOperation"); | 2975 Comment cmnt(masm_, "[ UnaryOperation"); |
| (...skipping 6321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9297 // Call the function from C++. | 9297 // Call the function from C++. |
| 9298 return FUNCTION_CAST<ModuloFunction>(buffer); | 9298 return FUNCTION_CAST<ModuloFunction>(buffer); |
| 9299 } | 9299 } |
| 9300 | 9300 |
| 9301 #endif | 9301 #endif |
| 9302 | 9302 |
| 9303 | 9303 |
| 9304 #undef __ | 9304 #undef __ |
| 9305 | 9305 |
| 9306 } } // namespace v8::internal | 9306 } } // namespace v8::internal |
| OLD | NEW |