| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_PPC | 5 #if V8_TARGET_ARCH_PPC |
| 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 2070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2081 __ bind(&l_call); | 2081 __ bind(&l_call); |
| 2082 __ LoadP(load_receiver, MemOperand(sp, kPointerSize)); | 2082 __ LoadP(load_receiver, MemOperand(sp, kPointerSize)); |
| 2083 __ LoadP(load_name, MemOperand(sp, 2 * kPointerSize)); | 2083 __ LoadP(load_name, MemOperand(sp, 2 * kPointerSize)); |
| 2084 __ mov(LoadDescriptor::SlotRegister(), | 2084 __ mov(LoadDescriptor::SlotRegister(), |
| 2085 Operand(SmiFromSlot(expr->KeyedLoadFeedbackSlot()))); | 2085 Operand(SmiFromSlot(expr->KeyedLoadFeedbackSlot()))); |
| 2086 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate(), SLOPPY).code(); | 2086 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate(), SLOPPY).code(); |
| 2087 CallIC(ic, TypeFeedbackId::None()); | 2087 CallIC(ic, TypeFeedbackId::None()); |
| 2088 __ mr(r4, r3); | 2088 __ mr(r4, r3); |
| 2089 __ StoreP(r4, MemOperand(sp, 2 * kPointerSize)); | 2089 __ StoreP(r4, MemOperand(sp, 2 * kPointerSize)); |
| 2090 SetCallPosition(expr, 1); | 2090 SetCallPosition(expr, 1); |
| 2091 CallFunctionStub stub(isolate(), 1, CALL_AS_METHOD); | 2091 __ li(r3, Operand(1)); |
| 2092 __ CallStub(&stub); | 2092 __ Call(isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
| 2093 | 2093 |
| 2094 __ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 2094 __ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 2095 __ Drop(1); // The function is still on the stack; drop it. | 2095 __ Drop(1); // The function is still on the stack; drop it. |
| 2096 | 2096 |
| 2097 // if (!result.done) goto l_try; | 2097 // if (!result.done) goto l_try; |
| 2098 __ Move(load_receiver, r3); | 2098 __ Move(load_receiver, r3); |
| 2099 | 2099 |
| 2100 __ push(load_receiver); // save result | 2100 __ push(load_receiver); // save result |
| 2101 __ LoadRoot(load_name, Heap::kdone_stringRootIndex); // "done" | 2101 __ LoadRoot(load_name, Heap::kdone_stringRootIndex); // "done" |
| 2102 __ mov(LoadDescriptor::SlotRegister(), | 2102 __ mov(LoadDescriptor::SlotRegister(), |
| (...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2807 void FullCodeGenerator::CallIC(Handle<Code> code, TypeFeedbackId ast_id) { | 2807 void FullCodeGenerator::CallIC(Handle<Code> code, TypeFeedbackId ast_id) { |
| 2808 ic_total_count_++; | 2808 ic_total_count_++; |
| 2809 __ Call(code, RelocInfo::CODE_TARGET, ast_id); | 2809 __ Call(code, RelocInfo::CODE_TARGET, ast_id); |
| 2810 } | 2810 } |
| 2811 | 2811 |
| 2812 | 2812 |
| 2813 // Code common for calls using the IC. | 2813 // Code common for calls using the IC. |
| 2814 void FullCodeGenerator::EmitCallWithLoadIC(Call* expr) { | 2814 void FullCodeGenerator::EmitCallWithLoadIC(Call* expr) { |
| 2815 Expression* callee = expr->expression(); | 2815 Expression* callee = expr->expression(); |
| 2816 | 2816 |
| 2817 CallICState::CallType call_type = | |
| 2818 callee->IsVariableProxy() ? CallICState::FUNCTION : CallICState::METHOD; | |
| 2819 | |
| 2820 // Get the target function. | 2817 // Get the target function. |
| 2821 if (call_type == CallICState::FUNCTION) { | 2818 if (callee->IsVariableProxy()) { |
| 2822 { | 2819 { |
| 2823 StackValueContext context(this); | 2820 StackValueContext context(this); |
| 2824 EmitVariableLoad(callee->AsVariableProxy()); | 2821 EmitVariableLoad(callee->AsVariableProxy()); |
| 2825 PrepareForBailout(callee, NO_REGISTERS); | 2822 PrepareForBailout(callee, NO_REGISTERS); |
| 2826 } | 2823 } |
| 2827 // Push undefined as receiver. This is patched in the method prologue if it | 2824 // Push undefined as receiver. This is patched in the method prologue if it |
| 2828 // is a sloppy mode method. | 2825 // is a sloppy mode method. |
| 2829 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); | 2826 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); |
| 2830 __ push(r0); | 2827 __ push(r0); |
| 2831 } else { | 2828 } else { |
| 2832 // Load the function from the receiver. | 2829 // Load the function from the receiver. |
| 2833 DCHECK(callee->IsProperty()); | 2830 DCHECK(callee->IsProperty()); |
| 2834 DCHECK(!callee->AsProperty()->IsSuperAccess()); | 2831 DCHECK(!callee->AsProperty()->IsSuperAccess()); |
| 2835 __ LoadP(LoadDescriptor::ReceiverRegister(), MemOperand(sp, 0)); | 2832 __ LoadP(LoadDescriptor::ReceiverRegister(), MemOperand(sp, 0)); |
| 2836 EmitNamedPropertyLoad(callee->AsProperty()); | 2833 EmitNamedPropertyLoad(callee->AsProperty()); |
| 2837 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); | 2834 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); |
| 2838 // Push the target function under the receiver. | 2835 // Push the target function under the receiver. |
| 2839 __ LoadP(r0, MemOperand(sp, 0)); | 2836 __ LoadP(r0, MemOperand(sp, 0)); |
| 2840 __ push(r0); | 2837 __ push(r0); |
| 2841 __ StoreP(r3, MemOperand(sp, kPointerSize)); | 2838 __ StoreP(r3, MemOperand(sp, kPointerSize)); |
| 2842 } | 2839 } |
| 2843 | 2840 |
| 2844 EmitCall(expr, call_type); | 2841 EmitCall(expr); |
| 2845 } | 2842 } |
| 2846 | 2843 |
| 2847 | 2844 |
| 2848 void FullCodeGenerator::EmitSuperCallWithLoadIC(Call* expr) { | 2845 void FullCodeGenerator::EmitSuperCallWithLoadIC(Call* expr) { |
| 2849 Expression* callee = expr->expression(); | 2846 Expression* callee = expr->expression(); |
| 2850 DCHECK(callee->IsProperty()); | 2847 DCHECK(callee->IsProperty()); |
| 2851 Property* prop = callee->AsProperty(); | 2848 Property* prop = callee->AsProperty(); |
| 2852 DCHECK(prop->IsSuperAccess()); | 2849 DCHECK(prop->IsSuperAccess()); |
| 2853 SetExpressionPosition(prop); | 2850 SetExpressionPosition(prop); |
| 2854 | 2851 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2872 // - key | 2869 // - key |
| 2873 // - language_mode | 2870 // - language_mode |
| 2874 __ CallRuntime(Runtime::kLoadFromSuper, 4); | 2871 __ CallRuntime(Runtime::kLoadFromSuper, 4); |
| 2875 | 2872 |
| 2876 // Replace home_object with target function. | 2873 // Replace home_object with target function. |
| 2877 __ StoreP(r3, MemOperand(sp, kPointerSize)); | 2874 __ StoreP(r3, MemOperand(sp, kPointerSize)); |
| 2878 | 2875 |
| 2879 // Stack here: | 2876 // Stack here: |
| 2880 // - target function | 2877 // - target function |
| 2881 // - this (receiver) | 2878 // - this (receiver) |
| 2882 EmitCall(expr, CallICState::METHOD); | 2879 EmitCall(expr); |
| 2883 } | 2880 } |
| 2884 | 2881 |
| 2885 | 2882 |
| 2886 // Code common for calls using the IC. | 2883 // Code common for calls using the IC. |
| 2887 void FullCodeGenerator::EmitKeyedCallWithLoadIC(Call* expr, Expression* key) { | 2884 void FullCodeGenerator::EmitKeyedCallWithLoadIC(Call* expr, Expression* key) { |
| 2888 // Load the key. | 2885 // Load the key. |
| 2889 VisitForAccumulatorValue(key); | 2886 VisitForAccumulatorValue(key); |
| 2890 | 2887 |
| 2891 Expression* callee = expr->expression(); | 2888 Expression* callee = expr->expression(); |
| 2892 | 2889 |
| 2893 // Load the function from the receiver. | 2890 // Load the function from the receiver. |
| 2894 DCHECK(callee->IsProperty()); | 2891 DCHECK(callee->IsProperty()); |
| 2895 __ LoadP(LoadDescriptor::ReceiverRegister(), MemOperand(sp, 0)); | 2892 __ LoadP(LoadDescriptor::ReceiverRegister(), MemOperand(sp, 0)); |
| 2896 __ Move(LoadDescriptor::NameRegister(), r3); | 2893 __ Move(LoadDescriptor::NameRegister(), r3); |
| 2897 EmitKeyedPropertyLoad(callee->AsProperty()); | 2894 EmitKeyedPropertyLoad(callee->AsProperty()); |
| 2898 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); | 2895 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); |
| 2899 | 2896 |
| 2900 // Push the target function under the receiver. | 2897 // Push the target function under the receiver. |
| 2901 __ LoadP(ip, MemOperand(sp, 0)); | 2898 __ LoadP(ip, MemOperand(sp, 0)); |
| 2902 __ push(ip); | 2899 __ push(ip); |
| 2903 __ StoreP(r3, MemOperand(sp, kPointerSize)); | 2900 __ StoreP(r3, MemOperand(sp, kPointerSize)); |
| 2904 | 2901 |
| 2905 EmitCall(expr, CallICState::METHOD); | 2902 EmitCall(expr); |
| 2906 } | 2903 } |
| 2907 | 2904 |
| 2908 | 2905 |
| 2909 void FullCodeGenerator::EmitKeyedSuperCallWithLoadIC(Call* expr) { | 2906 void FullCodeGenerator::EmitKeyedSuperCallWithLoadIC(Call* expr) { |
| 2910 Expression* callee = expr->expression(); | 2907 Expression* callee = expr->expression(); |
| 2911 DCHECK(callee->IsProperty()); | 2908 DCHECK(callee->IsProperty()); |
| 2912 Property* prop = callee->AsProperty(); | 2909 Property* prop = callee->AsProperty(); |
| 2913 DCHECK(prop->IsSuperAccess()); | 2910 DCHECK(prop->IsSuperAccess()); |
| 2914 | 2911 |
| 2915 SetExpressionPosition(prop); | 2912 SetExpressionPosition(prop); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2931 // - key | 2928 // - key |
| 2932 // - language_mode | 2929 // - language_mode |
| 2933 __ CallRuntime(Runtime::kLoadKeyedFromSuper, 4); | 2930 __ CallRuntime(Runtime::kLoadKeyedFromSuper, 4); |
| 2934 | 2931 |
| 2935 // Replace home_object with target function. | 2932 // Replace home_object with target function. |
| 2936 __ StoreP(r3, MemOperand(sp, kPointerSize)); | 2933 __ StoreP(r3, MemOperand(sp, kPointerSize)); |
| 2937 | 2934 |
| 2938 // Stack here: | 2935 // Stack here: |
| 2939 // - target function | 2936 // - target function |
| 2940 // - this (receiver) | 2937 // - this (receiver) |
| 2941 EmitCall(expr, CallICState::METHOD); | 2938 EmitCall(expr); |
| 2942 } | 2939 } |
| 2943 | 2940 |
| 2944 | 2941 |
| 2945 void FullCodeGenerator::EmitCall(Call* expr, CallICState::CallType call_type) { | 2942 void FullCodeGenerator::EmitCall(Call* expr) { |
| 2946 // Load the arguments. | 2943 // Load the arguments. |
| 2947 ZoneList<Expression*>* args = expr->arguments(); | 2944 ZoneList<Expression*>* args = expr->arguments(); |
| 2948 int arg_count = args->length(); | 2945 int arg_count = args->length(); |
| 2949 for (int i = 0; i < arg_count; i++) { | 2946 for (int i = 0; i < arg_count; i++) { |
| 2950 VisitForStackValue(args->at(i)); | 2947 VisitForStackValue(args->at(i)); |
| 2951 } | 2948 } |
| 2952 | 2949 |
| 2953 PrepareForBailoutForId(expr->CallId(), NO_REGISTERS); | 2950 PrepareForBailoutForId(expr->CallId(), NO_REGISTERS); |
| 2954 SetCallPosition(expr, arg_count); | 2951 SetCallPosition(expr, arg_count); |
| 2955 Handle<Code> ic = CodeFactory::CallIC(isolate(), arg_count, call_type).code(); | 2952 Handle<Code> ic = CodeFactory::CallIC(isolate(), arg_count).code(); |
| 2956 __ LoadSmiLiteral(r6, SmiFromSlot(expr->CallFeedbackICSlot())); | 2953 __ LoadSmiLiteral(r6, SmiFromSlot(expr->CallFeedbackICSlot())); |
| 2957 __ LoadP(r4, MemOperand(sp, (arg_count + 1) * kPointerSize), r0); | 2954 __ LoadP(r4, MemOperand(sp, (arg_count + 1) * kPointerSize), r0); |
| 2958 // Don't assign a type feedback id to the IC, since type feedback is provided | 2955 // Don't assign a type feedback id to the IC, since type feedback is provided |
| 2959 // by the vector above. | 2956 // by the vector above. |
| 2960 CallIC(ic); | 2957 CallIC(ic); |
| 2961 | 2958 |
| 2962 RecordJSReturnSite(expr); | 2959 RecordJSReturnSite(expr); |
| 2963 // Restore context register. | 2960 // Restore context register. |
| 2964 __ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 2961 __ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 2965 context()->DropAndPlug(1, r3); | 2962 context()->DropAndPlug(1, r3); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3053 __ push(r4); | 3050 __ push(r4); |
| 3054 EmitResolvePossiblyDirectEval(arg_count); | 3051 EmitResolvePossiblyDirectEval(arg_count); |
| 3055 | 3052 |
| 3056 // Touch up the stack with the resolved function. | 3053 // Touch up the stack with the resolved function. |
| 3057 __ StoreP(r3, MemOperand(sp, (arg_count + 1) * kPointerSize), r0); | 3054 __ StoreP(r3, MemOperand(sp, (arg_count + 1) * kPointerSize), r0); |
| 3058 | 3055 |
| 3059 PrepareForBailoutForId(expr->EvalId(), NO_REGISTERS); | 3056 PrepareForBailoutForId(expr->EvalId(), NO_REGISTERS); |
| 3060 | 3057 |
| 3061 // Record source position for debugger. | 3058 // Record source position for debugger. |
| 3062 SetCallPosition(expr, arg_count); | 3059 SetCallPosition(expr, arg_count); |
| 3063 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); | |
| 3064 __ LoadP(r4, MemOperand(sp, (arg_count + 1) * kPointerSize), r0); | 3060 __ LoadP(r4, MemOperand(sp, (arg_count + 1) * kPointerSize), r0); |
| 3065 __ CallStub(&stub); | 3061 __ mov(r3, Operand(arg_count)); |
| 3062 __ Call(isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
| 3066 RecordJSReturnSite(expr); | 3063 RecordJSReturnSite(expr); |
| 3067 // Restore context register. | 3064 // Restore context register. |
| 3068 __ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 3065 __ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 3069 context()->DropAndPlug(1, r3); | 3066 context()->DropAndPlug(1, r3); |
| 3070 } | 3067 } |
| 3071 | 3068 |
| 3072 | 3069 |
| 3073 void FullCodeGenerator::VisitCallNew(CallNew* expr) { | 3070 void FullCodeGenerator::VisitCallNew(CallNew* expr) { |
| 3074 Comment cmnt(masm_, "[ CallNew"); | 3071 Comment cmnt(masm_, "[ CallNew"); |
| 3075 // According to ECMA-262, section 11.2.2, page 44, the function | 3072 // According to ECMA-262, section 11.2.2, page 44, the function |
| (...skipping 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4252 __ LoadP(r3, FieldMemOperand(r3, JSGlobalObject::kNativeContextOffset)); | 4249 __ LoadP(r3, FieldMemOperand(r3, JSGlobalObject::kNativeContextOffset)); |
| 4253 __ LoadP(r3, ContextOperand(r3, expr->context_index())); | 4250 __ LoadP(r3, ContextOperand(r3, expr->context_index())); |
| 4254 } | 4251 } |
| 4255 | 4252 |
| 4256 | 4253 |
| 4257 void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) { | 4254 void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) { |
| 4258 ZoneList<Expression*>* args = expr->arguments(); | 4255 ZoneList<Expression*>* args = expr->arguments(); |
| 4259 int arg_count = args->length(); | 4256 int arg_count = args->length(); |
| 4260 | 4257 |
| 4261 SetCallPosition(expr, arg_count); | 4258 SetCallPosition(expr, arg_count); |
| 4262 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); | |
| 4263 __ LoadP(r4, MemOperand(sp, (arg_count + 1) * kPointerSize), r0); | 4259 __ LoadP(r4, MemOperand(sp, (arg_count + 1) * kPointerSize), r0); |
| 4264 __ CallStub(&stub); | 4260 __ mov(r3, Operand(arg_count)); |
| 4261 __ Call(isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
| 4265 } | 4262 } |
| 4266 | 4263 |
| 4267 | 4264 |
| 4268 void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) { | 4265 void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) { |
| 4269 ZoneList<Expression*>* args = expr->arguments(); | 4266 ZoneList<Expression*>* args = expr->arguments(); |
| 4270 int arg_count = args->length(); | 4267 int arg_count = args->length(); |
| 4271 | 4268 |
| 4272 if (expr->is_jsruntime()) { | 4269 if (expr->is_jsruntime()) { |
| 4273 Comment cmnt(masm_, "[ CallRuntime"); | 4270 Comment cmnt(masm_, "[ CallRuntime"); |
| 4274 EmitLoadJSRuntimeFunction(expr); | 4271 EmitLoadJSRuntimeFunction(expr); |
| (...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5049 return ON_STACK_REPLACEMENT; | 5046 return ON_STACK_REPLACEMENT; |
| 5050 } | 5047 } |
| 5051 | 5048 |
| 5052 DCHECK(interrupt_address == | 5049 DCHECK(interrupt_address == |
| 5053 isolate->builtins()->OsrAfterStackCheck()->entry()); | 5050 isolate->builtins()->OsrAfterStackCheck()->entry()); |
| 5054 return OSR_AFTER_STACK_CHECK; | 5051 return OSR_AFTER_STACK_CHECK; |
| 5055 } | 5052 } |
| 5056 } // namespace internal | 5053 } // namespace internal |
| 5057 } // namespace v8 | 5054 } // namespace v8 |
| 5058 #endif // V8_TARGET_ARCH_PPC | 5055 #endif // V8_TARGET_ARCH_PPC |
| OLD | NEW |