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 2097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2108 __ ldr(load_receiver, MemOperand(sp, kPointerSize)); | 2108 __ ldr(load_receiver, MemOperand(sp, kPointerSize)); |
2109 __ ldr(load_name, MemOperand(sp, 2 * kPointerSize)); | 2109 __ ldr(load_name, MemOperand(sp, 2 * kPointerSize)); |
2110 __ mov(LoadDescriptor::SlotRegister(), | 2110 __ mov(LoadDescriptor::SlotRegister(), |
2111 Operand(SmiFromSlot(expr->KeyedLoadFeedbackSlot()))); | 2111 Operand(SmiFromSlot(expr->KeyedLoadFeedbackSlot()))); |
2112 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate(), SLOPPY).code(); | 2112 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate(), SLOPPY).code(); |
2113 CallIC(ic, TypeFeedbackId::None()); | 2113 CallIC(ic, TypeFeedbackId::None()); |
2114 __ mov(r1, r0); | 2114 __ mov(r1, r0); |
2115 __ str(r1, MemOperand(sp, 2 * kPointerSize)); | 2115 __ str(r1, MemOperand(sp, 2 * kPointerSize)); |
2116 SetCallPosition(expr, 1); | 2116 SetCallPosition(expr, 1); |
2117 __ mov(r0, Operand(1)); | 2117 __ mov(r0, Operand(1)); |
2118 __ Call(isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); | 2118 __ Call( |
| 2119 isolate()->builtins()->Call(ConvertReceiverMode::kNotNullOrUndefined), |
| 2120 RelocInfo::CODE_TARGET); |
2119 | 2121 |
2120 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 2122 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
2121 __ Drop(1); // The function is still on the stack; drop it. | 2123 __ Drop(1); // The function is still on the stack; drop it. |
2122 | 2124 |
2123 // if (!result.done) goto l_try; | 2125 // if (!result.done) goto l_try; |
2124 __ bind(&l_loop); | 2126 __ bind(&l_loop); |
2125 __ Move(load_receiver, r0); | 2127 __ Move(load_receiver, r0); |
2126 | 2128 |
2127 __ push(load_receiver); // save result | 2129 __ push(load_receiver); // save result |
2128 __ LoadRoot(load_name, Heap::kdone_stringRootIndex); // "done" | 2130 __ LoadRoot(load_name, Heap::kdone_stringRootIndex); // "done" |
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2801 __ Call(code, RelocInfo::CODE_TARGET, ast_id, al, | 2803 __ Call(code, RelocInfo::CODE_TARGET, ast_id, al, |
2802 NEVER_INLINE_TARGET_ADDRESS); | 2804 NEVER_INLINE_TARGET_ADDRESS); |
2803 } | 2805 } |
2804 | 2806 |
2805 | 2807 |
2806 // Code common for calls using the IC. | 2808 // Code common for calls using the IC. |
2807 void FullCodeGenerator::EmitCallWithLoadIC(Call* expr) { | 2809 void FullCodeGenerator::EmitCallWithLoadIC(Call* expr) { |
2808 Expression* callee = expr->expression(); | 2810 Expression* callee = expr->expression(); |
2809 | 2811 |
2810 // Get the target function. | 2812 // Get the target function. |
| 2813 ConvertReceiverMode convert_mode; |
2811 if (callee->IsVariableProxy()) { | 2814 if (callee->IsVariableProxy()) { |
2812 { StackValueContext context(this); | 2815 { StackValueContext context(this); |
2813 EmitVariableLoad(callee->AsVariableProxy()); | 2816 EmitVariableLoad(callee->AsVariableProxy()); |
2814 PrepareForBailout(callee, NO_REGISTERS); | 2817 PrepareForBailout(callee, NO_REGISTERS); |
2815 } | 2818 } |
2816 // Push undefined as receiver. This is patched in the method prologue if it | 2819 // Push undefined as receiver. This is patched in the method prologue if it |
2817 // is a sloppy mode method. | 2820 // is a sloppy mode method. |
2818 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); | 2821 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); |
2819 __ push(ip); | 2822 __ push(ip); |
| 2823 convert_mode = ConvertReceiverMode::kNullOrUndefined; |
2820 } else { | 2824 } else { |
2821 // Load the function from the receiver. | 2825 // Load the function from the receiver. |
2822 DCHECK(callee->IsProperty()); | 2826 DCHECK(callee->IsProperty()); |
2823 DCHECK(!callee->AsProperty()->IsSuperAccess()); | 2827 DCHECK(!callee->AsProperty()->IsSuperAccess()); |
2824 __ ldr(LoadDescriptor::ReceiverRegister(), MemOperand(sp, 0)); | 2828 __ ldr(LoadDescriptor::ReceiverRegister(), MemOperand(sp, 0)); |
2825 EmitNamedPropertyLoad(callee->AsProperty()); | 2829 EmitNamedPropertyLoad(callee->AsProperty()); |
2826 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); | 2830 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); |
2827 // Push the target function under the receiver. | 2831 // Push the target function under the receiver. |
2828 __ ldr(ip, MemOperand(sp, 0)); | 2832 __ ldr(ip, MemOperand(sp, 0)); |
2829 __ push(ip); | 2833 __ push(ip); |
2830 __ str(r0, MemOperand(sp, kPointerSize)); | 2834 __ str(r0, MemOperand(sp, kPointerSize)); |
| 2835 convert_mode = ConvertReceiverMode::kNotNullOrUndefined; |
2831 } | 2836 } |
2832 | 2837 |
2833 EmitCall(expr); | 2838 EmitCall(expr, convert_mode); |
2834 } | 2839 } |
2835 | 2840 |
2836 | 2841 |
2837 void FullCodeGenerator::EmitSuperCallWithLoadIC(Call* expr) { | 2842 void FullCodeGenerator::EmitSuperCallWithLoadIC(Call* expr) { |
2838 Expression* callee = expr->expression(); | 2843 Expression* callee = expr->expression(); |
2839 DCHECK(callee->IsProperty()); | 2844 DCHECK(callee->IsProperty()); |
2840 Property* prop = callee->AsProperty(); | 2845 Property* prop = callee->AsProperty(); |
2841 DCHECK(prop->IsSuperAccess()); | 2846 DCHECK(prop->IsSuperAccess()); |
2842 SetExpressionPosition(prop); | 2847 SetExpressionPosition(prop); |
2843 | 2848 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2887 __ ldr(LoadDescriptor::ReceiverRegister(), MemOperand(sp, 0)); | 2892 __ ldr(LoadDescriptor::ReceiverRegister(), MemOperand(sp, 0)); |
2888 __ Move(LoadDescriptor::NameRegister(), r0); | 2893 __ Move(LoadDescriptor::NameRegister(), r0); |
2889 EmitKeyedPropertyLoad(callee->AsProperty()); | 2894 EmitKeyedPropertyLoad(callee->AsProperty()); |
2890 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); | 2895 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); |
2891 | 2896 |
2892 // Push the target function under the receiver. | 2897 // Push the target function under the receiver. |
2893 __ ldr(ip, MemOperand(sp, 0)); | 2898 __ ldr(ip, MemOperand(sp, 0)); |
2894 __ push(ip); | 2899 __ push(ip); |
2895 __ str(r0, MemOperand(sp, kPointerSize)); | 2900 __ str(r0, MemOperand(sp, kPointerSize)); |
2896 | 2901 |
2897 EmitCall(expr); | 2902 EmitCall(expr, ConvertReceiverMode::kNotNullOrUndefined); |
2898 } | 2903 } |
2899 | 2904 |
2900 | 2905 |
2901 void FullCodeGenerator::EmitKeyedSuperCallWithLoadIC(Call* expr) { | 2906 void FullCodeGenerator::EmitKeyedSuperCallWithLoadIC(Call* expr) { |
2902 Expression* callee = expr->expression(); | 2907 Expression* callee = expr->expression(); |
2903 DCHECK(callee->IsProperty()); | 2908 DCHECK(callee->IsProperty()); |
2904 Property* prop = callee->AsProperty(); | 2909 Property* prop = callee->AsProperty(); |
2905 DCHECK(prop->IsSuperAccess()); | 2910 DCHECK(prop->IsSuperAccess()); |
2906 | 2911 |
2907 SetExpressionPosition(prop); | 2912 SetExpressionPosition(prop); |
(...skipping 21 matching lines...) Expand all Loading... |
2929 // Replace home_object with target function. | 2934 // Replace home_object with target function. |
2930 __ str(r0, MemOperand(sp, kPointerSize)); | 2935 __ str(r0, MemOperand(sp, kPointerSize)); |
2931 | 2936 |
2932 // Stack here: | 2937 // Stack here: |
2933 // - target function | 2938 // - target function |
2934 // - this (receiver) | 2939 // - this (receiver) |
2935 EmitCall(expr); | 2940 EmitCall(expr); |
2936 } | 2941 } |
2937 | 2942 |
2938 | 2943 |
2939 void FullCodeGenerator::EmitCall(Call* expr) { | 2944 void FullCodeGenerator::EmitCall(Call* expr, ConvertReceiverMode mode) { |
2940 // Load the arguments. | 2945 // Load the arguments. |
2941 ZoneList<Expression*>* args = expr->arguments(); | 2946 ZoneList<Expression*>* args = expr->arguments(); |
2942 int arg_count = args->length(); | 2947 int arg_count = args->length(); |
2943 for (int i = 0; i < arg_count; i++) { | 2948 for (int i = 0; i < arg_count; i++) { |
2944 VisitForStackValue(args->at(i)); | 2949 VisitForStackValue(args->at(i)); |
2945 } | 2950 } |
2946 | 2951 |
2947 PrepareForBailoutForId(expr->CallId(), NO_REGISTERS); | 2952 PrepareForBailoutForId(expr->CallId(), NO_REGISTERS); |
2948 SetCallPosition(expr, arg_count); | 2953 SetCallPosition(expr, arg_count); |
2949 Handle<Code> ic = CodeFactory::CallIC(isolate(), arg_count).code(); | 2954 Handle<Code> ic = CodeFactory::CallIC(isolate(), arg_count, mode).code(); |
2950 __ mov(r3, Operand(SmiFromSlot(expr->CallFeedbackICSlot()))); | 2955 __ mov(r3, Operand(SmiFromSlot(expr->CallFeedbackICSlot()))); |
2951 __ ldr(r1, MemOperand(sp, (arg_count + 1) * kPointerSize)); | 2956 __ ldr(r1, MemOperand(sp, (arg_count + 1) * kPointerSize)); |
2952 // Don't assign a type feedback id to the IC, since type feedback is provided | 2957 // Don't assign a type feedback id to the IC, since type feedback is provided |
2953 // by the vector above. | 2958 // by the vector above. |
2954 CallIC(ic); | 2959 CallIC(ic); |
2955 | 2960 |
2956 RecordJSReturnSite(expr); | 2961 RecordJSReturnSite(expr); |
2957 // Restore context register. | 2962 // Restore context register. |
2958 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 2963 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
2959 context()->DropAndPlug(1, r0); | 2964 context()->DropAndPlug(1, r0); |
(...skipping 1258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4218 } | 4223 } |
4219 | 4224 |
4220 | 4225 |
4221 void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) { | 4226 void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) { |
4222 ZoneList<Expression*>* args = expr->arguments(); | 4227 ZoneList<Expression*>* args = expr->arguments(); |
4223 int arg_count = args->length(); | 4228 int arg_count = args->length(); |
4224 | 4229 |
4225 SetCallPosition(expr, arg_count); | 4230 SetCallPosition(expr, arg_count); |
4226 __ ldr(r1, MemOperand(sp, (arg_count + 1) * kPointerSize)); | 4231 __ ldr(r1, MemOperand(sp, (arg_count + 1) * kPointerSize)); |
4227 __ mov(r0, Operand(arg_count)); | 4232 __ mov(r0, Operand(arg_count)); |
4228 __ Call(isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); | 4233 __ Call(isolate()->builtins()->Call(ConvertReceiverMode::kNullOrUndefined), |
| 4234 RelocInfo::CODE_TARGET); |
4229 } | 4235 } |
4230 | 4236 |
4231 | 4237 |
4232 void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) { | 4238 void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) { |
4233 ZoneList<Expression*>* args = expr->arguments(); | 4239 ZoneList<Expression*>* args = expr->arguments(); |
4234 int arg_count = args->length(); | 4240 int arg_count = args->length(); |
4235 | 4241 |
4236 if (expr->is_jsruntime()) { | 4242 if (expr->is_jsruntime()) { |
4237 Comment cmnt(masm_, "[ CallRuntime"); | 4243 Comment cmnt(masm_, "[ CallRuntime"); |
4238 EmitLoadJSRuntimeFunction(expr); | 4244 EmitLoadJSRuntimeFunction(expr); |
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5085 DCHECK(interrupt_address == | 5091 DCHECK(interrupt_address == |
5086 isolate->builtins()->OsrAfterStackCheck()->entry()); | 5092 isolate->builtins()->OsrAfterStackCheck()->entry()); |
5087 return OSR_AFTER_STACK_CHECK; | 5093 return OSR_AFTER_STACK_CHECK; |
5088 } | 5094 } |
5089 | 5095 |
5090 | 5096 |
5091 } // namespace internal | 5097 } // namespace internal |
5092 } // namespace v8 | 5098 } // namespace v8 |
5093 | 5099 |
5094 #endif // V8_TARGET_ARCH_ARM | 5100 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |