OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 3171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3182 | 3182 |
3183 // TODO(jbramley): Don't use static registers here, but take them as arguments. | 3183 // TODO(jbramley): Don't use static registers here, but take them as arguments. |
3184 static void GenerateRecordCallTarget(MacroAssembler* masm) { | 3184 static void GenerateRecordCallTarget(MacroAssembler* masm) { |
3185 ASM_LOCATION("GenerateRecordCallTarget"); | 3185 ASM_LOCATION("GenerateRecordCallTarget"); |
3186 // Cache the called function in a feedback vector slot. Cache states are | 3186 // Cache the called function in a feedback vector slot. Cache states are |
3187 // uninitialized, monomorphic (indicated by a JSFunction), and megamorphic. | 3187 // uninitialized, monomorphic (indicated by a JSFunction), and megamorphic. |
3188 // x0 : number of arguments to the construct function | 3188 // x0 : number of arguments to the construct function |
3189 // x1 : the function to call | 3189 // x1 : the function to call |
3190 // x2 : feedback vector | 3190 // x2 : feedback vector |
3191 // x3 : slot in feedback vector (smi) | 3191 // x3 : slot in feedback vector (smi) |
3192 Label initialize, done, miss, megamorphic, not_array_function; | 3192 Label check_array, initialize_array, initialize_non_array, megamorphic, done; |
3193 | 3193 |
3194 ASSERT_EQ(*TypeFeedbackInfo::MegamorphicSentinel(masm->isolate()), | 3194 ASSERT_EQ(*TypeFeedbackInfo::MegamorphicSentinel(masm->isolate()), |
3195 masm->isolate()->heap()->undefined_value()); | 3195 masm->isolate()->heap()->undefined_value()); |
| 3196 Heap::RootListIndex kMegamorphicRootIndex = Heap::kUndefinedValueRootIndex; |
3196 ASSERT_EQ(*TypeFeedbackInfo::UninitializedSentinel(masm->isolate()), | 3197 ASSERT_EQ(*TypeFeedbackInfo::UninitializedSentinel(masm->isolate()), |
3197 masm->isolate()->heap()->the_hole_value()); | 3198 masm->isolate()->heap()->the_hole_value()); |
| 3199 Heap::RootListIndex kUninitializedRootIndex = Heap::kTheHoleValueRootIndex; |
| 3200 ASSERT_EQ(*TypeFeedbackInfo::PremonomorphicSentinel(masm->isolate()), |
| 3201 masm->isolate()->heap()->null_value()); |
| 3202 Heap::RootListIndex kPremonomorphicRootIndex = Heap::kNullValueRootIndex; |
3198 | 3203 |
3199 // Load the cache state. | 3204 // Load the cache state. |
3200 __ Add(x4, x2, Operand::UntagSmiAndScale(x3, kPointerSizeLog2)); | 3205 __ Add(x4, x2, Operand::UntagSmiAndScale(x3, kPointerSizeLog2)); |
3201 __ Ldr(x4, FieldMemOperand(x4, FixedArray::kHeaderSize)); | 3206 __ Ldr(x4, FieldMemOperand(x4, FixedArray::kHeaderSize)); |
3202 | 3207 |
3203 // A monomorphic cache hit or an already megamorphic state: invoke the | 3208 // A monomorphic cache hit or an already megamorphic state: invoke the |
3204 // function without changing the state. | 3209 // function without changing the state. |
3205 __ Cmp(x4, x1); | 3210 __ Cmp(x4, x1); |
3206 __ B(eq, &done); | 3211 __ B(eq, &done); |
| 3212 __ JumpIfRoot(x4, kMegamorphicRootIndex, &done); |
3207 | 3213 |
3208 // If we came here, we need to see if we are the array function. | 3214 // Check if we're dealing with the Array function or not. |
3209 // If we didn't have a matching function, and we didn't find the megamorph | 3215 __ LoadArrayFunction(x5); |
3210 // sentinel, then we have in the slot either some other function or an | 3216 __ Cmp(x1, x5); |
3211 // AllocationSite. Do a map check on the object in ecx. | 3217 __ B(eq, &check_array); |
3212 __ Ldr(x5, FieldMemOperand(x4, AllocationSite::kMapOffset)); | |
3213 __ JumpIfNotRoot(x5, Heap::kAllocationSiteMapRootIndex, &miss); | |
3214 | 3218 |
3215 // Make sure the function is the Array() function | 3219 // Non-array cache: Check the cache state. |
3216 __ LoadArrayFunction(x4); | 3220 __ JumpIfRoot(x4, kPremonomorphicRootIndex, &initialize_non_array); |
3217 __ Cmp(x1, x4); | 3221 __ JumpIfNotRoot(x4, kUninitializedRootIndex, &megamorphic); |
3218 __ B(ne, &megamorphic); | |
3219 __ B(&done); | |
3220 | 3222 |
3221 __ Bind(&miss); | 3223 // Non-array cache: Uninitialized -> premonomorphic. The sentinel is an |
3222 | 3224 // immortal immovable object (null) so no write-barrier is needed. |
3223 // A monomorphic miss (i.e, here the cache is not uninitialized) goes | |
3224 // megamorphic. | |
3225 __ JumpIfRoot(x4, Heap::kTheHoleValueRootIndex, &initialize); | |
3226 // MegamorphicSentinel is an immortal immovable object (undefined) so no | |
3227 // write-barrier is needed. | |
3228 __ Bind(&megamorphic); | |
3229 __ Add(x4, x2, Operand::UntagSmiAndScale(x3, kPointerSizeLog2)); | 3225 __ Add(x4, x2, Operand::UntagSmiAndScale(x3, kPointerSizeLog2)); |
3230 __ LoadRoot(x10, Heap::kUndefinedValueRootIndex); | 3226 __ LoadRoot(x10, kPremonomorphicRootIndex); |
3231 __ Str(x10, FieldMemOperand(x4, FixedArray::kHeaderSize)); | 3227 __ Str(x10, FieldMemOperand(x4, FixedArray::kHeaderSize)); |
3232 __ B(&done); | 3228 __ B(&done); |
3233 | 3229 |
3234 // An uninitialized cache is patched with the function or sentinel to | 3230 // Array cache: Check the cache state to see if we're in a monomorphic |
3235 // indicate the ElementsKind if function is the Array constructor. | 3231 // state where the state object is an AllocationSite object. |
3236 __ Bind(&initialize); | 3232 __ Bind(&check_array); |
3237 // Make sure the function is the Array() function | 3233 __ Ldr(x5, FieldMemOperand(x4, AllocationSite::kMapOffset)); |
3238 __ LoadArrayFunction(x4); | 3234 __ JumpIfRoot(x5, Heap::kAllocationSiteMapRootIndex, &done); |
3239 __ Cmp(x1, x4); | |
3240 __ B(ne, ¬_array_function); | |
3241 | 3235 |
3242 // The target function is the Array constructor, | 3236 // Array cache: Uninitialized or premonomorphic -> monomorphic. |
3243 // Create an AllocationSite if we don't already have it, store it in the slot. | 3237 __ JumpIfRoot(x4, kUninitializedRootIndex, &initialize_array); |
| 3238 __ JumpIfRoot(x4, kPremonomorphicRootIndex, &initialize_array); |
| 3239 |
| 3240 // Both caches: Monomorphic -> megamorphic. The sentinel is an |
| 3241 // immortal immovable object (undefined) so no write-barrier is needed. |
| 3242 __ Bind(&megamorphic); |
| 3243 __ Add(x4, x2, Operand::UntagSmiAndScale(x3, kPointerSizeLog2)); |
| 3244 __ LoadRoot(x10, kMegamorphicRootIndex); |
| 3245 __ Str(x10, FieldMemOperand(x4, FixedArray::kHeaderSize)); |
| 3246 __ B(&done); |
| 3247 |
| 3248 // Array cache: Uninitialized or premonomorphic -> monomorphic. |
| 3249 __ Bind(&initialize_array); |
3244 { | 3250 { |
3245 FrameScope scope(masm, StackFrame::INTERNAL); | 3251 FrameScope scope(masm, StackFrame::INTERNAL); |
3246 CreateAllocationSiteStub create_stub; | 3252 CreateAllocationSiteStub create_stub; |
3247 | 3253 |
3248 // Arguments register must be smi-tagged to call out. | 3254 // Arguments register must be smi-tagged to call out. |
3249 __ SmiTag(x0); | 3255 __ SmiTag(x0); |
3250 __ Push(x0, x1, x2, x3); | 3256 __ Push(x0, x1, x2, x3); |
3251 | 3257 |
3252 __ CallStub(&create_stub); | 3258 __ CallStub(&create_stub); |
3253 | 3259 |
3254 __ Pop(x3, x2, x1, x0); | 3260 __ Pop(x3, x2, x1, x0); |
3255 __ SmiUntag(x0); | 3261 __ SmiUntag(x0); |
3256 } | 3262 } |
3257 __ B(&done); | 3263 __ B(&done); |
3258 | 3264 |
3259 __ Bind(¬_array_function); | 3265 // Non-array cache: Premonomorphic -> monomorphic. |
3260 // An uninitialized cache is patched with the function. | 3266 __ Bind(&initialize_non_array); |
3261 | |
3262 __ Add(x4, x2, Operand::UntagSmiAndScale(x3, kPointerSizeLog2)); | 3267 __ Add(x4, x2, Operand::UntagSmiAndScale(x3, kPointerSizeLog2)); |
3263 // TODO(all): Does the value need to be left in x4? If not, FieldMemOperand | 3268 // TODO(all): Does the value need to be left in x4? If not, FieldMemOperand |
3264 // could be used to avoid this add. | 3269 // could be used to avoid this add. |
3265 __ Add(x4, x4, FixedArray::kHeaderSize - kHeapObjectTag); | 3270 __ Add(x4, x4, FixedArray::kHeaderSize - kHeapObjectTag); |
3266 __ Str(x1, MemOperand(x4, 0)); | 3271 __ Str(x1, MemOperand(x4, 0)); |
3267 | 3272 |
3268 __ Push(x4, x2, x1); | 3273 __ Push(x4, x2, x1); |
3269 __ RecordWrite(x2, x4, x1, kLRHasNotBeenSaved, kDontSaveFPRegs, | 3274 __ RecordWrite(x2, x4, x1, kLRHasNotBeenSaved, kDontSaveFPRegs, |
3270 EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); | 3275 EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); |
3271 __ Pop(x1, x2, x4); | 3276 __ Pop(x1, x2, x4); |
3272 | 3277 |
3273 // TODO(all): Are x4, x2 and x1 outputs? This isn't clear. | 3278 // TODO(all): Are x4, x2 and x1 outputs? This isn't clear. |
3274 | |
3275 __ Bind(&done); | 3279 __ Bind(&done); |
3276 } | 3280 } |
3277 | 3281 |
3278 | 3282 |
3279 void CallFunctionStub::Generate(MacroAssembler* masm) { | 3283 void CallFunctionStub::Generate(MacroAssembler* masm) { |
3280 ASM_LOCATION("CallFunctionStub::Generate"); | 3284 ASM_LOCATION("CallFunctionStub::Generate"); |
3281 // x1 function the function to call | 3285 // x1 function the function to call |
3282 // x2 : feedback vector | 3286 // x2 : feedback vector |
3283 // x3 : slot in feedback vector (smi) (if x2 is not undefined) | 3287 // x3 : slot in feedback vector (smi) (if x2 is not undefined) |
3284 Register function = x1; | 3288 Register function = x1; |
(...skipping 2435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5720 MemOperand(fp, 6 * kPointerSize), | 5724 MemOperand(fp, 6 * kPointerSize), |
5721 NULL); | 5725 NULL); |
5722 } | 5726 } |
5723 | 5727 |
5724 | 5728 |
5725 #undef __ | 5729 #undef __ |
5726 | 5730 |
5727 } } // namespace v8::internal | 5731 } } // namespace v8::internal |
5728 | 5732 |
5729 #endif // V8_TARGET_ARCH_A64 | 5733 #endif // V8_TARGET_ARCH_A64 |
OLD | NEW |