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

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

Issue 170903002: MIPS: Second attempt at introducing a premonomorphic state in the call target caches. (Closed) Base URL: https://github.com/v8/v8.git@gbl
Patch Set: Created 6 years, 10 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
« no previous file with comments | « no previous file | no next file » | 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 3141 matching lines...) Expand 10 before | Expand all | Expand 10 after
3152 3152
3153 3153
3154 static void GenerateRecordCallTarget(MacroAssembler* masm) { 3154 static void GenerateRecordCallTarget(MacroAssembler* masm) {
3155 // Cache the called function in a feedback vector slot. Cache states 3155 // Cache the called function in a feedback vector slot. Cache states
3156 // are uninitialized, monomorphic (indicated by a JSFunction), and 3156 // are uninitialized, monomorphic (indicated by a JSFunction), and
3157 // megamorphic. 3157 // megamorphic.
3158 // a0 : number of arguments to the construct function 3158 // a0 : number of arguments to the construct function
3159 // a1 : the function to call 3159 // a1 : the function to call
3160 // a2 : Feedback vector 3160 // a2 : Feedback vector
3161 // a3 : slot in feedback vector (Smi) 3161 // a3 : slot in feedback vector (Smi)
3162 Label initialize, done, miss, megamorphic, not_array_function; 3162 Label check_array, initialize_array, initialize_non_array, megamorphic, done;
3163 3163
3164 ASSERT_EQ(*TypeFeedbackInfo::MegamorphicSentinel(masm->isolate()), 3164 ASSERT_EQ(*TypeFeedbackInfo::MegamorphicSentinel(masm->isolate()),
3165 masm->isolate()->heap()->undefined_value()); 3165 masm->isolate()->heap()->undefined_value());
3166 Heap::RootListIndex kMegamorphicRootIndex = Heap::kUndefinedValueRootIndex;
3166 ASSERT_EQ(*TypeFeedbackInfo::UninitializedSentinel(masm->isolate()), 3167 ASSERT_EQ(*TypeFeedbackInfo::UninitializedSentinel(masm->isolate()),
3167 masm->isolate()->heap()->the_hole_value()); 3168 masm->isolate()->heap()->the_hole_value());
3169 Heap::RootListIndex kUninitializedRootIndex = Heap::kTheHoleValueRootIndex;
3170 ASSERT_EQ(*TypeFeedbackInfo::PremonomorphicSentinel(masm->isolate()),
3171 masm->isolate()->heap()->null_value());
3172 Heap::RootListIndex kPremonomorphicRootIndex = Heap::kNullValueRootIndex;
3168 3173
3169 // Load the cache state into t0. 3174 // Load the cache state into t0.
3170 __ sll(t0, a3, kPointerSizeLog2 - kSmiTagSize); 3175 __ sll(t0, a3, kPointerSizeLog2 - kSmiTagSize);
3171 __ Addu(t0, a2, Operand(t0)); 3176 __ Addu(t0, a2, Operand(t0));
3172 __ lw(t0, FieldMemOperand(t0, FixedArray::kHeaderSize)); 3177 __ lw(t0, FieldMemOperand(t0, FixedArray::kHeaderSize));
3173 3178
3174 // A monomorphic cache hit or an already megamorphic state: invoke the 3179 // A monomorphic cache hit or an already megamorphic state: invoke the
3175 // function without changing the state. 3180 // function without changing the state.
3176 __ Branch(&done, eq, t0, Operand(a1)); 3181 __ Branch(&done, eq, t0, Operand(a1));
3182 __ LoadRoot(at, kMegamorphicRootIndex);
3183 __ Branch(&done, eq, t0, Operand(at));
3177 3184
3178 // If we came here, we need to see if we are the array function. 3185 // Check if we're dealing with the Array function or not.
3179 // If we didn't have a matching function, and we didn't find the megamorph 3186 __ LoadArrayFunction(t1);
3180 // sentinel, then we have in the slot either some other function or an 3187 __ Branch(&check_array, eq, a1, Operand(t1));
3181 // AllocationSite. Do a map check on the object in a3. 3188
3189 // Non-array cache: Check the cache state.
3190 __ LoadRoot(at, kPremonomorphicRootIndex);
3191 __ Branch(&initialize_non_array, eq, t0, Operand(at));
3192 __ LoadRoot(at, kUninitializedRootIndex);
3193 __ Branch(&megamorphic, ne, t0, Operand(at));
3194
3195 // Non-array cache: Uninitialized -> premonomorphic. The sentinel is an
3196 // immortal immovable object (null) so no write-barrier is needed.
3197 __ sll(at, a3, kPointerSizeLog2 - kSmiTagSize);
3198 __ Addu(t0, a2, at);
3199 __ LoadRoot(at, kPremonomorphicRootIndex);
3200 __ Branch(USE_DELAY_SLOT, &done);
Paul Lind 2014/02/18 19:19:55 +1 for delay slot filling. (there is a similar pat
3201 __ sw(at, FieldMemOperand(t0, FixedArray::kHeaderSize));
3202
3203 // Array cache: Check the cache state to see if we're in a monomorphic
3204 // state where the state object is an AllocationSite object.
3205 __ bind(&check_array);
3182 __ lw(t1, FieldMemOperand(t0, 0)); 3206 __ lw(t1, FieldMemOperand(t0, 0));
3183 __ LoadRoot(at, Heap::kAllocationSiteMapRootIndex); 3207 __ LoadRoot(at, Heap::kAllocationSiteMapRootIndex);
3184 __ Branch(&miss, ne, t1, Operand(at)); 3208 __ Branch(&done, eq, t1, Operand(at));
3185 3209
3186 // Make sure the function is the Array() function 3210 // Array cache: Uninitialized or premonomorphic -> monomorphic.
3187 __ LoadArrayFunction(t0); 3211 __ LoadRoot(at, kUninitializedRootIndex);
3188 __ Branch(&megamorphic, ne, a1, Operand(t0)); 3212 __ Branch(&initialize_array, eq, t0, Operand(at));
3189 __ jmp(&done); 3213 __ LoadRoot(at, kPremonomorphicRootIndex);
3214 __ Branch(&initialize_array, eq, t0, Operand(at));
3190 3215
3191 __ bind(&miss); 3216 // Both caches: Monomorphic -> megamorphic. The sentinel is an
3192 3217 // immortal immovable object (undefined) so no write-barrier is needed.
3193 // A monomorphic miss (i.e, here the cache is not uninitialized) goes
3194 // megamorphic.
3195 __ LoadRoot(at, Heap::kTheHoleValueRootIndex);
3196 __ Branch(&initialize, eq, t0, Operand(at));
3197 // MegamorphicSentinel is an immortal immovable object (undefined) so no
3198 // write-barrier is needed.
3199 __ bind(&megamorphic); 3218 __ bind(&megamorphic);
3200 __ sll(t0, a3, kPointerSizeLog2 - kSmiTagSize); 3219 __ sll(t0, a3, kPointerSizeLog2 - kSmiTagSize);
3201 __ Addu(t0, a2, Operand(t0)); 3220 __ Addu(t0, a2, Operand(t0));
3202 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); 3221 __ LoadRoot(at, kMegamorphicRootIndex);
3203 __ sw(at, FieldMemOperand(t0, FixedArray::kHeaderSize)); 3222 __ sw(at, FieldMemOperand(t0, FixedArray::kHeaderSize));
3204 __ jmp(&done); 3223 __ jmp(&done);
3205 3224
3206 // An uninitialized cache is patched with the function or sentinel to 3225 // Array cache: Uninitialized or premonomorphic -> monomorphic.
3207 // indicate the ElementsKind if function is the Array constructor. 3226 __ bind(&initialize_array);
3208 __ bind(&initialize);
3209 // Make sure the function is the Array() function
3210 __ LoadArrayFunction(t0);
3211 __ Branch(&not_array_function, ne, a1, Operand(t0));
3212
3213 // The target function is the Array constructor.
3214 // Create an AllocationSite if we don't already have it, store it in the slot.
3215 { 3227 {
3216 FrameScope scope(masm, StackFrame::INTERNAL); 3228 FrameScope scope(masm, StackFrame::INTERNAL);
3217 const RegList kSavedRegs = 3229 const RegList kSavedRegs =
3218 1 << 4 | // a0 3230 1 << 4 | // a0
3219 1 << 5 | // a1 3231 1 << 5 | // a1
3220 1 << 6 | // a2 3232 1 << 6 | // a2
3221 1 << 7; // a3 3233 1 << 7; // a3
3222 3234
3223 // Arguments register must be smi-tagged to call out. 3235 // Arguments register must be smi-tagged to call out.
3224 __ SmiTag(a0); 3236 __ SmiTag(a0);
3225 __ MultiPush(kSavedRegs); 3237 __ MultiPush(kSavedRegs);
3226 3238
3227 CreateAllocationSiteStub create_stub; 3239 CreateAllocationSiteStub create_stub;
3228 __ CallStub(&create_stub); 3240 __ CallStub(&create_stub);
3229 3241
3230 __ MultiPop(kSavedRegs); 3242 __ MultiPop(kSavedRegs);
3231 __ SmiUntag(a0); 3243 __ SmiUntag(a0);
3232 } 3244 }
3233 __ Branch(&done); 3245 __ Branch(&done);
3234 3246
3235 __ bind(&not_array_function); 3247 // Non-array cache: Premonomorphic -> monomorphic.
3236 3248 __ bind(&initialize_non_array);
3237 __ sll(t0, a3, kPointerSizeLog2 - kSmiTagSize); 3249 __ sll(t0, a3, kPointerSizeLog2 - kSmiTagSize);
3238 __ Addu(t0, a2, Operand(t0)); 3250 __ Addu(t0, a2, Operand(t0));
3239 __ Addu(t0, t0, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); 3251 __ Addu(t0, t0, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
3240 __ sw(a1, MemOperand(t0, 0)); 3252 __ sw(a1, MemOperand(t0, 0));
3241 3253
3242 __ Push(t0, a2, a1); 3254 __ Push(t0, a2, a1);
3243 __ RecordWrite(a2, t0, a1, kRAHasNotBeenSaved, kDontSaveFPRegs, 3255 __ RecordWrite(a2, t0, a1, kRAHasNotBeenSaved, kDontSaveFPRegs,
3244 EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); 3256 EMIT_REMEMBERED_SET, OMIT_SMI_CHECK);
3245 __ Pop(t0, a2, a1); 3257 __ Pop(t0, a2, a1);
3246 3258
(...skipping 2513 matching lines...) Expand 10 before | Expand all | Expand 10 after
5760 MemOperand(fp, 6 * kPointerSize), 5772 MemOperand(fp, 6 * kPointerSize),
5761 NULL); 5773 NULL);
5762 } 5774 }
5763 5775
5764 5776
5765 #undef __ 5777 #undef __
5766 5778
5767 } } // namespace v8::internal 5779 } } // namespace v8::internal
5768 5780
5769 #endif // V8_TARGET_ARCH_MIPS 5781 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698