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

Side by Side Diff: src/heap.cc

Issue 23444029: Add OptimizedCodeList and DeoptimizedCodeList to native contexts. Both lists are weak. This makes i… (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed final comments. Created 7 years, 3 months 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
« no previous file with comments | « src/deoptimizer.cc ('k') | src/ia32/macro-assembler-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1598 matching lines...) Expand 10 before | Expand all | Expand 10 after
1609 static void VisitLiveObject(Heap*, JSFunction*, 1609 static void VisitLiveObject(Heap*, JSFunction*,
1610 WeakObjectRetainer*, bool) { 1610 WeakObjectRetainer*, bool) {
1611 } 1611 }
1612 1612
1613 static void VisitPhantomObject(Heap*, JSFunction*) { 1613 static void VisitPhantomObject(Heap*, JSFunction*) {
1614 } 1614 }
1615 }; 1615 };
1616 1616
1617 1617
1618 template<> 1618 template<>
1619 struct WeakListVisitor<Code> {
1620 static void SetWeakNext(Code* code, Object* next) {
1621 code->set_next_code_link(next);
1622 }
1623
1624 static Object* WeakNext(Code* code) {
1625 return code->next_code_link();
1626 }
1627
1628 static int WeakNextOffset() {
1629 return Code::kNextCodeLinkOffset;
1630 }
1631
1632 static void VisitLiveObject(Heap*, Code*,
1633 WeakObjectRetainer*, bool) {
1634 }
1635
1636 static void VisitPhantomObject(Heap*, Code*) {
1637 }
1638 };
1639
1640
1641 template<>
1619 struct WeakListVisitor<Context> { 1642 struct WeakListVisitor<Context> {
1620 static void SetWeakNext(Context* context, Object* next) { 1643 static void SetWeakNext(Context* context, Object* next) {
1621 context->set(Context::NEXT_CONTEXT_LINK, 1644 context->set(Context::NEXT_CONTEXT_LINK,
1622 next, 1645 next,
1623 UPDATE_WRITE_BARRIER); 1646 UPDATE_WRITE_BARRIER);
1624 } 1647 }
1625 1648
1626 static Object* WeakNext(Context* context) { 1649 static Object* WeakNext(Context* context) {
1627 return context->get(Context::NEXT_CONTEXT_LINK); 1650 return context->get(Context::NEXT_CONTEXT_LINK);
1628 } 1651 }
1629 1652
1630 static void VisitLiveObject(Heap* heap, 1653 static void VisitLiveObject(Heap* heap,
1631 Context* context, 1654 Context* context,
1632 WeakObjectRetainer* retainer, 1655 WeakObjectRetainer* retainer,
1633 bool record_slots) { 1656 bool record_slots) {
1634 // Process the weak list of optimized functions for the context. 1657 // Process the three weak lists linked off the context.
1635 Object* function_list_head = 1658 DoWeakList<JSFunction>(heap, context, retainer, record_slots,
1636 VisitWeakList<JSFunction>( 1659 Context::OPTIMIZED_FUNCTIONS_LIST);
1637 heap, 1660 DoWeakList<Code>(heap, context, retainer, record_slots,
1638 context->get(Context::OPTIMIZED_FUNCTIONS_LIST), 1661 Context::OPTIMIZED_CODE_LIST);
1639 retainer, 1662 DoWeakList<Code>(heap, context, retainer, record_slots,
1640 record_slots); 1663 Context::DEOPTIMIZED_CODE_LIST);
1641 context->set(Context::OPTIMIZED_FUNCTIONS_LIST, 1664 }
1642 function_list_head, 1665
1643 UPDATE_WRITE_BARRIER); 1666 template<class T>
1667 static void DoWeakList(Heap* heap,
1668 Context* context,
1669 WeakObjectRetainer* retainer,
1670 bool record_slots,
1671 int index) {
1672 // Visit the weak list, removing dead intermediate elements.
1673 Object* list_head = VisitWeakList<T>(heap, context->get(index), retainer,
1674 record_slots);
1675
1676 // Update the list head.
1677 context->set(index, list_head, UPDATE_WRITE_BARRIER);
1678
1644 if (record_slots) { 1679 if (record_slots) {
1645 Object** optimized_functions = 1680 // Record the updated slot if necessary.
1646 HeapObject::RawField( 1681 Object** head_slot = HeapObject::RawField(
1647 context, FixedArray::SizeFor(Context::OPTIMIZED_FUNCTIONS_LIST)); 1682 context, FixedArray::SizeFor(index));
1648 heap->mark_compact_collector()->RecordSlot( 1683 heap->mark_compact_collector()->RecordSlot(
1649 optimized_functions, optimized_functions, function_list_head); 1684 head_slot, head_slot, list_head);
1650 } 1685 }
1651 } 1686 }
1652 1687
1653 static void VisitPhantomObject(Heap*, Context*) { 1688 static void VisitPhantomObject(Heap*, Context*) {
1654 } 1689 }
1655 1690
1656 static int WeakNextOffset() { 1691 static int WeakNextOffset() {
1657 return FixedArray::SizeFor(Context::NEXT_CONTEXT_LINK); 1692 return FixedArray::SizeFor(Context::NEXT_CONTEXT_LINK);
1658 } 1693 }
1659 }; 1694 };
(...skipping 6400 matching lines...) Expand 10 before | Expand all | Expand 10 after
8060 if (FLAG_concurrent_recompilation) { 8095 if (FLAG_concurrent_recompilation) {
8061 heap_->relocation_mutex_->Lock(); 8096 heap_->relocation_mutex_->Lock();
8062 #ifdef DEBUG 8097 #ifdef DEBUG
8063 heap_->relocation_mutex_locked_by_optimizer_thread_ = 8098 heap_->relocation_mutex_locked_by_optimizer_thread_ =
8064 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread(); 8099 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread();
8065 #endif // DEBUG 8100 #endif // DEBUG
8066 } 8101 }
8067 } 8102 }
8068 8103
8069 } } // namespace v8::internal 8104 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/deoptimizer.cc ('k') | src/ia32/macro-assembler-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698