Chromium Code Reviews| 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 | 145 |
| 146 ProfileEntryHookStub::MaybeCallEntryHook(masm_); | 146 ProfileEntryHookStub::MaybeCallEntryHook(masm_); |
| 147 | 147 |
| 148 #ifdef DEBUG | 148 #ifdef DEBUG |
| 149 if (strlen(FLAG_stop_at) > 0 && | 149 if (strlen(FLAG_stop_at) > 0 && |
| 150 info->function()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) { | 150 info->function()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) { |
| 151 __ stop("stop-at"); | 151 __ stop("stop-at"); |
| 152 } | 152 } |
| 153 #endif | 153 #endif |
| 154 | 154 |
| 155 // Strict mode functions and builtins need to replace the receiver | 155 // Classic mode functions and builtins need to replace the receiver with the |
| 156 // with undefined when called as functions (without an explicit | 156 // global proxy when called as functions (without an explicit receiver |
| 157 // receiver object). t1 is zero for method calls and non-zero for | 157 // object). |
| 158 // function calls. | 158 if (info->is_classic_mode() && !info->is_native()) { |
| 159 if (!info->is_classic_mode() || info->is_native()) { | |
| 160 Label ok; | 159 Label ok; |
| 161 __ Branch(&ok, eq, t1, Operand(zero_reg)); | 160 __ Branch(&ok, eq, t1, Operand(zero_reg)); |
| 162 int receiver_offset = info->scope()->num_parameters() * kPointerSize; | 161 int receiver_offset = info->scope()->num_parameters() * kPointerSize; |
| 162 __ lw(at, MemOperand(sp, receiver_offset)); | |
| 163 __ LoadRoot(a2, Heap::kUndefinedValueRootIndex); | 163 __ LoadRoot(a2, Heap::kUndefinedValueRootIndex); |
| 164 __ Branch(&ok, ne, a2, Operand(at)); | |
| 165 | |
| 166 __ lw(a2, GlobalObjectOperand()); | |
| 167 __ lw(a2, FieldMemOperand(a2, GlobalObject::kGlobalReceiverOffset)); | |
| 168 | |
| 164 __ sw(a2, MemOperand(sp, receiver_offset)); | 169 __ sw(a2, MemOperand(sp, receiver_offset)); |
| 170 | |
| 165 __ bind(&ok); | 171 __ bind(&ok); |
| 166 } | 172 } |
| 167 | 173 |
| 168 // Open a frame scope to indicate that there is a frame on the stack. The | 174 // Open a frame scope to indicate that there is a frame on the stack. The |
| 169 // MANUAL indicates that the scope shouldn't actually generate code to set up | 175 // MANUAL indicates that the scope shouldn't actually generate code to set up |
| 170 // the frame (that is done below). | 176 // the frame (that is done below). |
| 171 FrameScope frame_scope(masm_, StackFrame::MANUAL); | 177 FrameScope frame_scope(masm_, StackFrame::MANUAL); |
| 172 | 178 |
| 173 info->set_prologue_offset(masm_->pc_offset()); | 179 info->set_prologue_offset(masm_->pc_offset()); |
| 174 __ Prologue(BUILD_FUNCTION_FRAME); | 180 __ Prologue(BUILD_FUNCTION_FRAME); |
| (...skipping 2604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2779 __ push(a1); | 2785 __ push(a1); |
| 2780 EmitResolvePossiblyDirectEval(arg_count); | 2786 EmitResolvePossiblyDirectEval(arg_count); |
| 2781 | 2787 |
| 2782 // The runtime call returns a pair of values in v0 (function) and | 2788 // The runtime call returns a pair of values in v0 (function) and |
| 2783 // v1 (receiver). Touch up the stack with the right values. | 2789 // v1 (receiver). Touch up the stack with the right values. |
| 2784 __ sw(v0, MemOperand(sp, (arg_count + 1) * kPointerSize)); | 2790 __ sw(v0, MemOperand(sp, (arg_count + 1) * kPointerSize)); |
| 2785 __ sw(v1, MemOperand(sp, arg_count * kPointerSize)); | 2791 __ sw(v1, MemOperand(sp, arg_count * kPointerSize)); |
| 2786 } | 2792 } |
| 2787 // Record source position for debugger. | 2793 // Record source position for debugger. |
| 2788 SetSourcePosition(expr->position()); | 2794 SetSourcePosition(expr->position()); |
| 2789 CallFunctionStub stub(arg_count, RECEIVER_MIGHT_BE_IMPLICIT); | 2795 CallFunctionStub stub(arg_count, NO_CALL_FUNCTION_FLAGS); |
| 2790 __ lw(a1, MemOperand(sp, (arg_count + 1) * kPointerSize)); | 2796 __ lw(a1, MemOperand(sp, (arg_count + 1) * kPointerSize)); |
| 2791 __ CallStub(&stub); | 2797 __ CallStub(&stub); |
| 2792 RecordJSReturnSite(expr); | 2798 RecordJSReturnSite(expr); |
| 2793 // Restore context register. | 2799 // Restore context register. |
| 2794 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 2800 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 2795 context()->DropAndPlug(1, v0); | 2801 context()->DropAndPlug(1, v0); |
| 2796 } else if (proxy != NULL && proxy->var()->IsUnallocated()) { | 2802 } else if (proxy != NULL && proxy->var()->IsUnallocated()) { |
| 2797 // Push global object as receiver for the call IC. | 2803 // Push global object as receiver for the call IC. |
| 2798 __ lw(a0, GlobalObjectOperand()); | 2804 __ lw(a0, GlobalObjectOperand()); |
| 2799 __ push(a0); | 2805 __ push(a0); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 2821 // function and receiver and have the slow path jump around this | 2827 // function and receiver and have the slow path jump around this |
| 2822 // code. | 2828 // code. |
| 2823 if (done.is_linked()) { | 2829 if (done.is_linked()) { |
| 2824 Label call; | 2830 Label call; |
| 2825 __ Branch(&call); | 2831 __ Branch(&call); |
| 2826 __ bind(&done); | 2832 __ bind(&done); |
| 2827 // Push function. | 2833 // Push function. |
| 2828 __ push(v0); | 2834 __ push(v0); |
| 2829 // The receiver is implicitly the global receiver. Indicate this | 2835 // The receiver is implicitly the global receiver. Indicate this |
| 2830 // by passing the hole to the call function stub. | 2836 // by passing the hole to the call function stub. |
| 2831 __ LoadRoot(a1, Heap::kTheHoleValueRootIndex); | 2837 __ LoadRoot(a1, Heap::kUndefinedValueRootIndex); |
| 2832 __ push(a1); | 2838 __ push(a1); |
| 2833 __ bind(&call); | 2839 __ bind(&call); |
| 2834 } | 2840 } |
| 2835 | 2841 |
| 2836 // The receiver is either the global receiver or an object found | 2842 // The receiver is either the global receiver or an object found |
| 2837 // by LoadContextSlot. That object could be the hole if the | 2843 // by LoadContextSlot. |
| 2838 // receiver is implicitly the global object. | 2844 EmitCallWithStub(expr, NO_CALL_FUNCTION_FLAGS); |
| 2839 EmitCallWithStub(expr, RECEIVER_MIGHT_BE_IMPLICIT); | |
| 2840 } else if (property != NULL) { | 2845 } else if (property != NULL) { |
| 2841 { PreservePositionScope scope(masm()->positions_recorder()); | 2846 { PreservePositionScope scope(masm()->positions_recorder()); |
| 2842 VisitForStackValue(property->obj()); | 2847 VisitForStackValue(property->obj()); |
| 2843 } | 2848 } |
| 2844 if (property->key()->IsPropertyName()) { | 2849 if (property->key()->IsPropertyName()) { |
| 2845 EmitCallWithIC(expr, | 2850 EmitCallWithIC(expr, |
| 2846 property->key()->AsLiteral()->value(), | 2851 property->key()->AsLiteral()->value(), |
| 2847 NOT_CONTEXTUAL); | 2852 NOT_CONTEXTUAL); |
| 2848 } else { | 2853 } else { |
| 2849 EmitKeyedCallWithIC(expr, property->key()); | 2854 EmitKeyedCallWithIC(expr, property->key()); |
| 2850 } | 2855 } |
| 2851 } else { | 2856 } else { |
| 2852 // Call to an arbitrary expression not handled specially above. | 2857 // Call to an arbitrary expression not handled specially above. |
| 2853 { PreservePositionScope scope(masm()->positions_recorder()); | 2858 { PreservePositionScope scope(masm()->positions_recorder()); |
| 2854 VisitForStackValue(callee); | 2859 VisitForStackValue(callee); |
| 2855 } | 2860 } |
| 2856 // Push the hole as receiver. | 2861 // Push the hole as receiver. |
| 2857 // It will be correctly replaced in the call stub. | 2862 // It will be correctly replaced in the call stub. |
| 2858 __ LoadRoot(a1, Heap::kTheHoleValueRootIndex); | 2863 __ LoadRoot(a1, Heap::kUndefinedValueRootIndex); |
|
Paul Lind
2014/01/14 16:21:37
nit: comment no longer correct, please delete.
| |
| 2859 __ push(a1); | 2864 __ push(a1); |
| 2860 // Emit function call. | 2865 // Emit function call. |
| 2861 EmitCallWithStub(expr, RECEIVER_IS_IMPLICIT); | 2866 EmitCallWithStub(expr, NO_CALL_FUNCTION_FLAGS); |
| 2862 } | 2867 } |
| 2863 | 2868 |
| 2864 #ifdef DEBUG | 2869 #ifdef DEBUG |
| 2865 // RecordJSReturnSite should have been called. | 2870 // RecordJSReturnSite should have been called. |
| 2866 ASSERT(expr->return_is_recorded_); | 2871 ASSERT(expr->return_is_recorded_); |
| 2867 #endif | 2872 #endif |
| 2868 } | 2873 } |
| 2869 | 2874 |
| 2870 | 2875 |
| 2871 void FullCodeGenerator::VisitCallNew(CallNew* expr) { | 2876 void FullCodeGenerator::VisitCallNew(CallNew* expr) { |
| (...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3792 Label runtime, done; | 3797 Label runtime, done; |
| 3793 // Check for non-function argument (including proxy). | 3798 // Check for non-function argument (including proxy). |
| 3794 __ JumpIfSmi(v0, &runtime); | 3799 __ JumpIfSmi(v0, &runtime); |
| 3795 __ GetObjectType(v0, a1, a1); | 3800 __ GetObjectType(v0, a1, a1); |
| 3796 __ Branch(&runtime, ne, a1, Operand(JS_FUNCTION_TYPE)); | 3801 __ Branch(&runtime, ne, a1, Operand(JS_FUNCTION_TYPE)); |
| 3797 | 3802 |
| 3798 // InvokeFunction requires the function in a1. Move it in there. | 3803 // InvokeFunction requires the function in a1. Move it in there. |
| 3799 __ mov(a1, result_register()); | 3804 __ mov(a1, result_register()); |
| 3800 ParameterCount count(arg_count); | 3805 ParameterCount count(arg_count); |
| 3801 __ InvokeFunction(a1, count, CALL_FUNCTION, | 3806 __ InvokeFunction(a1, count, CALL_FUNCTION, |
| 3802 NullCallWrapper(), CALL_AS_METHOD); | 3807 NullCallWrapper(), CALL_AS_FUNCTION); |
| 3803 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 3808 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 3804 __ jmp(&done); | 3809 __ jmp(&done); |
| 3805 | 3810 |
| 3806 __ bind(&runtime); | 3811 __ bind(&runtime); |
| 3807 __ push(v0); | 3812 __ push(v0); |
| 3808 __ CallRuntime(Runtime::kCall, args->length()); | 3813 __ CallRuntime(Runtime::kCall, args->length()); |
| 3809 __ bind(&done); | 3814 __ bind(&done); |
| 3810 | 3815 |
| 3811 context()->Plug(v0); | 3816 context()->Plug(v0); |
| 3812 } | 3817 } |
| (...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4967 Assembler::target_address_at(pc_immediate_load_address)) == | 4972 Assembler::target_address_at(pc_immediate_load_address)) == |
| 4968 reinterpret_cast<uint32_t>( | 4973 reinterpret_cast<uint32_t>( |
| 4969 isolate->builtins()->OsrAfterStackCheck()->entry())); | 4974 isolate->builtins()->OsrAfterStackCheck()->entry())); |
| 4970 return OSR_AFTER_STACK_CHECK; | 4975 return OSR_AFTER_STACK_CHECK; |
| 4971 } | 4976 } |
| 4972 | 4977 |
| 4973 | 4978 |
| 4974 } } // namespace v8::internal | 4979 } } // namespace v8::internal |
| 4975 | 4980 |
| 4976 #endif // V8_TARGET_ARCH_MIPS | 4981 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |