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/code-stubs-ia32.cc

Issue 7302003: Support slots recording for compaction during incremental marking. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/gc
Patch Set: fix presubmit, remove last debug check Created 9 years, 5 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.h ('k') | src/ia32/deoptimizer-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 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
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 two instructions are generated with labels so as to get the
6241 // fixed up correctly by the bind(Label*) call. We patch it back and forth 6242 // offset fixed up correctly by the bind(Label*) call. We patch it back and
6242 // between a 2-byte compare instruction (a nop in this position) and the real 6243 // forth between a 2-byte compare instruction (a nop in this position) and the
6243 // branch when we start and stop incremental heap marking. 6244 // real 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, INCREMENTAL);
6257
6258 __ bind(&skip_to_incremental_compacting);
6259 GenerateIncremental(masm, INCREMENTAL_COMPACTION);
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, Mode mode) {
6264 regs_.Save(masm); 6274 regs_.Save(masm);
6265 6275
6266 if (remembered_set_action_ == EMIT_REMEMBERED_SET) { 6276 if (remembered_set_action_ == EMIT_REMEMBERED_SET) {
6267 Label dont_need_remembered_set; 6277 Label dont_need_remembered_set;
6268 6278
6269 __ mov(regs_.scratch0(), Operand(regs_.address(), 0)); 6279 __ mov(regs_.scratch0(), Operand(regs_.address(), 0));
6270 __ JumpIfNotInNewSpace(regs_.scratch0(), 6280 __ JumpIfNotInNewSpace(regs_.scratch0(),
6271 regs_.scratch0(), 6281 regs_.scratch0(),
6272 &dont_need_remembered_set); 6282 &dont_need_remembered_set);
6273 6283
6274 __ CheckPageFlag(regs_.object(), 6284 __ CheckPageFlag(regs_.object(),
6275 regs_.scratch0(), 6285 regs_.scratch0(),
6276 MemoryChunk::SCAN_ON_SCAVENGE, 6286 1 << MemoryChunk::SCAN_ON_SCAVENGE,
6277 not_zero, 6287 not_zero,
6278 &dont_need_remembered_set); 6288 &dont_need_remembered_set);
6279 6289
6280 // First notify the incremental marker if necessary, then update the 6290 // First notify the incremental marker if necessary, then update the
6281 // remembered set. 6291 // remembered set.
6282 CheckNeedsToInformIncrementalMarker( 6292 CheckNeedsToInformIncrementalMarker(
6283 masm, kUpdateRememberedSetOnNoNeedToInformIncrementalMarker); 6293 masm,
6284 InformIncrementalMarker(masm); 6294 kUpdateRememberedSetOnNoNeedToInformIncrementalMarker,
6295 mode);
6296 InformIncrementalMarker(masm, mode);
6285 regs_.Restore(masm); 6297 regs_.Restore(masm);
6286 __ RememberedSetHelper( 6298 __ RememberedSetHelper(
6287 address_, value_, save_fp_regs_mode_, MacroAssembler::kReturnAtEnd); 6299 address_, value_, save_fp_regs_mode_, MacroAssembler::kReturnAtEnd);
6288 6300
6289 __ bind(&dont_need_remembered_set); 6301 __ bind(&dont_need_remembered_set);
6290 } 6302 }
6291 6303
6292 CheckNeedsToInformIncrementalMarker( 6304 CheckNeedsToInformIncrementalMarker(
6293 masm, kReturnOnNoNeedToInformIncrementalMarker); 6305 masm,
6294 InformIncrementalMarker(masm); 6306 kReturnOnNoNeedToInformIncrementalMarker,
6307 mode);
6308 InformIncrementalMarker(masm, mode);
6295 regs_.Restore(masm); 6309 regs_.Restore(masm);
6296 __ ret(0); 6310 __ ret(0);
6297 } 6311 }
6298 6312
6299 6313
6300 void RecordWriteStub::InformIncrementalMarker(MacroAssembler* masm) { 6314 void RecordWriteStub::InformIncrementalMarker(
6315 MacroAssembler* masm,
6316 RecordWriteStub::Mode mode) {
6301 regs_.SaveCallerSaveRegisters(masm, save_fp_regs_mode_); 6317 regs_.SaveCallerSaveRegisters(masm, save_fp_regs_mode_);
6302 int argument_count = 3; 6318 int argument_count = 3;
6303 __ PrepareCallCFunction(argument_count, regs_.scratch0()); 6319 __ PrepareCallCFunction(argument_count, regs_.scratch0());
6304 __ mov(Operand(esp, 0 * kPointerSize), regs_.object()); 6320 __ mov(Operand(esp, 0 * kPointerSize), regs_.object());
6305 __ mov(regs_.scratch0(), Operand(regs_.address(), 0)); 6321 if (mode == INCREMENTAL_COMPACTION) {
6306 __ mov(Operand(esp, 1 * kPointerSize), regs_.scratch0()); // Value. 6322 __ mov(Operand(esp, 1 * kPointerSize), regs_.address()); // Slot.
6323 } else {
6324 ASSERT(mode == INCREMENTAL);
6325 __ mov(regs_.scratch0(), Operand(regs_.address(), 0));
6326 __ mov(Operand(esp, 1 * kPointerSize), regs_.scratch0()); // Value.
6327 }
6307 __ mov(Operand(esp, 2 * kPointerSize), 6328 __ mov(Operand(esp, 2 * kPointerSize),
6308 Immediate(ExternalReference::isolate_address())); 6329 Immediate(ExternalReference::isolate_address()));
6330
6309 // TODO(gc): Create a fast version of this C function that does not duplicate 6331 // TODO(gc): Create a fast version of this C function that does not duplicate
6310 // the checks done in the stub. 6332 // the checks done in the stub.
6311 __ CallCFunction( 6333 if (mode == INCREMENTAL_COMPACTION) {
6312 ExternalReference::incremental_marking_record_write_function( 6334 __ CallCFunction(
6313 masm->isolate()), 6335 ExternalReference::incremental_evacuation_record_write_function(
6314 argument_count); 6336 masm->isolate()),
6337 argument_count);
6338 } else {
6339 ASSERT(mode == INCREMENTAL);
6340 __ CallCFunction(
6341 ExternalReference::incremental_marking_record_write_function(
6342 masm->isolate()),
6343 argument_count);
6344 }
6315 regs_.RestoreCallerSaveRegisters(masm, save_fp_regs_mode_); 6345 regs_.RestoreCallerSaveRegisters(masm, save_fp_regs_mode_);
6316 } 6346 }
6317 6347
6318 6348
6319 void RecordWriteStub::CheckNeedsToInformIncrementalMarker( 6349 void RecordWriteStub::CheckNeedsToInformIncrementalMarker(
6320 MacroAssembler* masm, 6350 MacroAssembler* masm,
6321 RecordWriteStub::OnNoNeedToInformIncrementalMarker on_no_need) { 6351 RecordWriteStub::OnNoNeedToInformIncrementalMarker on_no_need,
6322 Label object_is_black, need_incremental; 6352 RecordWriteStub::Mode mode) {
6353 Label object_is_black, need_incremental, need_incremental_pop_object;
6323 6354
6324 // Let's look at the color of the object: If it is not black we don't have 6355 // Let's look at the color of the object: If it is not black we don't have
6325 // to inform the incremental marker. 6356 // to inform the incremental marker.
6326 __ JumpIfBlack(regs_.object(), 6357 __ JumpIfBlack(regs_.object(),
6327 regs_.scratch0(), 6358 regs_.scratch0(),
6328 regs_.scratch1(), 6359 regs_.scratch1(),
6329 &object_is_black, 6360 &object_is_black,
6330 Label::kNear); 6361 Label::kNear);
6331 6362
6332 regs_.Restore(masm); 6363 regs_.Restore(masm);
6333 if (on_no_need == kUpdateRememberedSetOnNoNeedToInformIncrementalMarker) { 6364 if (on_no_need == kUpdateRememberedSetOnNoNeedToInformIncrementalMarker) {
6334 __ RememberedSetHelper( 6365 __ RememberedSetHelper(
6335 address_, value_, save_fp_regs_mode_, MacroAssembler::kReturnAtEnd); 6366 address_, value_, save_fp_regs_mode_, MacroAssembler::kReturnAtEnd);
6336 } else { 6367 } else {
6337 __ ret(0); 6368 __ ret(0);
6338 } 6369 }
6339 6370
6340 __ bind(&object_is_black); 6371 __ bind(&object_is_black);
6341 6372
6342 // Get the value from the slot. 6373 // Get the value from the slot.
6343 __ mov(regs_.scratch0(), Operand(regs_.address(), 0)); 6374 __ mov(regs_.scratch0(), Operand(regs_.address(), 0));
6344 6375
6376 if (mode == INCREMENTAL_COMPACTION) {
6377 Label ensure_not_white;
6378
6379 __ CheckPageFlag(regs_.scratch0(), // Contains value.
6380 regs_.scratch1(), // Scratch.
6381 MemoryChunk::kEvacuationCandidateMask,
6382 zero,
6383 &ensure_not_white,
6384 Label::kNear);
6385
6386 __ CheckPageFlag(regs_.object(),
6387 regs_.scratch1(), // Scratch.
6388 MemoryChunk::kEvacuationCandidateOrNewSpaceMask,
6389 not_zero,
6390 &ensure_not_white,
6391 Label::kNear);
6392
6393 __ jmp(&need_incremental);
6394
6395 __ bind(&ensure_not_white);
6396 }
6397
6345 // We need an extra register for this, so we push the object register 6398 // We need an extra register for this, so we push the object register
6346 // temporarily. 6399 // temporarily.
6347 __ push(regs_.object()); 6400 __ push(regs_.object());
6348 __ EnsureNotWhite(regs_.scratch0(), // The value. 6401 __ EnsureNotWhite(regs_.scratch0(), // The value.
6349 regs_.scratch1(), // Scratch. 6402 regs_.scratch1(), // Scratch.
6350 regs_.object(), // Scratch. 6403 regs_.object(), // Scratch.
6351 &need_incremental, 6404 &need_incremental_pop_object,
6352 Label::kNear); 6405 Label::kNear);
6406 __ pop(regs_.object());
6353 6407
6354 __ pop(regs_.object());
6355 regs_.Restore(masm); 6408 regs_.Restore(masm);
6356 if (on_no_need == kUpdateRememberedSetOnNoNeedToInformIncrementalMarker) { 6409 if (on_no_need == kUpdateRememberedSetOnNoNeedToInformIncrementalMarker) {
6357 __ RememberedSetHelper( 6410 __ RememberedSetHelper(
6358 address_, value_, save_fp_regs_mode_, MacroAssembler::kReturnAtEnd); 6411 address_, value_, save_fp_regs_mode_, MacroAssembler::kReturnAtEnd);
6359 } else { 6412 } else {
6360 __ ret(0); 6413 __ ret(0);
6361 } 6414 }
6362 6415
6416 __ bind(&need_incremental_pop_object);
6417 __ pop(regs_.object());
6418
6363 __ bind(&need_incremental); 6419 __ bind(&need_incremental);
6364 __ pop(regs_.object());
6365 6420
6366 // Fall through when we need to inform the incremental marker. 6421 // Fall through when we need to inform the incremental marker.
6367 } 6422 }
6368 6423
6369 6424
6370 #undef __ 6425 #undef __
6371 6426
6372 } } // namespace v8::internal 6427 } } // namespace v8::internal
6373 6428
6374 #endif // V8_TARGET_ARCH_IA32 6429 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/code-stubs-ia32.h ('k') | src/ia32/deoptimizer-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698