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

Side by Side Diff: src/ia32/macro-assembler-ia32.cc

Issue 6092007: Write buffer based write barrier for IA32 and Crankshaft. Currently... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: '' Created 9 years, 11 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/macro-assembler-ia32.h ('k') | src/ia32/stub-cache-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 30 matching lines...) Expand all
41 // ------------------------------------------------------------------------- 41 // -------------------------------------------------------------------------
42 // MacroAssembler implementation. 42 // MacroAssembler implementation.
43 43
44 MacroAssembler::MacroAssembler(void* buffer, int size) 44 MacroAssembler::MacroAssembler(void* buffer, int size)
45 : Assembler(buffer, size), 45 : Assembler(buffer, size),
46 generating_stub_(false), 46 generating_stub_(false),
47 allow_stub_calls_(true), 47 allow_stub_calls_(true),
48 code_object_(Heap::undefined_value()) { 48 code_object_(Heap::undefined_value()) {
49 } 49 }
50 50
51 #ifdef ENABLE_CARDMARKING_WRITE_BARRIER
52 void MacroAssembler::RecordWriteHelper(Register object, 51 void MacroAssembler::RecordWriteHelper(Register object,
53 Register addr, 52 Register addr,
54 Register scratch) { 53 Register scratch,
54 SaveFPRegsMode save_fp) {
55 if (FLAG_debug_code) { 55 if (FLAG_debug_code) {
56 // Check that the object is not in new space. 56 // Check that the object is not in new space.
57 Label not_in_new_space; 57 Label not_in_new_space;
58 InNewSpace(object, scratch, not_equal, &not_in_new_space); 58 InNewSpace(object, scratch, not_equal, &not_in_new_space);
59 Abort("new-space object passed to RecordWriteHelper"); 59 Abort("new-space object passed to RecordWriteHelper");
60 bind(&not_in_new_space); 60 bind(&not_in_new_space);
61 } 61 }
62 62
63 // Compute the page start address from the heap object pointer, and reuse 63 // Load write buffer top.
64 // the 'object' register for it. 64 ExternalReference write_buffer = ExternalReference::write_buffer_top();
65 and_(object, ~Page::kPageAlignmentMask); 65 mov(scratch, Operand::StaticVariable(write_buffer));
66 66 // Store pointer to buffer.
67 // Compute number of region covering addr. See Page::GetRegionNumberForAddress 67 mov(Operand(scratch, 0), addr);
68 // method for more details. 68 // Increment buffer top.
69 and_(addr, Page::kPageAlignmentMask); 69 add(Operand(scratch), Immediate(kPointerSize));
70 shr(addr, Page::kRegionSizeLog2); 70 // Write back new top of buffer.
71 71 mov(Operand::StaticVariable(write_buffer), scratch);
72 // Set dirty mark for region. 72 // Call stub on end of buffer.
73 bts(Operand(object, Page::kDirtyFlagOffset), addr); 73 NearLabel no_overflow;
74 // Check for end of buffer.
75 test(scratch, Immediate(WriteBuffer::kWriteBufferOverflowBit));
76 j(equal, &no_overflow);
77 WriteBufferOverflowStub write_buffer_overflow =
78 WriteBufferOverflowStub(save_fp);
79 CallStub(&write_buffer_overflow);
80 bind(&no_overflow);
74 } 81 }
75 82
76 83
77 void MacroAssembler::RecordWrite(Register object, 84 void MacroAssembler::RecordWrite(Register object,
78 int offset, 85 int offset,
79 Register value, 86 Register value,
80 Register scratch) { 87 Register scratch,
88 SaveFPRegsMode save_fp) {
81 // The compiled code assumes that record write doesn't change the 89 // The compiled code assumes that record write doesn't change the
82 // context register, so we check that none of the clobbered 90 // context register, so we check that none of the clobbered
83 // registers are esi. 91 // registers are esi.
84 ASSERT(!object.is(esi) && !value.is(esi) && !scratch.is(esi)); 92 ASSERT(!object.is(esi) && !value.is(esi) && !scratch.is(esi));
85 93
86 // First, check if a write barrier is even needed. The tests below 94 // First, check if a write barrier is even needed. The tests below
87 // catch stores of Smis and stores into young gen. 95 // catch stores of Smis and stores into young gen.
88 NearLabel done; 96 NearLabel done;
89 97
90 // Skip barrier if writing a smi. 98 // Skip barrier if writing a smi.
(...skipping 14 matching lines...) Expand all
105 lea(dst, Operand(object, offset)); 113 lea(dst, Operand(object, offset));
106 } else { 114 } else {
107 // Array access: calculate the destination address in the same manner as 115 // Array access: calculate the destination address in the same manner as
108 // KeyedStoreIC::GenerateGeneric. Multiply a smi by 2 to get an offset 116 // KeyedStoreIC::GenerateGeneric. Multiply a smi by 2 to get an offset
109 // into an array of words. 117 // into an array of words.
110 ASSERT_EQ(1, kSmiTagSize); 118 ASSERT_EQ(1, kSmiTagSize);
111 ASSERT_EQ(0, kSmiTag); 119 ASSERT_EQ(0, kSmiTag);
112 lea(dst, Operand(object, dst, times_half_pointer_size, 120 lea(dst, Operand(object, dst, times_half_pointer_size,
113 FixedArray::kHeaderSize - kHeapObjectTag)); 121 FixedArray::kHeaderSize - kHeapObjectTag));
114 } 122 }
115 RecordWriteHelper(object, dst, value); 123 RecordWriteHelper(object, dst, value, save_fp);
116 124
117 bind(&done); 125 bind(&done);
118 126
119 // Clobber all input registers when running with the debug-code flag 127 // Clobber all input registers when running with the debug-code flag
120 // turned on to provoke errors. 128 // turned on to provoke errors.
121 if (FLAG_debug_code) { 129 if (FLAG_debug_code) {
122 mov(object, Immediate(BitCast<int32_t>(kZapValue))); 130 mov(object, Immediate(BitCast<int32_t>(kZapValue)));
123 mov(value, Immediate(BitCast<int32_t>(kZapValue))); 131 mov(value, Immediate(BitCast<int32_t>(kZapValue)));
124 mov(scratch, Immediate(BitCast<int32_t>(kZapValue))); 132 mov(scratch, Immediate(BitCast<int32_t>(kZapValue)));
125 } 133 }
126 } 134 }
127 135
128 136
129 void MacroAssembler::RecordWrite(Register object, 137 void MacroAssembler::RecordWrite(Register object,
130 Register address, 138 Register address,
131 Register value) { 139 Register value,
140 SaveFPRegsMode save_fp) {
132 // The compiled code assumes that record write doesn't change the 141 // The compiled code assumes that record write doesn't change the
133 // context register, so we check that none of the clobbered 142 // context register, so we check that none of the clobbered
134 // registers are esi. 143 // registers are esi.
135 ASSERT(!object.is(esi) && !value.is(esi) && !address.is(esi)); 144 ASSERT(!object.is(esi) && !value.is(esi) && !address.is(esi));
136 145
137 // First, check if a write barrier is even needed. The tests below 146 // First, check if a write barrier is even needed. The tests below
138 // catch stores of Smis and stores into young gen. 147 // catch stores of Smis and stores into young gen.
139 Label done; 148 Label done;
140 149
141 // Skip barrier if writing a smi. 150 // Skip barrier if writing a smi.
142 ASSERT_EQ(0, kSmiTag); 151 ASSERT_EQ(0, kSmiTag);
143 test(value, Immediate(kSmiTagMask)); 152 test(value, Immediate(kSmiTagMask));
144 j(zero, &done); 153 j(zero, &done);
145 154
146 InNewSpace(object, value, equal, &done); 155 InNewSpace(object, value, equal, &done);
147 156
148 RecordWriteHelper(object, address, value); 157 RecordWriteHelper(object, address, value, save_fp);
149 158
150 bind(&done); 159 bind(&done);
151 160
152 // Clobber all input registers when running with the debug-code flag 161 // Clobber all input registers when running with the debug-code flag
153 // turned on to provoke errors. 162 // turned on to provoke errors.
154 if (FLAG_debug_code) { 163 if (FLAG_debug_code) {
155 mov(object, Immediate(BitCast<int32_t>(kZapValue))); 164 mov(object, Immediate(BitCast<int32_t>(kZapValue)));
156 mov(address, Immediate(BitCast<int32_t>(kZapValue))); 165 mov(address, Immediate(BitCast<int32_t>(kZapValue)));
157 mov(value, Immediate(BitCast<int32_t>(kZapValue))); 166 mov(value, Immediate(BitCast<int32_t>(kZapValue)));
158 } 167 }
159 } 168 }
160 #endif 169
161 170
162 #ifdef ENABLE_DEBUGGER_SUPPORT 171 #ifdef ENABLE_DEBUGGER_SUPPORT
163 void MacroAssembler::DebugBreak() { 172 void MacroAssembler::DebugBreak() {
164 Set(eax, Immediate(0)); 173 Set(eax, Immediate(0));
165 mov(ebx, Immediate(ExternalReference(Runtime::kDebugBreak))); 174 mov(ebx, Immediate(ExternalReference(Runtime::kDebugBreak)));
166 CEntryStub ces(1); 175 CEntryStub ces(1);
167 call(ces.GetCode(), RelocInfo::DEBUG_BREAK); 176 call(ces.GetCode(), RelocInfo::DEBUG_BREAK);
168 } 177 }
169 #endif 178 #endif
170 179
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 void MacroAssembler::EnterApiExitFrame(int argc) { 384 void MacroAssembler::EnterApiExitFrame(int argc) {
376 EnterExitFramePrologue(); 385 EnterExitFramePrologue();
377 EnterExitFrameEpilogue(argc, false); 386 EnterExitFrameEpilogue(argc, false);
378 } 387 }
379 388
380 389
381 void MacroAssembler::LeaveExitFrame(bool save_doubles) { 390 void MacroAssembler::LeaveExitFrame(bool save_doubles) {
382 // Optionally restore all XMM registers. 391 // Optionally restore all XMM registers.
383 if (save_doubles) { 392 if (save_doubles) {
384 CpuFeatures::Scope scope(SSE2); 393 CpuFeatures::Scope scope(SSE2);
385 int offset = -2 * kPointerSize; 394 if (save_doubles) {
386 for (int i = 0; i < XMMRegister::kNumRegisters; i++) { 395 int offset = -2 * kPointerSize;
387 XMMRegister reg = XMMRegister::from_code(i); 396 for (int i = 0; i < XMMRegister::kNumRegisters; i++) {
388 movdbl(reg, Operand(ebp, offset - ((i + 1) * kDoubleSize))); 397 XMMRegister reg = XMMRegister::from_code(i);
398 movdbl(reg, Operand(ebp, offset - ((i + 1) * kDoubleSize)));
399 }
400 } else if (FLAG_debug_code) {
401 // Zap all fp registers on a runtime call if we were not asked to preserve
402 // them.
403 push(eax);
404 mov(eax, Factory::nan_value());
405 for (int i = 0; i < XMMRegister::kNumRegisters; i++) {
406 XMMRegister reg = XMMRegister::from_code(i);
407 movdbl(reg, FieldOperand(eax, HeapNumber::kValueOffset));
408 }
409 pop(eax);
389 } 410 }
390 } 411 }
391 412
392 // Get the return address from the stack and restore the frame pointer. 413 // Get the return address from the stack and restore the frame pointer.
393 mov(ecx, Operand(ebp, 1 * kPointerSize)); 414 mov(ecx, Operand(ebp, 1 * kPointerSize));
394 mov(ebp, Operand(ebp, 0 * kPointerSize)); 415 mov(ebp, Operand(ebp, 0 * kPointerSize));
395 416
396 // Pop the arguments and the receiver from the caller stack. 417 // Pop the arguments and the receiver from the caller stack.
397 lea(esp, Operand(esi, 1 * kPointerSize)); 418 lea(esp, Operand(esi, 1 * kPointerSize));
398 419
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 1106
1086 void MacroAssembler::CallRuntime(Runtime::FunctionId id, int num_arguments) { 1107 void MacroAssembler::CallRuntime(Runtime::FunctionId id, int num_arguments) {
1087 CallRuntime(Runtime::FunctionForId(id), num_arguments); 1108 CallRuntime(Runtime::FunctionForId(id), num_arguments);
1088 } 1109 }
1089 1110
1090 1111
1091 void MacroAssembler::CallRuntimeSaveDoubles(Runtime::FunctionId id) { 1112 void MacroAssembler::CallRuntimeSaveDoubles(Runtime::FunctionId id) {
1092 Runtime::Function* function = Runtime::FunctionForId(id); 1113 Runtime::Function* function = Runtime::FunctionForId(id);
1093 Set(eax, Immediate(function->nargs)); 1114 Set(eax, Immediate(function->nargs));
1094 mov(ebx, Immediate(ExternalReference(function))); 1115 mov(ebx, Immediate(ExternalReference(function)));
1095 CEntryStub ces(1); 1116 CEntryStub ces(1, kSaveFPRegs);
1096 ces.SaveDoubles();
1097 CallStub(&ces); 1117 CallStub(&ces);
1098 } 1118 }
1099 1119
1100 1120
1101 MaybeObject* MacroAssembler::TryCallRuntime(Runtime::FunctionId id, 1121 MaybeObject* MacroAssembler::TryCallRuntime(Runtime::FunctionId id,
1102 int num_arguments) { 1122 int num_arguments) {
1103 return TryCallRuntime(Runtime::FunctionForId(id), num_arguments); 1123 return TryCallRuntime(Runtime::FunctionForId(id), num_arguments);
1104 } 1124 }
1105 1125
1106 1126
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after
1891 1911
1892 // Check that the code was patched as expected. 1912 // Check that the code was patched as expected.
1893 ASSERT(masm_.pc_ == address_ + size_); 1913 ASSERT(masm_.pc_ == address_ + size_);
1894 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); 1914 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap);
1895 } 1915 }
1896 1916
1897 1917
1898 } } // namespace v8::internal 1918 } } // namespace v8::internal
1899 1919
1900 #endif // V8_TARGET_ARCH_IA32 1920 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/macro-assembler-ia32.h ('k') | src/ia32/stub-cache-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698