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

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

Issue 1476413003: 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: REBASE. 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/mips/interface-descriptors-mips.cc ('k') | src/mips64/interface-descriptors-mips64.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 // 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_MIPS64 5 #if V8_TARGET_ARCH_MIPS64
6 6
7 #include "src/bootstrapper.h" 7 #include "src/bootstrapper.h"
8 #include "src/code-stubs.h" 8 #include "src/code-stubs.h"
9 #include "src/codegen.h" 9 #include "src/codegen.h"
10 #include "src/ic/handler-compiler.h" 10 #include "src/ic/handler-compiler.h"
(...skipping 2433 matching lines...) Expand 10 before | Expand all | Expand 10 after
2444 2444
2445 static void GenerateRecordCallTarget(MacroAssembler* masm) { 2445 static void GenerateRecordCallTarget(MacroAssembler* masm) {
2446 // Cache the called function in a feedback vector slot. Cache states 2446 // Cache the called function in a feedback vector slot. Cache states
2447 // are uninitialized, monomorphic (indicated by a JSFunction), and 2447 // are uninitialized, monomorphic (indicated by a JSFunction), and
2448 // megamorphic. 2448 // megamorphic.
2449 // a0 : number of arguments to the construct function 2449 // a0 : number of arguments to the construct function
2450 // a1 : the function to call 2450 // a1 : the function to call
2451 // a2 : feedback vector 2451 // a2 : feedback vector
2452 // a3 : slot in feedback vector (Smi) 2452 // a3 : slot in feedback vector (Smi)
2453 Label initialize, done, miss, megamorphic, not_array_function; 2453 Label initialize, done, miss, megamorphic, not_array_function;
2454 Label done_increment_count;
2454 2455
2455 DCHECK_EQ(*TypeFeedbackVector::MegamorphicSentinel(masm->isolate()), 2456 DCHECK_EQ(*TypeFeedbackVector::MegamorphicSentinel(masm->isolate()),
2456 masm->isolate()->heap()->megamorphic_symbol()); 2457 masm->isolate()->heap()->megamorphic_symbol());
2457 DCHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(masm->isolate()), 2458 DCHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(masm->isolate()),
2458 masm->isolate()->heap()->uninitialized_symbol()); 2459 masm->isolate()->heap()->uninitialized_symbol());
2459 2460
2460 // Load the cache state into a5. 2461 // Load the cache state into a5.
2461 __ dsrl(a5, a3, 32 - kPointerSizeLog2); 2462 __ dsrl(a5, a3, 32 - kPointerSizeLog2);
2462 __ Daddu(a5, a2, Operand(a5)); 2463 __ Daddu(a5, a2, Operand(a5));
2463 __ ld(a5, FieldMemOperand(a5, FixedArray::kHeaderSize)); 2464 __ ld(a5, FieldMemOperand(a5, FixedArray::kHeaderSize));
2464 2465
2465 // A monomorphic cache hit or an already megamorphic state: invoke the 2466 // A monomorphic cache hit or an already megamorphic state: invoke the
2466 // function without changing the state. 2467 // function without changing the state.
2467 // We don't know if a5 is a WeakCell or a Symbol, but it's harmless to read at 2468 // We don't know if a5 is a WeakCell or a Symbol, but it's harmless to read at
2468 // this position in a symbol (see static asserts in type-feedback-vector.h). 2469 // this position in a symbol (see static asserts in type-feedback-vector.h).
2469 Label check_allocation_site; 2470 Label check_allocation_site;
2470 Register feedback_map = a6; 2471 Register feedback_map = a6;
2471 Register weak_value = t0; 2472 Register weak_value = t0;
2472 __ ld(weak_value, FieldMemOperand(a5, WeakCell::kValueOffset)); 2473 __ ld(weak_value, FieldMemOperand(a5, WeakCell::kValueOffset));
2473 __ Branch(&done, eq, a1, Operand(weak_value)); 2474 __ Branch(&done_increment_count, eq, a1, Operand(weak_value));
2474 __ LoadRoot(at, Heap::kmegamorphic_symbolRootIndex); 2475 __ LoadRoot(at, Heap::kmegamorphic_symbolRootIndex);
2475 __ Branch(&done, eq, a5, Operand(at)); 2476 __ Branch(&done, eq, a5, Operand(at));
2476 __ ld(feedback_map, FieldMemOperand(a5, HeapObject::kMapOffset)); 2477 __ ld(feedback_map, FieldMemOperand(a5, HeapObject::kMapOffset));
2477 __ LoadRoot(at, Heap::kWeakCellMapRootIndex); 2478 __ LoadRoot(at, Heap::kWeakCellMapRootIndex);
2478 __ Branch(&check_allocation_site, ne, feedback_map, Operand(at)); 2479 __ Branch(&check_allocation_site, ne, feedback_map, Operand(at));
2479 2480
2480 // If the weak cell is cleared, we have a new chance to become monomorphic. 2481 // If the weak cell is cleared, we have a new chance to become monomorphic.
2481 __ JumpIfSmi(weak_value, &initialize); 2482 __ JumpIfSmi(weak_value, &initialize);
2482 __ jmp(&megamorphic); 2483 __ jmp(&megamorphic);
2483 2484
2484 __ bind(&check_allocation_site); 2485 __ bind(&check_allocation_site);
2485 // If we came here, we need to see if we are the array function. 2486 // If we came here, we need to see if we are the array function.
2486 // If we didn't have a matching function, and we didn't find the megamorph 2487 // If we didn't have a matching function, and we didn't find the megamorph
2487 // sentinel, then we have in the slot either some other function or an 2488 // sentinel, then we have in the slot either some other function or an
2488 // AllocationSite. 2489 // AllocationSite.
2489 __ LoadRoot(at, Heap::kAllocationSiteMapRootIndex); 2490 __ LoadRoot(at, Heap::kAllocationSiteMapRootIndex);
2490 __ Branch(&miss, ne, feedback_map, Operand(at)); 2491 __ Branch(&miss, ne, feedback_map, Operand(at));
2491 2492
2492 // Make sure the function is the Array() function 2493 // Make sure the function is the Array() function
2493 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, a5); 2494 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, a5);
2494 __ Branch(&megamorphic, ne, a1, Operand(a5)); 2495 __ Branch(&megamorphic, ne, a1, Operand(a5));
2495 __ jmp(&done); 2496 __ jmp(&done_increment_count);
2496 2497
2497 __ bind(&miss); 2498 __ bind(&miss);
2498 2499
2499 // A monomorphic miss (i.e, here the cache is not uninitialized) goes 2500 // A monomorphic miss (i.e, here the cache is not uninitialized) goes
2500 // megamorphic. 2501 // megamorphic.
2501 __ LoadRoot(at, Heap::kuninitialized_symbolRootIndex); 2502 __ LoadRoot(at, Heap::kuninitialized_symbolRootIndex);
2502 __ Branch(&initialize, eq, a5, Operand(at)); 2503 __ Branch(&initialize, eq, a5, Operand(at));
2503 // MegamorphicSentinel is an immortal immovable object (undefined) so no 2504 // MegamorphicSentinel is an immortal immovable object (undefined) so no
2504 // write-barrier is needed. 2505 // write-barrier is needed.
2505 __ bind(&megamorphic); 2506 __ bind(&megamorphic);
2506 __ dsrl(a5, a3, 32 - kPointerSizeLog2); 2507 __ dsrl(a5, a3, 32 - kPointerSizeLog2);
2507 __ Daddu(a5, a2, Operand(a5)); 2508 __ Daddu(a5, a2, Operand(a5));
2508 __ LoadRoot(at, Heap::kmegamorphic_symbolRootIndex); 2509 __ LoadRoot(at, Heap::kmegamorphic_symbolRootIndex);
2509 __ sd(at, FieldMemOperand(a5, FixedArray::kHeaderSize)); 2510 __ sd(at, FieldMemOperand(a5, FixedArray::kHeaderSize));
2510 __ jmp(&done); 2511 __ jmp(&done);
2511 2512
2512 // An uninitialized cache is patched with the function. 2513 // An uninitialized cache is patched with the function.
2513 __ bind(&initialize); 2514 __ bind(&initialize);
2515
2516 // Initialize the call counter.
2517 __ dsrl(at, a3, 32 - kPointerSizeLog2);
2518 __ Daddu(at, a2, Operand(at));
2519 __ li(t0, Operand(Smi::FromInt(CallICNexus::kCallCountIncrement)));
2520 __ sd(t0, FieldMemOperand(at, FixedArray::kHeaderSize + kPointerSize));
2521
2514 // Make sure the function is the Array() function. 2522 // Make sure the function is the Array() function.
2515 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, a5); 2523 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, a5);
2516 __ Branch(&not_array_function, ne, a1, Operand(a5)); 2524 __ Branch(&not_array_function, ne, a1, Operand(a5));
2517 2525
2518 // The target function is the Array constructor, 2526 // The target function is the Array constructor,
2519 // Create an AllocationSite if we don't already have it, store it in the 2527 // Create an AllocationSite if we don't already have it, store it in the
2520 // slot. 2528 // slot.
2521 CreateAllocationSiteStub create_stub(masm->isolate()); 2529 CreateAllocationSiteStub create_stub(masm->isolate());
2522 CallStubInRecordCallTarget(masm, &create_stub); 2530 CallStubInRecordCallTarget(masm, &create_stub);
2523 __ Branch(&done); 2531 __ Branch(&done);
2524 2532
2525 __ bind(&not_array_function); 2533 __ bind(&not_array_function);
2526 2534
2527 CreateWeakCellStub weak_cell_stub(masm->isolate()); 2535 CreateWeakCellStub weak_cell_stub(masm->isolate());
2528 CallStubInRecordCallTarget(masm, &weak_cell_stub); 2536 CallStubInRecordCallTarget(masm, &weak_cell_stub);
2537 __ Branch(&done);
2538
2539 __ bind(&done_increment_count);
2540 __ dsrl(a5, a3, 32 - kPointerSizeLog2);
2541 __ Daddu(a5, a2, Operand(a5));
2542 __ ld(t0, FieldMemOperand(a5, FixedArray::kHeaderSize + kPointerSize));
2543 __ Daddu(t0, t0,
2544 Operand(Smi::FromInt(ConstructICNexus::kCallCountIncrement)));
2545 __ sd(t0, FieldMemOperand(a5, FixedArray::kHeaderSize + kPointerSize));
2546
2529 __ bind(&done); 2547 __ bind(&done);
2530 } 2548 }
2531 2549
2532 2550
2533 void CallConstructStub::Generate(MacroAssembler* masm) { 2551 void ConstructICStub::Generate(MacroAssembler* masm) {
2534 // a0 : number of arguments 2552 // a0 : number of arguments
2535 // a1 : the function to call 2553 // a1 : the function to call
2536 // a2 : feedback vector 2554 // a2 : feedback vector
2537 // a3 : slot in feedback vector (Smi, for RecordCallTarget) 2555 // a3 : slot in feedback vector (Smi, for RecordCallTarget)
2538 2556
2539 Label non_function; 2557 Label non_function;
2540 // Check that the function is not a smi. 2558 // Check that the function is not a smi.
2541 __ JumpIfSmi(a1, &non_function); 2559 __ JumpIfSmi(a1, &non_function);
2542 // Check that the function is a JSFunction. 2560 // Check that the function is a JSFunction.
2543 __ GetObjectType(a1, a5, a5); 2561 __ GetObjectType(a1, a5, a5);
(...skipping 3052 matching lines...) Expand 10 before | Expand all | Expand 10 after
5596 MemOperand(fp, 6 * kPointerSize), NULL); 5614 MemOperand(fp, 6 * kPointerSize), NULL);
5597 } 5615 }
5598 5616
5599 5617
5600 #undef __ 5618 #undef __
5601 5619
5602 } // namespace internal 5620 } // namespace internal
5603 } // namespace v8 5621 } // namespace v8
5604 5622
5605 #endif // V8_TARGET_ARCH_MIPS64 5623 #endif // V8_TARGET_ARCH_MIPS64
OLDNEW
« no previous file with comments | « src/mips/interface-descriptors-mips.cc ('k') | src/mips64/interface-descriptors-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698