Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: src/heap.cc

Issue 12427: Merge regexp2000 back into bleeding_edge (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 // free space in the new space after the collection compared to 385 // free space in the new space after the collection compared to
386 // before. 386 // before.
387 if (space == NEW_SPACE && !MarkCompactCollector::HasCompacted()) { 387 if (space == NEW_SPACE && !MarkCompactCollector::HasCompacted()) {
388 Scavenge(); 388 Scavenge();
389 } 389 }
390 } else { 390 } else {
391 Scavenge(); 391 Scavenge();
392 } 392 }
393 Counters::objs_since_last_young.Set(0); 393 Counters::objs_since_last_young.Set(0);
394 394
395 // Process weak handles post gc. 395 PostGarbageCollectionProcessing();
396 GlobalHandles::PostGarbageCollectionProcessing();
397 396
398 if (collector == MARK_COMPACTOR) { 397 if (collector == MARK_COMPACTOR) {
399 // Register the amount of external allocated memory. 398 // Register the amount of external allocated memory.
400 amount_of_external_allocated_memory_at_last_global_gc_ = 399 amount_of_external_allocated_memory_at_last_global_gc_ =
401 amount_of_external_allocated_memory_; 400 amount_of_external_allocated_memory_;
402 } 401 }
403 402
404 if (collector == MARK_COMPACTOR && global_gc_epilogue_callback_) { 403 if (collector == MARK_COMPACTOR && global_gc_epilogue_callback_) {
405 ASSERT(!allocation_allowed_); 404 ASSERT(!allocation_allowed_);
406 global_gc_epilogue_callback_(); 405 global_gc_epilogue_callback_();
407 } 406 }
408 } 407 }
409 408
410 409
410 void Heap::PostGarbageCollectionProcessing() {
411 // Process weak handles post gc.
412 GlobalHandles::PostGarbageCollectionProcessing();
413 // Update flat string readers.
414 FlatStringReader::PostGarbageCollectionProcessing();
415 }
416
417
411 void Heap::MarkCompact(GCTracer* tracer) { 418 void Heap::MarkCompact(GCTracer* tracer) {
412 gc_state_ = MARK_COMPACT; 419 gc_state_ = MARK_COMPACT;
413 mc_count_++; 420 mc_count_++;
414 tracer->set_full_gc_count(mc_count_); 421 tracer->set_full_gc_count(mc_count_);
415 LOG(ResourceEvent("markcompact", "begin")); 422 LOG(ResourceEvent("markcompact", "begin"));
416 423
417 MarkCompactPrologue(); 424 MarkCompactPrologue();
418 425
419 MarkCompactCollector::CollectGarbage(tracer); 426 MarkCompactCollector::CollectGarbage(tracer);
420 427
(...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1575 } 1582 }
1576 1583
1577 Object* result = Heap::AllocateRawTwoByteString(1); 1584 Object* result = Heap::AllocateRawTwoByteString(1);
1578 if (result->IsFailure()) return result; 1585 if (result->IsFailure()) return result;
1579 String* answer = String::cast(result); 1586 String* answer = String::cast(result);
1580 answer->Set(StringShape(answer), 0, code); 1587 answer->Set(StringShape(answer), 0, code);
1581 return answer; 1588 return answer;
1582 } 1589 }
1583 1590
1584 1591
1592 Object* Heap::AllocateByteArray(int length, PretenureFlag pretenure) {
1593 if (pretenure == NOT_TENURED) {
1594 return AllocateByteArray(length);
1595 }
1596 int size = ByteArray::SizeFor(length);
1597 AllocationSpace space =
1598 size > MaxHeapObjectSize() ? LO_SPACE : OLD_DATA_SPACE;
1599
1600 Object* result = AllocateRaw(size, space, OLD_DATA_SPACE);
1601
1602 if (result->IsFailure()) return result;
1603
1604 reinterpret_cast<Array*>(result)->set_map(byte_array_map());
1605 reinterpret_cast<Array*>(result)->set_length(length);
1606 return result;
1607 }
1608
1609
1585 Object* Heap::AllocateByteArray(int length) { 1610 Object* Heap::AllocateByteArray(int length) {
1586 int size = ByteArray::SizeFor(length); 1611 int size = ByteArray::SizeFor(length);
1587 AllocationSpace space = 1612 AllocationSpace space =
1588 size > MaxHeapObjectSize() ? LO_SPACE : NEW_SPACE; 1613 size > MaxHeapObjectSize() ? LO_SPACE : NEW_SPACE;
1589 1614
1590 Object* result = AllocateRaw(size, space, OLD_DATA_SPACE); 1615 Object* result = AllocateRaw(size, space, OLD_DATA_SPACE);
1591 1616
1592 if (result->IsFailure()) return result; 1617 if (result->IsFailure()) return result;
1593 1618
1594 reinterpret_cast<Array*>(result)->set_map(byte_array_map()); 1619 reinterpret_cast<Array*>(result)->set_map(byte_array_map());
1595 reinterpret_cast<Array*>(result)->set_length(length); 1620 reinterpret_cast<Array*>(result)->set_length(length);
1596 return result; 1621 return result;
1597 } 1622 }
1598 1623
1599 1624
1600 Object* Heap::CreateCode(const CodeDesc& desc, 1625 Object* Heap::CreateCode(const CodeDesc& desc,
1601 ScopeInfo<>* sinfo, 1626 ScopeInfo<>* sinfo,
1602 Code::Flags flags) { 1627 Code::Flags flags,
1628 Code** self_reference) {
1603 // Compute size 1629 // Compute size
1604 int body_size = RoundUp(desc.instr_size + desc.reloc_size, kObjectAlignment); 1630 int body_size = RoundUp(desc.instr_size + desc.reloc_size, kObjectAlignment);
1605 int sinfo_size = 0; 1631 int sinfo_size = 0;
1606 if (sinfo != NULL) sinfo_size = sinfo->Serialize(NULL); 1632 if (sinfo != NULL) sinfo_size = sinfo->Serialize(NULL);
1607 int obj_size = Code::SizeFor(body_size, sinfo_size); 1633 int obj_size = Code::SizeFor(body_size, sinfo_size);
1608 Object* result; 1634 Object* result;
1609 if (obj_size > MaxHeapObjectSize()) { 1635 if (obj_size > MaxHeapObjectSize()) {
1610 result = lo_space_->AllocateRawCode(obj_size); 1636 result = lo_space_->AllocateRawCode(obj_size);
1611 } else { 1637 } else {
1612 result = code_space_->AllocateRaw(obj_size); 1638 result = code_space_->AllocateRaw(obj_size);
1613 } 1639 }
1614 1640
1615 if (result->IsFailure()) return result; 1641 if (result->IsFailure()) return result;
1616 1642
1617 // Initialize the object 1643 // Initialize the object
1618 HeapObject::cast(result)->set_map(code_map()); 1644 HeapObject::cast(result)->set_map(code_map());
1619 Code* code = Code::cast(result); 1645 Code* code = Code::cast(result);
1620 code->set_instruction_size(desc.instr_size); 1646 code->set_instruction_size(desc.instr_size);
1621 code->set_relocation_size(desc.reloc_size); 1647 code->set_relocation_size(desc.reloc_size);
1622 code->set_sinfo_size(sinfo_size); 1648 code->set_sinfo_size(sinfo_size);
1623 code->set_flags(flags); 1649 code->set_flags(flags);
1624 code->set_ic_flag(Code::IC_TARGET_IS_ADDRESS); 1650 code->set_ic_flag(Code::IC_TARGET_IS_ADDRESS);
1625 code->CopyFrom(desc); // migrate generated code 1651 // Allow self references to created code object.
1652 if (self_reference != NULL) {
1653 *self_reference = code;
1654 }
1655 // Migrate generated code.
1656 // The generated code can contain Object** values (typically from handles)
1657 // that are dereferenced during the copy to point directly to the actual heap
1658 // objects. These pointers can include references to the code object itself,
1659 // through the self_reference parameter.
1660 code->CopyFrom(desc);
1626 if (sinfo != NULL) sinfo->Serialize(code); // write scope info 1661 if (sinfo != NULL) sinfo->Serialize(code); // write scope info
1627 1662
1628 #ifdef DEBUG 1663 #ifdef DEBUG
1629 code->Verify(); 1664 code->Verify();
1630 #endif 1665 #endif
1631 return code; 1666 return code;
1632 } 1667 }
1633 1668
1634 1669
1635 Object* Heap::CopyCode(Code* code) { 1670 Object* Heap::CopyCode(Code* code) {
(...skipping 1678 matching lines...) Expand 10 before | Expand all | Expand 10 after
3314 #ifdef DEBUG 3349 #ifdef DEBUG
3315 bool Heap::GarbageCollectionGreedyCheck() { 3350 bool Heap::GarbageCollectionGreedyCheck() {
3316 ASSERT(FLAG_gc_greedy); 3351 ASSERT(FLAG_gc_greedy);
3317 if (Bootstrapper::IsActive()) return true; 3352 if (Bootstrapper::IsActive()) return true;
3318 if (disallow_allocation_failure()) return true; 3353 if (disallow_allocation_failure()) return true;
3319 return CollectGarbage(0, NEW_SPACE); 3354 return CollectGarbage(0, NEW_SPACE);
3320 } 3355 }
3321 #endif 3356 #endif
3322 3357
3323 } } // namespace v8::internal 3358 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698