| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1451 | 1451 |
| 1452 | 1452 |
| 1453 void MacroAssembler::AllocateAsciiString(Register result, | 1453 void MacroAssembler::AllocateAsciiString(Register result, |
| 1454 Register length, | 1454 Register length, |
| 1455 Register scratch1, | 1455 Register scratch1, |
| 1456 Register scratch2, | 1456 Register scratch2, |
| 1457 Register scratch3, | 1457 Register scratch3, |
| 1458 Label* gc_required) { | 1458 Label* gc_required) { |
| 1459 // Calculate the number of bytes needed for the characters in the string while | 1459 // Calculate the number of bytes needed for the characters in the string while |
| 1460 // observing object alignment. | 1460 // observing object alignment. |
| 1461 ASSERT((SeqAsciiString::kHeaderSize & kObjectAlignmentMask) == 0); | 1461 ASSERT((SeqOneByteString::kHeaderSize & kObjectAlignmentMask) == 0); |
| 1462 mov(scratch1, length); | 1462 mov(scratch1, length); |
| 1463 ASSERT(kCharSize == 1); | 1463 ASSERT(kCharSize == 1); |
| 1464 add(scratch1, Immediate(kObjectAlignmentMask)); | 1464 add(scratch1, Immediate(kObjectAlignmentMask)); |
| 1465 and_(scratch1, Immediate(~kObjectAlignmentMask)); | 1465 and_(scratch1, Immediate(~kObjectAlignmentMask)); |
| 1466 | 1466 |
| 1467 // Allocate ASCII string in new space. | 1467 // Allocate ASCII string in new space. |
| 1468 AllocateInNewSpace(SeqAsciiString::kHeaderSize, | 1468 AllocateInNewSpace(SeqOneByteString::kHeaderSize, |
| 1469 times_1, | 1469 times_1, |
| 1470 scratch1, | 1470 scratch1, |
| 1471 result, | 1471 result, |
| 1472 scratch2, | 1472 scratch2, |
| 1473 scratch3, | 1473 scratch3, |
| 1474 gc_required, | 1474 gc_required, |
| 1475 TAG_OBJECT); | 1475 TAG_OBJECT); |
| 1476 | 1476 |
| 1477 // Set the map, length and hash field. | 1477 // Set the map, length and hash field. |
| 1478 mov(FieldOperand(result, HeapObject::kMapOffset), | 1478 mov(FieldOperand(result, HeapObject::kMapOffset), |
| 1479 Immediate(isolate()->factory()->ascii_string_map())); | 1479 Immediate(isolate()->factory()->ascii_string_map())); |
| 1480 mov(scratch1, length); | 1480 mov(scratch1, length); |
| 1481 SmiTag(scratch1); | 1481 SmiTag(scratch1); |
| 1482 mov(FieldOperand(result, String::kLengthOffset), scratch1); | 1482 mov(FieldOperand(result, String::kLengthOffset), scratch1); |
| 1483 mov(FieldOperand(result, String::kHashFieldOffset), | 1483 mov(FieldOperand(result, String::kHashFieldOffset), |
| 1484 Immediate(String::kEmptyHashField)); | 1484 Immediate(String::kEmptyHashField)); |
| 1485 } | 1485 } |
| 1486 | 1486 |
| 1487 | 1487 |
| 1488 void MacroAssembler::AllocateAsciiString(Register result, | 1488 void MacroAssembler::AllocateAsciiString(Register result, |
| 1489 int length, | 1489 int length, |
| 1490 Register scratch1, | 1490 Register scratch1, |
| 1491 Register scratch2, | 1491 Register scratch2, |
| 1492 Label* gc_required) { | 1492 Label* gc_required) { |
| 1493 ASSERT(length > 0); | 1493 ASSERT(length > 0); |
| 1494 | 1494 |
| 1495 // Allocate ASCII string in new space. | 1495 // Allocate ASCII string in new space. |
| 1496 AllocateInNewSpace(SeqAsciiString::SizeFor(length), | 1496 AllocateInNewSpace(SeqOneByteString::SizeFor(length), |
| 1497 result, | 1497 result, |
| 1498 scratch1, | 1498 scratch1, |
| 1499 scratch2, | 1499 scratch2, |
| 1500 gc_required, | 1500 gc_required, |
| 1501 TAG_OBJECT); | 1501 TAG_OBJECT); |
| 1502 | 1502 |
| 1503 // Set the map, length and hash field. | 1503 // Set the map, length and hash field. |
| 1504 mov(FieldOperand(result, HeapObject::kMapOffset), | 1504 mov(FieldOperand(result, HeapObject::kMapOffset), |
| 1505 Immediate(isolate()->factory()->ascii_string_map())); | 1505 Immediate(isolate()->factory()->ascii_string_map())); |
| 1506 mov(FieldOperand(result, String::kLengthOffset), | 1506 mov(FieldOperand(result, String::kLengthOffset), |
| (...skipping 1406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2913 | 2913 |
| 2914 bind(¬_external); | 2914 bind(¬_external); |
| 2915 // Sequential string, either ASCII or UC16. | 2915 // Sequential string, either ASCII or UC16. |
| 2916 ASSERT(kOneByteStringTag == 0x04); | 2916 ASSERT(kOneByteStringTag == 0x04); |
| 2917 and_(length, Immediate(kStringEncodingMask)); | 2917 and_(length, Immediate(kStringEncodingMask)); |
| 2918 xor_(length, Immediate(kStringEncodingMask)); | 2918 xor_(length, Immediate(kStringEncodingMask)); |
| 2919 add(length, Immediate(0x04)); | 2919 add(length, Immediate(0x04)); |
| 2920 // Value now either 4 (if ASCII) or 8 (if UC16), i.e., char-size shifted | 2920 // Value now either 4 (if ASCII) or 8 (if UC16), i.e., char-size shifted |
| 2921 // by 2. If we multiply the string length as smi by this, it still | 2921 // by 2. If we multiply the string length as smi by this, it still |
| 2922 // won't overflow a 32-bit value. | 2922 // won't overflow a 32-bit value. |
| 2923 ASSERT_EQ(SeqAsciiString::kMaxSize, SeqTwoByteString::kMaxSize); | 2923 ASSERT_EQ(SeqOneByteString::kMaxSize, SeqTwoByteString::kMaxSize); |
| 2924 ASSERT(SeqAsciiString::kMaxSize <= | 2924 ASSERT(SeqOneByteString::kMaxSize <= |
| 2925 static_cast<int>(0xffffffffu >> (2 + kSmiTagSize))); | 2925 static_cast<int>(0xffffffffu >> (2 + kSmiTagSize))); |
| 2926 imul(length, FieldOperand(value, String::kLengthOffset)); | 2926 imul(length, FieldOperand(value, String::kLengthOffset)); |
| 2927 shr(length, 2 + kSmiTagSize + kSmiShiftSize); | 2927 shr(length, 2 + kSmiTagSize + kSmiShiftSize); |
| 2928 add(length, Immediate(SeqString::kHeaderSize + kObjectAlignmentMask)); | 2928 add(length, Immediate(SeqString::kHeaderSize + kObjectAlignmentMask)); |
| 2929 and_(length, Immediate(~kObjectAlignmentMask)); | 2929 and_(length, Immediate(~kObjectAlignmentMask)); |
| 2930 | 2930 |
| 2931 bind(&is_data_object); | 2931 bind(&is_data_object); |
| 2932 // Value is a data object, and it is white. Mark it black. Since we know | 2932 // Value is a data object, and it is white. Mark it black. Since we know |
| 2933 // that the object is white we can make it black by flipping one bit. | 2933 // that the object is white we can make it black by flipping one bit. |
| 2934 or_(Operand(bitmap_scratch, MemoryChunk::kHeaderSize), mask_scratch); | 2934 or_(Operand(bitmap_scratch, MemoryChunk::kHeaderSize), mask_scratch); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2984 j(not_equal, call_runtime); | 2984 j(not_equal, call_runtime); |
| 2985 | 2985 |
| 2986 mov(ecx, FieldOperand(ebx, Map::kPrototypeOffset)); | 2986 mov(ecx, FieldOperand(ebx, Map::kPrototypeOffset)); |
| 2987 cmp(ecx, isolate()->factory()->null_value()); | 2987 cmp(ecx, isolate()->factory()->null_value()); |
| 2988 j(not_equal, &next); | 2988 j(not_equal, &next); |
| 2989 } | 2989 } |
| 2990 | 2990 |
| 2991 } } // namespace v8::internal | 2991 } } // namespace v8::internal |
| 2992 | 2992 |
| 2993 #endif // V8_TARGET_ARCH_IA32 | 2993 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |