Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(340)

Side by Side Diff: src/ia32/codegen-ia32.cc

Issue 6824078: Move most of the incremental marking write barrier to generated code. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: '' Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 // SlotOperand loads context.reg() with the context object 263 // SlotOperand loads context.reg() with the context object
264 // stored to, used below in RecordWrite. 264 // stored to, used below in RecordWrite.
265 Result context = allocator_->Allocate(); 265 Result context = allocator_->Allocate();
266 ASSERT(context.is_valid()); 266 ASSERT(context.is_valid());
267 __ mov(SlotOperand(slot, context.reg()), value.reg()); 267 __ mov(SlotOperand(slot, context.reg()), value.reg());
268 int offset = FixedArray::kHeaderSize + slot->index() * kPointerSize; 268 int offset = FixedArray::kHeaderSize + slot->index() * kPointerSize;
269 Result scratch = allocator_->Allocate(); 269 Result scratch = allocator_->Allocate();
270 ASSERT(scratch.is_valid()); 270 ASSERT(scratch.is_valid());
271 frame_->Spill(context.reg()); 271 frame_->Spill(context.reg());
272 frame_->Spill(value.reg()); 272 frame_->Spill(value.reg());
273 __ RecordWrite(context.reg(), 273 __ RecordWriteField(context.reg(),
274 offset, 274 offset,
275 value.reg(), 275 value.reg(),
276 scratch.reg(), 276 scratch.reg(),
277 kDontSaveFPRegs); 277 kDontSaveFPRegs);
278 } 278 }
279 } 279 }
280 } 280 }
281 281
282 // Store the arguments object. This must happen after context 282 // Store the arguments object. This must happen after context
283 // initialization because the arguments object may be stored in 283 // initialization because the arguments object may be stored in
284 // the context. 284 // the context.
285 if (ArgumentsMode() != NO_ARGUMENTS_ALLOCATION) { 285 if (ArgumentsMode() != NO_ARGUMENTS_ALLOCATION) {
286 StoreArgumentsObject(true); 286 StoreArgumentsObject(true);
287 } 287 }
(...skipping 5040 matching lines...) Expand 10 before | Expand all | Expand 10 after
5328 __ mov(SlotOperand(slot, start.reg()), value.reg()); 5328 __ mov(SlotOperand(slot, start.reg()), value.reg());
5329 5329
5330 // RecordWrite may destroy the value registers. 5330 // RecordWrite may destroy the value registers.
5331 // 5331 //
5332 // TODO(204): Avoid actually spilling when the value is not 5332 // TODO(204): Avoid actually spilling when the value is not
5333 // needed (probably the common case). 5333 // needed (probably the common case).
5334 frame_->Spill(value.reg()); 5334 frame_->Spill(value.reg());
5335 int offset = FixedArray::kHeaderSize + slot->index() * kPointerSize; 5335 int offset = FixedArray::kHeaderSize + slot->index() * kPointerSize;
5336 Result temp = allocator_->Allocate(); 5336 Result temp = allocator_->Allocate();
5337 ASSERT(temp.is_valid()); 5337 ASSERT(temp.is_valid());
5338 __ RecordWrite(start.reg(), 5338 __ RecordWriteField(start.reg(),
5339 offset, 5339 offset,
5340 value.reg(), 5340 value.reg(),
5341 temp.reg(), 5341 temp.reg(),
5342 kDontSaveFPRegs); 5342 kDontSaveFPRegs);
5343 // The results start, value, and temp are unused by going out of 5343 // The results start, value, and temp are unused by going out of
5344 // scope. 5344 // scope.
5345 } 5345 }
5346 5346
5347 exit.Bind(); 5347 exit.Bind();
5348 } 5348 }
5349 } 5349 }
5350 5350
5351 5351
5352 void CodeGenerator::VisitSlot(Slot* slot) { 5352 void CodeGenerator::VisitSlot(Slot* slot) {
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
5737 FieldOperand(elements.reg(), JSObject::kElementsOffset)); 5737 FieldOperand(elements.reg(), JSObject::kElementsOffset));
5738 5738
5739 // Write to the indexed properties array. 5739 // Write to the indexed properties array.
5740 int offset = i * kPointerSize + FixedArray::kHeaderSize; 5740 int offset = i * kPointerSize + FixedArray::kHeaderSize;
5741 __ mov(FieldOperand(elements.reg(), offset), prop_value.reg()); 5741 __ mov(FieldOperand(elements.reg(), offset), prop_value.reg());
5742 5742
5743 // Update the write barrier for the array address. 5743 // Update the write barrier for the array address.
5744 frame_->Spill(prop_value.reg()); // Overwritten by the write barrier. 5744 frame_->Spill(prop_value.reg()); // Overwritten by the write barrier.
5745 Result scratch = allocator_->Allocate(); 5745 Result scratch = allocator_->Allocate();
5746 ASSERT(scratch.is_valid()); 5746 ASSERT(scratch.is_valid());
5747 __ RecordWrite(elements.reg(), 5747 __ RecordWriteField(elements.reg(),
5748 offset, 5748 offset,
5749 prop_value.reg(), 5749 prop_value.reg(),
5750 scratch.reg(), 5750 scratch.reg(),
5751 kDontSaveFPRegs); 5751 kDontSaveFPRegs);
5752 } 5752 }
5753 } 5753 }
5754 5754
5755 5755
5756 void CodeGenerator::VisitCatchExtensionObject(CatchExtensionObject* node) { 5756 void CodeGenerator::VisitCatchExtensionObject(CatchExtensionObject* node) {
5757 ASSERT(!in_safe_int32_mode()); 5757 ASSERT(!in_safe_int32_mode());
5758 ASSERT(!in_spilled_code()); 5758 ASSERT(!in_spilled_code());
5759 // Call runtime routine to allocate the catch extension object and 5759 // Call runtime routine to allocate the catch extension object and
5760 // assign the exception value to the catch variable. 5760 // assign the exception value to the catch variable.
5761 Comment cmnt(masm_, "[ CatchExtensionObject"); 5761 Comment cmnt(masm_, "[ CatchExtensionObject");
(...skipping 1612 matching lines...) Expand 10 before | Expand all | Expand 10 after
7374 __ mov(FieldOperand(object.reg(), JSValue::kValueOffset), value.reg()); 7374 __ mov(FieldOperand(object.reg(), JSValue::kValueOffset), value.reg());
7375 7375
7376 // Update the write barrier. Save the value as it will be 7376 // Update the write barrier. Save the value as it will be
7377 // overwritten by the write barrier code and is needed afterward. 7377 // overwritten by the write barrier code and is needed afterward.
7378 Result duplicate_value = allocator_->Allocate(); 7378 Result duplicate_value = allocator_->Allocate();
7379 ASSERT(duplicate_value.is_valid()); 7379 ASSERT(duplicate_value.is_valid());
7380 __ mov(duplicate_value.reg(), value.reg()); 7380 __ mov(duplicate_value.reg(), value.reg());
7381 // The object register is also overwritten by the write barrier and 7381 // The object register is also overwritten by the write barrier and
7382 // possibly aliased in the frame. 7382 // possibly aliased in the frame.
7383 frame_->Spill(object.reg()); 7383 frame_->Spill(object.reg());
7384 __ RecordWrite(object.reg(), JSValue::kValueOffset, duplicate_value.reg(), 7384 __ RecordWriteField(object.reg(),
7385 scratch.reg(), kDontSaveFPRegs); 7385 JSValue::kValueOffset,
7386 duplicate_value.reg(),
7387 scratch.reg(),
7388 kDontSaveFPRegs);
7386 duplicate_value.Unuse(); 7389 duplicate_value.Unuse();
7387 7390
7388 object.Unuse(); 7391 object.Unuse();
7389 scratch.Unuse(); 7392 scratch.Unuse();
7390 7393
7391 // Leave. 7394 // Leave.
7392 leave.Bind(&value); 7395 leave.Bind(&value);
7393 frame_->Push(&value); 7396 frame_->Push(&value);
7394 } 7397 }
7395 7398
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
7649 __ lea(ebx, Operand(edx, JSFunctionResultCache::kEntrySize << 1)); 7652 __ lea(ebx, Operand(edx, JSFunctionResultCache::kEntrySize << 1));
7650 __ mov(FieldOperand(ecx, JSFunctionResultCache::kCacheSizeOffset), ebx); 7653 __ mov(FieldOperand(ecx, JSFunctionResultCache::kCacheSizeOffset), ebx);
7651 7654
7652 // Update the cache itself. 7655 // Update the cache itself.
7653 // edx holds the index. 7656 // edx holds the index.
7654 __ bind(&update_cache); 7657 __ bind(&update_cache);
7655 __ pop(ebx); // restore the key 7658 __ pop(ebx); // restore the key
7656 __ mov(FieldOperand(ecx, JSFunctionResultCache::kFingerOffset), edx); 7659 __ mov(FieldOperand(ecx, JSFunctionResultCache::kFingerOffset), edx);
7657 // Store key. 7660 // Store key.
7658 __ mov(CodeGenerator::FixedArrayElementOperand(ecx, edx), ebx); 7661 __ mov(CodeGenerator::FixedArrayElementOperand(ecx, edx), ebx);
7659 __ RecordWrite(ecx, 0, ebx, edx, kDontSaveFPRegs); 7662 __ RecordWriteArray(ecx, ebx, edx, kDontSaveFPRegs);
7660 7663
7661 // Store value. 7664 // Store value.
7662 __ pop(ecx); // restore the cache. 7665 __ pop(ecx); // restore the cache.
7663 __ mov(edx, FieldOperand(ecx, JSFunctionResultCache::kFingerOffset)); 7666 __ mov(edx, FieldOperand(ecx, JSFunctionResultCache::kFingerOffset));
7664 __ add(Operand(edx), Immediate(Smi::FromInt(1))); 7667 __ add(Operand(edx), Immediate(Smi::FromInt(1)));
7665 __ mov(ebx, eax); 7668 __ mov(ebx, eax);
7666 __ mov(CodeGenerator::FixedArrayElementOperand(ecx, edx), ebx); 7669 __ mov(CodeGenerator::FixedArrayElementOperand(ecx, edx), ebx);
7667 __ RecordWrite(ecx, 0, ebx, edx, kDontSaveFPRegs); 7670 __ RecordWriteArray(ecx, ebx, edx, kDontSaveFPRegs);
7668 7671
7669 if (!dst_.is(eax)) { 7672 if (!dst_.is(eax)) {
7670 __ mov(dst_, eax); 7673 __ mov(dst_, eax);
7671 } 7674 }
7672 } 7675 }
7673 7676
7674 7677
7675 void CodeGenerator::GenerateGetFromCache(ZoneList<Expression*>* args) { 7678 void CodeGenerator::GenerateGetFromCache(ZoneList<Expression*>* args) {
7676 ASSERT_EQ(2, args->length()); 7679 ASSERT_EQ(2, args->length());
7677 7680
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
7831 7834
7832 Label done; 7835 Label done;
7833 __ InNewSpace(tmp1.reg(), tmp2.reg(), equal, &done); 7836 __ InNewSpace(tmp1.reg(), tmp2.reg(), equal, &done);
7834 // Possible optimization: do a check that both values are Smis 7837 // Possible optimization: do a check that both values are Smis
7835 // (or them and test against Smi mask.) 7838 // (or them and test against Smi mask.)
7836 7839
7837 // Since we are swapping two objects, the incremental marker is not disturbed, 7840 // Since we are swapping two objects, the incremental marker is not disturbed,
7838 // so we don't call the stub that handles this. TODO(gc): Optimize by 7841 // so we don't call the stub that handles this. TODO(gc): Optimize by
7839 // checking the scan_on_scavenge flag, probably by calling the stub. 7842 // checking the scan_on_scavenge flag, probably by calling the stub.
7840 __ mov(tmp2.reg(), tmp1.reg()); 7843 __ mov(tmp2.reg(), tmp1.reg());
7841 __ RememberedSetHelper(tmp2.reg(), 7844 __ int3();
7842 index1.reg(), 7845 __ RememberedSetHelper(index1.reg(), eax, kDontSaveFPRegs);
7843 object.reg(), 7846 __ RememberedSetHelper(index2.reg(), eax, kDontSaveFPRegs);
7844 kDontSaveFPRegs);
7845 __ RememberedSetHelper(tmp1.reg(),
7846 index2.reg(),
7847 object.reg(),
7848 kDontSaveFPRegs);
7849 __ bind(&done); 7847 __ bind(&done);
7850 7848
7851 deferred->BindExit(); 7849 deferred->BindExit();
7852 frame_->Push(Factory::undefined_value()); 7850 frame_->Push(Factory::undefined_value());
7853 } 7851 }
7854 7852
7855 7853
7856 void CodeGenerator::GenerateCallFunction(ZoneList<Expression*>* args) { 7854 void CodeGenerator::GenerateCallFunction(ZoneList<Expression*>* args) {
7857 Comment cmnt(masm_, "[ GenerateCallFunction"); 7855 Comment cmnt(masm_, "[ GenerateCallFunction");
7858 7856
(...skipping 1926 matching lines...) Expand 10 before | Expand all | Expand 10 after
9785 frame_->Spill(value.reg()); 9783 frame_->Spill(value.reg());
9786 9784
9787 // If the receiver and the value share a register allocate a new 9785 // If the receiver and the value share a register allocate a new
9788 // register for the receiver. 9786 // register for the receiver.
9789 if (receiver.reg().is(value.reg())) { 9787 if (receiver.reg().is(value.reg())) {
9790 receiver = allocator()->Allocate(); 9788 receiver = allocator()->Allocate();
9791 ASSERT(receiver.is_valid()); 9789 ASSERT(receiver.is_valid());
9792 __ mov(receiver.reg(), Operand(value.reg())); 9790 __ mov(receiver.reg(), Operand(value.reg()));
9793 } 9791 }
9794 9792
9795 // Update the write barrier. To save instructions in the inlined
9796 // version we do not filter smis.
9797 Label skip_write_barrier;
9798 __ InNewSpace(receiver.reg(), value.reg(), equal, &skip_write_barrier);
9799 int delta_to_record_write = masm_->SizeOfCodeGeneratedSince(&patch_site); 9793 int delta_to_record_write = masm_->SizeOfCodeGeneratedSince(&patch_site);
9800 __ lea(scratch.reg(), Operand(receiver.reg(), offset)); 9794 __ lea(scratch.reg(), Operand(receiver.reg(), offset));
9801 // This code does not work with the incremental marker! Luckily this file 9795 __ RecordWrite(receiver.reg(),
9802 // is going away soon. 9796 scratch.reg(),
9803 __ RememberedSetHelper(receiver.reg(), 9797 value.reg(),
9804 scratch.reg(), 9798 EMIT_REMEMBERED_SET,
9805 value.reg(), 9799 kDontSaveFPRegs);
9806 kDontSaveFPRegs);
9807 if (FLAG_debug_code) { 9800 if (FLAG_debug_code) {
9808 __ mov(receiver.reg(), Immediate(BitCast<int32_t>(kZapValue))); 9801 __ mov(receiver.reg(), Immediate(BitCast<int32_t>(kZapValue)));
9809 __ mov(value.reg(), Immediate(BitCast<int32_t>(kZapValue))); 9802 __ mov(value.reg(), Immediate(BitCast<int32_t>(kZapValue)));
9810 __ mov(scratch.reg(), Immediate(BitCast<int32_t>(kZapValue))); 9803 __ mov(scratch.reg(), Immediate(BitCast<int32_t>(kZapValue)));
9811 } 9804 }
9812 __ bind(&skip_write_barrier);
9813 value.Unuse(); 9805 value.Unuse();
9814 scratch.Unuse(); 9806 scratch.Unuse();
9815 receiver.Unuse(); 9807 receiver.Unuse();
9816 done.Jump(&result); 9808 done.Jump(&result);
9817 9809
9818 slow.Bind(&value, &receiver); 9810 slow.Bind(&value, &receiver);
9819 frame()->Push(&receiver); 9811 frame()->Push(&receiver);
9820 frame()->Push(&value); 9812 frame()->Push(&value);
9821 result = frame()->CallStoreIC(name, is_contextual, strict_mode_flag()); 9813 result = frame()->CallStoreIC(name, is_contextual, strict_mode_flag());
9822 // Encode the offset to the map check instruction and the offset 9814 // Encode the offset to the map check instruction and the offset
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
10391 memcpy(base, desc.buffer, desc.instr_size); 10383 memcpy(base, desc.buffer, desc.instr_size);
10392 CPU::FlushICache(base, desc.instr_size); 10384 CPU::FlushICache(base, desc.instr_size);
10393 return FUNCTION_CAST<MemCopyFunction>(reinterpret_cast<Address>(base)); 10385 return FUNCTION_CAST<MemCopyFunction>(reinterpret_cast<Address>(base));
10394 } 10386 }
10395 10387
10396 #undef __ 10388 #undef __
10397 10389
10398 } } // namespace v8::internal 10390 } } // namespace v8::internal
10399 10391
10400 #endif // V8_TARGET_ARCH_IA32 10392 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698