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