OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 1501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1512 ExternalAsciiString* external_string = ExternalAsciiString::cast(result); | 1512 ExternalAsciiString* external_string = ExternalAsciiString::cast(result); |
1513 external_string->set_length(length); | 1513 external_string->set_length(length); |
1514 external_string->set_resource(resource); | 1514 external_string->set_resource(resource); |
1515 | 1515 |
1516 return result; | 1516 return result; |
1517 } | 1517 } |
1518 | 1518 |
1519 | 1519 |
1520 Object* Heap::AllocateExternalStringFromTwoByte( | 1520 Object* Heap::AllocateExternalStringFromTwoByte( |
1521 ExternalTwoByteString::Resource* resource) { | 1521 ExternalTwoByteString::Resource* resource) { |
1522 Map* map; | |
1523 int length = resource->length(); | 1522 int length = resource->length(); |
1524 if (length <= String::kMaxShortStringSize) { | |
1525 map = short_external_string_map(); | |
1526 } else if (length <= String::kMaxMediumStringSize) { | |
1527 map = medium_external_string_map(); | |
1528 } else { | |
1529 map = long_external_string_map(); | |
1530 } | |
1531 | 1523 |
| 1524 Map* map = ExternalTwoByteString::StringMap(length); |
1532 Object* result = Allocate(map, NEW_SPACE); | 1525 Object* result = Allocate(map, NEW_SPACE); |
1533 if (result->IsFailure()) return result; | 1526 if (result->IsFailure()) return result; |
1534 | 1527 |
1535 ExternalTwoByteString* external_string = ExternalTwoByteString::cast(result); | 1528 ExternalTwoByteString* external_string = ExternalTwoByteString::cast(result); |
1536 external_string->set_length(length); | 1529 external_string->set_length(length); |
1537 external_string->set_resource(resource); | 1530 external_string->set_resource(resource); |
1538 | 1531 |
1539 return result; | 1532 return result; |
1540 } | 1533 } |
1541 | 1534 |
1542 | 1535 |
1543 Object* Heap::AllocateExternalSymbolFromTwoByte( | 1536 Object* Heap::AllocateExternalSymbolFromTwoByte( |
1544 ExternalTwoByteString::Resource* resource) { | 1537 ExternalTwoByteString::Resource* resource) { |
1545 Map* map; | |
1546 int length = resource->length(); | 1538 int length = resource->length(); |
1547 if (length <= String::kMaxShortStringSize) { | |
1548 map = short_external_symbol_map(); | |
1549 } else if (length <= String::kMaxMediumStringSize) { | |
1550 map = medium_external_symbol_map(); | |
1551 } else { | |
1552 map = long_external_symbol_map(); | |
1553 } | |
1554 | 1539 |
| 1540 Map* map = ExternalTwoByteString::SymbolMap(length); |
1555 Object* result = Allocate(map, OLD_DATA_SPACE); | 1541 Object* result = Allocate(map, OLD_DATA_SPACE); |
1556 if (result->IsFailure()) return result; | 1542 if (result->IsFailure()) return result; |
1557 | 1543 |
1558 ExternalTwoByteString* external_string = ExternalTwoByteString::cast(result); | 1544 ExternalTwoByteString* external_string = ExternalTwoByteString::cast(result); |
1559 external_string->set_length(length); | 1545 external_string->set_length(length); |
1560 external_string->set_resource(resource); | 1546 external_string->set_resource(resource); |
1561 | 1547 |
1562 return result; | 1548 return result; |
1563 } | 1549 } |
1564 | 1550 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1611 Object* result = AllocateRaw(size, space, OLD_DATA_SPACE); | 1597 Object* result = AllocateRaw(size, space, OLD_DATA_SPACE); |
1612 | 1598 |
1613 if (result->IsFailure()) return result; | 1599 if (result->IsFailure()) return result; |
1614 | 1600 |
1615 reinterpret_cast<Array*>(result)->set_map(byte_array_map()); | 1601 reinterpret_cast<Array*>(result)->set_map(byte_array_map()); |
1616 reinterpret_cast<Array*>(result)->set_length(length); | 1602 reinterpret_cast<Array*>(result)->set_length(length); |
1617 return result; | 1603 return result; |
1618 } | 1604 } |
1619 | 1605 |
1620 | 1606 |
| 1607 void Heap::CreateFillerObjectAt(Address addr, int size) { |
| 1608 if (size == 0) return; |
| 1609 HeapObject* filler = HeapObject::FromAddress(addr); |
| 1610 if (size == kPointerSize) { |
| 1611 filler->set_map(Heap::one_word_filler_map()); |
| 1612 } else { |
| 1613 filler->set_map(Heap::byte_array_map()); |
| 1614 ByteArray::cast(filler)->set_length(ByteArray::LengthFor(size)); |
| 1615 } |
| 1616 } |
| 1617 |
| 1618 |
1621 Object* Heap::CreateCode(const CodeDesc& desc, | 1619 Object* Heap::CreateCode(const CodeDesc& desc, |
1622 ScopeInfo<>* sinfo, | 1620 ScopeInfo<>* sinfo, |
1623 Code::Flags flags, | 1621 Code::Flags flags, |
1624 Code** self_reference) { | 1622 Code** self_reference) { |
1625 // Compute size | 1623 // Compute size |
1626 int body_size = RoundUp(desc.instr_size + desc.reloc_size, kObjectAlignment); | 1624 int body_size = RoundUp(desc.instr_size + desc.reloc_size, kObjectAlignment); |
1627 int sinfo_size = 0; | 1625 int sinfo_size = 0; |
1628 if (sinfo != NULL) sinfo_size = sinfo->Serialize(NULL); | 1626 if (sinfo != NULL) sinfo_size = sinfo->Serialize(NULL); |
1629 int obj_size = Code::SizeFor(body_size, sinfo_size); | 1627 int obj_size = Code::SizeFor(body_size, sinfo_size); |
1630 Object* result; | 1628 Object* result; |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2062 if (map == short_sliced_ascii_string_map()) { | 2060 if (map == short_sliced_ascii_string_map()) { |
2063 return short_sliced_ascii_symbol_map(); | 2061 return short_sliced_ascii_symbol_map(); |
2064 } | 2062 } |
2065 if (map == medium_sliced_ascii_string_map()) { | 2063 if (map == medium_sliced_ascii_string_map()) { |
2066 return medium_sliced_ascii_symbol_map(); | 2064 return medium_sliced_ascii_symbol_map(); |
2067 } | 2065 } |
2068 if (map == long_sliced_ascii_string_map()) { | 2066 if (map == long_sliced_ascii_string_map()) { |
2069 return long_sliced_ascii_symbol_map(); | 2067 return long_sliced_ascii_symbol_map(); |
2070 } | 2068 } |
2071 | 2069 |
2072 if (map == short_external_string_map()) return short_external_string_map(); | 2070 if (map == short_external_string_map()) { |
2073 if (map == medium_external_string_map()) return medium_external_string_map(); | 2071 return short_external_symbol_map(); |
2074 if (map == long_external_string_map()) return long_external_string_map(); | 2072 } |
| 2073 if (map == medium_external_string_map()) { |
| 2074 return medium_external_symbol_map(); |
| 2075 } |
| 2076 if (map == long_external_string_map()) { |
| 2077 return long_external_symbol_map(); |
| 2078 } |
2075 | 2079 |
2076 if (map == short_external_ascii_string_map()) { | 2080 if (map == short_external_ascii_string_map()) { |
2077 return short_external_ascii_string_map(); | 2081 return short_external_ascii_symbol_map(); |
2078 } | 2082 } |
2079 if (map == medium_external_ascii_string_map()) { | 2083 if (map == medium_external_ascii_string_map()) { |
2080 return medium_external_ascii_string_map(); | 2084 return medium_external_ascii_symbol_map(); |
2081 } | 2085 } |
2082 if (map == long_external_ascii_string_map()) { | 2086 if (map == long_external_ascii_string_map()) { |
2083 return long_external_ascii_string_map(); | 2087 return long_external_ascii_symbol_map(); |
2084 } | 2088 } |
2085 | 2089 |
2086 // No match found. | 2090 // No match found. |
2087 return NULL; | 2091 return NULL; |
2088 } | 2092 } |
2089 | 2093 |
2090 | 2094 |
2091 Object* Heap::AllocateInternalSymbol(unibrow::CharacterStream* buffer, | 2095 Object* Heap::AllocateInternalSymbol(unibrow::CharacterStream* buffer, |
2092 int chars, | 2096 int chars, |
2093 uint32_t length_field) { | 2097 uint32_t length_field) { |
(...skipping 1258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3352 #ifdef DEBUG | 3356 #ifdef DEBUG |
3353 bool Heap::GarbageCollectionGreedyCheck() { | 3357 bool Heap::GarbageCollectionGreedyCheck() { |
3354 ASSERT(FLAG_gc_greedy); | 3358 ASSERT(FLAG_gc_greedy); |
3355 if (Bootstrapper::IsActive()) return true; | 3359 if (Bootstrapper::IsActive()) return true; |
3356 if (disallow_allocation_failure()) return true; | 3360 if (disallow_allocation_failure()) return true; |
3357 return CollectGarbage(0, NEW_SPACE); | 3361 return CollectGarbage(0, NEW_SPACE); |
3358 } | 3362 } |
3359 #endif | 3363 #endif |
3360 | 3364 |
3361 } } // namespace v8::internal | 3365 } } // namespace v8::internal |
OLD | NEW |