Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 49 | 49 |
| 50 | 50 |
| 51 static void RecordWriteHelper(MacroAssembler* masm, | 51 static void RecordWriteHelper(MacroAssembler* masm, |
| 52 Register object, | 52 Register object, |
| 53 Register addr, | 53 Register addr, |
| 54 Register scratch) { | 54 Register scratch) { |
| 55 Label fast; | 55 Label fast; |
| 56 | 56 |
| 57 // Compute the page address from the heap object pointer, leave it | 57 // Compute the page address from the heap object pointer, leave it |
| 58 // in 'object'. | 58 // in 'object'. |
| 59 masm->and_(object, ~Page::kPageAlignmentMask); | 59 masm->and_(object, ~Page::kPageAlignmentMask); |
|
Kevin Millikin (Chromium)
2009/08/05 10:26:15
This whole function is probably clearer if we intr
| |
| 60 | 60 |
| 61 // Compute the bit addr in the remembered set, leave it in "addr". | 61 // Compute the bit addr in the remembered set, leave it in "addr". |
| 62 masm->sub(addr, Operand(object)); | 62 masm->sub(addr, Operand(object)); |
| 63 masm->shr(addr, kObjectAlignmentBits); | 63 masm->shr(addr, kObjectAlignmentBits); |
| 64 | 64 |
| 65 // If the bit offset lies beyond the normal remembered set range, it is in | 65 // If the bit offset lies beyond the normal remembered set range, it is in |
| 66 // the extra remembered set area of a large object. | 66 // the extra remembered set area of a large object. |
| 67 masm->cmp(addr, Page::kPageSize / kPointerSize); | 67 masm->cmp(addr, Page::kPageSize / kPointerSize); |
| 68 masm->j(less, &fast); | 68 masm->j(less, &fast); |
| 69 | 69 |
| 70 // Adjust 'addr' to be relative to the start of the extra remembered set | 70 // Adjust 'addr' to be relative to the start of the extra remembered set |
|
William Hesse
2009/08/05 10:17:50
This comment is no longer right. I would comment
Kevin Millikin (Chromium)
2009/08/05 10:26:15
I would ditch the whole comment and use symbolic a
| |
| 71 // and the page address in 'object' to be the address of the extra | 71 // and the page address in 'object' to be the address of the extra |
| 72 // remembered set. | 72 // remembered set. |
| 73 masm->sub(Operand(addr), Immediate(Page::kPageSize / kPointerSize)); | 73 |
| 74 // Load the array length into 'scratch' and multiply by four to get the | 74 // Find the length of the FixedArray. |
| 75 // size in bytes of the elements. | |
| 76 masm->mov(scratch, Operand(object, Page::kObjectStartOffset | 75 masm->mov(scratch, Operand(object, Page::kObjectStartOffset |
| 77 + FixedArray::kLengthOffset)); | 76 + FixedArray::kLengthOffset)); |
| 78 masm->shl(scratch, kObjectAlignmentBits); | |
| 79 // Add the page header, array header, and array body size to the page | |
| 80 // address. | |
| 81 masm->add(Operand(object), Immediate(Page::kObjectStartOffset | |
| 82 + FixedArray::kHeaderSize)); | |
| 83 masm->add(object, Operand(scratch)); | |
| 84 | 77 |
| 85 | 78 // The RSet extension area lies after the FixedArray, i.e., |
|
William Hesse
2009/08/05 10:17:50
how about "after the FixedArray, at"
| |
| 79 // at | |
| 80 // object + kObjectStartOffset + FixedArray::kHeaderSize + 8 * scratch | |
|
Kevin Millikin (Chromium)
2009/08/05 10:26:15
Surely not 8?
| |
| 81 // Make object point to (size of normal RSet) before that, so that we | |
| 82 // can address the bit directly with addr. | |
| 83 masm->lea(object, | |
| 84 Operand(object, scratch, times_pointer_size, | |
| 85 Page::kObjectStartOffset + FixedArray::kHeaderSize | |
| 86 - Page::kRSetEndOffset)); | |
| 86 // NOTE: For now, we use the bit-test-and-set (bts) x86 instruction | 87 // NOTE: For now, we use the bit-test-and-set (bts) x86 instruction |
| 87 // to limit code size. We should probably evaluate this decision by | 88 // to limit code size. We should probably evaluate this decision by |
| 88 // measuring the performance of an equivalent implementation using | 89 // measuring the performance of an equivalent implementation using |
| 89 // "simpler" instructions | 90 // "simpler" instructions |
| 90 masm->bind(&fast); | 91 masm->bind(&fast); |
| 91 masm->bts(Operand(object, 0), addr); | 92 masm->bts(Operand(object, Page::kRSetOffset), addr); |
| 92 } | 93 } |
| 93 | 94 |
| 94 | 95 |
| 95 class RecordWriteStub : public CodeStub { | 96 class RecordWriteStub : public CodeStub { |
| 96 public: | 97 public: |
| 97 RecordWriteStub(Register object, Register addr, Register scratch) | 98 RecordWriteStub(Register object, Register addr, Register scratch) |
| 98 : object_(object), addr_(addr), scratch_(scratch) { } | 99 : object_(object), addr_(addr), scratch_(scratch) { } |
| 99 | 100 |
| 100 void Generate(MacroAssembler* masm); | 101 void Generate(MacroAssembler* masm); |
| 101 | 102 |
| (...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1029 // Indicate that code has changed. | 1030 // Indicate that code has changed. |
| 1030 CPU::FlushICache(address_, size_); | 1031 CPU::FlushICache(address_, size_); |
| 1031 | 1032 |
| 1032 // Check that the code was patched as expected. | 1033 // Check that the code was patched as expected. |
| 1033 ASSERT(masm_.pc_ == address_ + size_); | 1034 ASSERT(masm_.pc_ == address_ + size_); |
| 1034 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 1035 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
| 1035 } | 1036 } |
| 1036 | 1037 |
| 1037 | 1038 |
| 1038 } } // namespace v8::internal | 1039 } } // namespace v8::internal |
| OLD | NEW |