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

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

Issue 1485303002: PPC: Provide call counts for constructor calls, surface them as a vector IC. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years 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 | « src/full-codegen/ppc/full-codegen-ppc.cc ('k') | src/ppc/interface-descriptors-ppc.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 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/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 2410 matching lines...) Expand 10 before | Expand all | Expand 10 after
2421 2421
2422 static void GenerateRecordCallTarget(MacroAssembler* masm) { 2422 static void GenerateRecordCallTarget(MacroAssembler* masm) {
2423 // Cache the called function in a feedback vector slot. Cache states 2423 // Cache the called function in a feedback vector slot. Cache states
2424 // are uninitialized, monomorphic (indicated by a JSFunction), and 2424 // are uninitialized, monomorphic (indicated by a JSFunction), and
2425 // megamorphic. 2425 // megamorphic.
2426 // r3 : number of arguments to the construct function 2426 // r3 : number of arguments to the construct function
2427 // r4 : the function to call 2427 // r4 : the function to call
2428 // r5 : feedback vector 2428 // r5 : feedback vector
2429 // r6 : slot in feedback vector (Smi) 2429 // r6 : slot in feedback vector (Smi)
2430 Label initialize, done, miss, megamorphic, not_array_function; 2430 Label initialize, done, miss, megamorphic, not_array_function;
2431 Label done_increment_count;
2431 2432
2432 DCHECK_EQ(*TypeFeedbackVector::MegamorphicSentinel(masm->isolate()), 2433 DCHECK_EQ(*TypeFeedbackVector::MegamorphicSentinel(masm->isolate()),
2433 masm->isolate()->heap()->megamorphic_symbol()); 2434 masm->isolate()->heap()->megamorphic_symbol());
2434 DCHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(masm->isolate()), 2435 DCHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(masm->isolate()),
2435 masm->isolate()->heap()->uninitialized_symbol()); 2436 masm->isolate()->heap()->uninitialized_symbol());
2436 2437
2437 // Load the cache state into r8. 2438 // Load the cache state into r8.
2438 __ SmiToPtrArrayOffset(r8, r6); 2439 __ SmiToPtrArrayOffset(r8, r6);
2439 __ add(r8, r5, r8); 2440 __ add(r8, r5, r8);
2440 __ LoadP(r8, FieldMemOperand(r8, FixedArray::kHeaderSize)); 2441 __ LoadP(r8, FieldMemOperand(r8, FixedArray::kHeaderSize));
2441 2442
2442 // A monomorphic cache hit or an already megamorphic state: invoke the 2443 // A monomorphic cache hit or an already megamorphic state: invoke the
2443 // function without changing the state. 2444 // function without changing the state.
2444 // We don't know if r8 is a WeakCell or a Symbol, but it's harmless to read at 2445 // We don't know if r8 is a WeakCell or a Symbol, but it's harmless to read at
2445 // this position in a symbol (see static asserts in type-feedback-vector.h). 2446 // this position in a symbol (see static asserts in type-feedback-vector.h).
2446 Label check_allocation_site; 2447 Label check_allocation_site;
2447 Register feedback_map = r9; 2448 Register feedback_map = r9;
2448 Register weak_value = r10; 2449 Register weak_value = r10;
2449 __ LoadP(weak_value, FieldMemOperand(r8, WeakCell::kValueOffset)); 2450 __ LoadP(weak_value, FieldMemOperand(r8, WeakCell::kValueOffset));
2450 __ cmp(r4, weak_value); 2451 __ cmp(r4, weak_value);
2451 __ beq(&done); 2452 __ beq(&done_increment_count);
2452 __ CompareRoot(r8, Heap::kmegamorphic_symbolRootIndex); 2453 __ CompareRoot(r8, Heap::kmegamorphic_symbolRootIndex);
2453 __ beq(&done); 2454 __ beq(&done);
2454 __ LoadP(feedback_map, FieldMemOperand(r8, HeapObject::kMapOffset)); 2455 __ LoadP(feedback_map, FieldMemOperand(r8, HeapObject::kMapOffset));
2455 __ CompareRoot(feedback_map, Heap::kWeakCellMapRootIndex); 2456 __ CompareRoot(feedback_map, Heap::kWeakCellMapRootIndex);
2456 __ bne(&check_allocation_site); 2457 __ bne(&check_allocation_site);
2457 2458
2458 // If the weak cell is cleared, we have a new chance to become monomorphic. 2459 // If the weak cell is cleared, we have a new chance to become monomorphic.
2459 __ JumpIfSmi(weak_value, &initialize); 2460 __ JumpIfSmi(weak_value, &initialize);
2460 __ b(&megamorphic); 2461 __ b(&megamorphic);
2461 2462
2462 __ bind(&check_allocation_site); 2463 __ bind(&check_allocation_site);
2463 // If we came here, we need to see if we are the array function. 2464 // If we came here, we need to see if we are the array function.
2464 // If we didn't have a matching function, and we didn't find the megamorph 2465 // If we didn't have a matching function, and we didn't find the megamorph
2465 // sentinel, then we have in the slot either some other function or an 2466 // sentinel, then we have in the slot either some other function or an
2466 // AllocationSite. 2467 // AllocationSite.
2467 __ CompareRoot(feedback_map, Heap::kAllocationSiteMapRootIndex); 2468 __ CompareRoot(feedback_map, Heap::kAllocationSiteMapRootIndex);
2468 __ bne(&miss); 2469 __ bne(&miss);
2469 2470
2470 // Make sure the function is the Array() function 2471 // Make sure the function is the Array() function
2471 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r8); 2472 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r8);
2472 __ cmp(r4, r8); 2473 __ cmp(r4, r8);
2473 __ bne(&megamorphic); 2474 __ bne(&megamorphic);
2474 __ b(&done); 2475 __ b(&done_increment_count);
2475 2476
2476 __ bind(&miss); 2477 __ bind(&miss);
2477 2478
2478 // A monomorphic miss (i.e, here the cache is not uninitialized) goes 2479 // A monomorphic miss (i.e, here the cache is not uninitialized) goes
2479 // megamorphic. 2480 // megamorphic.
2480 __ CompareRoot(r8, Heap::kuninitialized_symbolRootIndex); 2481 __ CompareRoot(r8, Heap::kuninitialized_symbolRootIndex);
2481 __ beq(&initialize); 2482 __ beq(&initialize);
2482 // MegamorphicSentinel is an immortal immovable object (undefined) so no 2483 // MegamorphicSentinel is an immortal immovable object (undefined) so no
2483 // write-barrier is needed. 2484 // write-barrier is needed.
2484 __ bind(&megamorphic); 2485 __ bind(&megamorphic);
2485 __ SmiToPtrArrayOffset(r8, r6); 2486 __ SmiToPtrArrayOffset(r8, r6);
2486 __ add(r8, r5, r8); 2487 __ add(r8, r5, r8);
2487 __ LoadRoot(ip, Heap::kmegamorphic_symbolRootIndex); 2488 __ LoadRoot(ip, Heap::kmegamorphic_symbolRootIndex);
2488 __ StoreP(ip, FieldMemOperand(r8, FixedArray::kHeaderSize), r0); 2489 __ StoreP(ip, FieldMemOperand(r8, FixedArray::kHeaderSize), r0);
2489 __ jmp(&done); 2490 __ jmp(&done);
2490 2491
2491 // An uninitialized cache is patched with the function 2492 // An uninitialized cache is patched with the function
2492 __ bind(&initialize); 2493 __ bind(&initialize);
2493 2494
2495 // Initialize the call counter.
2496 __ LoadSmiLiteral(r8, Smi::FromInt(CallICNexus::kCallCountIncrement));
2497 __ SmiToPtrArrayOffset(r7, r6);
2498 __ add(r7, r5, r7);
2499 __ StoreP(r8, FieldMemOperand(r7, FixedArray::kHeaderSize + kPointerSize),
2500 r0);
2501
2494 // Make sure the function is the Array() function. 2502 // Make sure the function is the Array() function.
2495 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r8); 2503 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r8);
2496 __ cmp(r4, r8); 2504 __ cmp(r4, r8);
2497 __ bne(&not_array_function); 2505 __ bne(&not_array_function);
2498 2506
2499 // The target function is the Array constructor, 2507 // The target function is the Array constructor,
2500 // Create an AllocationSite if we don't already have it, store it in the 2508 // Create an AllocationSite if we don't already have it, store it in the
2501 // slot. 2509 // slot.
2502 CreateAllocationSiteStub create_stub(masm->isolate()); 2510 CreateAllocationSiteStub create_stub(masm->isolate());
2503 CallStubInRecordCallTarget(masm, &create_stub); 2511 CallStubInRecordCallTarget(masm, &create_stub);
2504 __ b(&done); 2512 __ b(&done);
2505 2513
2506 __ bind(&not_array_function); 2514 __ bind(&not_array_function);
2507
2508 CreateWeakCellStub weak_cell_stub(masm->isolate()); 2515 CreateWeakCellStub weak_cell_stub(masm->isolate());
2509 CallStubInRecordCallTarget(masm, &weak_cell_stub); 2516 CallStubInRecordCallTarget(masm, &weak_cell_stub);
2517 __ b(&done);
2518
2519 __ bind(&done_increment_count);
2520 __ SmiToPtrArrayOffset(r7, r6);
2521 __ add(r7, r5, r7);
2522 __ LoadP(r8, FieldMemOperand(r7, FixedArray::kHeaderSize + kPointerSize));
2523 __ AddSmiLiteral(r8, r8, Smi::FromInt(CallICNexus::kCallCountIncrement), r0);
2524 __ StoreP(r8, FieldMemOperand(r7, FixedArray::kHeaderSize + kPointerSize),
2525 r0);
2526
2510 __ bind(&done); 2527 __ bind(&done);
2511 } 2528 }
2512 2529
2513 2530
2514 void CallConstructStub::Generate(MacroAssembler* masm) { 2531 void ConstructICStub::Generate(MacroAssembler* masm) {
2515 // r3 : number of arguments 2532 // r3 : number of arguments
2516 // r4 : the function to call 2533 // r4 : the function to call
2517 // r5 : feedback vector 2534 // r5 : feedback vector
2518 // r6 : slot in feedback vector (Smi, for RecordCallTarget) 2535 // r6 : slot in feedback vector (Smi, for RecordCallTarget)
2519 2536
2520 Label non_function; 2537 Label non_function;
2521 // Check that the function is not a smi. 2538 // Check that the function is not a smi.
2522 __ JumpIfSmi(r4, &non_function); 2539 __ JumpIfSmi(r4, &non_function);
2523 // Check that the function is a JSFunction. 2540 // Check that the function is a JSFunction.
2524 __ CompareObjectType(r4, r8, r8, JS_FUNCTION_TYPE); 2541 __ CompareObjectType(r4, r8, r8, JS_FUNCTION_TYPE);
(...skipping 3116 matching lines...) Expand 10 before | Expand all | Expand 10 after
5641 kStackUnwindSpace, NULL, 5658 kStackUnwindSpace, NULL,
5642 MemOperand(fp, 6 * kPointerSize), NULL); 5659 MemOperand(fp, 6 * kPointerSize), NULL);
5643 } 5660 }
5644 5661
5645 5662
5646 #undef __ 5663 #undef __
5647 } // namespace internal 5664 } // namespace internal
5648 } // namespace v8 5665 } // namespace v8
5649 5666
5650 #endif // V8_TARGET_ARCH_PPC 5667 #endif // V8_TARGET_ARCH_PPC
OLDNEW
« no previous file with comments | « src/full-codegen/ppc/full-codegen-ppc.cc ('k') | src/ppc/interface-descriptors-ppc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698