| 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 1314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1325 } else { | 1325 } else { |
| 1326 sub(result, Immediate(object_size)); | 1326 sub(result, Immediate(object_size)); |
| 1327 } | 1327 } |
| 1328 } else if (tag_result) { | 1328 } else if (tag_result) { |
| 1329 ASSERT(kHeapObjectTag == 1); | 1329 ASSERT(kHeapObjectTag == 1); |
| 1330 inc(result); | 1330 inc(result); |
| 1331 } | 1331 } |
| 1332 } | 1332 } |
| 1333 | 1333 |
| 1334 | 1334 |
| 1335 void MacroAssembler::AllocateInNewSpace( | 1335 void MacroAssembler::Allocate(int header_size, |
| 1336 int header_size, | 1336 ScaleFactor element_size, |
| 1337 ScaleFactor element_size, | 1337 Register element_count, |
| 1338 Register element_count, | 1338 RegisterValueType element_count_type, |
| 1339 RegisterValueType element_count_type, | 1339 Register result, |
| 1340 Register result, | 1340 Register result_end, |
| 1341 Register result_end, | 1341 Register scratch, |
| 1342 Register scratch, | 1342 Label* gc_required, |
| 1343 Label* gc_required, | 1343 AllocationFlags flags) { |
| 1344 AllocationFlags flags) { | |
| 1345 ASSERT((flags & SIZE_IN_WORDS) == 0); | 1344 ASSERT((flags & SIZE_IN_WORDS) == 0); |
| 1346 ASSERT((flags & PRETENURE_OLD_POINTER_SPACE) == 0); | |
| 1347 if (!FLAG_inline_new) { | 1345 if (!FLAG_inline_new) { |
| 1348 if (emit_debug_code()) { | 1346 if (emit_debug_code()) { |
| 1349 // Trash the registers to simulate an allocation failure. | 1347 // Trash the registers to simulate an allocation failure. |
| 1350 mov(result, Immediate(0x7091)); | 1348 mov(result, Immediate(0x7091)); |
| 1351 mov(result_end, Immediate(0x7191)); | 1349 mov(result_end, Immediate(0x7191)); |
| 1352 if (scratch.is_valid()) { | 1350 if (scratch.is_valid()) { |
| 1353 mov(scratch, Immediate(0x7291)); | 1351 mov(scratch, Immediate(0x7291)); |
| 1354 } | 1352 } |
| 1355 // Register element_count is not modified by the function. | 1353 // Register element_count is not modified by the function. |
| 1356 } | 1354 } |
| 1357 jmp(gc_required); | 1355 jmp(gc_required); |
| 1358 return; | 1356 return; |
| 1359 } | 1357 } |
| 1360 ASSERT(!result.is(result_end)); | 1358 ASSERT(!result.is(result_end)); |
| 1361 | 1359 |
| 1362 // Load address of new object into result. | 1360 // Load address of new object into result. |
| 1363 LoadAllocationTopHelper(result, scratch, flags); | 1361 LoadAllocationTopHelper(result, scratch, flags); |
| 1364 | 1362 |
| 1365 // Align the next allocation. Storing the filler map without checking top is | 1363 // Align the next allocation. Storing the filler map without checking top is |
| 1366 // always safe because the limit of the heap is always aligned. | 1364 // always safe because the limit of the heap is always aligned. |
| 1367 if ((flags & DOUBLE_ALIGNMENT) != 0) { | 1365 if ((flags & DOUBLE_ALIGNMENT) != 0) { |
| 1366 ASSERT((flags & PRETENURE_OLD_POINTER_SPACE) == 0); |
| 1368 ASSERT(kPointerAlignment * 2 == kDoubleAlignment); | 1367 ASSERT(kPointerAlignment * 2 == kDoubleAlignment); |
| 1369 Label aligned; | 1368 Label aligned; |
| 1370 test(result, Immediate(kDoubleAlignmentMask)); | 1369 test(result, Immediate(kDoubleAlignmentMask)); |
| 1371 j(zero, &aligned, Label::kNear); | 1370 j(zero, &aligned, Label::kNear); |
| 1372 mov(Operand(result, 0), | 1371 mov(Operand(result, 0), |
| 1373 Immediate(isolate()->factory()->one_pointer_filler_map())); | 1372 Immediate(isolate()->factory()->one_pointer_filler_map())); |
| 1374 add(result, Immediate(kDoubleSize / 2)); | 1373 add(result, Immediate(kDoubleSize / 2)); |
| 1375 bind(&aligned); | 1374 bind(&aligned); |
| 1376 } | 1375 } |
| 1377 | 1376 |
| 1378 // Calculate new top and bail out if new space is exhausted. | 1377 // Calculate new top and bail out if space is exhausted. |
| 1379 ExternalReference new_space_allocation_limit = | 1378 ExternalReference allocation_limit = |
| 1380 ExternalReference::new_space_allocation_limit_address(isolate()); | 1379 AllocationUtils::GetAllocationLimitReference(isolate(), flags); |
| 1381 | 1380 |
| 1382 // We assume that element_count*element_size + header_size does not | 1381 // We assume that element_count*element_size + header_size does not |
| 1383 // overflow. | 1382 // overflow. |
| 1384 if (element_count_type == REGISTER_VALUE_IS_SMI) { | 1383 if (element_count_type == REGISTER_VALUE_IS_SMI) { |
| 1385 STATIC_ASSERT(static_cast<ScaleFactor>(times_2 - 1) == times_1); | 1384 STATIC_ASSERT(static_cast<ScaleFactor>(times_2 - 1) == times_1); |
| 1386 STATIC_ASSERT(static_cast<ScaleFactor>(times_4 - 1) == times_2); | 1385 STATIC_ASSERT(static_cast<ScaleFactor>(times_4 - 1) == times_2); |
| 1387 STATIC_ASSERT(static_cast<ScaleFactor>(times_8 - 1) == times_4); | 1386 STATIC_ASSERT(static_cast<ScaleFactor>(times_8 - 1) == times_4); |
| 1388 ASSERT(element_size >= times_2); | 1387 ASSERT(element_size >= times_2); |
| 1389 ASSERT(kSmiTagSize == 1); | 1388 ASSERT(kSmiTagSize == 1); |
| 1390 element_size = static_cast<ScaleFactor>(element_size - 1); | 1389 element_size = static_cast<ScaleFactor>(element_size - 1); |
| 1391 } else { | 1390 } else { |
| 1392 ASSERT(element_count_type == REGISTER_VALUE_IS_INT32); | 1391 ASSERT(element_count_type == REGISTER_VALUE_IS_INT32); |
| 1393 } | 1392 } |
| 1394 lea(result_end, Operand(element_count, element_size, header_size)); | 1393 lea(result_end, Operand(element_count, element_size, header_size)); |
| 1395 add(result_end, result); | 1394 add(result_end, result); |
| 1396 j(carry, gc_required); | 1395 j(carry, gc_required); |
| 1397 cmp(result_end, Operand::StaticVariable(new_space_allocation_limit)); | 1396 cmp(result_end, Operand::StaticVariable(allocation_limit)); |
| 1398 j(above, gc_required); | 1397 j(above, gc_required); |
| 1399 | 1398 |
| 1400 if ((flags & TAG_OBJECT) != 0) { | 1399 if ((flags & TAG_OBJECT) != 0) { |
| 1401 ASSERT(kHeapObjectTag == 1); | 1400 ASSERT(kHeapObjectTag == 1); |
| 1402 inc(result); | 1401 inc(result); |
| 1403 } | 1402 } |
| 1404 | 1403 |
| 1405 // Update allocation top. | 1404 // Update allocation top. |
| 1406 UpdateAllocationTopHelper(result_end, scratch, flags); | 1405 UpdateAllocationTopHelper(result_end, scratch, flags); |
| 1407 } | 1406 } |
| 1408 | 1407 |
| 1409 | 1408 |
| 1410 void MacroAssembler::AllocateInNewSpace(Register object_size, | 1409 void MacroAssembler::Allocate(Register object_size, |
| 1411 Register result, | 1410 Register result, |
| 1412 Register result_end, | 1411 Register result_end, |
| 1413 Register scratch, | 1412 Register scratch, |
| 1414 Label* gc_required, | 1413 Label* gc_required, |
| 1415 AllocationFlags flags) { | 1414 AllocationFlags flags) { |
| 1416 ASSERT((flags & (RESULT_CONTAINS_TOP | SIZE_IN_WORDS)) == 0); | 1415 ASSERT((flags & (RESULT_CONTAINS_TOP | SIZE_IN_WORDS)) == 0); |
| 1417 ASSERT((flags & PRETENURE_OLD_POINTER_SPACE) == 0); | |
| 1418 if (!FLAG_inline_new) { | 1416 if (!FLAG_inline_new) { |
| 1419 if (emit_debug_code()) { | 1417 if (emit_debug_code()) { |
| 1420 // Trash the registers to simulate an allocation failure. | 1418 // Trash the registers to simulate an allocation failure. |
| 1421 mov(result, Immediate(0x7091)); | 1419 mov(result, Immediate(0x7091)); |
| 1422 mov(result_end, Immediate(0x7191)); | 1420 mov(result_end, Immediate(0x7191)); |
| 1423 if (scratch.is_valid()) { | 1421 if (scratch.is_valid()) { |
| 1424 mov(scratch, Immediate(0x7291)); | 1422 mov(scratch, Immediate(0x7291)); |
| 1425 } | 1423 } |
| 1426 // object_size is left unchanged by this function. | 1424 // object_size is left unchanged by this function. |
| 1427 } | 1425 } |
| 1428 jmp(gc_required); | 1426 jmp(gc_required); |
| 1429 return; | 1427 return; |
| 1430 } | 1428 } |
| 1431 ASSERT(!result.is(result_end)); | 1429 ASSERT(!result.is(result_end)); |
| 1432 | 1430 |
| 1433 // Load address of new object into result. | 1431 // Load address of new object into result. |
| 1434 LoadAllocationTopHelper(result, scratch, flags); | 1432 LoadAllocationTopHelper(result, scratch, flags); |
| 1435 | 1433 |
| 1436 // Align the next allocation. Storing the filler map without checking top is | 1434 // Align the next allocation. Storing the filler map without checking top is |
| 1437 // always safe because the limit of the heap is always aligned. | 1435 // always safe because the limit of the heap is always aligned. |
| 1438 if ((flags & DOUBLE_ALIGNMENT) != 0) { | 1436 if ((flags & DOUBLE_ALIGNMENT) != 0) { |
| 1437 ASSERT((flags & PRETENURE_OLD_POINTER_SPACE) == 0); |
| 1439 ASSERT(kPointerAlignment * 2 == kDoubleAlignment); | 1438 ASSERT(kPointerAlignment * 2 == kDoubleAlignment); |
| 1440 Label aligned; | 1439 Label aligned; |
| 1441 test(result, Immediate(kDoubleAlignmentMask)); | 1440 test(result, Immediate(kDoubleAlignmentMask)); |
| 1442 j(zero, &aligned, Label::kNear); | 1441 j(zero, &aligned, Label::kNear); |
| 1443 mov(Operand(result, 0), | 1442 mov(Operand(result, 0), |
| 1444 Immediate(isolate()->factory()->one_pointer_filler_map())); | 1443 Immediate(isolate()->factory()->one_pointer_filler_map())); |
| 1445 add(result, Immediate(kDoubleSize / 2)); | 1444 add(result, Immediate(kDoubleSize / 2)); |
| 1446 bind(&aligned); | 1445 bind(&aligned); |
| 1447 } | 1446 } |
| 1448 | 1447 |
| 1449 // Calculate new top and bail out if new space is exhausted. | 1448 // Calculate new top and bail out if space is exhausted. |
| 1450 ExternalReference new_space_allocation_limit = | 1449 ExternalReference allocation_limit = |
| 1451 ExternalReference::new_space_allocation_limit_address(isolate()); | 1450 AllocationUtils::GetAllocationLimitReference(isolate(), flags); |
| 1451 |
| 1452 if (!object_size.is(result_end)) { | 1452 if (!object_size.is(result_end)) { |
| 1453 mov(result_end, object_size); | 1453 mov(result_end, object_size); |
| 1454 } | 1454 } |
| 1455 add(result_end, result); | 1455 add(result_end, result); |
| 1456 j(carry, gc_required); | 1456 j(carry, gc_required); |
| 1457 cmp(result_end, Operand::StaticVariable(new_space_allocation_limit)); | 1457 cmp(result_end, Operand::StaticVariable(allocation_limit)); |
| 1458 j(above, gc_required); | 1458 j(above, gc_required); |
| 1459 | 1459 |
| 1460 // Tag result if requested. | 1460 // Tag result if requested. |
| 1461 if ((flags & TAG_OBJECT) != 0) { | 1461 if ((flags & TAG_OBJECT) != 0) { |
| 1462 ASSERT(kHeapObjectTag == 1); | 1462 ASSERT(kHeapObjectTag == 1); |
| 1463 inc(result); | 1463 inc(result); |
| 1464 } | 1464 } |
| 1465 | 1465 |
| 1466 // Update allocation top. | 1466 // Update allocation top. |
| 1467 UpdateAllocationTopHelper(result_end, scratch, flags); | 1467 UpdateAllocationTopHelper(result_end, scratch, flags); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1504 Label* gc_required) { | 1504 Label* gc_required) { |
| 1505 // Calculate the number of bytes needed for the characters in the string while | 1505 // Calculate the number of bytes needed for the characters in the string while |
| 1506 // observing object alignment. | 1506 // observing object alignment. |
| 1507 ASSERT((SeqTwoByteString::kHeaderSize & kObjectAlignmentMask) == 0); | 1507 ASSERT((SeqTwoByteString::kHeaderSize & kObjectAlignmentMask) == 0); |
| 1508 ASSERT(kShortSize == 2); | 1508 ASSERT(kShortSize == 2); |
| 1509 // scratch1 = length * 2 + kObjectAlignmentMask. | 1509 // scratch1 = length * 2 + kObjectAlignmentMask. |
| 1510 lea(scratch1, Operand(length, length, times_1, kObjectAlignmentMask)); | 1510 lea(scratch1, Operand(length, length, times_1, kObjectAlignmentMask)); |
| 1511 and_(scratch1, Immediate(~kObjectAlignmentMask)); | 1511 and_(scratch1, Immediate(~kObjectAlignmentMask)); |
| 1512 | 1512 |
| 1513 // Allocate two byte string in new space. | 1513 // Allocate two byte string in new space. |
| 1514 AllocateInNewSpace(SeqTwoByteString::kHeaderSize, | 1514 Allocate(SeqTwoByteString::kHeaderSize, |
| 1515 times_1, | 1515 times_1, |
| 1516 scratch1, | 1516 scratch1, |
| 1517 REGISTER_VALUE_IS_INT32, | 1517 REGISTER_VALUE_IS_INT32, |
| 1518 result, | 1518 result, |
| 1519 scratch2, | 1519 scratch2, |
| 1520 scratch3, | 1520 scratch3, |
| 1521 gc_required, | 1521 gc_required, |
| 1522 TAG_OBJECT); | 1522 TAG_OBJECT); |
| 1523 | 1523 |
| 1524 // Set the map, length and hash field. | 1524 // Set the map, length and hash field. |
| 1525 mov(FieldOperand(result, HeapObject::kMapOffset), | 1525 mov(FieldOperand(result, HeapObject::kMapOffset), |
| 1526 Immediate(isolate()->factory()->string_map())); | 1526 Immediate(isolate()->factory()->string_map())); |
| 1527 mov(scratch1, length); | 1527 mov(scratch1, length); |
| 1528 SmiTag(scratch1); | 1528 SmiTag(scratch1); |
| 1529 mov(FieldOperand(result, String::kLengthOffset), scratch1); | 1529 mov(FieldOperand(result, String::kLengthOffset), scratch1); |
| 1530 mov(FieldOperand(result, String::kHashFieldOffset), | 1530 mov(FieldOperand(result, String::kHashFieldOffset), |
| 1531 Immediate(String::kEmptyHashField)); | 1531 Immediate(String::kEmptyHashField)); |
| 1532 } | 1532 } |
| 1533 | 1533 |
| 1534 | 1534 |
| 1535 void MacroAssembler::AllocateAsciiString(Register result, | 1535 void MacroAssembler::AllocateAsciiString(Register result, |
| 1536 Register length, | 1536 Register length, |
| 1537 Register scratch1, | 1537 Register scratch1, |
| 1538 Register scratch2, | 1538 Register scratch2, |
| 1539 Register scratch3, | 1539 Register scratch3, |
| 1540 Label* gc_required) { | 1540 Label* gc_required) { |
| 1541 // Calculate the number of bytes needed for the characters in the string while | 1541 // Calculate the number of bytes needed for the characters in the string while |
| 1542 // observing object alignment. | 1542 // observing object alignment. |
| 1543 ASSERT((SeqOneByteString::kHeaderSize & kObjectAlignmentMask) == 0); | 1543 ASSERT((SeqOneByteString::kHeaderSize & kObjectAlignmentMask) == 0); |
| 1544 mov(scratch1, length); | 1544 mov(scratch1, length); |
| 1545 ASSERT(kCharSize == 1); | 1545 ASSERT(kCharSize == 1); |
| 1546 add(scratch1, Immediate(kObjectAlignmentMask)); | 1546 add(scratch1, Immediate(kObjectAlignmentMask)); |
| 1547 and_(scratch1, Immediate(~kObjectAlignmentMask)); | 1547 and_(scratch1, Immediate(~kObjectAlignmentMask)); |
| 1548 | 1548 |
| 1549 // Allocate ASCII string in new space. | 1549 // Allocate ASCII string in new space. |
| 1550 AllocateInNewSpace(SeqOneByteString::kHeaderSize, | 1550 Allocate(SeqOneByteString::kHeaderSize, |
| 1551 times_1, | 1551 times_1, |
| 1552 scratch1, | 1552 scratch1, |
| 1553 REGISTER_VALUE_IS_INT32, | 1553 REGISTER_VALUE_IS_INT32, |
| 1554 result, | 1554 result, |
| 1555 scratch2, | 1555 scratch2, |
| 1556 scratch3, | 1556 scratch3, |
| 1557 gc_required, | 1557 gc_required, |
| 1558 TAG_OBJECT); | 1558 TAG_OBJECT); |
| 1559 | 1559 |
| 1560 // Set the map, length and hash field. | 1560 // Set the map, length and hash field. |
| 1561 mov(FieldOperand(result, HeapObject::kMapOffset), | 1561 mov(FieldOperand(result, HeapObject::kMapOffset), |
| 1562 Immediate(isolate()->factory()->ascii_string_map())); | 1562 Immediate(isolate()->factory()->ascii_string_map())); |
| 1563 mov(scratch1, length); | 1563 mov(scratch1, length); |
| 1564 SmiTag(scratch1); | 1564 SmiTag(scratch1); |
| 1565 mov(FieldOperand(result, String::kLengthOffset), scratch1); | 1565 mov(FieldOperand(result, String::kLengthOffset), scratch1); |
| 1566 mov(FieldOperand(result, String::kHashFieldOffset), | 1566 mov(FieldOperand(result, String::kHashFieldOffset), |
| 1567 Immediate(String::kEmptyHashField)); | 1567 Immediate(String::kEmptyHashField)); |
| 1568 } | 1568 } |
| (...skipping 1528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3097 j(greater, &no_info_available); | 3097 j(greater, &no_info_available); |
| 3098 cmp(MemOperand(scratch_reg, -AllocationSiteInfo::kSize), | 3098 cmp(MemOperand(scratch_reg, -AllocationSiteInfo::kSize), |
| 3099 Immediate(Handle<Map>(isolate()->heap()->allocation_site_info_map()))); | 3099 Immediate(Handle<Map>(isolate()->heap()->allocation_site_info_map()))); |
| 3100 bind(&no_info_available); | 3100 bind(&no_info_available); |
| 3101 } | 3101 } |
| 3102 | 3102 |
| 3103 | 3103 |
| 3104 } } // namespace v8::internal | 3104 } } // namespace v8::internal |
| 3105 | 3105 |
| 3106 #endif // V8_TARGET_ARCH_IA32 | 3106 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |