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

Side by Side Diff: src/mips/code-stubs-mips.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/log.cc ('k') | src/mips/interface-descriptors-mips.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_MIPS 5 #if V8_TARGET_ARCH_MIPS
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 2398 matching lines...) Expand 10 before | Expand all | Expand 10 after
2409 2409
2410 static void GenerateRecordCallTarget(MacroAssembler* masm) { 2410 static void GenerateRecordCallTarget(MacroAssembler* masm) {
2411 // Cache the called function in a feedback vector slot. Cache states 2411 // Cache the called function in a feedback vector slot. Cache states
2412 // are uninitialized, monomorphic (indicated by a JSFunction), and 2412 // are uninitialized, monomorphic (indicated by a JSFunction), and
2413 // megamorphic. 2413 // megamorphic.
2414 // a0 : number of arguments to the construct function 2414 // a0 : number of arguments to the construct function
2415 // a1 : the function to call 2415 // a1 : the function to call
2416 // a2 : feedback vector 2416 // a2 : feedback vector
2417 // a3 : slot in feedback vector (Smi) 2417 // a3 : slot in feedback vector (Smi)
2418 Label initialize, done, miss, megamorphic, not_array_function; 2418 Label initialize, done, miss, megamorphic, not_array_function;
2419 Label done_increment_count;
2419 2420
2420 DCHECK_EQ(*TypeFeedbackVector::MegamorphicSentinel(masm->isolate()), 2421 DCHECK_EQ(*TypeFeedbackVector::MegamorphicSentinel(masm->isolate()),
2421 masm->isolate()->heap()->megamorphic_symbol()); 2422 masm->isolate()->heap()->megamorphic_symbol());
2422 DCHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(masm->isolate()), 2423 DCHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(masm->isolate()),
2423 masm->isolate()->heap()->uninitialized_symbol()); 2424 masm->isolate()->heap()->uninitialized_symbol());
2424 2425
2425 // Load the cache state into t2. 2426 // Load the cache state into t2.
2426 __ sll(t2, a3, kPointerSizeLog2 - kSmiTagSize); 2427 __ sll(t2, a3, kPointerSizeLog2 - kSmiTagSize);
2427 __ Addu(t2, a2, Operand(t2)); 2428 __ Addu(t2, a2, Operand(t2));
2428 __ lw(t2, FieldMemOperand(t2, FixedArray::kHeaderSize)); 2429 __ lw(t2, FieldMemOperand(t2, FixedArray::kHeaderSize));
2429 2430
2430 // A monomorphic cache hit or an already megamorphic state: invoke the 2431 // A monomorphic cache hit or an already megamorphic state: invoke the
2431 // function without changing the state. 2432 // function without changing the state.
2432 // We don't know if t2 is a WeakCell or a Symbol, but it's harmless to read at 2433 // We don't know if t2 is a WeakCell or a Symbol, but it's harmless to read at
2433 // this position in a symbol (see static asserts in type-feedback-vector.h). 2434 // this position in a symbol (see static asserts in type-feedback-vector.h).
2434 Label check_allocation_site; 2435 Label check_allocation_site;
2435 Register feedback_map = t1; 2436 Register feedback_map = t1;
2436 Register weak_value = t4; 2437 Register weak_value = t4;
2437 __ lw(weak_value, FieldMemOperand(t2, WeakCell::kValueOffset)); 2438 __ lw(weak_value, FieldMemOperand(t2, WeakCell::kValueOffset));
2438 __ Branch(&done, eq, a1, Operand(weak_value)); 2439 __ Branch(&done_increment_count, eq, a1, Operand(weak_value));
2439 __ LoadRoot(at, Heap::kmegamorphic_symbolRootIndex); 2440 __ LoadRoot(at, Heap::kmegamorphic_symbolRootIndex);
2440 __ Branch(&done, eq, t2, Operand(at)); 2441 __ Branch(&done, eq, t2, Operand(at));
2441 __ lw(feedback_map, FieldMemOperand(t2, HeapObject::kMapOffset)); 2442 __ lw(feedback_map, FieldMemOperand(t2, HeapObject::kMapOffset));
2442 __ LoadRoot(at, Heap::kWeakCellMapRootIndex); 2443 __ LoadRoot(at, Heap::kWeakCellMapRootIndex);
2443 __ Branch(&check_allocation_site, ne, feedback_map, Operand(at)); 2444 __ Branch(&check_allocation_site, ne, feedback_map, Operand(at));
2444 2445
2445 // If the weak cell is cleared, we have a new chance to become monomorphic. 2446 // If the weak cell is cleared, we have a new chance to become monomorphic.
2446 __ JumpIfSmi(weak_value, &initialize); 2447 __ JumpIfSmi(weak_value, &initialize);
2447 __ jmp(&megamorphic); 2448 __ jmp(&megamorphic);
2448 2449
2449 __ bind(&check_allocation_site); 2450 __ bind(&check_allocation_site);
2450 // If we came here, we need to see if we are the array function. 2451 // If we came here, we need to see if we are the array function.
2451 // If we didn't have a matching function, and we didn't find the megamorph 2452 // If we didn't have a matching function, and we didn't find the megamorph
2452 // sentinel, then we have in the slot either some other function or an 2453 // sentinel, then we have in the slot either some other function or an
2453 // AllocationSite. 2454 // AllocationSite.
2454 __ LoadRoot(at, Heap::kAllocationSiteMapRootIndex); 2455 __ LoadRoot(at, Heap::kAllocationSiteMapRootIndex);
2455 __ Branch(&miss, ne, feedback_map, Operand(at)); 2456 __ Branch(&miss, ne, feedback_map, Operand(at));
2456 2457
2457 // Make sure the function is the Array() function 2458 // Make sure the function is the Array() function
2458 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, t2); 2459 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, t2);
2459 __ Branch(&megamorphic, ne, a1, Operand(t2)); 2460 __ Branch(&megamorphic, ne, a1, Operand(t2));
2460 __ jmp(&done); 2461 __ jmp(&done_increment_count);
2461 2462
2462 __ bind(&miss); 2463 __ bind(&miss);
2463 2464
2464 // A monomorphic miss (i.e, here the cache is not uninitialized) goes 2465 // A monomorphic miss (i.e, here the cache is not uninitialized) goes
2465 // megamorphic. 2466 // megamorphic.
2466 __ LoadRoot(at, Heap::kuninitialized_symbolRootIndex); 2467 __ LoadRoot(at, Heap::kuninitialized_symbolRootIndex);
2467 __ Branch(&initialize, eq, t2, Operand(at)); 2468 __ Branch(&initialize, eq, t2, Operand(at));
2468 // MegamorphicSentinel is an immortal immovable object (undefined) so no 2469 // MegamorphicSentinel is an immortal immovable object (undefined) so no
2469 // write-barrier is needed. 2470 // write-barrier is needed.
2470 __ bind(&megamorphic); 2471 __ bind(&megamorphic);
2471 __ sll(t2, a3, kPointerSizeLog2 - kSmiTagSize); 2472 __ sll(t2, a3, kPointerSizeLog2 - kSmiTagSize);
2472 __ Addu(t2, a2, Operand(t2)); 2473 __ Addu(t2, a2, Operand(t2));
2473 __ LoadRoot(at, Heap::kmegamorphic_symbolRootIndex); 2474 __ LoadRoot(at, Heap::kmegamorphic_symbolRootIndex);
2474 __ sw(at, FieldMemOperand(t2, FixedArray::kHeaderSize)); 2475 __ sw(at, FieldMemOperand(t2, FixedArray::kHeaderSize));
2475 __ jmp(&done); 2476 __ jmp(&done);
2476 2477
2477 // An uninitialized cache is patched with the function. 2478 // An uninitialized cache is patched with the function.
2478 __ bind(&initialize); 2479 __ bind(&initialize);
2480
2481 // Initialize the call counter.
2482 __ sll(t0, a3, kPointerSizeLog2 - kSmiTagSize);
2483 __ Addu(t0, a2, Operand(t0));
2484 __ li(t1, Operand(Smi::FromInt(ConstructICNexus::kCallCountIncrement)));
2485 __ sw(t1, FieldMemOperand(t0, FixedArray::kHeaderSize + kPointerSize));
2486
2479 // Make sure the function is the Array() function. 2487 // Make sure the function is the Array() function.
2480 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, t2); 2488 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, t2);
2481 __ Branch(&not_array_function, ne, a1, Operand(t2)); 2489 __ Branch(&not_array_function, ne, a1, Operand(t2));
2482 2490
2483 // The target function is the Array constructor, 2491 // The target function is the Array constructor,
2484 // Create an AllocationSite if we don't already have it, store it in the 2492 // Create an AllocationSite if we don't already have it, store it in the
2485 // slot. 2493 // slot.
2486 CreateAllocationSiteStub create_stub(masm->isolate()); 2494 CreateAllocationSiteStub create_stub(masm->isolate());
2487 CallStubInRecordCallTarget(masm, &create_stub); 2495 CallStubInRecordCallTarget(masm, &create_stub);
2488 __ Branch(&done); 2496 __ Branch(&done);
2489 2497
2490 __ bind(&not_array_function); 2498 __ bind(&not_array_function);
2491 CreateWeakCellStub weak_cell_stub(masm->isolate()); 2499 CreateWeakCellStub weak_cell_stub(masm->isolate());
2492 CallStubInRecordCallTarget(masm, &weak_cell_stub); 2500 CallStubInRecordCallTarget(masm, &weak_cell_stub);
2501 __ Branch(&done);
2502
2503 __ bind(&done_increment_count);
2504 __ sll(t0, a3, kPointerSizeLog2 - kSmiTagSize);
2505 __ Addu(t0, a2, Operand(t0));
2506 __ lw(t1, FieldMemOperand(t0, FixedArray::kHeaderSize + kPointerSize));
2507 __ Addu(t1, t1, Operand(Smi::FromInt(ConstructICNexus::kCallCountIncrement)));
2508 __ sw(t1, FieldMemOperand(t0, FixedArray::kHeaderSize + kPointerSize));
2509
2493 __ bind(&done); 2510 __ bind(&done);
2494 } 2511 }
2495 2512
2496 2513
2497 void CallConstructStub::Generate(MacroAssembler* masm) { 2514 void ConstructICStub::Generate(MacroAssembler* masm) {
2498 // a0 : number of arguments 2515 // a0 : number of arguments
2499 // a1 : the function to call 2516 // a1 : the function to call
2500 // a2 : feedback vector 2517 // a2 : feedback vector
2501 // a3 : slot in feedback vector (Smi, for RecordCallTarget) 2518 // a3 : slot in feedback vector (Smi, for RecordCallTarget)
2502 2519
2503 Label non_function; 2520 Label non_function;
2504 // Check that the function is not a smi. 2521 // Check that the function is not a smi.
2505 __ JumpIfSmi(a1, &non_function); 2522 __ JumpIfSmi(a1, &non_function);
2506 // Check that the function is a JSFunction. 2523 // Check that the function is a JSFunction.
2507 __ GetObjectType(a1, t1, t1); 2524 __ GetObjectType(a1, t1, t1);
(...skipping 3058 matching lines...) Expand 10 before | Expand all | Expand 10 after
5566 MemOperand(fp, 6 * kPointerSize), NULL); 5583 MemOperand(fp, 6 * kPointerSize), NULL);
5567 } 5584 }
5568 5585
5569 5586
5570 #undef __ 5587 #undef __
5571 5588
5572 } // namespace internal 5589 } // namespace internal
5573 } // namespace v8 5590 } // namespace v8
5574 5591
5575 #endif // V8_TARGET_ARCH_MIPS 5592 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/log.cc ('k') | src/mips/interface-descriptors-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698