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_MIPS64 | 5 #if V8_TARGET_ARCH_MIPS64 |
6 | 6 |
7 #include "src/code-stubs.h" | 7 #include "src/code-stubs.h" |
8 #include "src/api-arguments.h" | 8 #include "src/api-arguments.h" |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 4582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4593 } | 4593 } |
4594 __ jmp(&done_allocate); | 4594 __ jmp(&done_allocate); |
4595 | 4595 |
4596 // Fall back to %NewStrictArguments. | 4596 // Fall back to %NewStrictArguments. |
4597 __ bind(&too_big_for_new_space); | 4597 __ bind(&too_big_for_new_space); |
4598 __ Push(a1); | 4598 __ Push(a1); |
4599 __ TailCallRuntime(Runtime::kNewStrictArguments); | 4599 __ TailCallRuntime(Runtime::kNewStrictArguments); |
4600 } | 4600 } |
4601 | 4601 |
4602 | 4602 |
4603 void StoreGlobalViaContextStub::Generate(MacroAssembler* masm) { | |
4604 Register context_reg = cp; | |
4605 Register slot_reg = a2; | |
4606 Register value_reg = a0; | |
4607 Register cell_reg = a4; | |
4608 Register cell_value_reg = a5; | |
4609 Register cell_details_reg = a6; | |
4610 Label fast_heapobject_case, fast_smi_case, slow_case; | |
4611 | |
4612 if (FLAG_debug_code) { | |
4613 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); | |
4614 __ Check(ne, kUnexpectedValue, value_reg, Operand(at)); | |
4615 } | |
4616 | |
4617 // Go up context chain to the script context. | |
4618 for (int i = 0; i < depth(); ++i) { | |
4619 __ ld(cell_reg, ContextMemOperand(context_reg, Context::PREVIOUS_INDEX)); | |
4620 context_reg = cell_reg; | |
4621 } | |
4622 | |
4623 // Load the PropertyCell at the specified slot. | |
4624 __ Dlsa(at, context_reg, slot_reg, kPointerSizeLog2); | |
4625 __ ld(cell_reg, ContextMemOperand(at, 0)); | |
4626 | |
4627 // Load PropertyDetails for the cell (actually only the cell_type and kind). | |
4628 __ ld(cell_details_reg, | |
4629 FieldMemOperand(cell_reg, PropertyCell::kDetailsOffset)); | |
4630 __ SmiUntag(cell_details_reg); | |
4631 __ And(cell_details_reg, cell_details_reg, | |
4632 PropertyDetails::PropertyCellTypeField::kMask | | |
4633 PropertyDetails::KindField::kMask | | |
4634 PropertyDetails::kAttributesReadOnlyMask); | |
4635 | |
4636 // Check if PropertyCell holds mutable data. | |
4637 Label not_mutable_data; | |
4638 __ Branch(¬_mutable_data, ne, cell_details_reg, | |
4639 Operand(PropertyDetails::PropertyCellTypeField::encode( | |
4640 PropertyCellType::kMutable) | | |
4641 PropertyDetails::KindField::encode(kData))); | |
4642 __ JumpIfSmi(value_reg, &fast_smi_case); | |
4643 __ bind(&fast_heapobject_case); | |
4644 __ sd(value_reg, FieldMemOperand(cell_reg, PropertyCell::kValueOffset)); | |
4645 __ RecordWriteField(cell_reg, PropertyCell::kValueOffset, value_reg, | |
4646 cell_details_reg, kRAHasNotBeenSaved, kDontSaveFPRegs, | |
4647 EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); | |
4648 // RecordWriteField clobbers the value register, so we need to reload. | |
4649 __ Ret(USE_DELAY_SLOT); | |
4650 __ ld(value_reg, FieldMemOperand(cell_reg, PropertyCell::kValueOffset)); | |
4651 __ bind(¬_mutable_data); | |
4652 | |
4653 // Check if PropertyCell value matches the new value (relevant for Constant, | |
4654 // ConstantType and Undefined cells). | |
4655 Label not_same_value; | |
4656 __ ld(cell_value_reg, FieldMemOperand(cell_reg, PropertyCell::kValueOffset)); | |
4657 __ Branch(¬_same_value, ne, value_reg, Operand(cell_value_reg)); | |
4658 // Make sure the PropertyCell is not marked READ_ONLY. | |
4659 __ And(at, cell_details_reg, PropertyDetails::kAttributesReadOnlyMask); | |
4660 __ Branch(&slow_case, ne, at, Operand(zero_reg)); | |
4661 if (FLAG_debug_code) { | |
4662 Label done; | |
4663 // This can only be true for Constant, ConstantType and Undefined cells, | |
4664 // because we never store the_hole via this stub. | |
4665 __ Branch(&done, eq, cell_details_reg, | |
4666 Operand(PropertyDetails::PropertyCellTypeField::encode( | |
4667 PropertyCellType::kConstant) | | |
4668 PropertyDetails::KindField::encode(kData))); | |
4669 __ Branch(&done, eq, cell_details_reg, | |
4670 Operand(PropertyDetails::PropertyCellTypeField::encode( | |
4671 PropertyCellType::kConstantType) | | |
4672 PropertyDetails::KindField::encode(kData))); | |
4673 __ Check(eq, kUnexpectedValue, cell_details_reg, | |
4674 Operand(PropertyDetails::PropertyCellTypeField::encode( | |
4675 PropertyCellType::kUndefined) | | |
4676 PropertyDetails::KindField::encode(kData))); | |
4677 __ bind(&done); | |
4678 } | |
4679 __ Ret(); | |
4680 __ bind(¬_same_value); | |
4681 | |
4682 // Check if PropertyCell contains data with constant type (and is not | |
4683 // READ_ONLY). | |
4684 __ Branch(&slow_case, ne, cell_details_reg, | |
4685 Operand(PropertyDetails::PropertyCellTypeField::encode( | |
4686 PropertyCellType::kConstantType) | | |
4687 PropertyDetails::KindField::encode(kData))); | |
4688 | |
4689 // Now either both old and new values must be SMIs or both must be heap | |
4690 // objects with same map. | |
4691 Label value_is_heap_object; | |
4692 __ JumpIfNotSmi(value_reg, &value_is_heap_object); | |
4693 __ JumpIfNotSmi(cell_value_reg, &slow_case); | |
4694 // Old and new values are SMIs, no need for a write barrier here. | |
4695 __ bind(&fast_smi_case); | |
4696 __ Ret(USE_DELAY_SLOT); | |
4697 __ sd(value_reg, FieldMemOperand(cell_reg, PropertyCell::kValueOffset)); | |
4698 __ bind(&value_is_heap_object); | |
4699 __ JumpIfSmi(cell_value_reg, &slow_case); | |
4700 Register cell_value_map_reg = cell_value_reg; | |
4701 __ ld(cell_value_map_reg, | |
4702 FieldMemOperand(cell_value_reg, HeapObject::kMapOffset)); | |
4703 __ Branch(&fast_heapobject_case, eq, cell_value_map_reg, | |
4704 FieldMemOperand(value_reg, HeapObject::kMapOffset)); | |
4705 | |
4706 // Fallback to the runtime. | |
4707 __ bind(&slow_case); | |
4708 __ SmiTag(slot_reg); | |
4709 __ Push(slot_reg, value_reg); | |
4710 __ TailCallRuntime(is_strict(language_mode()) | |
4711 ? Runtime::kStoreGlobalViaContext_Strict | |
4712 : Runtime::kStoreGlobalViaContext_Sloppy); | |
4713 } | |
4714 | |
4715 | |
4716 static int AddressOffset(ExternalReference ref0, ExternalReference ref1) { | 4603 static int AddressOffset(ExternalReference ref0, ExternalReference ref1) { |
4717 int64_t offset = (ref0.address() - ref1.address()); | 4604 int64_t offset = (ref0.address() - ref1.address()); |
4718 DCHECK(static_cast<int>(offset) == offset); | 4605 DCHECK(static_cast<int>(offset) == offset); |
4719 return static_cast<int>(offset); | 4606 return static_cast<int>(offset); |
4720 } | 4607 } |
4721 | 4608 |
4722 | 4609 |
4723 // Calls an API function. Allocates HandleScope, extracts returned value | 4610 // Calls an API function. Allocates HandleScope, extracts returned value |
4724 // from handle and propagates exceptions. Restores context. stack_space | 4611 // from handle and propagates exceptions. Restores context. stack_space |
4725 // - space to be unwound on exit (includes the call JS arguments space and | 4612 // - space to be unwound on exit (includes the call JS arguments space and |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5023 kStackUnwindSpace, kInvalidStackOffset, | 4910 kStackUnwindSpace, kInvalidStackOffset, |
5024 return_value_operand, NULL); | 4911 return_value_operand, NULL); |
5025 } | 4912 } |
5026 | 4913 |
5027 #undef __ | 4914 #undef __ |
5028 | 4915 |
5029 } // namespace internal | 4916 } // namespace internal |
5030 } // namespace v8 | 4917 } // namespace v8 |
5031 | 4918 |
5032 #endif // V8_TARGET_ARCH_MIPS64 | 4919 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |