| 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) { | 117 ASSERT(!object.is(value)); |
| 118 ASSERT(!object.is(index)); |
| 119 ASSERT(!value.is(index)); |
| 120 if (emit_debug_code()) { |
| 121 NearLabel ok; |
| 122 test(object, Immediate(kSmiTagMask)); |
| 123 j(not_zero, &ok); |
| 124 int3(); |
| 125 bind(&ok); |
| 126 } |
| 127 |
| 127 // First, check if a write barrier is even needed. The tests below | 128 // First, check if a write barrier is even needed. The tests below |
| 128 // catch stores of Smis and stores into young gen. | 129 // catch stores of Smis. |
| 129 NearLabel done; | 130 NearLabel done; |
| 130 | 131 |
| 131 // Skip barrier if writing a smi. | 132 // Skip barrier if writing a smi. |
| 132 ASSERT_EQ(0, kSmiTag); | 133 ASSERT_EQ(0, kSmiTag); |
| 133 test(value, Immediate(kSmiTagMask)); | 134 test(value, Immediate(kSmiTagMask)); |
| 134 j(zero, &done); | 135 j(zero, &done); |
| 135 | 136 |
| 136 // The offset is relative to a tagged or untagged HeapObject pointer, | 137 // Array access: calculate the destination address in the same manner as |
| 137 // so either offset or offset + kHeapObjectTag must be a | 138 // KeyedStoreIC::GenerateGeneric. Multiply a smi by 2 to get an offset |
| 138 // multiple of kPointerSize. | 139 // into an array of words. |
| 139 ASSERT(IsAligned(offset, kPointerSize) || | 140 ASSERT_EQ(1, kSmiTagSize); |
| 140 IsAligned(offset + kHeapObjectTag, kPointerSize)); | 141 ASSERT_EQ(0, kSmiTag); |
| 142 Register dst = index; |
| 143 lea(dst, Operand(object, index, times_half_pointer_size, |
| 144 FixedArray::kHeaderSize - kHeapObjectTag)); |
| 141 | 145 |
| 142 if (offset != 0) { | 146 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 | 147 |
| 144 // to store the address of the cell that is being stored to. | 148 bind(&done); |
| 145 lea(dst, Operand(object, offset)); | 149 |
| 146 } else { | 150 // Clobber all input registers when running with the debug-code flag |
| 147 // Array access: calculate the destination address in the same manner as | 151 // turned on to provoke errors. |
| 148 // KeyedStoreIC::GenerateGeneric. Multiply a smi by 2 to get an offset | 152 if (emit_debug_code()) { |
| 149 // into an array of words. | 153 mov(object, Immediate(BitCast<int32_t>(kZapValue))); |
| 150 ASSERT_EQ(1, kSmiTagSize); | 154 mov(value, Immediate(BitCast<int32_t>(kZapValue))); |
| 151 ASSERT_EQ(0, kSmiTag); | 155 mov(index, Immediate(BitCast<int32_t>(kZapValue))); |
| 152 lea(dst, Operand(object, dst, times_half_pointer_size, | 156 } |
| 153 FixedArray::kHeaderSize - kHeapObjectTag)); | 157 } |
| 158 |
| 159 |
| 160 void MacroAssembler::RecordWriteField(Register object, |
| 161 int offset, |
| 162 Register value, |
| 163 Register dst, |
| 164 SaveFPRegsMode save_fp) { |
| 165 ASSERT(!object.is(value)); |
| 166 ASSERT(!object.is(dst)); |
| 167 ASSERT(!value.is(dst)); |
| 168 if (emit_debug_code()) { |
| 169 NearLabel ok; |
| 170 test(object, Immediate(kSmiTagMask)); |
| 171 j(not_zero, &ok); |
| 172 int3(); |
| 173 bind(&ok); |
| 174 } |
| 175 |
| 176 // First, check if a write barrier is even needed. The tests below |
| 177 // catch stores of Smis. |
| 178 NearLabel done; |
| 179 |
| 180 // Skip barrier if writing a smi. |
| 181 ASSERT_EQ(0, kSmiTag); |
| 182 test(value, Immediate(kSmiTagMask)); |
| 183 j(zero, &done); |
| 184 |
| 185 // Although the object register is tagged, the offset is relative to the start |
| 186 // of the object, so offset must be a multiple of kPointerSize. |
| 187 ASSERT(IsAligned(offset, kPointerSize)); |
| 188 |
| 189 lea(dst, FieldOperand(object, offset)); |
| 190 if (emit_debug_code()) { |
| 191 NearLabel ok; |
| 192 test_b(Operand(dst), (1 << kPointerSizeLog2) - 1); |
| 193 j(zero, &ok); |
| 194 int3(); |
| 195 bind(&ok); |
| 154 } | 196 } |
| 155 | 197 |
| 156 RecordWrite(object, dst, value, EMIT_REMEMBERED_SET, save_fp, OMIT_SMI_CHECK); | 198 RecordWrite(object, dst, value, EMIT_REMEMBERED_SET, save_fp, OMIT_SMI_CHECK); |
| 157 | 199 |
| 158 bind(&done); | 200 bind(&done); |
| 159 | 201 |
| 160 // Clobber all input registers when running with the debug-code flag | 202 // Clobber all input registers when running with the debug-code flag |
| 161 // turned on to provoke errors. | 203 // turned on to provoke errors. |
| 162 if (emit_debug_code()) { | 204 if (emit_debug_code()) { |
| 163 mov(object, Immediate(BitCast<int32_t>(kZapValue))); | 205 mov(object, Immediate(BitCast<int32_t>(kZapValue))); |
| 164 mov(value, Immediate(BitCast<int32_t>(kZapValue))); | 206 mov(value, Immediate(BitCast<int32_t>(kZapValue))); |
| 165 mov(dst, Immediate(BitCast<int32_t>(kZapValue))); | 207 mov(dst, Immediate(BitCast<int32_t>(kZapValue))); |
| 166 } | 208 } |
| 167 } | 209 } |
| 168 | 210 |
| 169 | 211 |
| 170 void MacroAssembler::RecordWrite(Register object, | 212 void MacroAssembler::RecordWrite(Register object, |
| 171 Register address, | 213 Register address, |
| 172 Register value, | 214 Register value, |
| 173 EmitRememberedSet emit_remembered_set, | 215 EmitRememberedSet emit_remembered_set, |
| 174 SaveFPRegsMode fp_mode, | 216 SaveFPRegsMode fp_mode, |
| 175 SmiCheck smi_check) { | 217 SmiCheck smi_check) { |
| 218 ASSERT(!object.is(value)); |
| 219 ASSERT(!object.is(address)); |
| 220 ASSERT(!value.is(address)); |
| 221 if (emit_debug_code()) { |
| 222 NearLabel ok; |
| 223 test(object, Immediate(kSmiTagMask)); |
| 224 j(not_zero, &ok); |
| 225 int3(); |
| 226 bind(&ok); |
| 227 } |
| 228 |
| 176 if (emit_remembered_set == OMIT_REMEMBERED_SET && | 229 if (emit_remembered_set == OMIT_REMEMBERED_SET && |
| 177 FLAG_incremental_marking == false) { | 230 FLAG_incremental_marking == false) { |
| 178 return; | 231 return; |
| 179 } | 232 } |
| 180 // First, check if a write barrier is even needed. The tests below | 233 // First, check if a write barrier is even needed. The tests below |
| 181 // catch stores of Smis and stores into young gen. | 234 // catch stores of Smis and stores into young gen. |
| 182 NearLabel done; | 235 NearLabel done; |
| 183 | 236 |
| 237 if (emit_debug_code()) { |
| 238 NearLabel ok; |
| 239 test(object, Immediate(kSmiTagMask)); |
| 240 j(not_zero, &ok); |
| 241 int3(); |
| 242 bind(&ok); |
| 243 } |
| 244 |
| 184 if (smi_check == INLINE_SMI_CHECK) { | 245 if (smi_check == INLINE_SMI_CHECK) { |
| 185 // Skip barrier if writing a smi. | 246 // Skip barrier if writing a smi. |
| 186 ASSERT_EQ(0, kSmiTag); | 247 ASSERT_EQ(0, kSmiTag); |
| 187 test(value, Immediate(kSmiTagMask)); | 248 test(value, Immediate(kSmiTagMask)); |
| 188 j(zero, &done); | 249 j(zero, &done); |
| 189 } | 250 } |
| 190 | 251 |
| 191 RecordWriteStub stub(object, value, address, emit_remembered_set, fp_mode); | 252 RecordWriteStub stub(object, value, address, emit_remembered_set, fp_mode); |
| 192 CallStub(&stub); | 253 CallStub(&stub); |
| 193 | 254 |
| (...skipping 1875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2069 | 2130 |
| 2070 call(Operand(function)); | 2131 call(Operand(function)); |
| 2071 if (OS::ActivationFrameAlignment() != 0) { | 2132 if (OS::ActivationFrameAlignment() != 0) { |
| 2072 mov(esp, Operand(esp, num_arguments * kPointerSize)); | 2133 mov(esp, Operand(esp, num_arguments * kPointerSize)); |
| 2073 } else { | 2134 } else { |
| 2074 add(Operand(esp), Immediate(num_arguments * sizeof(int32_t))); | 2135 add(Operand(esp), Immediate(num_arguments * sizeof(int32_t))); |
| 2075 } | 2136 } |
| 2076 } | 2137 } |
| 2077 | 2138 |
| 2078 | 2139 |
| 2140 bool Aliasing(Register r1, Register r2, Register r3, Register r4) { |
| 2141 if (r1.is(r2)) return true; |
| 2142 if (r1.is(r3)) return true; |
| 2143 if (r1.is(r4)) return true; |
| 2144 if (r2.is(r3)) return true; |
| 2145 if (r2.is(r4)) return true; |
| 2146 if (r3.is(r4)) return true; |
| 2147 return false; |
| 2148 } |
| 2149 |
| 2150 |
| 2079 CodePatcher::CodePatcher(byte* address, int size) | 2151 CodePatcher::CodePatcher(byte* address, int size) |
| 2080 : address_(address), size_(size), masm_(address, size + Assembler::kGap) { | 2152 : address_(address), size_(size), masm_(address, size + Assembler::kGap) { |
| 2081 // Create a new macro assembler pointing to the address of the code to patch. | 2153 // Create a new macro assembler pointing to the address of the code to patch. |
| 2082 // The size is adjusted with kGap on order for the assembler to generate size | 2154 // The size is adjusted with kGap on order for the assembler to generate size |
| 2083 // bytes of instructions without failing with buffer size constraints. | 2155 // bytes of instructions without failing with buffer size constraints. |
| 2084 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 2156 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
| 2085 } | 2157 } |
| 2086 | 2158 |
| 2087 | 2159 |
| 2088 CodePatcher::~CodePatcher() { | 2160 CodePatcher::~CodePatcher() { |
| 2089 // Indicate that code has changed. | 2161 // Indicate that code has changed. |
| 2090 CPU::FlushICache(address_, size_); | 2162 CPU::FlushICache(address_, size_); |
| 2091 | 2163 |
| 2092 // Check that the code was patched as expected. | 2164 // Check that the code was patched as expected. |
| 2093 ASSERT(masm_.pc_ == address_ + size_); | 2165 ASSERT(masm_.pc_ == address_ + size_); |
| 2094 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 2166 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
| 2095 } | 2167 } |
| 2096 | 2168 |
| 2097 | 2169 |
| 2098 } } // namespace v8::internal | 2170 } } // namespace v8::internal |
| 2099 | 2171 |
| 2100 #endif // V8_TARGET_ARCH_IA32 | 2172 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |