Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(764)

Side by Side Diff: src/arm/code-stubs-arm.cc

Issue 172523002: Create a function call IC (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/arm/builtins-arm.cc ('k') | src/arm/debug-arm.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2959 matching lines...) Expand 10 before | Expand all | Expand 10 after
2970 2970
2971 __ Push(r4, r2, r1); 2971 __ Push(r4, r2, r1);
2972 __ RecordWrite(r2, r4, r1, kLRHasNotBeenSaved, kDontSaveFPRegs, 2972 __ RecordWrite(r2, r4, r1, kLRHasNotBeenSaved, kDontSaveFPRegs,
2973 EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); 2973 EMIT_REMEMBERED_SET, OMIT_SMI_CHECK);
2974 __ Pop(r4, r2, r1); 2974 __ Pop(r4, r2, r1);
2975 2975
2976 __ bind(&done); 2976 __ bind(&done);
2977 } 2977 }
2978 2978
2979 2979
2980 void CallFunctionStub::Generate(MacroAssembler* masm) { 2980 static void GenericCallHelper(MacroAssembler* masm,
2981 const CallIC::State& state) {
2981 // r1 : the function to call 2982 // r1 : the function to call
2982 // r2 : feedback vector
2983 // r3 : (only if r2 is not the megamorphic symbol) slot in feedback
2984 // vector (Smi)
2985 Label slow, non_function, wrap, cont; 2983 Label slow, non_function, wrap, cont;
2986 2984
2987 if (NeedsChecks()) { 2985 if (state.IsGeneric()) {
2988 // Check that the function is really a JavaScript function. 2986 // Check that the function is really a JavaScript function.
2989 // r1: pushed function (to be verified) 2987 // r1: pushed function (to be verified)
2990 __ JumpIfSmi(r1, &non_function); 2988 __ JumpIfSmi(r1, &non_function);
2991 2989
2992 // Goto slow case if we do not have a function. 2990 // Goto slow case if we do not have a function.
2993 __ CompareObjectType(r1, r4, r4, JS_FUNCTION_TYPE); 2991 __ CompareObjectType(r1, r4, r4, JS_FUNCTION_TYPE);
2994 __ b(ne, &slow); 2992 __ b(ne, &slow);
2995
2996 if (RecordCallTarget()) {
2997 GenerateRecordCallTarget(masm);
2998 // Type information was updated. Because we may call Array, which
2999 // expects either undefined or an AllocationSite in ebx we need
3000 // to set ebx to undefined.
3001 __ LoadRoot(r2, Heap::kUndefinedValueRootIndex);
3002 }
3003 } 2993 }
3004 2994
3005 // Fast-case: Invoke the function now. 2995 // Fast-case: Invoke the function now.
3006 // r1: pushed function 2996 // r1: pushed function
3007 ParameterCount actual(argc_); 2997 int argc = state.arg_count();
2998 ParameterCount actual(argc);
3008 2999
3009 if (CallAsMethod()) { 3000 if (state.CallAsMethod()) {
3010 if (NeedsChecks()) { 3001 if (state.IsGeneric()) {
3011 // Do not transform the receiver for strict mode functions. 3002 // Do not transform the receiver for strict mode functions.
3012 __ ldr(r3, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); 3003 __ ldr(r3, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset));
3013 __ ldr(r4, FieldMemOperand(r3, SharedFunctionInfo::kCompilerHintsOffset)); 3004 __ ldr(r4, FieldMemOperand(r3, SharedFunctionInfo::kCompilerHintsOffset));
3014 __ tst(r4, Operand(1 << (SharedFunctionInfo::kStrictModeFunction + 3005 __ tst(r4, Operand(1 << (SharedFunctionInfo::kStrictModeFunction +
3015 kSmiTagSize))); 3006 kSmiTagSize)));
3016 __ b(ne, &cont); 3007 __ b(ne, &cont);
3017 3008
3018 // Do not transform the receiver for native (Compilerhints already in r3). 3009 // Do not transform the receiver for native (Compilerhints already in r3).
3019 __ tst(r4, Operand(1 << (SharedFunctionInfo::kNative + kSmiTagSize))); 3010 __ tst(r4, Operand(1 << (SharedFunctionInfo::kNative + kSmiTagSize)));
3020 __ b(ne, &cont); 3011 __ b(ne, &cont);
3021 } 3012 }
3022 3013
3023 // Compute the receiver in sloppy mode. 3014 if (state.IsSloppy()) {
3024 __ ldr(r3, MemOperand(sp, argc_ * kPointerSize)); 3015 // Compute the receiver in sloppy mode.
3016 __ ldr(r3, MemOperand(sp, argc * kPointerSize));
3025 3017
3026 if (NeedsChecks()) {
3027 __ JumpIfSmi(r3, &wrap); 3018 __ JumpIfSmi(r3, &wrap);
3028 __ CompareObjectType(r3, r4, r4, FIRST_SPEC_OBJECT_TYPE); 3019 __ CompareObjectType(r3, r4, r4, FIRST_SPEC_OBJECT_TYPE);
3029 __ b(lt, &wrap); 3020 __ b(lt, &wrap);
3030 } else {
3031 __ jmp(&wrap);
3032 } 3021 }
3033 3022
3034 __ bind(&cont); 3023 __ bind(&cont);
3035 } 3024 }
3036 __ InvokeFunction(r1, actual, JUMP_FUNCTION, NullCallWrapper());
3037 3025
3038 if (NeedsChecks()) { 3026 if (state.ArgumentsMustMatch()) {
3027 __ InvokeFunction(r1, actual, actual, JUMP_FUNCTION, NullCallWrapper());
3028 } else {
3029 __ InvokeFunction(r1, actual, JUMP_FUNCTION, NullCallWrapper());
3030 }
3031
3032 if (state.IsGeneric()) {
3039 // Slow-case: Non-function called. 3033 // Slow-case: Non-function called.
3040 __ bind(&slow); 3034 __ bind(&slow);
3041 if (RecordCallTarget()) {
3042 // If there is a call target cache, mark it megamorphic in the
3043 // non-function case. MegamorphicSentinel is an immortal immovable
3044 // object (megamorphic symbol) so no write barrier is needed.
3045 ASSERT_EQ(*TypeFeedbackInfo::MegamorphicSentinel(masm->isolate()),
3046 masm->isolate()->heap()->megamorphic_symbol());
3047 __ add(r5, r2, Operand::PointerOffsetFromSmiKey(r3));
3048 __ LoadRoot(ip, Heap::kMegamorphicSymbolRootIndex);
3049 __ str(ip, FieldMemOperand(r5, FixedArray::kHeaderSize));
3050 }
3051 // Check for function proxy. 3035 // Check for function proxy.
3052 __ cmp(r4, Operand(JS_FUNCTION_PROXY_TYPE)); 3036 __ cmp(r4, Operand(JS_FUNCTION_PROXY_TYPE));
3053 __ b(ne, &non_function); 3037 __ b(ne, &non_function);
3054 __ push(r1); // put proxy as additional argument 3038 __ push(r1); // put proxy as additional argument
3055 __ mov(r0, Operand(argc_ + 1, RelocInfo::NONE32)); 3039 __ mov(r0, Operand(argc + 1, RelocInfo::NONE32));
3056 __ mov(r2, Operand::Zero()); 3040 __ mov(r2, Operand::Zero());
3057 __ GetBuiltinFunction(r1, Builtins::CALL_FUNCTION_PROXY); 3041 __ GetBuiltinFunction(r1, Builtins::CALL_FUNCTION_PROXY);
3058 { 3042 {
3059 Handle<Code> adaptor = 3043 Handle<Code> adaptor =
3060 masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(); 3044 masm->isolate()->builtins()->ArgumentsAdaptorTrampoline();
3061 __ Jump(adaptor, RelocInfo::CODE_TARGET); 3045 __ Jump(adaptor, RelocInfo::CODE_TARGET);
3062 } 3046 }
3063 3047
3064 // CALL_NON_FUNCTION expects the non-function callee as receiver (instead 3048 // CALL_NON_FUNCTION expects the non-function callee as receiver (instead
3065 // of the original receiver from the call site). 3049 // of the original receiver from the call site).
3066 __ bind(&non_function); 3050 __ bind(&non_function);
3067 __ str(r1, MemOperand(sp, argc_ * kPointerSize)); 3051 __ str(r1, MemOperand(sp, argc * kPointerSize));
3068 __ mov(r0, Operand(argc_)); // Set up the number of arguments. 3052 __ mov(r0, Operand(argc)); // Set up the number of arguments.
3069 __ mov(r2, Operand::Zero()); 3053 __ mov(r2, Operand::Zero());
3070 __ GetBuiltinFunction(r1, Builtins::CALL_NON_FUNCTION); 3054 __ GetBuiltinFunction(r1, Builtins::CALL_NON_FUNCTION);
3071 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), 3055 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(),
3072 RelocInfo::CODE_TARGET); 3056 RelocInfo::CODE_TARGET);
3073 } 3057 }
3074 3058
3075 if (CallAsMethod()) { 3059 if (state.CallAsMethod() && state.IsSloppy()) {
3076 __ bind(&wrap); 3060 __ bind(&wrap);
3061
3062 if (!state.IsGeneric()) {
3063 __ ldr(r5, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset));
3064 __ ldr(r4, FieldMemOperand(r5, SharedFunctionInfo::kCompilerHintsOffset));
3065
3066 // Do not transform the receiver for native
3067 __ tst(r4, Operand(1 << (SharedFunctionInfo::kNative + kSmiTagSize)));
3068 __ b(ne, &cont);
3069 }
3070
3077 // Wrap the receiver and patch it back onto the stack. 3071 // Wrap the receiver and patch it back onto the stack.
3078 { FrameAndConstantPoolScope frame_scope(masm, StackFrame::INTERNAL); 3072 { FrameAndConstantPoolScope frame_scope(masm, StackFrame::INTERNAL);
3079 __ Push(r1, r3); 3073 __ Push(r1, r3);
3080 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); 3074 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION);
3081 __ pop(r1); 3075 __ pop(r1);
3082 } 3076 }
3083 __ str(r0, MemOperand(sp, argc_ * kPointerSize)); 3077 __ str(r0, MemOperand(sp, argc * kPointerSize));
3084 __ jmp(&cont); 3078 __ jmp(&cont);
3085 } 3079 }
3086 } 3080 }
3087 3081
3088 3082
3083 void CallFunctionStub::Generate(MacroAssembler* masm) {
3084 // r1 : the function to call
3085
3086 // GenericCallHelper expresses it's options in terms of CallIC::State.
3087 CallIC::CallType call_type = CallAsMethod() ?
3088 CallIC::METHOD : CallIC::FUNCTION;
3089
3090 if (NeedsChecks()) {
3091 GenericCallHelper(masm,
3092 CallIC::State::SlowCallState(
3093 argc_,
3094 call_type));
3095 } else {
3096 GenericCallHelper(masm,
3097 CallIC::State::MonomorphicCallState(
3098 argc_,
3099 call_type,
3100 CallIC::ARGUMENTS_COUNT_UNKNOWN,
3101 SLOPPY));
3102 }
3103 }
3104
3105
3089 void CallConstructStub::Generate(MacroAssembler* masm) { 3106 void CallConstructStub::Generate(MacroAssembler* masm) {
3090 // r0 : number of arguments 3107 // r0 : number of arguments
3091 // r1 : the function to call 3108 // r1 : the function to call
3092 // r2 : feedback vector 3109 // r2 : feedback vector
3093 // r3 : (only if r2 is not the megamorphic symbol) slot in feedback 3110 // r3 : (only if r2 is not the megamorphic symbol) slot in feedback
3094 // vector (Smi) 3111 // vector (Smi)
3095 Label slow, non_function_call; 3112 Label slow, non_function_call;
3096 3113
3097 // Check that the function is not a smi. 3114 // Check that the function is not a smi.
3098 __ JumpIfSmi(r1, &non_function_call); 3115 __ JumpIfSmi(r1, &non_function_call);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
3143 __ bind(&non_function_call); 3160 __ bind(&non_function_call);
3144 __ GetBuiltinFunction(r1, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR); 3161 __ GetBuiltinFunction(r1, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR);
3145 __ bind(&do_call); 3162 __ bind(&do_call);
3146 // Set expected number of arguments to zero (not changing r0). 3163 // Set expected number of arguments to zero (not changing r0).
3147 __ mov(r2, Operand::Zero()); 3164 __ mov(r2, Operand::Zero());
3148 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), 3165 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(),
3149 RelocInfo::CODE_TARGET); 3166 RelocInfo::CODE_TARGET);
3150 } 3167 }
3151 3168
3152 3169
3170 void CallICStub::GenerateMonomorphicCall(MacroAssembler* masm) {
3171 GenericCallHelper(masm,
3172 CallIC::State::MonomorphicCallState(
3173 state_.arg_count(),
3174 state_.call_type(),
3175 state_.argument_check(),
3176 state_.strict_mode()));
3177 }
3178
3179
3180 void CallICStub::GenerateSlowCall(MacroAssembler* masm) {
3181 GenericCallHelper(masm,
3182 CallIC::State::SlowCallState(
3183 state_.arg_count(),
3184 state_.call_type()));
3185 }
3186
3187
3188 void CallICStub::Generate(MacroAssembler* masm) {
3189 // r1 - function
3190 // r2 - vector
3191 // r3 - slot id (Smi)
3192 Label extra_checks_or_miss, slow;
3193
3194 // The checks. First, does r1 match the recorded monomorphic target?
3195 __ add(r4, r2, Operand::PointerOffsetFromSmiKey(r3));
3196 __ ldr(r4, FieldMemOperand(r4, FixedArray::kHeaderSize));
3197 __ cmp(r1, r4);
3198 __ b(ne, &extra_checks_or_miss);
3199
3200 GenerateMonomorphicCall(masm);
3201
3202 __ bind(&extra_checks_or_miss);
3203 if (IsGeneric()) {
3204 Label miss_uninit;
3205
3206 __ CompareRoot(r4, Heap::kMegamorphicSymbolRootIndex);
3207 __ b(eq, &slow);
3208 __ CompareRoot(r4, Heap::kUninitializedSymbolRootIndex);
3209 __ b(eq, &miss_uninit);
3210 // If we get here, go from monomorphic to megamorphic, Don't bother missing,
3211 // just update.
3212 __ add(r4, r2, Operand::PointerOffsetFromSmiKey(r3));
3213 __ LoadRoot(ip, Heap::kMegamorphicSymbolRootIndex);
3214 __ str(ip, FieldMemOperand(r4, FixedArray::kHeaderSize));
3215 __ jmp(&slow);
3216
3217 __ bind(&miss_uninit);
3218 }
3219
3220 GenerateMiss(masm);
3221
3222 // the slow case
3223 __ bind(&slow);
3224 GenerateSlowCall(masm);
3225 }
3226
3227
3228 void CallICStub::GenerateMiss(MacroAssembler* masm) {
3229 // Get the receiver of the function from the stack; 1 ~ return address.
3230 __ ldr(r4, MemOperand(sp, (state_.arg_count() + 1) * kPointerSize));
3231
3232 {
3233 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
3234
3235 // Push the receiver and the function and feedback info.
3236 __ Push(r4, r1, r2, r3);
3237
3238 // Call the entry.
3239 ExternalReference miss = ExternalReference(IC_Utility(IC::kCallIC_Miss),
3240 masm->isolate());
3241 __ CallExternalReference(miss, 4);
3242
3243 // Move result to edi and exit the internal frame.
3244 __ mov(r1, r0);
3245 }
3246 }
3247
3248
3153 // StringCharCodeAtGenerator 3249 // StringCharCodeAtGenerator
3154 void StringCharCodeAtGenerator::GenerateFast(MacroAssembler* masm) { 3250 void StringCharCodeAtGenerator::GenerateFast(MacroAssembler* masm) {
3155 Label flat_string; 3251 Label flat_string;
3156 Label ascii_string; 3252 Label ascii_string;
3157 Label got_char_code; 3253 Label got_char_code;
3158 Label sliced_string; 3254 Label sliced_string;
3159 3255
3160 // If the receiver is a smi trigger the non-string case. 3256 // If the receiver is a smi trigger the non-string case.
3161 __ JumpIfSmi(object_, receiver_not_string_); 3257 __ JumpIfSmi(object_, receiver_not_string_);
3162 3258
(...skipping 2296 matching lines...) Expand 10 before | Expand all | Expand 10 after
5459 MemOperand(fp, 6 * kPointerSize), 5555 MemOperand(fp, 6 * kPointerSize),
5460 NULL); 5556 NULL);
5461 } 5557 }
5462 5558
5463 5559
5464 #undef __ 5560 #undef __
5465 5561
5466 } } // namespace v8::internal 5562 } } // namespace v8::internal
5467 5563
5468 #endif // V8_TARGET_ARCH_ARM 5564 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/arm/builtins-arm.cc ('k') | src/arm/debug-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698