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 1613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1624 | 1624 |
1625 Object* Heap::CreateCode(const CodeDesc& desc, | 1625 Object* Heap::CreateCode(const CodeDesc& desc, |
1626 ScopeInfo<>* sinfo, | 1626 ScopeInfo<>* sinfo, |
1627 Code::Flags flags, | 1627 Code::Flags flags, |
1628 Handle<Object> self_reference) { | 1628 Handle<Object> self_reference) { |
1629 // Compute size | 1629 // Compute size |
1630 int body_size = RoundUp(desc.instr_size + desc.reloc_size, kObjectAlignment); | 1630 int body_size = RoundUp(desc.instr_size + desc.reloc_size, kObjectAlignment); |
1631 int sinfo_size = 0; | 1631 int sinfo_size = 0; |
1632 if (sinfo != NULL) sinfo_size = sinfo->Serialize(NULL); | 1632 if (sinfo != NULL) sinfo_size = sinfo->Serialize(NULL); |
1633 int obj_size = Code::SizeFor(body_size, sinfo_size); | 1633 int obj_size = Code::SizeFor(body_size, sinfo_size); |
1634 ASSERT((obj_size % Code::kCodeAlignment) == 0); | |
Kasper Lund
2009/02/27 10:32:11
IsAligned(obj_size, Code::kCodeAlignment) would be
iposva
2009/02/27 11:08:28
Done.
| |
1634 Object* result; | 1635 Object* result; |
1635 if (obj_size > MaxHeapObjectSize()) { | 1636 if (obj_size > MaxHeapObjectSize()) { |
1636 result = lo_space_->AllocateRawCode(obj_size); | 1637 result = lo_space_->AllocateRawCode(obj_size); |
1637 } else { | 1638 } else { |
1638 result = code_space_->AllocateRaw(obj_size); | 1639 result = code_space_->AllocateRaw(obj_size); |
1639 } | 1640 } |
1640 | 1641 |
1641 if (result->IsFailure()) return result; | 1642 if (result->IsFailure()) return result; |
1642 | 1643 |
1643 // Initialize the object | 1644 // Initialize the object |
(...skipping 14 matching lines...) Expand all Loading... | |
1658 // that are dereferenced during the copy to point directly to the actual heap | 1659 // that are dereferenced during the copy to point directly to the actual heap |
1659 // objects. These pointers can include references to the code object itself, | 1660 // objects. These pointers can include references to the code object itself, |
1660 // through the self_reference parameter. | 1661 // through the self_reference parameter. |
1661 code->CopyFrom(desc); | 1662 code->CopyFrom(desc); |
1662 if (sinfo != NULL) sinfo->Serialize(code); // write scope info | 1663 if (sinfo != NULL) sinfo->Serialize(code); // write scope info |
1663 LOG(CodeAllocateEvent(code, desc.origin)); | 1664 LOG(CodeAllocateEvent(code, desc.origin)); |
1664 | 1665 |
1665 #ifdef DEBUG | 1666 #ifdef DEBUG |
1666 code->Verify(); | 1667 code->Verify(); |
1667 #endif | 1668 #endif |
1668 return code; | 1669 return code; |
Kasper Lund
2009/02/27 10:32:11
It would be nice if you could assert that the entr
iposva
2009/02/27 11:08:28
Done now as part of CodeVerify().
| |
1669 } | 1670 } |
1670 | 1671 |
1671 | 1672 |
1672 Object* Heap::CopyCode(Code* code) { | 1673 Object* Heap::CopyCode(Code* code) { |
1673 // Allocate an object the same size as the code object. | 1674 // Allocate an object the same size as the code object. |
1674 int obj_size = code->Size(); | 1675 int obj_size = code->Size(); |
1675 Object* result; | 1676 Object* result; |
1676 if (obj_size > MaxHeapObjectSize()) { | 1677 if (obj_size > MaxHeapObjectSize()) { |
1677 result = lo_space_->AllocateRawCode(obj_size); | 1678 result = lo_space_->AllocateRawCode(obj_size); |
1678 } else { | 1679 } else { |
(...skipping 1646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3325 #ifdef DEBUG | 3326 #ifdef DEBUG |
3326 bool Heap::GarbageCollectionGreedyCheck() { | 3327 bool Heap::GarbageCollectionGreedyCheck() { |
3327 ASSERT(FLAG_gc_greedy); | 3328 ASSERT(FLAG_gc_greedy); |
3328 if (Bootstrapper::IsActive()) return true; | 3329 if (Bootstrapper::IsActive()) return true; |
3329 if (disallow_allocation_failure()) return true; | 3330 if (disallow_allocation_failure()) return true; |
3330 return CollectGarbage(0, NEW_SPACE); | 3331 return CollectGarbage(0, NEW_SPACE); |
3331 } | 3332 } |
3332 #endif | 3333 #endif |
3333 | 3334 |
3334 } } // namespace v8::internal | 3335 } } // namespace v8::internal |
OLD | NEW |