| 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 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #if V8_TARGET_ARCH_MIPS | 7 #if V8_TARGET_ARCH_MIPS |
| 8 | 8 |
| 9 #include "src/ic-inl.h" | 9 #include "src/ic-inl.h" |
| 10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 Register scratch1, | 554 Register scratch1, |
| 555 Register scratch2, | 555 Register scratch2, |
| 556 Label* miss_label) { | 556 Label* miss_label) { |
| 557 // a0 : value | 557 // a0 : value |
| 558 Label exit; | 558 Label exit; |
| 559 | 559 |
| 560 // Stub never generated for non-global objects that require access | 560 // Stub never generated for non-global objects that require access |
| 561 // checks. | 561 // checks. |
| 562 ASSERT(object->IsJSGlobalProxy() || !object->IsAccessCheckNeeded()); | 562 ASSERT(object->IsJSGlobalProxy() || !object->IsAccessCheckNeeded()); |
| 563 | 563 |
| 564 int index = lookup->GetFieldIndex().field_index(); | 564 FieldIndex index = lookup->GetFieldIndex(); |
| 565 | |
| 566 // Adjust for the number of properties stored in the object. Even in the | |
| 567 // face of a transition we can use the old map here because the size of the | |
| 568 // object and the number of in-object properties is not going to change. | |
| 569 index -= object->map()->inobject_properties(); | |
| 570 | 565 |
| 571 Representation representation = lookup->representation(); | 566 Representation representation = lookup->representation(); |
| 572 ASSERT(!representation.IsNone()); | 567 ASSERT(!representation.IsNone()); |
| 573 if (representation.IsSmi()) { | 568 if (representation.IsSmi()) { |
| 574 __ JumpIfNotSmi(value_reg, miss_label); | 569 __ JumpIfNotSmi(value_reg, miss_label); |
| 575 } else if (representation.IsHeapObject()) { | 570 } else if (representation.IsHeapObject()) { |
| 576 __ JumpIfSmi(value_reg, miss_label); | 571 __ JumpIfSmi(value_reg, miss_label); |
| 577 HeapType* field_type = lookup->GetFieldType(); | 572 HeapType* field_type = lookup->GetFieldType(); |
| 578 HeapType::Iterator<Map> it = field_type->Classes(); | 573 HeapType::Iterator<Map> it = field_type->Classes(); |
| 579 if (!it.Done()) { | 574 if (!it.Done()) { |
| 580 __ lw(scratch1, FieldMemOperand(value_reg, HeapObject::kMapOffset)); | 575 __ lw(scratch1, FieldMemOperand(value_reg, HeapObject::kMapOffset)); |
| 581 Label do_store; | 576 Label do_store; |
| 582 Handle<Map> current; | 577 Handle<Map> current; |
| 583 while (true) { | 578 while (true) { |
| 584 // Do the CompareMap() directly within the Branch() functions. | 579 // Do the CompareMap() directly within the Branch() functions. |
| 585 current = it.Current(); | 580 current = it.Current(); |
| 586 it.Advance(); | 581 it.Advance(); |
| 587 if (it.Done()) { | 582 if (it.Done()) { |
| 588 __ Branch(miss_label, ne, scratch1, Operand(current)); | 583 __ Branch(miss_label, ne, scratch1, Operand(current)); |
| 589 break; | 584 break; |
| 590 } | 585 } |
| 591 __ Branch(&do_store, eq, scratch1, Operand(current)); | 586 __ Branch(&do_store, eq, scratch1, Operand(current)); |
| 592 } | 587 } |
| 593 __ bind(&do_store); | 588 __ bind(&do_store); |
| 594 } | 589 } |
| 595 } else if (representation.IsDouble()) { | 590 } else if (representation.IsDouble()) { |
| 596 // Load the double storage. | 591 // Load the double storage. |
| 597 if (index < 0) { | 592 if (index.is_inobject()) { |
| 598 int offset = object->map()->instance_size() + (index * kPointerSize); | 593 __ lw(scratch1, FieldMemOperand(receiver_reg, index.offset())); |
| 599 __ lw(scratch1, FieldMemOperand(receiver_reg, offset)); | |
| 600 } else { | 594 } else { |
| 601 __ lw(scratch1, | 595 __ lw(scratch1, |
| 602 FieldMemOperand(receiver_reg, JSObject::kPropertiesOffset)); | 596 FieldMemOperand(receiver_reg, JSObject::kPropertiesOffset)); |
| 603 int offset = index * kPointerSize + FixedArray::kHeaderSize; | 597 __ lw(scratch1, FieldMemOperand(scratch1, index.offset())); |
| 604 __ lw(scratch1, FieldMemOperand(scratch1, offset)); | |
| 605 } | 598 } |
| 606 | 599 |
| 607 // Store the value into the storage. | 600 // Store the value into the storage. |
| 608 Label do_store, heap_number; | 601 Label do_store, heap_number; |
| 609 __ JumpIfNotSmi(value_reg, &heap_number); | 602 __ JumpIfNotSmi(value_reg, &heap_number); |
| 610 __ SmiUntag(scratch2, value_reg); | 603 __ SmiUntag(scratch2, value_reg); |
| 611 __ mtc1(scratch2, f6); | 604 __ mtc1(scratch2, f6); |
| 612 __ cvt_d_w(f4, f6); | 605 __ cvt_d_w(f4, f6); |
| 613 __ jmp(&do_store); | 606 __ jmp(&do_store); |
| 614 | 607 |
| 615 __ bind(&heap_number); | 608 __ bind(&heap_number); |
| 616 __ CheckMap(value_reg, scratch2, Heap::kHeapNumberMapRootIndex, | 609 __ CheckMap(value_reg, scratch2, Heap::kHeapNumberMapRootIndex, |
| 617 miss_label, DONT_DO_SMI_CHECK); | 610 miss_label, DONT_DO_SMI_CHECK); |
| 618 __ ldc1(f4, FieldMemOperand(value_reg, HeapNumber::kValueOffset)); | 611 __ ldc1(f4, FieldMemOperand(value_reg, HeapNumber::kValueOffset)); |
| 619 | 612 |
| 620 __ bind(&do_store); | 613 __ bind(&do_store); |
| 621 __ sdc1(f4, FieldMemOperand(scratch1, HeapNumber::kValueOffset)); | 614 __ sdc1(f4, FieldMemOperand(scratch1, HeapNumber::kValueOffset)); |
| 622 // Return the value (register v0). | 615 // Return the value (register v0). |
| 623 ASSERT(value_reg.is(a0)); | 616 ASSERT(value_reg.is(a0)); |
| 624 __ Ret(USE_DELAY_SLOT); | 617 __ Ret(USE_DELAY_SLOT); |
| 625 __ mov(v0, a0); | 618 __ mov(v0, a0); |
| 626 return; | 619 return; |
| 627 } | 620 } |
| 628 | 621 |
| 629 // TODO(verwaest): Share this code as a code stub. | 622 // TODO(verwaest): Share this code as a code stub. |
| 630 SmiCheck smi_check = representation.IsTagged() | 623 SmiCheck smi_check = representation.IsTagged() |
| 631 ? INLINE_SMI_CHECK : OMIT_SMI_CHECK; | 624 ? INLINE_SMI_CHECK : OMIT_SMI_CHECK; |
| 632 if (index < 0) { | 625 if (index.is_inobject()) { |
| 633 // Set the property straight into the object. | 626 // Set the property straight into the object. |
| 634 int offset = object->map()->instance_size() + (index * kPointerSize); | 627 __ sw(value_reg, FieldMemOperand(receiver_reg, index.offset())); |
| 635 __ sw(value_reg, FieldMemOperand(receiver_reg, offset)); | |
| 636 | 628 |
| 637 if (!representation.IsSmi()) { | 629 if (!representation.IsSmi()) { |
| 638 // Skip updating write barrier if storing a smi. | 630 // Skip updating write barrier if storing a smi. |
| 639 __ JumpIfSmi(value_reg, &exit); | 631 __ JumpIfSmi(value_reg, &exit); |
| 640 | 632 |
| 641 // Update the write barrier for the array address. | 633 // Update the write barrier for the array address. |
| 642 // Pass the now unused name_reg as a scratch register. | 634 // Pass the now unused name_reg as a scratch register. |
| 643 __ mov(name_reg, value_reg); | 635 __ mov(name_reg, value_reg); |
| 644 __ RecordWriteField(receiver_reg, | 636 __ RecordWriteField(receiver_reg, |
| 645 offset, | 637 index.offset(), |
| 646 name_reg, | 638 name_reg, |
| 647 scratch1, | 639 scratch1, |
| 648 kRAHasNotBeenSaved, | 640 kRAHasNotBeenSaved, |
| 649 kDontSaveFPRegs, | 641 kDontSaveFPRegs, |
| 650 EMIT_REMEMBERED_SET, | 642 EMIT_REMEMBERED_SET, |
| 651 smi_check); | 643 smi_check); |
| 652 } | 644 } |
| 653 } else { | 645 } else { |
| 654 // Write to the properties array. | 646 // Write to the properties array. |
| 655 int offset = index * kPointerSize + FixedArray::kHeaderSize; | |
| 656 // Get the properties array. | 647 // Get the properties array. |
| 657 __ lw(scratch1, | 648 __ lw(scratch1, |
| 658 FieldMemOperand(receiver_reg, JSObject::kPropertiesOffset)); | 649 FieldMemOperand(receiver_reg, JSObject::kPropertiesOffset)); |
| 659 __ sw(value_reg, FieldMemOperand(scratch1, offset)); | 650 __ sw(value_reg, FieldMemOperand(scratch1, index.offset())); |
| 660 | 651 |
| 661 if (!representation.IsSmi()) { | 652 if (!representation.IsSmi()) { |
| 662 // Skip updating write barrier if storing a smi. | 653 // Skip updating write barrier if storing a smi. |
| 663 __ JumpIfSmi(value_reg, &exit); | 654 __ JumpIfSmi(value_reg, &exit); |
| 664 | 655 |
| 665 // Update the write barrier for the array address. | 656 // Update the write barrier for the array address. |
| 666 // Ok to clobber receiver_reg and name_reg, since we return. | 657 // Ok to clobber receiver_reg and name_reg, since we return. |
| 667 __ mov(name_reg, value_reg); | 658 __ mov(name_reg, value_reg); |
| 668 __ RecordWriteField(scratch1, | 659 __ RecordWriteField(scratch1, |
| 669 offset, | 660 index.offset(), |
| 670 name_reg, | 661 name_reg, |
| 671 receiver_reg, | 662 receiver_reg, |
| 672 kRAHasNotBeenSaved, | 663 kRAHasNotBeenSaved, |
| 673 kDontSaveFPRegs, | 664 kDontSaveFPRegs, |
| 674 EMIT_REMEMBERED_SET, | 665 EMIT_REMEMBERED_SET, |
| 675 smi_check); | 666 smi_check); |
| 676 } | 667 } |
| 677 } | 668 } |
| 678 | 669 |
| 679 // Return the value (register v0). | 670 // Return the value (register v0). |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 990 __ Branch(&miss, ne, scratch2(), Operand(callback)); | 981 __ Branch(&miss, ne, scratch2(), Operand(callback)); |
| 991 } | 982 } |
| 992 | 983 |
| 993 HandlerFrontendFooter(name, &miss); | 984 HandlerFrontendFooter(name, &miss); |
| 994 return reg; | 985 return reg; |
| 995 } | 986 } |
| 996 | 987 |
| 997 | 988 |
| 998 void LoadStubCompiler::GenerateLoadField(Register reg, | 989 void LoadStubCompiler::GenerateLoadField(Register reg, |
| 999 Handle<JSObject> holder, | 990 Handle<JSObject> holder, |
| 1000 PropertyIndex field, | 991 FieldIndex field, |
| 1001 Representation representation) { | 992 Representation representation) { |
| 1002 if (!reg.is(receiver())) __ mov(receiver(), reg); | 993 if (!reg.is(receiver())) __ mov(receiver(), reg); |
| 1003 if (kind() == Code::LOAD_IC) { | 994 if (kind() == Code::LOAD_IC) { |
| 1004 LoadFieldStub stub(isolate(), | 995 LoadFieldStub stub(isolate(), field); |
| 1005 field.is_inobject(holder), | |
| 1006 field.translate(holder), | |
| 1007 representation); | |
| 1008 GenerateTailCall(masm(), stub.GetCode()); | 996 GenerateTailCall(masm(), stub.GetCode()); |
| 1009 } else { | 997 } else { |
| 1010 KeyedLoadFieldStub stub(isolate(), | 998 KeyedLoadFieldStub stub(isolate(), field); |
| 1011 field.is_inobject(holder), | |
| 1012 field.translate(holder), | |
| 1013 representation); | |
| 1014 GenerateTailCall(masm(), stub.GetCode()); | 999 GenerateTailCall(masm(), stub.GetCode()); |
| 1015 } | 1000 } |
| 1016 } | 1001 } |
| 1017 | 1002 |
| 1018 | 1003 |
| 1019 void LoadStubCompiler::GenerateLoadConstant(Handle<Object> value) { | 1004 void LoadStubCompiler::GenerateLoadConstant(Handle<Object> value) { |
| 1020 // Return the constant value. | 1005 // Return the constant value. |
| 1021 __ li(v0, value); | 1006 __ li(v0, value); |
| 1022 __ Ret(); | 1007 __ Ret(); |
| 1023 } | 1008 } |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1515 // ----------------------------------- | 1500 // ----------------------------------- |
| 1516 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss); | 1501 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss); |
| 1517 } | 1502 } |
| 1518 | 1503 |
| 1519 | 1504 |
| 1520 #undef __ | 1505 #undef __ |
| 1521 | 1506 |
| 1522 } } // namespace v8::internal | 1507 } } // namespace v8::internal |
| 1523 | 1508 |
| 1524 #endif // V8_TARGET_ARCH_MIPS | 1509 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |