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_ARM | 5 #if V8_TARGET_ARCH_ARM |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
10 #include "src/debug/debug.h" | 10 #include "src/debug/debug.h" |
(...skipping 3022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3033 } | 3033 } |
3034 } else { | 3034 } else { |
3035 VisitForStackValue(callee); | 3035 VisitForStackValue(callee); |
3036 // refEnv.WithBaseObject() | 3036 // refEnv.WithBaseObject() |
3037 __ LoadRoot(r2, Heap::kUndefinedValueRootIndex); | 3037 __ LoadRoot(r2, Heap::kUndefinedValueRootIndex); |
3038 __ push(r2); // Reserved receiver slot. | 3038 __ push(r2); // Reserved receiver slot. |
3039 } | 3039 } |
3040 } | 3040 } |
3041 | 3041 |
3042 | 3042 |
3043 void FullCodeGenerator::VisitCall(Call* expr) { | 3043 void FullCodeGenerator::EmitPossiblyEvalCall(Call* expr) { |
3044 #ifdef DEBUG | 3044 // In a call to eval, we first call |
3045 // We want to verify that RecordJSReturnSite gets called on all paths | 3045 // RuntimeHidden_asResolvePossiblyDirectEval to resolve the function we need |
3046 // through this function. Avoid early returns. | 3046 // to call. Then we call the resolved function using the given arguments. |
3047 expr->return_is_recorded_ = false; | 3047 ZoneList<Expression*>* args = expr->arguments(); |
3048 #endif | 3048 int arg_count = args->length(); |
3049 | 3049 |
3050 Comment cmnt(masm_, "[ Call"); | 3050 PushCalleeAndWithBaseObject(expr); |
3051 Expression* callee = expr->expression(); | |
3052 Call::CallType call_type = expr->GetCallType(isolate()); | |
3053 | 3051 |
3054 if (call_type == Call::POSSIBLY_EVAL_CALL) { | 3052 // Push the arguments. |
3055 // In a call to eval, we first call | 3053 for (int i = 0; i < arg_count; i++) { |
3056 // RuntimeHidden_asResolvePossiblyDirectEval to resolve the function we need | 3054 VisitForStackValue(args->at(i)); |
3057 // to call. Then we call the resolved function using the given arguments. | |
3058 ZoneList<Expression*>* args = expr->arguments(); | |
3059 int arg_count = args->length(); | |
3060 | |
3061 PushCalleeAndWithBaseObject(expr); | |
3062 | |
3063 // Push the arguments. | |
3064 for (int i = 0; i < arg_count; i++) { | |
3065 VisitForStackValue(args->at(i)); | |
3066 } | |
3067 | |
3068 // Push a copy of the function (found below the arguments) and | |
3069 // resolve eval. | |
3070 __ ldr(r1, MemOperand(sp, (arg_count + 1) * kPointerSize)); | |
3071 __ push(r1); | |
3072 EmitResolvePossiblyDirectEval(arg_count); | |
3073 | |
3074 // Touch up the stack with the resolved function. | |
3075 __ str(r0, MemOperand(sp, (arg_count + 1) * kPointerSize)); | |
3076 | |
3077 PrepareForBailoutForId(expr->EvalId(), NO_REGISTERS); | |
3078 | |
3079 // Record source position for debugger. | |
3080 SetCallPosition(expr, arg_count); | |
3081 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); | |
3082 __ ldr(r1, MemOperand(sp, (arg_count + 1) * kPointerSize)); | |
3083 __ CallStub(&stub); | |
3084 RecordJSReturnSite(expr); | |
3085 // Restore context register. | |
3086 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | |
3087 context()->DropAndPlug(1, r0); | |
3088 } else if (call_type == Call::GLOBAL_CALL) { | |
3089 EmitCallWithLoadIC(expr); | |
3090 | |
3091 } else if (call_type == Call::LOOKUP_SLOT_CALL) { | |
3092 // Call to a lookup slot (dynamically introduced variable). | |
3093 PushCalleeAndWithBaseObject(expr); | |
3094 EmitCall(expr); | |
3095 } else if (call_type == Call::NAMED_PROPERTY_CALL) { | |
3096 Property* property = callee->AsProperty(); | |
3097 VisitForStackValue(property->obj()); | |
3098 EmitCallWithLoadIC(expr); | |
3099 } else if (call_type == Call::KEYED_PROPERTY_CALL) { | |
3100 Property* property = callee->AsProperty(); | |
3101 VisitForStackValue(property->obj()); | |
3102 EmitKeyedCallWithLoadIC(expr, property->key()); | |
3103 } else if (call_type == Call::NAMED_SUPER_PROPERTY_CALL) { | |
3104 EmitSuperCallWithLoadIC(expr); | |
3105 } else if (call_type == Call::KEYED_SUPER_PROPERTY_CALL) { | |
3106 EmitKeyedSuperCallWithLoadIC(expr); | |
3107 } else if (call_type == Call::SUPER_CALL) { | |
3108 EmitSuperConstructorCall(expr); | |
3109 } else { | |
3110 DCHECK(call_type == Call::OTHER_CALL); | |
3111 // Call to an arbitrary expression not handled specially above. | |
3112 VisitForStackValue(callee); | |
3113 __ LoadRoot(r1, Heap::kUndefinedValueRootIndex); | |
3114 __ push(r1); | |
3115 // Emit function call. | |
3116 EmitCall(expr); | |
3117 } | 3055 } |
3118 | 3056 |
3119 #ifdef DEBUG | 3057 // Push a copy of the function (found below the arguments) and |
3120 // RecordJSReturnSite should have been called. | 3058 // resolve eval. |
3121 DCHECK(expr->return_is_recorded_); | 3059 __ ldr(r1, MemOperand(sp, (arg_count + 1) * kPointerSize)); |
3122 #endif | 3060 __ push(r1); |
| 3061 EmitResolvePossiblyDirectEval(arg_count); |
| 3062 |
| 3063 // Touch up the stack with the resolved function. |
| 3064 __ str(r0, MemOperand(sp, (arg_count + 1) * kPointerSize)); |
| 3065 |
| 3066 PrepareForBailoutForId(expr->EvalId(), NO_REGISTERS); |
| 3067 |
| 3068 // Record source position for debugger. |
| 3069 SetCallPosition(expr, arg_count); |
| 3070 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); |
| 3071 __ ldr(r1, MemOperand(sp, (arg_count + 1) * kPointerSize)); |
| 3072 __ CallStub(&stub); |
| 3073 RecordJSReturnSite(expr); |
| 3074 // Restore context register. |
| 3075 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 3076 context()->DropAndPlug(1, r0); |
3123 } | 3077 } |
3124 | 3078 |
3125 | 3079 |
3126 void FullCodeGenerator::VisitCallNew(CallNew* expr) { | 3080 void FullCodeGenerator::VisitCallNew(CallNew* expr) { |
3127 Comment cmnt(masm_, "[ CallNew"); | 3081 Comment cmnt(masm_, "[ CallNew"); |
3128 // According to ECMA-262, section 11.2.2, page 44, the function | 3082 // According to ECMA-262, section 11.2.2, page 44, the function |
3129 // expression in new calls must be evaluated before the | 3083 // expression in new calls must be evaluated before the |
3130 // arguments. | 3084 // arguments. |
3131 | 3085 |
3132 // Push constructor on the stack. If it's not a function it's used as | 3086 // Push constructor on the stack. If it's not a function it's used as |
(...skipping 2057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5190 DCHECK(interrupt_address == | 5144 DCHECK(interrupt_address == |
5191 isolate->builtins()->OsrAfterStackCheck()->entry()); | 5145 isolate->builtins()->OsrAfterStackCheck()->entry()); |
5192 return OSR_AFTER_STACK_CHECK; | 5146 return OSR_AFTER_STACK_CHECK; |
5193 } | 5147 } |
5194 | 5148 |
5195 | 5149 |
5196 } // namespace internal | 5150 } // namespace internal |
5197 } // namespace v8 | 5151 } // namespace v8 |
5198 | 5152 |
5199 #endif // V8_TARGET_ARCH_ARM | 5153 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |