OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 #if V8_TARGET_ARCH_MIPS64 | 5 #if V8_TARGET_ARCH_MIPS64 |
6 | 6 |
7 // Note on Mips implementation: | 7 // Note on Mips implementation: |
8 // | 8 // |
9 // The result_register() for mips is the 'v0' register, which is defined | 9 // The result_register() for mips is the 'v0' register, which is defined |
10 // by the ABI to contain function return values. However, the first | 10 // by the ABI to contain function return values. However, the first |
(...skipping 3016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3027 } | 3027 } |
3028 } else { | 3028 } else { |
3029 VisitForStackValue(callee); | 3029 VisitForStackValue(callee); |
3030 // refEnv.WithBaseObject() | 3030 // refEnv.WithBaseObject() |
3031 __ LoadRoot(a2, Heap::kUndefinedValueRootIndex); | 3031 __ LoadRoot(a2, Heap::kUndefinedValueRootIndex); |
3032 __ push(a2); // Reserved receiver slot. | 3032 __ push(a2); // Reserved receiver slot. |
3033 } | 3033 } |
3034 } | 3034 } |
3035 | 3035 |
3036 | 3036 |
3037 void FullCodeGenerator::VisitCall(Call* expr) { | 3037 void FullCodeGenerator::EmitPossiblyEvalCall(Call* expr) { |
3038 #ifdef DEBUG | 3038 // In a call to eval, we first call RuntimeHidden_ResolvePossiblyDirectEval |
3039 // We want to verify that RecordJSReturnSite gets called on all paths | 3039 // to resolve the function we need to call. Then we call the resolved |
3040 // through this function. Avoid early returns. | 3040 // function using the given arguments. |
3041 expr->return_is_recorded_ = false; | 3041 ZoneList<Expression*>* args = expr->arguments(); |
3042 #endif | 3042 int arg_count = args->length(); |
| 3043 PushCalleeAndWithBaseObject(expr); |
3043 | 3044 |
3044 Comment cmnt(masm_, "[ Call"); | 3045 // Push the arguments. |
3045 Expression* callee = expr->expression(); | 3046 for (int i = 0; i < arg_count; i++) { |
3046 Call::CallType call_type = expr->GetCallType(isolate()); | 3047 VisitForStackValue(args->at(i)); |
3047 | |
3048 if (call_type == Call::POSSIBLY_EVAL_CALL) { | |
3049 // In a call to eval, we first call RuntimeHidden_ResolvePossiblyDirectEval | |
3050 // to resolve the function we need to call. Then we call the resolved | |
3051 // function using the given arguments. | |
3052 ZoneList<Expression*>* args = expr->arguments(); | |
3053 int arg_count = args->length(); | |
3054 PushCalleeAndWithBaseObject(expr); | |
3055 | |
3056 // Push the arguments. | |
3057 for (int i = 0; i < arg_count; i++) { | |
3058 VisitForStackValue(args->at(i)); | |
3059 } | |
3060 | |
3061 // Push a copy of the function (found below the arguments) and | |
3062 // resolve eval. | |
3063 __ ld(a1, MemOperand(sp, (arg_count + 1) * kPointerSize)); | |
3064 __ push(a1); | |
3065 EmitResolvePossiblyDirectEval(arg_count); | |
3066 | |
3067 // Touch up the stack with the resolved function. | |
3068 __ sd(v0, MemOperand(sp, (arg_count + 1) * kPointerSize)); | |
3069 | |
3070 PrepareForBailoutForId(expr->EvalId(), NO_REGISTERS); | |
3071 // Record source position for debugger. | |
3072 SetCallPosition(expr, arg_count); | |
3073 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); | |
3074 __ ld(a1, MemOperand(sp, (arg_count + 1) * kPointerSize)); | |
3075 __ CallStub(&stub); | |
3076 RecordJSReturnSite(expr); | |
3077 // Restore context register. | |
3078 __ ld(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | |
3079 context()->DropAndPlug(1, v0); | |
3080 } else if (call_type == Call::GLOBAL_CALL) { | |
3081 EmitCallWithLoadIC(expr); | |
3082 } else if (call_type == Call::LOOKUP_SLOT_CALL) { | |
3083 // Call to a lookup slot (dynamically introduced variable). | |
3084 PushCalleeAndWithBaseObject(expr); | |
3085 EmitCall(expr); | |
3086 } else if (call_type == Call::NAMED_PROPERTY_CALL) { | |
3087 Property* property = callee->AsProperty(); | |
3088 VisitForStackValue(property->obj()); | |
3089 EmitCallWithLoadIC(expr); | |
3090 } else if (call_type == Call::KEYED_PROPERTY_CALL) { | |
3091 Property* property = callee->AsProperty(); | |
3092 VisitForStackValue(property->obj()); | |
3093 EmitKeyedCallWithLoadIC(expr, property->key()); | |
3094 } else if (call_type == Call::NAMED_SUPER_PROPERTY_CALL) { | |
3095 EmitSuperCallWithLoadIC(expr); | |
3096 } else if (call_type == Call::KEYED_SUPER_PROPERTY_CALL) { | |
3097 EmitKeyedSuperCallWithLoadIC(expr); | |
3098 } else if (call_type == Call::SUPER_CALL) { | |
3099 EmitSuperConstructorCall(expr); | |
3100 } else { | |
3101 DCHECK(call_type == Call::OTHER_CALL); | |
3102 // Call to an arbitrary expression not handled specially above. | |
3103 VisitForStackValue(callee); | |
3104 __ LoadRoot(a1, Heap::kUndefinedValueRootIndex); | |
3105 __ push(a1); | |
3106 // Emit function call. | |
3107 EmitCall(expr); | |
3108 } | 3048 } |
3109 | 3049 |
3110 #ifdef DEBUG | 3050 // Push a copy of the function (found below the arguments) and |
3111 // RecordJSReturnSite should have been called. | 3051 // resolve eval. |
3112 DCHECK(expr->return_is_recorded_); | 3052 __ ld(a1, MemOperand(sp, (arg_count + 1) * kPointerSize)); |
3113 #endif | 3053 __ push(a1); |
| 3054 EmitResolvePossiblyDirectEval(arg_count); |
| 3055 |
| 3056 // Touch up the stack with the resolved function. |
| 3057 __ sd(v0, MemOperand(sp, (arg_count + 1) * kPointerSize)); |
| 3058 |
| 3059 PrepareForBailoutForId(expr->EvalId(), NO_REGISTERS); |
| 3060 // Record source position for debugger. |
| 3061 SetCallPosition(expr, arg_count); |
| 3062 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); |
| 3063 __ ld(a1, MemOperand(sp, (arg_count + 1) * kPointerSize)); |
| 3064 __ CallStub(&stub); |
| 3065 RecordJSReturnSite(expr); |
| 3066 // Restore context register. |
| 3067 __ ld(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 3068 context()->DropAndPlug(1, v0); |
3114 } | 3069 } |
3115 | 3070 |
3116 | 3071 |
3117 void FullCodeGenerator::VisitCallNew(CallNew* expr) { | 3072 void FullCodeGenerator::VisitCallNew(CallNew* expr) { |
3118 Comment cmnt(masm_, "[ CallNew"); | 3073 Comment cmnt(masm_, "[ CallNew"); |
3119 // According to ECMA-262, section 11.2.2, page 44, the function | 3074 // According to ECMA-262, section 11.2.2, page 44, the function |
3120 // expression in new calls must be evaluated before the | 3075 // expression in new calls must be evaluated before the |
3121 // arguments. | 3076 // arguments. |
3122 | 3077 |
3123 // Push constructor on the stack. If it's not a function it's used as | 3078 // Push constructor on the stack. If it's not a function it's used as |
(...skipping 2035 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5159 reinterpret_cast<uint64_t>( | 5114 reinterpret_cast<uint64_t>( |
5160 isolate->builtins()->OsrAfterStackCheck()->entry())); | 5115 isolate->builtins()->OsrAfterStackCheck()->entry())); |
5161 return OSR_AFTER_STACK_CHECK; | 5116 return OSR_AFTER_STACK_CHECK; |
5162 } | 5117 } |
5163 | 5118 |
5164 | 5119 |
5165 } // namespace internal | 5120 } // namespace internal |
5166 } // namespace v8 | 5121 } // namespace v8 |
5167 | 5122 |
5168 #endif // V8_TARGET_ARCH_MIPS64 | 5123 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |