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

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

Issue 1517993003: [heap] Black is encoded with 11, grey with 10. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #if V8_TARGET_ARCH_X64 5 #if V8_TARGET_ARCH_X64
6 6
7 #include "src/base/bits.h" 7 #include "src/base/bits.h"
8 #include "src/base/division-by-constant.h" 8 #include "src/base/division-by-constant.h"
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 5262 matching lines...) Expand 10 before | Expand all | Expand 10 after
5273 if (mask < (1 << kBitsPerByte)) { 5273 if (mask < (1 << kBitsPerByte)) {
5274 testb(Operand(scratch, MemoryChunk::kFlagsOffset), 5274 testb(Operand(scratch, MemoryChunk::kFlagsOffset),
5275 Immediate(static_cast<uint8_t>(mask))); 5275 Immediate(static_cast<uint8_t>(mask)));
5276 } else { 5276 } else {
5277 testl(Operand(scratch, MemoryChunk::kFlagsOffset), Immediate(mask)); 5277 testl(Operand(scratch, MemoryChunk::kFlagsOffset), Immediate(mask));
5278 } 5278 }
5279 j(cc, condition_met, condition_met_distance); 5279 j(cc, condition_met, condition_met_distance);
5280 } 5280 }
5281 5281
5282 5282
5283 void MacroAssembler::JumpIfBlack(Register object, 5283 void MacroAssembler::JumpIfBlack(Register object, Register scratch0,
5284 Register bitmap_scratch, 5284 Register scratch1, Label* on_black,
5285 Register mask_scratch, 5285 Label::Distance on_black_near) {
ulan 2016/01/05 14:45:23 let's keep the old name for on_black_distance.
Hannes Payer (out of office) 2016/01/07 20:17:33 Done.
5286 Label* on_black, 5286 HasColor(object, scratch0, scratch1, on_black, on_black_near, 1,
5287 Label::Distance on_black_distance) { 5287 1); // kBlackBitPattern.
5288 DCHECK(!AreAliased(object, bitmap_scratch, mask_scratch, rcx)); 5288 DCHECK(strcmp(Marking::kBlackBitPattern, "11") == 0);
5289 GetMarkBits(object, bitmap_scratch, mask_scratch);
5290
5291 DCHECK(strcmp(Marking::kBlackBitPattern, "10") == 0);
5292 // The mask_scratch register contains a 1 at the position of the first bit
5293 // and a 0 at all other positions, including the position of the second bit.
5294 movp(rcx, mask_scratch);
5295 // Make rcx into a mask that covers both marking bits using the operation
5296 // rcx = mask | (mask << 1).
5297 leap(rcx, Operand(mask_scratch, mask_scratch, times_2, 0));
5298 // Note that we are using a 4-byte aligned 8-byte load.
ulan 2016/01/05 14:45:23 // This change here should be sufficient to conver
Hannes Payer (out of office) 2016/01/07 20:17:33 Not sure what you mean here? Should I bring back t
Hannes Payer (out of office) 2016/01/11 12:24:32 After discussing offline, I kept x64 special and s
5299 andp(rcx, Operand(bitmap_scratch, MemoryChunk::kHeaderSize));
5300 cmpp(mask_scratch, rcx);
5301 j(equal, on_black, on_black_distance);
5302 } 5289 }
5303 5290
5304 5291
5292 void MacroAssembler::HasColor(Register object, Register bitmap_scratch,
5293 Register mask_scratch, Label* has_color,
5294 Label::Distance has_color_distance, int first_bit,
5295 int second_bit) {
5296 DCHECK(!AreAliased(object, bitmap_scratch, mask_scratch, rcx));
5297
5298 GetMarkBits(object, bitmap_scratch, mask_scratch);
5299
5300 Label other_color, word_boundary;
5301 testp(Operand(bitmap_scratch, MemoryChunk::kHeaderSize), mask_scratch);
5302 j(first_bit == 1 ? zero : not_zero, &other_color, Label::kNear);
5303 shlp(mask_scratch, Immediate(1));
5304 j(zero, &word_boundary, Label::kNear);
5305 testp(Operand(bitmap_scratch, MemoryChunk::kHeaderSize), mask_scratch);
5306 j(second_bit == 1 ? not_zero : zero, has_color, has_color_distance);
5307 jmp(&other_color, Label::kNear);
5308
5309 bind(&word_boundary);
5310 testb(Operand(bitmap_scratch, MemoryChunk::kHeaderSize + kPointerSize),
5311 Immediate(1));
5312
5313 j(second_bit == 1 ? not_zero : zero, has_color, has_color_distance);
5314 bind(&other_color);
5315 }
5316
5317
5305 void MacroAssembler::GetMarkBits(Register addr_reg, 5318 void MacroAssembler::GetMarkBits(Register addr_reg,
5306 Register bitmap_reg, 5319 Register bitmap_reg,
5307 Register mask_reg) { 5320 Register mask_reg) {
5308 DCHECK(!AreAliased(addr_reg, bitmap_reg, mask_reg, rcx)); 5321 DCHECK(!AreAliased(addr_reg, bitmap_reg, mask_reg, rcx));
5309 movp(bitmap_reg, addr_reg); 5322 movp(bitmap_reg, addr_reg);
5310 // Sign extended 32 bit immediate. 5323 // Sign extended 32 bit immediate.
5311 andp(bitmap_reg, Immediate(~Page::kPageAlignmentMask)); 5324 andp(bitmap_reg, Immediate(~Page::kPageAlignmentMask));
5312 movp(rcx, addr_reg); 5325 movp(rcx, addr_reg);
5313 int shift = 5326 int shift =
5314 Bitmap::kBitsPerCellLog2 + kPointerSizeLog2 - Bitmap::kBytesPerCellLog2; 5327 Bitmap::kBitsPerCellLog2 + kPointerSizeLog2 - Bitmap::kBytesPerCellLog2;
5315 shrl(rcx, Immediate(shift)); 5328 shrl(rcx, Immediate(shift));
5316 andp(rcx, 5329 andp(rcx,
5317 Immediate((Page::kPageAlignmentMask >> shift) & 5330 Immediate((Page::kPageAlignmentMask >> shift) &
5318 ~(Bitmap::kBytesPerCell - 1))); 5331 ~(Bitmap::kBytesPerCell - 1)));
5319 5332
5320 addp(bitmap_reg, rcx); 5333 addp(bitmap_reg, rcx);
5321 movp(rcx, addr_reg); 5334 movp(rcx, addr_reg);
5322 shrl(rcx, Immediate(kPointerSizeLog2)); 5335 shrl(rcx, Immediate(kPointerSizeLog2));
5323 andp(rcx, Immediate((1 << Bitmap::kBitsPerCellLog2) - 1)); 5336 andp(rcx, Immediate((1 << Bitmap::kBitsPerCellLog2) - 1));
5324 movl(mask_reg, Immediate(1)); 5337 movl(mask_reg, Immediate(3));
5325 shlp_cl(mask_reg); 5338 shlp_cl(mask_reg);
5326 } 5339 }
5327 5340
5328 5341
5329 void MacroAssembler::JumpIfWhite(Register value, Register bitmap_scratch, 5342 void MacroAssembler::JumpIfWhite(Register value, Register bitmap_scratch,
5330 Register mask_scratch, Label* value_is_white, 5343 Register mask_scratch, Label* value_is_white,
5331 Label::Distance distance) { 5344 Label::Distance distance) {
5332 DCHECK(!AreAliased(value, bitmap_scratch, mask_scratch, rcx)); 5345 DCHECK(!AreAliased(value, bitmap_scratch, mask_scratch, rcx));
5333 GetMarkBits(value, bitmap_scratch, mask_scratch); 5346 GetMarkBits(value, bitmap_scratch, mask_scratch);
5334 5347
5335 // If the value is black or grey we don't need to do anything. 5348 // If the value is black or grey we don't need to do anything.
5336 DCHECK(strcmp(Marking::kWhiteBitPattern, "00") == 0); 5349 DCHECK(strcmp(Marking::kWhiteBitPattern, "00") == 0);
5337 DCHECK(strcmp(Marking::kBlackBitPattern, "10") == 0); 5350 DCHECK(strcmp(Marking::kBlackBitPattern, "11") == 0);
5338 DCHECK(strcmp(Marking::kGreyBitPattern, "11") == 0); 5351 DCHECK(strcmp(Marking::kGreyBitPattern, "10") == 0);
5339 DCHECK(strcmp(Marking::kImpossibleBitPattern, "01") == 0); 5352 DCHECK(strcmp(Marking::kImpossibleBitPattern, "01") == 0);
5340 5353
5341 // Since both black and grey have a 1 in the first position and white does 5354 // Since both black and grey have a 1 in the first position and white does
5342 // not have a 1 there we only need to check one bit. 5355 // not have a 1 there we only need to check one bit.
5343 testp(Operand(bitmap_scratch, MemoryChunk::kHeaderSize), mask_scratch); 5356 testp(Operand(bitmap_scratch, MemoryChunk::kHeaderSize), mask_scratch);
5344 j(zero, value_is_white, distance); 5357 j(zero, value_is_white, distance);
5345 } 5358 }
5346 5359
5347 5360
5348 void MacroAssembler::CheckEnumCache(Register null_value, Label* call_runtime) { 5361 void MacroAssembler::CheckEnumCache(Register null_value, Label* call_runtime) {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
5460 movl(rax, dividend); 5473 movl(rax, dividend);
5461 shrl(rax, Immediate(31)); 5474 shrl(rax, Immediate(31));
5462 addl(rdx, rax); 5475 addl(rdx, rax);
5463 } 5476 }
5464 5477
5465 5478
5466 } // namespace internal 5479 } // namespace internal
5467 } // namespace v8 5480 } // namespace v8
5468 5481
5469 #endif // V8_TARGET_ARCH_X64 5482 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698