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/base/bits.h" | 7 #include "src/base/bits.h" |
8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 2268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2279 | 2279 |
2280 static void GenerateRecordCallTarget(MacroAssembler* masm) { | 2280 static void GenerateRecordCallTarget(MacroAssembler* masm) { |
2281 // Cache the called function in a feedback vector slot. Cache states | 2281 // Cache the called function in a feedback vector slot. Cache states |
2282 // are uninitialized, monomorphic (indicated by a JSFunction), and | 2282 // are uninitialized, monomorphic (indicated by a JSFunction), and |
2283 // megamorphic. | 2283 // megamorphic. |
2284 // r0 : number of arguments to the construct function | 2284 // r0 : number of arguments to the construct function |
2285 // r1 : the function to call | 2285 // r1 : the function to call |
2286 // r2 : feedback vector | 2286 // r2 : feedback vector |
2287 // r3 : slot in feedback vector (Smi) | 2287 // r3 : slot in feedback vector (Smi) |
2288 Label initialize, done, miss, megamorphic, not_array_function; | 2288 Label initialize, done, miss, megamorphic, not_array_function; |
| 2289 Label done_increment_count; |
2289 | 2290 |
2290 DCHECK_EQ(*TypeFeedbackVector::MegamorphicSentinel(masm->isolate()), | 2291 DCHECK_EQ(*TypeFeedbackVector::MegamorphicSentinel(masm->isolate()), |
2291 masm->isolate()->heap()->megamorphic_symbol()); | 2292 masm->isolate()->heap()->megamorphic_symbol()); |
2292 DCHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(masm->isolate()), | 2293 DCHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(masm->isolate()), |
2293 masm->isolate()->heap()->uninitialized_symbol()); | 2294 masm->isolate()->heap()->uninitialized_symbol()); |
2294 | 2295 |
2295 // Load the cache state into r5. | 2296 // Load the cache state into r5. |
2296 __ add(r5, r2, Operand::PointerOffsetFromSmiKey(r3)); | 2297 __ add(r5, r2, Operand::PointerOffsetFromSmiKey(r3)); |
2297 __ ldr(r5, FieldMemOperand(r5, FixedArray::kHeaderSize)); | 2298 __ ldr(r5, FieldMemOperand(r5, FixedArray::kHeaderSize)); |
2298 | 2299 |
2299 // A monomorphic cache hit or an already megamorphic state: invoke the | 2300 // A monomorphic cache hit or an already megamorphic state: invoke the |
2300 // function without changing the state. | 2301 // function without changing the state. |
2301 // We don't know if r5 is a WeakCell or a Symbol, but it's harmless to read at | 2302 // We don't know if r5 is a WeakCell or a Symbol, but it's harmless to read at |
2302 // this position in a symbol (see static asserts in type-feedback-vector.h). | 2303 // this position in a symbol (see static asserts in type-feedback-vector.h). |
2303 Label check_allocation_site; | 2304 Label check_allocation_site; |
2304 Register feedback_map = r6; | 2305 Register feedback_map = r6; |
2305 Register weak_value = r9; | 2306 Register weak_value = r9; |
2306 __ ldr(weak_value, FieldMemOperand(r5, WeakCell::kValueOffset)); | 2307 __ ldr(weak_value, FieldMemOperand(r5, WeakCell::kValueOffset)); |
2307 __ cmp(r1, weak_value); | 2308 __ cmp(r1, weak_value); |
2308 __ b(eq, &done); | 2309 __ b(eq, &done_increment_count); |
2309 __ CompareRoot(r5, Heap::kmegamorphic_symbolRootIndex); | 2310 __ CompareRoot(r5, Heap::kmegamorphic_symbolRootIndex); |
2310 __ b(eq, &done); | 2311 __ b(eq, &done); |
2311 __ ldr(feedback_map, FieldMemOperand(r5, HeapObject::kMapOffset)); | 2312 __ ldr(feedback_map, FieldMemOperand(r5, HeapObject::kMapOffset)); |
2312 __ CompareRoot(feedback_map, Heap::kWeakCellMapRootIndex); | 2313 __ CompareRoot(feedback_map, Heap::kWeakCellMapRootIndex); |
2313 __ b(ne, &check_allocation_site); | 2314 __ b(ne, &check_allocation_site); |
2314 | 2315 |
2315 // If the weak cell is cleared, we have a new chance to become monomorphic. | 2316 // If the weak cell is cleared, we have a new chance to become monomorphic. |
2316 __ JumpIfSmi(weak_value, &initialize); | 2317 __ JumpIfSmi(weak_value, &initialize); |
2317 __ jmp(&megamorphic); | 2318 __ jmp(&megamorphic); |
2318 | 2319 |
2319 __ bind(&check_allocation_site); | 2320 __ bind(&check_allocation_site); |
2320 // If we came here, we need to see if we are the array function. | 2321 // If we came here, we need to see if we are the array function. |
2321 // If we didn't have a matching function, and we didn't find the megamorph | 2322 // If we didn't have a matching function, and we didn't find the megamorph |
2322 // sentinel, then we have in the slot either some other function or an | 2323 // sentinel, then we have in the slot either some other function or an |
2323 // AllocationSite. | 2324 // AllocationSite. |
2324 __ CompareRoot(feedback_map, Heap::kAllocationSiteMapRootIndex); | 2325 __ CompareRoot(feedback_map, Heap::kAllocationSiteMapRootIndex); |
2325 __ b(ne, &miss); | 2326 __ b(ne, &miss); |
2326 | 2327 |
2327 // Make sure the function is the Array() function | 2328 // Make sure the function is the Array() function |
2328 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r5); | 2329 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r5); |
2329 __ cmp(r1, r5); | 2330 __ cmp(r1, r5); |
2330 __ b(ne, &megamorphic); | 2331 __ b(ne, &megamorphic); |
2331 __ jmp(&done); | 2332 __ jmp(&done_increment_count); |
2332 | 2333 |
2333 __ bind(&miss); | 2334 __ bind(&miss); |
2334 | 2335 |
2335 // A monomorphic miss (i.e, here the cache is not uninitialized) goes | 2336 // A monomorphic miss (i.e, here the cache is not uninitialized) goes |
2336 // megamorphic. | 2337 // megamorphic. |
2337 __ CompareRoot(r5, Heap::kuninitialized_symbolRootIndex); | 2338 __ CompareRoot(r5, Heap::kuninitialized_symbolRootIndex); |
2338 __ b(eq, &initialize); | 2339 __ b(eq, &initialize); |
2339 // MegamorphicSentinel is an immortal immovable object (undefined) so no | 2340 // MegamorphicSentinel is an immortal immovable object (undefined) so no |
2340 // write-barrier is needed. | 2341 // write-barrier is needed. |
2341 __ bind(&megamorphic); | 2342 __ bind(&megamorphic); |
2342 __ add(r5, r2, Operand::PointerOffsetFromSmiKey(r3)); | 2343 __ add(r5, r2, Operand::PointerOffsetFromSmiKey(r3)); |
2343 __ LoadRoot(ip, Heap::kmegamorphic_symbolRootIndex); | 2344 __ LoadRoot(ip, Heap::kmegamorphic_symbolRootIndex); |
2344 __ str(ip, FieldMemOperand(r5, FixedArray::kHeaderSize)); | 2345 __ str(ip, FieldMemOperand(r5, FixedArray::kHeaderSize)); |
2345 __ jmp(&done); | 2346 __ jmp(&done); |
2346 | 2347 |
2347 // An uninitialized cache is patched with the function | 2348 // An uninitialized cache is patched with the function |
2348 __ bind(&initialize); | 2349 __ bind(&initialize); |
2349 | 2350 |
| 2351 // Initialize the call counter. |
| 2352 __ Move(r5, Operand(Smi::FromInt(CallICNexus::kCallCountIncrement))); |
| 2353 __ add(r4, r2, Operand::PointerOffsetFromSmiKey(r3)); |
| 2354 __ str(r5, FieldMemOperand(r4, FixedArray::kHeaderSize + kPointerSize)); |
| 2355 |
2350 // Make sure the function is the Array() function | 2356 // Make sure the function is the Array() function |
2351 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r5); | 2357 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r5); |
2352 __ cmp(r1, r5); | 2358 __ cmp(r1, r5); |
2353 __ b(ne, ¬_array_function); | 2359 __ b(ne, ¬_array_function); |
2354 | 2360 |
2355 // The target function is the Array constructor, | 2361 // The target function is the Array constructor, |
2356 // Create an AllocationSite if we don't already have it, store it in the | 2362 // Create an AllocationSite if we don't already have it, store it in the |
2357 // slot. | 2363 // slot. |
2358 CreateAllocationSiteStub create_stub(masm->isolate()); | 2364 CreateAllocationSiteStub create_stub(masm->isolate()); |
2359 CallStubInRecordCallTarget(masm, &create_stub); | 2365 CallStubInRecordCallTarget(masm, &create_stub); |
2360 __ b(&done); | 2366 __ b(&done); |
2361 | 2367 |
2362 __ bind(¬_array_function); | 2368 __ bind(¬_array_function); |
2363 CreateWeakCellStub weak_cell_stub(masm->isolate()); | 2369 CreateWeakCellStub weak_cell_stub(masm->isolate()); |
2364 CallStubInRecordCallTarget(masm, &weak_cell_stub); | 2370 CallStubInRecordCallTarget(masm, &weak_cell_stub); |
| 2371 __ b(&done); |
| 2372 |
| 2373 __ bind(&done_increment_count); |
| 2374 __ add(r4, r2, Operand::PointerOffsetFromSmiKey(r3)); |
| 2375 __ add(r4, r4, Operand(FixedArray::kHeaderSize + kPointerSize)); |
| 2376 __ ldr(r5, FieldMemOperand(r4, 0)); |
| 2377 __ add(r5, r5, Operand(Smi::FromInt(CallICNexus::kCallCountIncrement))); |
| 2378 __ str(r5, FieldMemOperand(r4, 0)); |
| 2379 |
2365 __ bind(&done); | 2380 __ bind(&done); |
2366 } | 2381 } |
2367 | 2382 |
2368 | 2383 |
2369 void CallConstructStub::Generate(MacroAssembler* masm) { | 2384 void ConstructICStub::Generate(MacroAssembler* masm) { |
2370 // r0 : number of arguments | 2385 // r0 : number of arguments |
2371 // r1 : the function to call | 2386 // r1 : the function to call |
2372 // r2 : feedback vector | 2387 // r2 : feedback vector |
2373 // r3 : slot in feedback vector (Smi, for RecordCallTarget) | 2388 // r3 : slot in feedback vector (Smi, for RecordCallTarget) |
2374 | 2389 |
2375 Label non_function; | 2390 Label non_function; |
2376 // Check that the function is not a smi. | 2391 // Check that the function is not a smi. |
2377 __ JumpIfSmi(r1, &non_function); | 2392 __ JumpIfSmi(r1, &non_function); |
2378 // Check that the function is a JSFunction. | 2393 // Check that the function is a JSFunction. |
2379 __ CompareObjectType(r1, r5, r5, JS_FUNCTION_TYPE); | 2394 __ CompareObjectType(r1, r5, r5, JS_FUNCTION_TYPE); |
(...skipping 2987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5367 MemOperand(fp, 6 * kPointerSize), NULL); | 5382 MemOperand(fp, 6 * kPointerSize), NULL); |
5368 } | 5383 } |
5369 | 5384 |
5370 | 5385 |
5371 #undef __ | 5386 #undef __ |
5372 | 5387 |
5373 } // namespace internal | 5388 } // namespace internal |
5374 } // namespace v8 | 5389 } // namespace v8 |
5375 | 5390 |
5376 #endif // V8_TARGET_ARCH_ARM | 5391 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |