Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 79 mov(Operand(esp, 1 * kPointerSize), value); | 79 mov(Operand(esp, 1 * kPointerSize), value); |
| 80 CallCFunction( | 80 CallCFunction( |
| 81 ExternalReference::incremental_marking_record_write_function(), 2); | 81 ExternalReference::incremental_marking_record_write_function(), 2); |
| 82 | 82 |
| 83 for (int i = Register::kNumRegisters - 1; i >= 0; i--) { | 83 for (int i = Register::kNumRegisters - 1; i >= 0; i--) { |
| 84 if (preserve[i]) pop(Register::from_code(i)); | 84 if (preserve[i]) pop(Register::from_code(i)); |
| 85 } | 85 } |
| 86 } | 86 } |
| 87 | 87 |
| 88 | 88 |
| 89 void MacroAssembler::RememberedSetHelper(Register object, | 89 void MacroAssembler::RememberedSetHelper(Register addr, |
| 90 Register addr, | |
| 91 Register scratch, | 90 Register scratch, |
| 92 SaveFPRegsMode save_fp) { | 91 SaveFPRegsMode save_fp) { |
| 93 if (emit_debug_code()) { | 92 NearLabel done; |
| 94 // Check that the object is not in new space. | |
| 95 Label not_in_new_space; | |
| 96 InNewSpace(object, scratch, not_equal, ¬_in_new_space); | |
| 97 Abort("new-space object passed to RememberedSetHelper"); | |
| 98 bind(¬_in_new_space); | |
| 99 } | |
| 100 | |
| 101 // Load store buffer top. | 93 // Load store buffer top. |
| 102 ExternalReference store_buffer = ExternalReference::store_buffer_top(); | 94 ExternalReference store_buffer = ExternalReference::store_buffer_top(); |
| 103 mov(scratch, Operand::StaticVariable(store_buffer)); | 95 mov(scratch, Operand::StaticVariable(store_buffer)); |
| 104 // Store pointer to buffer. | 96 // Store pointer to buffer. |
| 105 mov(Operand(scratch, 0), addr); | 97 mov(Operand(scratch, 0), addr); |
| 106 // Increment buffer top. | 98 // Increment buffer top. |
| 107 add(Operand(scratch), Immediate(kPointerSize)); | 99 add(Operand(scratch), Immediate(kPointerSize)); |
| 108 // Write back new top of buffer. | 100 // Write back new top of buffer. |
| 109 mov(Operand::StaticVariable(store_buffer), scratch); | 101 mov(Operand::StaticVariable(store_buffer), scratch); |
| 110 // Call stub on end of buffer. | 102 // Call stub on end of buffer. |
| 111 NearLabel no_overflow; | |
| 112 // Check for end of buffer. | 103 // Check for end of buffer. |
| 113 test(scratch, Immediate(StoreBuffer::kStoreBufferOverflowBit)); | 104 test(scratch, Immediate(StoreBuffer::kStoreBufferOverflowBit)); |
| 114 j(equal, &no_overflow); | 105 j(equal, &done); |
| 115 StoreBufferOverflowStub store_buffer_overflow = | 106 StoreBufferOverflowStub store_buffer_overflow = |
| 116 StoreBufferOverflowStub(save_fp); | 107 StoreBufferOverflowStub(save_fp); |
| 117 CallStub(&store_buffer_overflow); | 108 CallStub(&store_buffer_overflow); |
| 118 bind(&no_overflow); | 109 bind(&done); |
| 119 } | 110 } |
| 120 | 111 |
| 121 | 112 |
| 122 void MacroAssembler::RecordWrite(Register object, | 113 void MacroAssembler::RecordWriteArray(Register object, |
| 123 int offset, | 114 Register value, |
| 124 Register value, | 115 Register index, |
| 125 Register dst, | 116 SaveFPRegsMode save_fp) { |
| 126 SaveFPRegsMode save_fp) { | |
| 127 // First, check if a write barrier is even needed. The tests below | 117 // First, check if a write barrier is even needed. The tests below |
| 128 // catch stores of Smis and stores into young gen. | 118 // catch stores of Smis. |
| 129 NearLabel done; | 119 NearLabel done; |
| 130 | 120 |
| 131 // Skip barrier if writing a smi. | 121 // Skip barrier if writing a smi. |
| 132 ASSERT_EQ(0, kSmiTag); | 122 ASSERT_EQ(0, kSmiTag); |
| 133 test(value, Immediate(kSmiTagMask)); | 123 test(value, Immediate(kSmiTagMask)); |
| 134 j(zero, &done); | 124 j(zero, &done); |
| 135 | 125 |
| 136 // The offset is relative to a tagged or untagged HeapObject pointer, | 126 // Array access: calculate the destination address in the same manner as |
| 137 // so either offset or offset + kHeapObjectTag must be a | 127 // KeyedStoreIC::GenerateGeneric. Multiply a smi by 2 to get an offset |
| 138 // multiple of kPointerSize. | 128 // into an array of words. |
| 139 ASSERT(IsAligned(offset, kPointerSize) || | 129 ASSERT_EQ(1, kSmiTagSize); |
| 140 IsAligned(offset + kHeapObjectTag, kPointerSize)); | 130 ASSERT_EQ(0, kSmiTag); |
| 131 Register dst = index; | |
| 132 lea(dst, Operand(object, index, times_half_pointer_size, | |
| 133 FixedArray::kHeaderSize - kHeapObjectTag)); | |
| 141 | 134 |
| 142 if (offset != 0) { | 135 RecordWrite(object, dst, value, EMIT_REMEMBERED_SET, save_fp, OMIT_SMI_CHECK); |
| 143 // If offset is unspecified, then dst is a scratch register. We use it | 136 |
| 144 // to store the address of the cell that is being stored to. | 137 bind(&done); |
| 145 lea(dst, Operand(object, offset)); | 138 |
| 146 } else { | 139 // Clobber all input registers when running with the debug-code flag |
| 147 // Array access: calculate the destination address in the same manner as | 140 // turned on to provoke errors. |
| 148 // KeyedStoreIC::GenerateGeneric. Multiply a smi by 2 to get an offset | 141 if (emit_debug_code()) { |
| 149 // into an array of words. | 142 mov(object, Immediate(BitCast<int32_t>(kZapValue))); |
| 150 ASSERT_EQ(1, kSmiTagSize); | 143 mov(value, Immediate(BitCast<int32_t>(kZapValue))); |
| 151 ASSERT_EQ(0, kSmiTag); | 144 mov(index, Immediate(BitCast<int32_t>(kZapValue))); |
| 152 lea(dst, Operand(object, dst, times_half_pointer_size, | 145 } |
| 153 FixedArray::kHeaderSize - kHeapObjectTag)); | 146 } |
| 147 | |
| 148 | |
| 149 void MacroAssembler::RecordWriteField(Register object, | |
| 150 int offset, | |
| 151 Register value, | |
| 152 Register dst, | |
| 153 SaveFPRegsMode save_fp) { | |
| 154 // First, check if a write barrier is even needed. The tests below | |
| 155 // catch stores of Smis. | |
| 156 NearLabel done; | |
| 157 | |
| 158 // Skip barrier if writing a smi. | |
| 159 ASSERT_EQ(0, kSmiTag); | |
| 160 test(value, Immediate(kSmiTagMask)); | |
| 161 j(zero, &done); | |
| 162 | |
| 163 // Although the object register is tagged, the offset is relative to the start | |
| 164 // of the object, so so offset must be a multiple of kPointerSize. | |
|
Vyacheslav Egorov (Chromium)
2011/04/16 17:50:36
so so -> so
Erik Corry
2011/04/23 17:00:11
Done.
| |
| 165 ASSERT(IsAligned(offset, kPointerSize)); | |
| 166 | |
| 167 lea(dst, FieldOperand(object, offset)); | |
| 168 if (emit_debug_code()) { | |
| 169 NearLabel ok; | |
| 170 test_b(Operand(dst), (1 << kPointerSizeLog2) - 1); | |
| 171 j(zero, &ok); | |
| 172 int3(); | |
| 173 bind(&ok); | |
| 154 } | 174 } |
| 155 | 175 |
| 156 RecordWrite(object, dst, value, EMIT_REMEMBERED_SET, save_fp, OMIT_SMI_CHECK); | 176 RecordWrite(object, dst, value, EMIT_REMEMBERED_SET, save_fp, OMIT_SMI_CHECK); |
| 157 | 177 |
| 158 bind(&done); | 178 bind(&done); |
| 159 | 179 |
| 160 // Clobber all input registers when running with the debug-code flag | 180 // Clobber all input registers when running with the debug-code flag |
| 161 // turned on to provoke errors. | 181 // turned on to provoke errors. |
| 162 if (emit_debug_code()) { | 182 if (emit_debug_code()) { |
| 163 mov(object, Immediate(BitCast<int32_t>(kZapValue))); | 183 mov(object, Immediate(BitCast<int32_t>(kZapValue))); |
| (...skipping 1913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2077 | 2097 |
| 2078 // Check that the code was patched as expected. | 2098 // Check that the code was patched as expected. |
| 2079 ASSERT(masm_.pc_ == address_ + size_); | 2099 ASSERT(masm_.pc_ == address_ + size_); |
| 2080 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 2100 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
| 2081 } | 2101 } |
| 2082 | 2102 |
| 2083 | 2103 |
| 2084 } } // namespace v8::internal | 2104 } } // namespace v8::internal |
| 2085 | 2105 |
| 2086 #endif // V8_TARGET_ARCH_IA32 | 2106 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |