OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 | 230 |
231 // Clobber clobbered input registers when running with the debug-code flag | 231 // Clobber clobbered input registers when running with the debug-code flag |
232 // turned on to provoke errors. | 232 // turned on to provoke errors. |
233 if (emit_debug_code()) { | 233 if (emit_debug_code()) { |
234 mov(value, Immediate(BitCast<int32_t>(kZapValue))); | 234 mov(value, Immediate(BitCast<int32_t>(kZapValue))); |
235 mov(dst, Immediate(BitCast<int32_t>(kZapValue))); | 235 mov(dst, Immediate(BitCast<int32_t>(kZapValue))); |
236 } | 236 } |
237 } | 237 } |
238 | 238 |
239 | 239 |
| 240 void MacroAssembler::RecordWriteForMap( |
| 241 Register object, |
| 242 Handle<Map> map, |
| 243 Register scratch1, |
| 244 Register scratch2, |
| 245 SaveFPRegsMode save_fp) { |
| 246 // First, check if a write barrier is even needed. The tests below |
| 247 // catch stores of Smis. |
| 248 Label done; |
| 249 |
| 250 Register address = scratch1; |
| 251 Register value = scratch2; |
| 252 if (emit_debug_code()) { |
| 253 Label ok; |
| 254 lea(address, FieldOperand(object, HeapObject::kMapOffset)); |
| 255 test_b(address, (1 << kPointerSizeLog2) - 1); |
| 256 j(zero, &ok, Label::kNear); |
| 257 int3(); |
| 258 bind(&ok); |
| 259 } |
| 260 |
| 261 ASSERT(!object.is(value)); |
| 262 ASSERT(!object.is(address)); |
| 263 ASSERT(!value.is(address)); |
| 264 if (emit_debug_code()) { |
| 265 AbortIfSmi(object); |
| 266 } |
| 267 |
| 268 if (!FLAG_incremental_marking) { |
| 269 return; |
| 270 } |
| 271 |
| 272 // A single check of the map's pages interesting flag suffices, since it is |
| 273 // only set during incremental collection, and then it's also guaranteed that |
| 274 // the from object's page's interesting flag is also set. This optimization |
| 275 // relies on the fact that maps can never be in new space. |
| 276 ASSERT(!isolate()->heap()->InNewSpace(*map)); |
| 277 CheckPageFlagForMap(map, |
| 278 MemoryChunk::kPointersToHereAreInterestingMask, |
| 279 zero, |
| 280 &done, |
| 281 Label::kNear); |
| 282 |
| 283 // Delay the initialization of |address| and |value| for the stub until it's |
| 284 // known that the will be needed. Up until this point their value are not |
| 285 // needed since they are embedded in the operands of instructions that need |
| 286 // them. |
| 287 lea(address, FieldOperand(object, HeapObject::kMapOffset)); |
| 288 mov(value, Immediate(map)); |
| 289 RecordWriteStub stub(object, value, address, OMIT_REMEMBERED_SET, save_fp); |
| 290 CallStub(&stub); |
| 291 |
| 292 bind(&done); |
| 293 |
| 294 // Clobber clobbered input registers when running with the debug-code flag |
| 295 // turned on to provoke errors. |
| 296 if (emit_debug_code()) { |
| 297 mov(value, Immediate(BitCast<int32_t>(kZapValue))); |
| 298 mov(scratch1, Immediate(BitCast<int32_t>(kZapValue))); |
| 299 mov(scratch2, Immediate(BitCast<int32_t>(kZapValue))); |
| 300 } |
| 301 } |
| 302 |
| 303 |
240 void MacroAssembler::RecordWrite(Register object, | 304 void MacroAssembler::RecordWrite(Register object, |
241 Register address, | 305 Register address, |
242 Register value, | 306 Register value, |
243 SaveFPRegsMode fp_mode, | 307 SaveFPRegsMode fp_mode, |
244 RememberedSetAction remembered_set_action, | 308 RememberedSetAction remembered_set_action, |
245 SmiCheck smi_check) { | 309 SmiCheck smi_check) { |
246 ASSERT(!object.is(value)); | 310 ASSERT(!object.is(value)); |
247 ASSERT(!object.is(address)); | 311 ASSERT(!object.is(address)); |
248 ASSERT(!value.is(address)); | 312 ASSERT(!value.is(address)); |
249 if (emit_debug_code()) { | 313 if (emit_debug_code()) { |
(...skipping 2361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2611 if (mask < (1 << kBitsPerByte)) { | 2675 if (mask < (1 << kBitsPerByte)) { |
2612 test_b(Operand(scratch, MemoryChunk::kFlagsOffset), | 2676 test_b(Operand(scratch, MemoryChunk::kFlagsOffset), |
2613 static_cast<uint8_t>(mask)); | 2677 static_cast<uint8_t>(mask)); |
2614 } else { | 2678 } else { |
2615 test(Operand(scratch, MemoryChunk::kFlagsOffset), Immediate(mask)); | 2679 test(Operand(scratch, MemoryChunk::kFlagsOffset), Immediate(mask)); |
2616 } | 2680 } |
2617 j(cc, condition_met, condition_met_distance); | 2681 j(cc, condition_met, condition_met_distance); |
2618 } | 2682 } |
2619 | 2683 |
2620 | 2684 |
| 2685 void MacroAssembler::CheckPageFlagForMap( |
| 2686 Handle<Map> map, |
| 2687 int mask, |
| 2688 Condition cc, |
| 2689 Label* condition_met, |
| 2690 Label::Distance condition_met_distance) { |
| 2691 ASSERT(cc == zero || cc == not_zero); |
| 2692 Page* page = Page::FromAddress(map->address()); |
| 2693 ExternalReference reference(ExternalReference::page_flags(page)); |
| 2694 // The inlined static address check of the page's flags relies |
| 2695 // on maps never being compacted. |
| 2696 ASSERT(!isolate()->heap()->mark_compact_collector()-> |
| 2697 IsOnEvacuationCandidate(*map)); |
| 2698 if (mask < (1 << kBitsPerByte)) { |
| 2699 test_b(Operand::StaticVariable(reference), static_cast<uint8_t>(mask)); |
| 2700 } else { |
| 2701 test(Operand::StaticVariable(reference), Immediate(mask)); |
| 2702 } |
| 2703 j(cc, condition_met, condition_met_distance); |
| 2704 } |
| 2705 |
| 2706 |
2621 void MacroAssembler::JumpIfBlack(Register object, | 2707 void MacroAssembler::JumpIfBlack(Register object, |
2622 Register scratch0, | 2708 Register scratch0, |
2623 Register scratch1, | 2709 Register scratch1, |
2624 Label* on_black, | 2710 Label* on_black, |
2625 Label::Distance on_black_near) { | 2711 Label::Distance on_black_near) { |
2626 HasColor(object, scratch0, scratch1, | 2712 HasColor(object, scratch0, scratch1, |
2627 on_black, on_black_near, | 2713 on_black, on_black_near, |
2628 1, 0); // kBlackBitPattern. | 2714 1, 0); // kBlackBitPattern. |
2629 ASSERT(strcmp(Marking::kBlackBitPattern, "10") == 0); | 2715 ASSERT(strcmp(Marking::kBlackBitPattern, "10") == 0); |
2630 } | 2716 } |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2822 // Load the prototype from the map and loop if non-null. | 2908 // Load the prototype from the map and loop if non-null. |
2823 bind(&check_prototype); | 2909 bind(&check_prototype); |
2824 mov(ecx, FieldOperand(ebx, Map::kPrototypeOffset)); | 2910 mov(ecx, FieldOperand(ebx, Map::kPrototypeOffset)); |
2825 cmp(ecx, isolate()->factory()->null_value()); | 2911 cmp(ecx, isolate()->factory()->null_value()); |
2826 j(not_equal, &next); | 2912 j(not_equal, &next); |
2827 } | 2913 } |
2828 | 2914 |
2829 } } // namespace v8::internal | 2915 } } // namespace v8::internal |
2830 | 2916 |
2831 #endif // V8_TARGET_ARCH_IA32 | 2917 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |