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

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, 7 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
« no previous file with comments | « src/ia32/code-stubs-ia32.cc ('k') | src/ia32/disasm-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 // SlotOperand loads context.reg() with the context object 264 // SlotOperand loads context.reg() with the context object
265 // stored to, used below in RecordWrite. 265 // stored to, used below in RecordWrite.
266 Result context = allocator_->Allocate(); 266 Result context = allocator_->Allocate();
267 ASSERT(context.is_valid()); 267 ASSERT(context.is_valid());
268 __ mov(SlotOperand(slot, context.reg()), value.reg()); 268 __ mov(SlotOperand(slot, context.reg()), value.reg());
269 int offset = FixedArray::kHeaderSize + slot->index() * kPointerSize; 269 int offset = FixedArray::kHeaderSize + slot->index() * kPointerSize;
270 Result scratch = allocator_->Allocate(); 270 Result scratch = allocator_->Allocate();
271 ASSERT(scratch.is_valid()); 271 ASSERT(scratch.is_valid());
272 frame_->Spill(context.reg()); 272 frame_->Spill(context.reg());
273 frame_->Spill(value.reg()); 273 frame_->Spill(value.reg());
274 __ RecordWrite(context.reg(), 274 __ RecordWriteField(context.reg(),
275 offset, 275 offset,
276 value.reg(), 276 value.reg(),
277 scratch.reg(), 277 scratch.reg(),
278 kDontSaveFPRegs); 278 kDontSaveFPRegs);
279 } 279 }
280 } 280 }
281 } 281 }
282 282
283 // Store the arguments object. This must happen after context 283 // Store the arguments object. This must happen after context
284 // initialization because the arguments object may be stored in 284 // initialization because the arguments object may be stored in
285 // the context. 285 // the context.
286 if (ArgumentsMode() != NO_ARGUMENTS_ALLOCATION) { 286 if (ArgumentsMode() != NO_ARGUMENTS_ALLOCATION) {
287 StoreArgumentsObject(true); 287 StoreArgumentsObject(true);
288 } 288 }
(...skipping 5044 matching lines...) Expand 10 before | Expand all | Expand 10 after
5333 __ mov(SlotOperand(slot, start.reg()), value.reg()); 5333 __ mov(SlotOperand(slot, start.reg()), value.reg());
5334 5334
5335 // RecordWrite may destroy the value registers. 5335 // RecordWrite may destroy the value registers.
5336 // 5336 //
5337 // TODO(204): Avoid actually spilling when the value is not 5337 // TODO(204): Avoid actually spilling when the value is not
5338 // needed (probably the common case). 5338 // needed (probably the common case).
5339 frame_->Spill(value.reg()); 5339 frame_->Spill(value.reg());
5340 int offset = FixedArray::kHeaderSize + slot->index() * kPointerSize; 5340 int offset = FixedArray::kHeaderSize + slot->index() * kPointerSize;
5341 Result temp = allocator_->Allocate(); 5341 Result temp = allocator_->Allocate();
5342 ASSERT(temp.is_valid()); 5342 ASSERT(temp.is_valid());
5343 __ RecordWrite(start.reg(), 5343 __ RecordWriteField(start.reg(),
5344 offset, 5344 offset,
5345 value.reg(), 5345 value.reg(),
5346 temp.reg(), 5346 temp.reg(),
5347 kDontSaveFPRegs); 5347 kDontSaveFPRegs);
5348 // The results start, value, and temp are unused by going out of 5348 // The results start, value, and temp are unused by going out of
5349 // scope. 5349 // scope.
5350 } 5350 }
5351 5351
5352 exit.Bind(); 5352 exit.Bind();
5353 } 5353 }
5354 } 5354 }
5355 5355
5356 5356
5357 void CodeGenerator::VisitSlot(Slot* slot) { 5357 void CodeGenerator::VisitSlot(Slot* slot) {
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
5742 FieldOperand(elements.reg(), JSObject::kElementsOffset)); 5742 FieldOperand(elements.reg(), JSObject::kElementsOffset));
5743 5743
5744 // Write to the indexed properties array. 5744 // Write to the indexed properties array.
5745 int offset = i * kPointerSize + FixedArray::kHeaderSize; 5745 int offset = i * kPointerSize + FixedArray::kHeaderSize;
5746 __ mov(FieldOperand(elements.reg(), offset), prop_value.reg()); 5746 __ mov(FieldOperand(elements.reg(), offset), prop_value.reg());
5747 5747
5748 // Update the write barrier for the array address. 5748 // Update the write barrier for the array address.
5749 frame_->Spill(prop_value.reg()); // Overwritten by the write barrier. 5749 frame_->Spill(prop_value.reg()); // Overwritten by the write barrier.
5750 Result scratch = allocator_->Allocate(); 5750 Result scratch = allocator_->Allocate();
5751 ASSERT(scratch.is_valid()); 5751 ASSERT(scratch.is_valid());
5752 __ RecordWrite(elements.reg(), 5752 __ RecordWriteField(elements.reg(),
5753 offset, 5753 offset,
5754 prop_value.reg(), 5754 prop_value.reg(),
5755 scratch.reg(), 5755 scratch.reg(),
5756 kDontSaveFPRegs); 5756 kDontSaveFPRegs);
5757 } 5757 }
5758 } 5758 }
5759 5759
5760 5760
5761 void CodeGenerator::VisitCatchExtensionObject(CatchExtensionObject* node) { 5761 void CodeGenerator::VisitCatchExtensionObject(CatchExtensionObject* node) {
5762 ASSERT(!in_safe_int32_mode()); 5762 ASSERT(!in_safe_int32_mode());
5763 ASSERT(!in_spilled_code()); 5763 ASSERT(!in_spilled_code());
5764 // Call runtime routine to allocate the catch extension object and 5764 // Call runtime routine to allocate the catch extension object and
5765 // assign the exception value to the catch variable. 5765 // assign the exception value to the catch variable.
5766 Comment cmnt(masm_, "[ CatchExtensionObject"); 5766 Comment cmnt(masm_, "[ CatchExtensionObject");
(...skipping 1612 matching lines...) Expand 10 before | Expand all | Expand 10 after
7379 __ mov(FieldOperand(object.reg(), JSValue::kValueOffset), value.reg()); 7379 __ mov(FieldOperand(object.reg(), JSValue::kValueOffset), value.reg());
7380 7380
7381 // Update the write barrier. Save the value as it will be 7381 // Update the write barrier. Save the value as it will be
7382 // overwritten by the write barrier code and is needed afterward. 7382 // overwritten by the write barrier code and is needed afterward.
7383 Result duplicate_value = allocator_->Allocate(); 7383 Result duplicate_value = allocator_->Allocate();
7384 ASSERT(duplicate_value.is_valid()); 7384 ASSERT(duplicate_value.is_valid());
7385 __ mov(duplicate_value.reg(), value.reg()); 7385 __ mov(duplicate_value.reg(), value.reg());
7386 // The object register is also overwritten by the write barrier and 7386 // The object register is also overwritten by the write barrier and
7387 // possibly aliased in the frame. 7387 // possibly aliased in the frame.
7388 frame_->Spill(object.reg()); 7388 frame_->Spill(object.reg());
7389 __ RecordWrite(object.reg(), JSValue::kValueOffset, duplicate_value.reg(), 7389 __ RecordWriteField(object.reg(),
7390 scratch.reg(), kDontSaveFPRegs); 7390 JSValue::kValueOffset,
7391 duplicate_value.reg(),
7392 scratch.reg(),
7393 kDontSaveFPRegs);
7391 duplicate_value.Unuse(); 7394 duplicate_value.Unuse();
7392 7395
7393 object.Unuse(); 7396 object.Unuse();
7394 scratch.Unuse(); 7397 scratch.Unuse();
7395 7398
7396 // Leave. 7399 // Leave.
7397 leave.Bind(&value); 7400 leave.Bind(&value);
7398 frame_->Push(&value); 7401 frame_->Push(&value);
7399 } 7402 }
7400 7403
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
7654 __ lea(ebx, Operand(edx, JSFunctionResultCache::kEntrySize << 1)); 7657 __ lea(ebx, Operand(edx, JSFunctionResultCache::kEntrySize << 1));
7655 __ mov(FieldOperand(ecx, JSFunctionResultCache::kCacheSizeOffset), ebx); 7658 __ mov(FieldOperand(ecx, JSFunctionResultCache::kCacheSizeOffset), ebx);
7656 7659
7657 // Update the cache itself. 7660 // Update the cache itself.
7658 // edx holds the index. 7661 // edx holds the index.
7659 __ bind(&update_cache); 7662 __ bind(&update_cache);
7660 __ pop(ebx); // restore the key 7663 __ pop(ebx); // restore the key
7661 __ mov(FieldOperand(ecx, JSFunctionResultCache::kFingerOffset), edx); 7664 __ mov(FieldOperand(ecx, JSFunctionResultCache::kFingerOffset), edx);
7662 // Store key. 7665 // Store key.
7663 __ mov(CodeGenerator::FixedArrayElementOperand(ecx, edx), ebx); 7666 __ mov(CodeGenerator::FixedArrayElementOperand(ecx, edx), ebx);
7664 __ RecordWrite(ecx, 0, ebx, edx, kDontSaveFPRegs); 7667 __ RecordWriteArray(ecx, ebx, edx, kDontSaveFPRegs);
7665 7668
7666 // Store value. 7669 // Store value.
7667 __ pop(ecx); // restore the cache. 7670 __ pop(ecx); // restore the cache.
7668 __ mov(edx, FieldOperand(ecx, JSFunctionResultCache::kFingerOffset)); 7671 __ mov(edx, FieldOperand(ecx, JSFunctionResultCache::kFingerOffset));
7669 __ add(Operand(edx), Immediate(Smi::FromInt(1))); 7672 __ add(Operand(edx), Immediate(Smi::FromInt(1)));
7670 __ mov(ebx, eax); 7673 __ mov(ebx, eax);
7671 __ mov(CodeGenerator::FixedArrayElementOperand(ecx, edx), ebx); 7674 __ mov(CodeGenerator::FixedArrayElementOperand(ecx, edx), ebx);
7672 __ RecordWrite(ecx, 0, ebx, edx, kDontSaveFPRegs); 7675 __ RecordWriteArray(ecx, ebx, edx, kDontSaveFPRegs);
7673 7676
7674 if (!dst_.is(eax)) { 7677 if (!dst_.is(eax)) {
7675 __ mov(dst_, eax); 7678 __ mov(dst_, eax);
7676 } 7679 }
7677 } 7680 }
7678 7681
7679 7682
7680 void CodeGenerator::GenerateGetFromCache(ZoneList<Expression*>* args) { 7683 void CodeGenerator::GenerateGetFromCache(ZoneList<Expression*>* args) {
7681 ASSERT_EQ(2, args->length()); 7684 ASSERT_EQ(2, args->length());
7682 7685
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
7836 7839
7837 Label done; 7840 Label done;
7838 __ InNewSpace(tmp1.reg(), tmp2.reg(), equal, &done); 7841 __ InNewSpace(tmp1.reg(), tmp2.reg(), equal, &done);
7839 // Possible optimization: do a check that both values are Smis 7842 // Possible optimization: do a check that both values are Smis
7840 // (or them and test against Smi mask.) 7843 // (or them and test against Smi mask.)
7841 7844
7842 // Since we are swapping two objects, the incremental marker is not disturbed, 7845 // Since we are swapping two objects, the incremental marker is not disturbed,
7843 // so we don't call the stub that handles this. TODO(gc): Optimize by 7846 // so we don't call the stub that handles this. TODO(gc): Optimize by
7844 // checking the scan_on_scavenge flag, probably by calling the stub. 7847 // checking the scan_on_scavenge flag, probably by calling the stub.
7845 __ mov(tmp2.reg(), tmp1.reg()); 7848 __ mov(tmp2.reg(), tmp1.reg());
7846 __ RememberedSetHelper(tmp2.reg(), 7849 __ int3();
7847 index1.reg(), 7850 __ RememberedSetHelper(index1.reg(), eax, kDontSaveFPRegs);
7848 object.reg(), 7851 __ RememberedSetHelper(index2.reg(), eax, kDontSaveFPRegs);
7849 kDontSaveFPRegs);
7850 __ RememberedSetHelper(tmp1.reg(),
7851 index2.reg(),
7852 object.reg(),
7853 kDontSaveFPRegs);
7854 __ bind(&done); 7852 __ bind(&done);
7855 7853
7856 deferred->BindExit(); 7854 deferred->BindExit();
7857 frame_->Push(FACTORY->undefined_value()); 7855 frame_->Push(FACTORY->undefined_value());
7858 } 7856 }
7859 7857
7860 7858
7861 void CodeGenerator::GenerateCallFunction(ZoneList<Expression*>* args) { 7859 void CodeGenerator::GenerateCallFunction(ZoneList<Expression*>* args) {
7862 Comment cmnt(masm_, "[ GenerateCallFunction"); 7860 Comment cmnt(masm_, "[ GenerateCallFunction");
7863 7861
(...skipping 1930 matching lines...) Expand 10 before | Expand all | Expand 10 after
9794 frame_->Spill(value.reg()); 9792 frame_->Spill(value.reg());
9795 9793
9796 // If the receiver and the value share a register allocate a new 9794 // If the receiver and the value share a register allocate a new
9797 // register for the receiver. 9795 // register for the receiver.
9798 if (receiver.reg().is(value.reg())) { 9796 if (receiver.reg().is(value.reg())) {
9799 receiver = allocator()->Allocate(); 9797 receiver = allocator()->Allocate();
9800 ASSERT(receiver.is_valid()); 9798 ASSERT(receiver.is_valid());
9801 __ mov(receiver.reg(), Operand(value.reg())); 9799 __ mov(receiver.reg(), Operand(value.reg()));
9802 } 9800 }
9803 9801
9804 // Update the write barrier. To save instructions in the inlined
9805 // version we do not filter smis.
9806 Label skip_write_barrier;
9807 __ InNewSpace(receiver.reg(), value.reg(), equal, &skip_write_barrier);
9808 int delta_to_record_write = masm_->SizeOfCodeGeneratedSince(&patch_site); 9802 int delta_to_record_write = masm_->SizeOfCodeGeneratedSince(&patch_site);
9809 __ lea(scratch.reg(), Operand(receiver.reg(), offset)); 9803 __ lea(scratch.reg(), Operand(receiver.reg(), offset));
9810 // This code does not work with the incremental marker! Luckily this file 9804 __ RecordWrite(receiver.reg(),
9811 // is going away soon. 9805 scratch.reg(),
9812 __ RememberedSetHelper(receiver.reg(), 9806 value.reg(),
9813 scratch.reg(), 9807 EMIT_REMEMBERED_SET,
9814 value.reg(), 9808 kDontSaveFPRegs);
9815 kDontSaveFPRegs);
9816 if (FLAG_debug_code) { 9809 if (FLAG_debug_code) {
9817 __ mov(receiver.reg(), Immediate(BitCast<int32_t>(kZapValue))); 9810 __ mov(receiver.reg(), Immediate(BitCast<int32_t>(kZapValue)));
9818 __ mov(value.reg(), Immediate(BitCast<int32_t>(kZapValue))); 9811 __ mov(value.reg(), Immediate(BitCast<int32_t>(kZapValue)));
9819 __ mov(scratch.reg(), Immediate(BitCast<int32_t>(kZapValue))); 9812 __ mov(scratch.reg(), Immediate(BitCast<int32_t>(kZapValue)));
9820 } 9813 }
9821 __ bind(&skip_write_barrier);
9822 value.Unuse(); 9814 value.Unuse();
9823 scratch.Unuse(); 9815 scratch.Unuse();
9824 receiver.Unuse(); 9816 receiver.Unuse();
9825 done.Jump(&result); 9817 done.Jump(&result);
9826 9818
9827 slow.Bind(&value, &receiver); 9819 slow.Bind(&value, &receiver);
9828 frame()->Push(&receiver); 9820 frame()->Push(&receiver);
9829 frame()->Push(&value); 9821 frame()->Push(&value);
9830 result = frame()->CallStoreIC(name, is_contextual, strict_mode_flag()); 9822 result = frame()->CallStoreIC(name, is_contextual, strict_mode_flag());
9831 // Encode the offset to the map check instruction and the offset 9823 // Encode the offset to the map check instruction and the offset
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
10400 memcpy(base, desc.buffer, desc.instr_size); 10392 memcpy(base, desc.buffer, desc.instr_size);
10401 CPU::FlushICache(base, desc.instr_size); 10393 CPU::FlushICache(base, desc.instr_size);
10402 return FUNCTION_CAST<MemCopyFunction>(reinterpret_cast<Address>(base)); 10394 return FUNCTION_CAST<MemCopyFunction>(reinterpret_cast<Address>(base));
10403 } 10395 }
10404 10396
10405 #undef __ 10397 #undef __
10406 10398
10407 } } // namespace v8::internal 10399 } } // namespace v8::internal
10408 10400
10409 #endif // V8_TARGET_ARCH_IA32 10401 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/code-stubs-ia32.cc ('k') | src/ia32/disasm-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698