Chromium Code Reviews| 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 2313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2324 jmp(&other_color, Label::kNear); | 2324 jmp(&other_color, Label::kNear); |
| 2325 | 2325 |
| 2326 bind(&word_boundary); | 2326 bind(&word_boundary); |
| 2327 test_b(Operand(bitmap_scratch, MemoryChunk::kHeaderSize + kPointerSize), 1); | 2327 test_b(Operand(bitmap_scratch, MemoryChunk::kHeaderSize + kPointerSize), 1); |
| 2328 | 2328 |
| 2329 j(second_bit == 1 ? not_zero : zero, has_color, has_color_distance); | 2329 j(second_bit == 1 ? not_zero : zero, has_color, has_color_distance); |
| 2330 bind(&other_color); | 2330 bind(&other_color); |
| 2331 } | 2331 } |
| 2332 | 2332 |
| 2333 | 2333 |
| 2334 // Detect some, but not all, common pointer-free objects. This is used by the | |
| 2335 // incremental write barrier which doesn't care about oddballs (they are always | |
| 2336 // marked black immediately so this code is not hit). | |
| 2337 void MacroAssembler::JumpIfDataObject( | |
| 2338 Register value, | |
| 2339 Register scratch, | |
| 2340 Label* not_data_object, | |
| 2341 Label::Distance not_data_object_distance) { | |
| 2342 Label is_data_object; | |
| 2343 mov(scratch, FieldOperand(value, HeapObject::kMapOffset)); | |
| 2344 cmp(scratch, FACTORY->heap_number_map()); | |
| 2345 j(equal, &is_data_object, Label::kNear); | |
| 2346 ASSERT(kConsStringTag == 1 && kIsConsStringMask == 1); | |
| 2347 ASSERT(kNotStringTag == 0x80 && kIsNotStringMask == 0x80); | |
| 2348 // If it's a string and it's not a cons string then it's an object containing | |
| 2349 // no GC pointers. | |
| 2350 test_b(FieldOperand(scratch, Map::kInstanceTypeOffset), | |
| 2351 kIsConsStringMask | kIsNotStringMask); | |
| 2352 j(not_zero, not_data_object, not_data_object_distance); | |
| 2353 bind(&is_data_object); | |
| 2354 } | |
| 2355 | |
| 2356 | |
| 2357 void MacroAssembler::GetMarkBits(Register addr_reg, | 2334 void MacroAssembler::GetMarkBits(Register addr_reg, |
| 2358 Register bitmap_reg, | 2335 Register bitmap_reg, |
| 2359 Register mask_reg) { | 2336 Register mask_reg) { |
| 2360 ASSERT(!AreAliased(addr_reg, bitmap_reg, mask_reg, ecx)); | 2337 ASSERT(!AreAliased(addr_reg, mask_reg, bitmap_reg, ecx)); |
| 2361 mov(bitmap_reg, Operand(addr_reg)); | 2338 mov(bitmap_reg, Immediate(~Page::kPageAlignmentMask)); |
| 2362 and_(bitmap_reg, ~Page::kPageAlignmentMask); | 2339 and_(Operand(bitmap_reg), addr_reg); |
| 2363 mov(ecx, Operand(addr_reg)); | 2340 mov(ecx, Operand(addr_reg)); |
| 2364 int shift = | 2341 int shift = |
| 2365 Bitmap::kBitsPerCellLog2 + kPointerSizeLog2 - Bitmap::kBytesPerCellLog2; | 2342 Bitmap::kBitsPerCellLog2 + kPointerSizeLog2 - Bitmap::kBytesPerCellLog2; |
| 2366 shr(ecx, shift); | 2343 shr(ecx, shift); |
| 2367 and_(ecx, | 2344 and_(ecx, |
| 2368 (Page::kPageAlignmentMask >> shift) & ~(Bitmap::kBytesPerCell - 1)); | 2345 (Page::kPageAlignmentMask >> shift) & ~(Bitmap::kBytesPerCell - 1)); |
| 2369 | 2346 |
| 2370 add(bitmap_reg, Operand(ecx)); | 2347 add(bitmap_reg, Operand(ecx)); |
| 2371 mov(ecx, Operand(addr_reg)); | 2348 mov(ecx, Operand(addr_reg)); |
| 2372 shr(ecx, kPointerSizeLog2); | 2349 shr(ecx, kPointerSizeLog2); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2405 // shl. May overflow making the check conservative. | 2382 // shl. May overflow making the check conservative. |
| 2406 add(mask_scratch, Operand(mask_scratch)); | 2383 add(mask_scratch, Operand(mask_scratch)); |
| 2407 test(mask_scratch, Operand(bitmap_scratch, MemoryChunk::kHeaderSize)); | 2384 test(mask_scratch, Operand(bitmap_scratch, MemoryChunk::kHeaderSize)); |
| 2408 j(zero, &ok, Label::kNear); | 2385 j(zero, &ok, Label::kNear); |
| 2409 int3(); | 2386 int3(); |
| 2410 bind(&ok); | 2387 bind(&ok); |
| 2411 pop(mask_scratch); | 2388 pop(mask_scratch); |
| 2412 } | 2389 } |
| 2413 | 2390 |
| 2414 // Value is white. We check whether it is data that doesn't need scanning. | 2391 // Value is white. We check whether it is data that doesn't need scanning. |
| 2415 JumpIfDataObject(value, ecx, value_is_white_and_not_data, distance); | 2392 // Currently only checks for HeapNumber and non-cons strings. |
| 2393 Register map = ecx; // Holds map while checking type. | |
| 2394 Register length = ecx; // Holds length of object after checking type. | |
| 2395 Label not_heap_number; | |
| 2396 Label is_data_object; | |
| 2416 | 2397 |
| 2398 // Check for heap-number | |
| 2399 mov(map, FieldOperand(value, HeapObject::kMapOffset)); | |
| 2400 cmp(map, FACTORY->heap_number_map()); | |
| 2401 j(not_equal, ¬_heap_number, Label::kNear); | |
| 2402 mov(length, Immediate(HeapNumber::kSize)); | |
| 2403 jmp(&is_data_object, Label::kNear); | |
| 2404 | |
| 2405 bind(¬_heap_number); | |
| 2406 // Check for strings. | |
| 2407 ASSERT(kConsStringTag == 1 && kIsConsStringMask == 1); | |
| 2408 ASSERT(kNotStringTag == 0x80 && kIsNotStringMask == 0x80); | |
| 2409 // If it's a string and it's not a cons string then it's an object containing | |
| 2410 // no GC pointers. | |
| 2411 Register instance_type = ecx; | |
| 2412 movzx_b(instance_type, FieldOperand(map, Map::kInstanceTypeOffset)); | |
| 2413 test_b(Operand(instance_type), kIsConsStringMask | kIsNotStringMask); | |
| 2414 j(not_zero, value_is_white_and_not_data); | |
| 2415 // It's a non-cons string. | |
| 2416 // If it's external, the length is just ExternalString::kSize. | |
| 2417 // Otherwise it's String::kHeaderSize + string->length() * (1 or 2). | |
| 2418 Label not_external; | |
| 2419 test_b(Operand(instance_type), kExternalStringTag); | |
|
Erik Corry
2011/06/24 09:46:17
You are making use of the fact that kExternalStrin
Lasse Reichstein
2011/06/24 11:09:08
Added assert.
Are we sure it's not more used in th
| |
| 2420 j(zero, ¬_external, Label::kNear); | |
| 2421 mov(length, Immediate(ExternalString::kSize)); | |
| 2422 jmp(&is_data_object, Label::kNear); | |
| 2423 bind(¬_external); | |
|
Erik Corry
2011/06/24 09:46:17
I think a blank line before bind(...) lines improv
Lasse Reichstein
2011/06/24 11:09:08
added
| |
| 2424 // Sequential string, either ASCII or UC16. | |
| 2425 ASSERT(kAsciiStringTag == 0x04); | |
| 2426 and_(Operand(length), Immediate(kStringEncodingMask)); | |
| 2427 xor_(Operand(length), Immediate(kStringEncodingMask)); | |
| 2428 add(Operand(length), Immediate(0x04)); | |
| 2429 // Value now either 4 (if ASCII) or 8 (if UC16), i.e., char-size shifted | |
| 2430 // by 2. If we multiply the string length as smi by this, it still | |
| 2431 // won't overflow a 32-bit value. | |
| 2432 ASSERT_EQ(SeqAsciiString::kMaxSize, SeqAsciiString::kMaxSize); | |
|
Erik Corry
2011/06/24 09:46:17
I have a hard time seeing the circumstances where
Lasse Reichstein
2011/06/24 11:09:08
*Cough*
Fixed.
| |
| 2433 ASSERT(SeqAsciiString::kMaxSize <= | |
| 2434 static_cast<int>(0xffffffffu >> (2 + kSmiTagSize))); | |
| 2435 imul(length, FieldOperand(value, String::kLengthOffset)); | |
| 2436 shr(length, 2 + kSmiTagSize); | |
| 2437 add(Operand(length), | |
| 2438 Immediate(SeqString::kHeaderSize + kObjectAlignmentMask)); | |
| 2439 and_(Operand(length), | |
| 2440 Immediate(~kObjectAlignmentMask)); | |
| 2441 | |
| 2442 bind(&is_data_object); | |
| 2417 // Value is a data object, and it is white. Mark it black. Since we know | 2443 // Value is a data object, and it is white. Mark it black. Since we know |
| 2418 // that the object is white we can make it black by flipping one bit. | 2444 // that the object is white we can make it black by flipping one bit. |
| 2419 or_(Operand(bitmap_scratch, MemoryChunk::kHeaderSize), mask_scratch); | 2445 or_(Operand(bitmap_scratch, MemoryChunk::kHeaderSize), mask_scratch); |
| 2446 | |
| 2447 and_(bitmap_scratch, Immediate(~Page::kPageAlignmentMask)); | |
| 2448 add(Operand(bitmap_scratch, MemoryChunk::kLiveBytesOffset), | |
|
Erik Corry
2011/06/24 09:46:17
I wonder how the performance of this read-modify-w
Lasse Reichstein
2011/06/24 11:09:08
Possibly a few cycle slower latency (but we're mos
| |
| 2449 length); | |
| 2450 | |
| 2420 bind(&done); | 2451 bind(&done); |
| 2421 } | 2452 } |
| 2422 | 2453 |
| 2423 } } // namespace v8::internal | 2454 } } // namespace v8::internal |
| 2424 | 2455 |
| 2425 #endif // V8_TARGET_ARCH_IA32 | 2456 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |