| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 1509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1520 #if ENABLE(ASSERT) || defined(LEAK_SANITIZER) || defined(ADDRESS_SANITIZER) | 1520 #if ENABLE(ASSERT) || defined(LEAK_SANITIZER) || defined(ADDRESS_SANITIZER) |
| 1521 memset(result, 0, payloadSize); | 1521 memset(result, 0, payloadSize); |
| 1522 #endif | 1522 #endif |
| 1523 ASSERT(heapPageFromAddress(headerAddress + allocationSize - 1)); | 1523 ASSERT(heapPageFromAddress(headerAddress + allocationSize - 1)); |
| 1524 return result; | 1524 return result; |
| 1525 } | 1525 } |
| 1526 | 1526 |
| 1527 template<typename T, typename HeapTraits> | 1527 template<typename T, typename HeapTraits> |
| 1528 Address Heap::allocate(size_t size) | 1528 Address Heap::allocate(size_t size) |
| 1529 { | 1529 { |
| 1530 ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::state(); | 1530 ASSERT_NOT_REACHED(); |
| 1531 ASSERT(state->isAllocationAllowed()); | 1531 return 0; |
| 1532 const GCInfo* gcInfo = GCInfoTrait<T>::get(); | |
| 1533 int heapIndex = HeapTraits::index(gcInfo->hasFinalizer()); | |
| 1534 BaseHeap* heap = state->heap(heapIndex); | |
| 1535 return static_cast<typename HeapTraits::HeapType*>(heap)->allocate(size, gcI
nfo); | |
| 1536 } | 1532 } |
| 1537 | 1533 |
| 1538 template<typename T> | 1534 template<typename T> |
| 1539 Address Heap::reallocate(void* previous, size_t size) | 1535 Address Heap::reallocate(void* previous, size_t size) |
| 1540 { | 1536 { |
| 1541 if (!size) { | 1537 if (!size) { |
| 1542 // If the new size is 0 this is equivalent to either | 1538 // If the new size is 0 this is equivalent to either |
| 1543 // free(previous) or malloc(0). In both cases we do | 1539 // free(previous) or malloc(0). In both cases we do |
| 1544 // nothing and return 0. | 1540 // nothing and return 0. |
| 1545 return 0; | 1541 return 0; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1612 return 0; | 1608 return 0; |
| 1613 } | 1609 } |
| 1614 | 1610 |
| 1615 static void deleteArray(void* ptr) | 1611 static void deleteArray(void* ptr) |
| 1616 { | 1612 { |
| 1617 ASSERT_NOT_REACHED(); | 1613 ASSERT_NOT_REACHED(); |
| 1618 } | 1614 } |
| 1619 | 1615 |
| 1620 static bool isAllocationAllowed() | 1616 static bool isAllocationAllowed() |
| 1621 { | 1617 { |
| 1622 return ThreadState::current()->isAllocationAllowed(); | 1618 ASSERT_NOT_REACHED(); |
| 1619 return false; |
| 1623 } | 1620 } |
| 1624 | 1621 |
| 1625 static void markUsingGCInfo(Visitor* visitor, const void* buffer) | 1622 static void markUsingGCInfo(Visitor* visitor, const void* buffer) |
| 1626 { | 1623 { |
| 1627 visitor->mark(buffer, FinalizedHeapObjectHeader::fromPayload(buffer)->tr
aceCallback()); | 1624 visitor->mark(buffer, FinalizedHeapObjectHeader::fromPayload(buffer)->tr
aceCallback()); |
| 1628 } | 1625 } |
| 1629 | 1626 |
| 1630 static void markNoTracing(Visitor* visitor, const void* t) { visitor->markNo
Tracing(t); } | 1627 static void markNoTracing(Visitor* visitor, const void* t) { visitor->markNo
Tracing(t); } |
| 1631 | 1628 |
| 1632 template<typename T, typename Traits> | 1629 template<typename T, typename Traits> |
| (...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2411 }; | 2408 }; |
| 2412 | 2409 |
| 2413 template<typename T> | 2410 template<typename T> |
| 2414 struct IfWeakMember<WeakMember<T> > { | 2411 struct IfWeakMember<WeakMember<T> > { |
| 2415 static bool isDead(Visitor* visitor, const WeakMember<T>& t) { return !visit
or->isAlive(t.get()); } | 2412 static bool isDead(Visitor* visitor, const WeakMember<T>& t) { return !visit
or->isAlive(t.get()); } |
| 2416 }; | 2413 }; |
| 2417 | 2414 |
| 2418 } | 2415 } |
| 2419 | 2416 |
| 2420 #endif // Heap_h | 2417 #endif // Heap_h |
| OLD | NEW |