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/code-stubs.h" | 7 #include "src/code-stubs.h" |
8 #include "src/api-arguments.h" | 8 #include "src/api-arguments.h" |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 4560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4571 } | 4571 } |
4572 __ jmp(&done_allocate); | 4572 __ jmp(&done_allocate); |
4573 | 4573 |
4574 // Fall back to %NewStrictArguments. | 4574 // Fall back to %NewStrictArguments. |
4575 __ bind(&too_big_for_new_space); | 4575 __ bind(&too_big_for_new_space); |
4576 __ Push(a1); | 4576 __ Push(a1); |
4577 __ TailCallRuntime(Runtime::kNewStrictArguments); | 4577 __ TailCallRuntime(Runtime::kNewStrictArguments); |
4578 } | 4578 } |
4579 | 4579 |
4580 | 4580 |
4581 void StoreGlobalViaContextStub::Generate(MacroAssembler* masm) { | |
4582 Register context_reg = cp; | |
4583 Register slot_reg = a2; | |
4584 Register value_reg = a0; | |
4585 Register cell_reg = t0; | |
4586 Register cell_value_reg = t1; | |
4587 Register cell_details_reg = t2; | |
4588 Label fast_heapobject_case, fast_smi_case, slow_case; | |
4589 | |
4590 if (FLAG_debug_code) { | |
4591 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); | |
4592 __ Check(ne, kUnexpectedValue, value_reg, Operand(at)); | |
4593 } | |
4594 | |
4595 // Go up context chain to the script context. | |
4596 for (int i = 0; i < depth(); ++i) { | |
4597 __ lw(cell_reg, ContextMemOperand(context_reg, Context::PREVIOUS_INDEX)); | |
4598 context_reg = cell_reg; | |
4599 } | |
4600 | |
4601 // Load the PropertyCell at the specified slot. | |
4602 __ Lsa(at, context_reg, slot_reg, kPointerSizeLog2); | |
4603 __ lw(cell_reg, ContextMemOperand(at, 0)); | |
4604 | |
4605 // Load PropertyDetails for the cell (actually only the cell_type and kind). | |
4606 __ lw(cell_details_reg, | |
4607 FieldMemOperand(cell_reg, PropertyCell::kDetailsOffset)); | |
4608 __ SmiUntag(cell_details_reg); | |
4609 __ And(cell_details_reg, cell_details_reg, | |
4610 PropertyDetails::PropertyCellTypeField::kMask | | |
4611 PropertyDetails::KindField::kMask | | |
4612 PropertyDetails::kAttributesReadOnlyMask); | |
4613 | |
4614 // Check if PropertyCell holds mutable data. | |
4615 Label not_mutable_data; | |
4616 __ Branch(¬_mutable_data, ne, cell_details_reg, | |
4617 Operand(PropertyDetails::PropertyCellTypeField::encode( | |
4618 PropertyCellType::kMutable) | | |
4619 PropertyDetails::KindField::encode(kData))); | |
4620 __ JumpIfSmi(value_reg, &fast_smi_case); | |
4621 __ bind(&fast_heapobject_case); | |
4622 __ sw(value_reg, FieldMemOperand(cell_reg, PropertyCell::kValueOffset)); | |
4623 __ RecordWriteField(cell_reg, PropertyCell::kValueOffset, value_reg, | |
4624 cell_details_reg, kRAHasNotBeenSaved, kDontSaveFPRegs, | |
4625 EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); | |
4626 // RecordWriteField clobbers the value register, so we need to reload. | |
4627 __ Ret(USE_DELAY_SLOT); | |
4628 __ lw(value_reg, FieldMemOperand(cell_reg, PropertyCell::kValueOffset)); | |
4629 __ bind(¬_mutable_data); | |
4630 | |
4631 // Check if PropertyCell value matches the new value (relevant for Constant, | |
4632 // ConstantType and Undefined cells). | |
4633 Label not_same_value; | |
4634 __ lw(cell_value_reg, FieldMemOperand(cell_reg, PropertyCell::kValueOffset)); | |
4635 __ Branch(¬_same_value, ne, value_reg, Operand(cell_value_reg)); | |
4636 // Make sure the PropertyCell is not marked READ_ONLY. | |
4637 __ And(at, cell_details_reg, PropertyDetails::kAttributesReadOnlyMask); | |
4638 __ Branch(&slow_case, ne, at, Operand(zero_reg)); | |
4639 if (FLAG_debug_code) { | |
4640 Label done; | |
4641 // This can only be true for Constant, ConstantType and Undefined cells, | |
4642 // because we never store the_hole via this stub. | |
4643 __ Branch(&done, eq, cell_details_reg, | |
4644 Operand(PropertyDetails::PropertyCellTypeField::encode( | |
4645 PropertyCellType::kConstant) | | |
4646 PropertyDetails::KindField::encode(kData))); | |
4647 __ Branch(&done, eq, cell_details_reg, | |
4648 Operand(PropertyDetails::PropertyCellTypeField::encode( | |
4649 PropertyCellType::kConstantType) | | |
4650 PropertyDetails::KindField::encode(kData))); | |
4651 __ Check(eq, kUnexpectedValue, cell_details_reg, | |
4652 Operand(PropertyDetails::PropertyCellTypeField::encode( | |
4653 PropertyCellType::kUndefined) | | |
4654 PropertyDetails::KindField::encode(kData))); | |
4655 __ bind(&done); | |
4656 } | |
4657 __ Ret(); | |
4658 __ bind(¬_same_value); | |
4659 | |
4660 // Check if PropertyCell contains data with constant type (and is not | |
4661 // READ_ONLY). | |
4662 __ Branch(&slow_case, ne, cell_details_reg, | |
4663 Operand(PropertyDetails::PropertyCellTypeField::encode( | |
4664 PropertyCellType::kConstantType) | | |
4665 PropertyDetails::KindField::encode(kData))); | |
4666 | |
4667 // Now either both old and new values must be SMIs or both must be heap | |
4668 // objects with same map. | |
4669 Label value_is_heap_object; | |
4670 __ JumpIfNotSmi(value_reg, &value_is_heap_object); | |
4671 __ JumpIfNotSmi(cell_value_reg, &slow_case); | |
4672 // Old and new values are SMIs, no need for a write barrier here. | |
4673 __ bind(&fast_smi_case); | |
4674 __ Ret(USE_DELAY_SLOT); | |
4675 __ sw(value_reg, FieldMemOperand(cell_reg, PropertyCell::kValueOffset)); | |
4676 __ bind(&value_is_heap_object); | |
4677 __ JumpIfSmi(cell_value_reg, &slow_case); | |
4678 Register cell_value_map_reg = cell_value_reg; | |
4679 __ lw(cell_value_map_reg, | |
4680 FieldMemOperand(cell_value_reg, HeapObject::kMapOffset)); | |
4681 __ Branch(&fast_heapobject_case, eq, cell_value_map_reg, | |
4682 FieldMemOperand(value_reg, HeapObject::kMapOffset)); | |
4683 | |
4684 // Fallback to the runtime. | |
4685 __ bind(&slow_case); | |
4686 __ SmiTag(slot_reg); | |
4687 __ Push(slot_reg, value_reg); | |
4688 __ TailCallRuntime(is_strict(language_mode()) | |
4689 ? Runtime::kStoreGlobalViaContext_Strict | |
4690 : Runtime::kStoreGlobalViaContext_Sloppy); | |
4691 } | |
4692 | |
4693 | |
4694 static int AddressOffset(ExternalReference ref0, ExternalReference ref1) { | 4581 static int AddressOffset(ExternalReference ref0, ExternalReference ref1) { |
4695 return ref0.address() - ref1.address(); | 4582 return ref0.address() - ref1.address(); |
4696 } | 4583 } |
4697 | 4584 |
4698 | 4585 |
4699 // Calls an API function. Allocates HandleScope, extracts returned value | 4586 // Calls an API function. Allocates HandleScope, extracts returned value |
4700 // from handle and propagates exceptions. Restores context. stack_space | 4587 // from handle and propagates exceptions. Restores context. stack_space |
4701 // - space to be unwound on exit (includes the call JS arguments space and | 4588 // - space to be unwound on exit (includes the call JS arguments space and |
4702 // the additional space allocated for the fast call). | 4589 // the additional space allocated for the fast call). |
4703 static void CallApiFunctionAndReturn( | 4590 static void CallApiFunctionAndReturn( |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4996 kStackUnwindSpace, kInvalidStackOffset, | 4883 kStackUnwindSpace, kInvalidStackOffset, |
4997 return_value_operand, NULL); | 4884 return_value_operand, NULL); |
4998 } | 4885 } |
4999 | 4886 |
5000 #undef __ | 4887 #undef __ |
5001 | 4888 |
5002 } // namespace internal | 4889 } // namespace internal |
5003 } // namespace v8 | 4890 } // namespace v8 |
5004 | 4891 |
5005 #endif // V8_TARGET_ARCH_MIPS | 4892 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |