OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 6217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6228 __ Drop(1); | 6228 __ Drop(1); |
6229 __ ret(2 * kPointerSize); | 6229 __ ret(2 * kPointerSize); |
6230 } | 6230 } |
6231 | 6231 |
6232 | 6232 |
6233 // Takes the input in 3 registers: address_ value_ and object_. A pointer to | 6233 // Takes the input in 3 registers: address_ value_ and object_. A pointer to |
6234 // the value has just been written into the object, now this stub makes sure | 6234 // the value has just been written into the object, now this stub makes sure |
6235 // we keep the GC informed. The word in the object where the value has been | 6235 // we keep the GC informed. The word in the object where the value has been |
6236 // written is in the address register. | 6236 // written is in the address register. |
6237 void RecordWriteStub::Generate(MacroAssembler* masm) { | 6237 void RecordWriteStub::Generate(MacroAssembler* masm) { |
6238 Label skip_non_incremental_part; | 6238 Label skip_to_incremental_noncompacting; |
6239 Label skip_to_incremental_compacting; | |
6239 | 6240 |
6240 // The first instruction is generated as a label so as to get the offset | 6241 // The first instruction is generated as a label so as to get the offset |
Erik Corry
2011/07/04 11:04:11
first instruction is -> first two instructions are
Vyacheslav Egorov (Chromium)
2011/08/05 12:50:28
Done.
| |
6241 // fixed up correctly by the bind(Label*) call. We patch it back and forth | 6242 // fixed up correctly by the bind(Label*) call. We patch it back and forth |
6242 // between a 2-byte compare instruction (a nop in this position) and the real | 6243 // between a 2-byte compare instruction (a nop in this position) and the real |
6243 // branch when we start and stop incremental heap marking. | 6244 // branch when we start and stop incremental heap marking. |
6244 __ jmp(&skip_non_incremental_part, Label::kNear); | 6245 __ jmp(&skip_to_incremental_noncompacting, Label::kNear); |
6245 if (!masm->isolate()->heap()->incremental_marking()->IsMarking()) { | 6246 __ jmp(&skip_to_incremental_compacting, Label::kFar); |
6246 ASSERT(masm->byte_at(masm->pc_offset() - 2) == | |
6247 kSkipNonIncrementalPartInstruction); | |
6248 masm->set_byte_at(masm->pc_offset() - 2, kTwoByteNopInstruction); | |
6249 } | |
6250 | 6247 |
6251 if (remembered_set_action_ == EMIT_REMEMBERED_SET) { | 6248 if (remembered_set_action_ == EMIT_REMEMBERED_SET) { |
6252 __ RememberedSetHelper( | 6249 __ RememberedSetHelper( |
6253 address_, value_, save_fp_regs_mode_, MacroAssembler::kReturnAtEnd); | 6250 address_, value_, save_fp_regs_mode_, MacroAssembler::kReturnAtEnd); |
6254 } else { | 6251 } else { |
6255 __ ret(0); | 6252 __ ret(0); |
6256 } | 6253 } |
6257 | 6254 |
6258 __ bind(&skip_non_incremental_part); | 6255 __ bind(&skip_to_incremental_noncompacting); |
6259 GenerateIncremental(masm); | 6256 GenerateIncremental(masm, kWithoutEvacuationCandidates); |
6257 | |
6258 __ bind(&skip_to_incremental_compacting); | |
6259 GenerateIncremental(masm, kWithEvacuationCandidates); | |
6260 | |
6261 if (!masm->isolate()->heap()->incremental_marking()->IsMarking()) { | |
6262 ASSERT(masm->byte_at(0) == kTwoByteJumpInstruction); | |
6263 masm->set_byte_at(0, kTwoByteNopInstruction); | |
6264 } | |
6265 | |
6266 if (!masm->isolate()->heap()->incremental_marking()->IsMarking()) { | |
6267 ASSERT(masm->byte_at(2) == kFiveByteJumpInstruction); | |
6268 masm->set_byte_at(2, kFiveByteNopInstruction); | |
6269 } | |
6260 } | 6270 } |
6261 | 6271 |
6262 | 6272 |
6263 void RecordWriteStub::GenerateIncremental(MacroAssembler* masm) { | 6273 void RecordWriteStub::GenerateIncremental(MacroAssembler* masm, |
6274 EvacuationState evacuation_state) { | |
6264 regs_.Save(masm); | 6275 regs_.Save(masm); |
6265 | 6276 |
6266 if (remembered_set_action_ == EMIT_REMEMBERED_SET) { | 6277 if (remembered_set_action_ == EMIT_REMEMBERED_SET) { |
6267 Label dont_need_remembered_set; | 6278 Label dont_need_remembered_set; |
6268 | 6279 |
6269 __ mov(regs_.scratch0(), Operand(regs_.address(), 0)); | 6280 __ mov(regs_.scratch0(), Operand(regs_.address(), 0)); |
6270 __ JumpIfNotInNewSpace(regs_.scratch0(), | 6281 __ JumpIfNotInNewSpace(regs_.scratch0(), |
6271 regs_.scratch0(), | 6282 regs_.scratch0(), |
6272 &dont_need_remembered_set); | 6283 &dont_need_remembered_set); |
6273 | 6284 |
6274 __ CheckPageFlag(regs_.object(), | 6285 __ CheckPageFlag(regs_.object(), |
6275 regs_.scratch0(), | 6286 regs_.scratch0(), |
6276 MemoryChunk::SCAN_ON_SCAVENGE, | 6287 1 << MemoryChunk::SCAN_ON_SCAVENGE, |
6277 not_zero, | 6288 not_zero, |
6278 &dont_need_remembered_set); | 6289 &dont_need_remembered_set); |
6279 | 6290 |
6280 // First notify the incremental marker if necessary, then update the | 6291 // First notify the incremental marker if necessary, then update the |
6281 // remembered set. | 6292 // remembered set. |
6282 CheckNeedsToInformIncrementalMarker( | 6293 CheckNeedsToInformIncrementalMarker( |
6283 masm, kUpdateRememberedSetOnNoNeedToInformIncrementalMarker); | 6294 masm, |
6284 InformIncrementalMarker(masm); | 6295 kUpdateRememberedSetOnNoNeedToInformIncrementalMarker, |
6296 evacuation_state); | |
6297 InformIncrementalMarker(masm, evacuation_state); | |
6285 regs_.Restore(masm); | 6298 regs_.Restore(masm); |
6286 __ RememberedSetHelper( | 6299 __ RememberedSetHelper( |
6287 address_, value_, save_fp_regs_mode_, MacroAssembler::kReturnAtEnd); | 6300 address_, value_, save_fp_regs_mode_, MacroAssembler::kReturnAtEnd); |
6288 | 6301 |
6289 __ bind(&dont_need_remembered_set); | 6302 __ bind(&dont_need_remembered_set); |
6290 } | 6303 } |
6291 | 6304 |
6292 CheckNeedsToInformIncrementalMarker( | 6305 CheckNeedsToInformIncrementalMarker( |
6293 masm, kReturnOnNoNeedToInformIncrementalMarker); | 6306 masm, |
6294 InformIncrementalMarker(masm); | 6307 kReturnOnNoNeedToInformIncrementalMarker, |
6308 evacuation_state); | |
6309 InformIncrementalMarker(masm, evacuation_state); | |
6295 regs_.Restore(masm); | 6310 regs_.Restore(masm); |
6296 __ ret(0); | 6311 __ ret(0); |
6297 } | 6312 } |
6298 | 6313 |
6299 | 6314 |
6300 void RecordWriteStub::InformIncrementalMarker(MacroAssembler* masm) { | 6315 void RecordWriteStub::InformIncrementalMarker( |
6316 MacroAssembler* masm, | |
6317 RecordWriteStub::EvacuationState evacuation_state) { | |
6301 regs_.SaveCallerSaveRegisters(masm, save_fp_regs_mode_); | 6318 regs_.SaveCallerSaveRegisters(masm, save_fp_regs_mode_); |
6302 int argument_count = 3; | 6319 int argument_count = 3; |
6303 __ PrepareCallCFunction(argument_count, regs_.scratch0()); | 6320 __ PrepareCallCFunction(argument_count, regs_.scratch0()); |
6304 __ mov(Operand(esp, 0 * kPointerSize), regs_.object()); | 6321 __ mov(Operand(esp, 0 * kPointerSize), regs_.object()); |
6305 __ mov(regs_.scratch0(), Operand(regs_.address(), 0)); | 6322 switch (evacuation_state) { |
Erik Corry
2011/07/04 11:04:11
This switch introduces a lot of boilerplate compar
Vyacheslav Egorov (Chromium)
2011/08/05 12:50:28
Done.
| |
6306 __ mov(Operand(esp, 1 * kPointerSize), regs_.scratch0()); // Value. | 6323 case kWithEvacuationCandidates: |
6324 __ mov(Operand(esp, 1 * kPointerSize), regs_.address()); // Slot. | |
6325 break; | |
6326 case kWithoutEvacuationCandidates: | |
6327 __ mov(regs_.scratch0(), Operand(regs_.address(), 0)); | |
6328 __ mov(Operand(esp, 1 * kPointerSize), regs_.scratch0()); // Value. | |
6329 break; | |
6330 default: | |
6331 UNREACHABLE(); | |
6332 } | |
6307 __ mov(Operand(esp, 2 * kPointerSize), | 6333 __ mov(Operand(esp, 2 * kPointerSize), |
6308 Immediate(ExternalReference::isolate_address())); | 6334 Immediate(ExternalReference::isolate_address())); |
6309 // TODO(gc): Create a fast version of this C function that does not duplicate | 6335 // TODO(gc): Create a fast version of this C function that does not duplicate |
6310 // the checks done in the stub. | 6336 // the checks done in the stub. |
6311 __ CallCFunction( | 6337 switch (evacuation_state) { |
Erik Corry
2011/07/04 11:04:11
And here.
Vyacheslav Egorov (Chromium)
2011/08/05 12:50:28
Done.
| |
6312 ExternalReference::incremental_marking_record_write_function( | 6338 case kWithEvacuationCandidates: |
6313 masm->isolate()), | 6339 __ CallCFunction( |
6314 argument_count); | 6340 ExternalReference::incremental_evacuation_record_write_function( |
6341 masm->isolate()), | |
6342 argument_count); | |
6343 break; | |
6344 case kWithoutEvacuationCandidates: | |
6345 __ CallCFunction( | |
6346 ExternalReference::incremental_marking_record_write_function( | |
6347 masm->isolate()), | |
6348 argument_count); | |
6349 break; | |
6350 default: | |
6351 UNREACHABLE(); | |
6352 } | |
6315 regs_.RestoreCallerSaveRegisters(masm, save_fp_regs_mode_); | 6353 regs_.RestoreCallerSaveRegisters(masm, save_fp_regs_mode_); |
6316 } | 6354 } |
6317 | 6355 |
6318 | 6356 |
6319 void RecordWriteStub::CheckNeedsToInformIncrementalMarker( | 6357 void RecordWriteStub::CheckNeedsToInformIncrementalMarker( |
6320 MacroAssembler* masm, | 6358 MacroAssembler* masm, |
6321 RecordWriteStub::OnNoNeedToInformIncrementalMarker on_no_need) { | 6359 RecordWriteStub::OnNoNeedToInformIncrementalMarker on_no_need, |
6322 Label object_is_black, need_incremental; | 6360 RecordWriteStub::EvacuationState evacuation_state) { |
6361 Label object_is_black, need_incremental, need_incremental_pop_object; | |
6323 | 6362 |
6324 // Let's look at the color of the object: If it is not black we don't have | 6363 // Let's look at the color of the object: If it is not black we don't have |
6325 // to inform the incremental marker. | 6364 // to inform the incremental marker. |
6326 __ JumpIfBlack(regs_.object(), | 6365 __ JumpIfBlack(regs_.object(), |
6327 regs_.scratch0(), | 6366 regs_.scratch0(), |
6328 regs_.scratch1(), | 6367 regs_.scratch1(), |
6329 &object_is_black, | 6368 &object_is_black, |
6330 Label::kNear); | 6369 Label::kNear); |
6331 | 6370 |
6332 regs_.Restore(masm); | 6371 regs_.Restore(masm); |
6333 if (on_no_need == kUpdateRememberedSetOnNoNeedToInformIncrementalMarker) { | 6372 if (on_no_need == kUpdateRememberedSetOnNoNeedToInformIncrementalMarker) { |
6334 __ RememberedSetHelper( | 6373 __ RememberedSetHelper( |
6335 address_, value_, save_fp_regs_mode_, MacroAssembler::kReturnAtEnd); | 6374 address_, value_, save_fp_regs_mode_, MacroAssembler::kReturnAtEnd); |
6336 } else { | 6375 } else { |
6337 __ ret(0); | 6376 __ ret(0); |
6338 } | 6377 } |
6339 | 6378 |
6340 __ bind(&object_is_black); | 6379 __ bind(&object_is_black); |
6341 | 6380 |
6342 // Get the value from the slot. | 6381 // Get the value from the slot. |
6343 __ mov(regs_.scratch0(), Operand(regs_.address(), 0)); | 6382 __ mov(regs_.scratch0(), Operand(regs_.address(), 0)); |
6344 | 6383 |
6384 if (evacuation_state == kWithEvacuationCandidates) { | |
6385 Label ensure_not_white; | |
6386 | |
6387 __ CheckPageFlag(regs_.scratch0(), // Contains value. | |
6388 regs_.scratch1(), // Scratch. | |
6389 MemoryChunk::kEvacuationCandidateMask, | |
6390 zero, | |
6391 &ensure_not_white, | |
6392 Label::kNear); | |
6393 | |
6394 __ CheckPageFlag(regs_.object(), | |
6395 regs_.scratch1(), // Scratch. | |
6396 MemoryChunk::kEvacuationCandidateOrNewSpaceMask, | |
6397 not_zero, | |
6398 &ensure_not_white, | |
6399 Label::kNear); | |
6400 | |
6401 __ jmp(&need_incremental); | |
6402 | |
6403 __ bind(&ensure_not_white); | |
6404 } | |
6405 | |
6345 // We need an extra register for this, so we push the object register | 6406 // We need an extra register for this, so we push the object register |
6346 // temporarily. | 6407 // temporarily. |
6347 __ push(regs_.object()); | 6408 __ push(regs_.object()); |
6348 __ EnsureNotWhite(regs_.scratch0(), // The value. | 6409 __ EnsureNotWhite(regs_.scratch0(), // The value. |
6349 regs_.scratch1(), // Scratch. | 6410 regs_.scratch1(), // Scratch. |
6350 regs_.object(), // Scratch. | 6411 regs_.object(), // Scratch. |
6351 &need_incremental, | 6412 &need_incremental_pop_object, |
6352 Label::kNear); | 6413 Label::kNear); |
6414 __ pop(regs_.object()); | |
6353 | 6415 |
6354 __ pop(regs_.object()); | |
6355 regs_.Restore(masm); | 6416 regs_.Restore(masm); |
6356 if (on_no_need == kUpdateRememberedSetOnNoNeedToInformIncrementalMarker) { | 6417 if (on_no_need == kUpdateRememberedSetOnNoNeedToInformIncrementalMarker) { |
6357 __ RememberedSetHelper( | 6418 __ RememberedSetHelper( |
6358 address_, value_, save_fp_regs_mode_, MacroAssembler::kReturnAtEnd); | 6419 address_, value_, save_fp_regs_mode_, MacroAssembler::kReturnAtEnd); |
6359 } else { | 6420 } else { |
6360 __ ret(0); | 6421 __ ret(0); |
6361 } | 6422 } |
6362 | 6423 |
6424 __ bind(&need_incremental_pop_object); | |
6425 __ pop(regs_.object()); | |
6426 | |
6363 __ bind(&need_incremental); | 6427 __ bind(&need_incremental); |
6364 __ pop(regs_.object()); | |
6365 | 6428 |
6366 // Fall through when we need to inform the incremental marker. | 6429 // Fall through when we need to inform the incremental marker. |
6367 } | 6430 } |
6368 | 6431 |
6369 | 6432 |
6370 #undef __ | 6433 #undef __ |
6371 | 6434 |
6372 } } // namespace v8::internal | 6435 } } // namespace v8::internal |
6373 | 6436 |
6374 #endif // V8_TARGET_ARCH_IA32 | 6437 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |