OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_HEAP_HEAP_INL_H_ | 5 #ifndef V8_HEAP_HEAP_INL_H_ |
6 #define V8_HEAP_HEAP_INL_H_ | 6 #define V8_HEAP_HEAP_INL_H_ |
7 | 7 |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "src/base/platform/platform.h" | 10 #include "src/base/platform/platform.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 *(--rear_) = reinterpret_cast<intptr_t>(target); | 39 *(--rear_) = reinterpret_cast<intptr_t>(target); |
40 *(--rear_) = size; | 40 *(--rear_) = size; |
41 // Assert no overflow into live objects. | 41 // Assert no overflow into live objects. |
42 #ifdef DEBUG | 42 #ifdef DEBUG |
43 SemiSpace::AssertValidRange(target->GetIsolate()->heap()->new_space()->top(), | 43 SemiSpace::AssertValidRange(target->GetIsolate()->heap()->new_space()->top(), |
44 reinterpret_cast<Address>(rear_)); | 44 reinterpret_cast<Address>(rear_)); |
45 #endif | 45 #endif |
46 } | 46 } |
47 | 47 |
48 | 48 |
| 49 #define ROOT_ACCESSOR(type, name, camel_name) \ |
| 50 type* Heap::name() { return type::cast(roots_[k##camel_name##RootIndex]); } |
| 51 ROOT_LIST(ROOT_ACCESSOR) |
| 52 #undef ROOT_ACCESSOR |
| 53 |
| 54 #define STRUCT_MAP_ACCESSOR(NAME, Name, name) \ |
| 55 Map* Heap::name##_map() { return Map::cast(roots_[k##Name##MapRootIndex]); } |
| 56 STRUCT_LIST(STRUCT_MAP_ACCESSOR) |
| 57 #undef STRUCT_MAP_ACCESSOR |
| 58 |
| 59 #define STRING_ACCESSOR(name, str) \ |
| 60 String* Heap::name() { return String::cast(roots_[k##name##RootIndex]); } |
| 61 INTERNALIZED_STRING_LIST(STRING_ACCESSOR) |
| 62 #undef STRING_ACCESSOR |
| 63 |
| 64 #define SYMBOL_ACCESSOR(name) \ |
| 65 Symbol* Heap::name() { return Symbol::cast(roots_[k##name##RootIndex]); } |
| 66 PRIVATE_SYMBOL_LIST(SYMBOL_ACCESSOR) |
| 67 #undef SYMBOL_ACCESSOR |
| 68 |
| 69 #define SYMBOL_ACCESSOR(name, varname, description) \ |
| 70 Symbol* Heap::name() { return Symbol::cast(roots_[k##name##RootIndex]); } |
| 71 PUBLIC_SYMBOL_LIST(SYMBOL_ACCESSOR) |
| 72 #undef SYMBOL_ACCESSOR |
| 73 |
| 74 #define ROOT_ACCESSOR(type, name, camel_name) \ |
| 75 void Heap::set_##name(type* value) { \ |
| 76 /* The deserializer makes use of the fact that these common roots are */ \ |
| 77 /* never in new space and never on a page that is being compacted. */ \ |
| 78 DCHECK(!deserialization_complete() || \ |
| 79 RootCanBeWrittenAfterInitialization(k##camel_name##RootIndex)); \ |
| 80 DCHECK(k##camel_name##RootIndex >= kOldSpaceRoots || !InNewSpace(value)); \ |
| 81 roots_[k##camel_name##RootIndex] = value; \ |
| 82 } |
| 83 ROOT_LIST(ROOT_ACCESSOR) |
| 84 #undef ROOT_ACCESSOR |
| 85 |
| 86 |
49 template <> | 87 template <> |
50 bool inline Heap::IsOneByte(Vector<const char> str, int chars) { | 88 bool inline Heap::IsOneByte(Vector<const char> str, int chars) { |
51 // TODO(dcarney): incorporate Latin-1 check when Latin-1 is supported? | 89 // TODO(dcarney): incorporate Latin-1 check when Latin-1 is supported? |
52 return chars == str.length(); | 90 return chars == str.length(); |
53 } | 91 } |
54 | 92 |
55 | 93 |
56 template <> | 94 template <> |
57 bool inline Heap::IsOneByte(String* str, int chars) { | 95 bool inline Heap::IsOneByte(String* str, int chars) { |
58 return str->IsOneByteRepresentation(); | 96 return str->IsOneByteRepresentation(); |
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 return condition ? true_value() : false_value(); | 701 return condition ? true_value() : false_value(); |
664 } | 702 } |
665 | 703 |
666 | 704 |
667 void Heap::CompletelyClearInstanceofCache() { | 705 void Heap::CompletelyClearInstanceofCache() { |
668 set_instanceof_cache_map(Smi::FromInt(0)); | 706 set_instanceof_cache_map(Smi::FromInt(0)); |
669 set_instanceof_cache_function(Smi::FromInt(0)); | 707 set_instanceof_cache_function(Smi::FromInt(0)); |
670 } | 708 } |
671 | 709 |
672 | 710 |
| 711 uint32_t Heap::HashSeed() { |
| 712 uint32_t seed = static_cast<uint32_t>(hash_seed()->value()); |
| 713 DCHECK(FLAG_randomize_hashes || seed == 0); |
| 714 return seed; |
| 715 } |
| 716 |
| 717 |
| 718 Smi* Heap::NextScriptId() { |
| 719 int next_id = last_script_id()->value() + 1; |
| 720 if (!Smi::IsValid(next_id) || next_id < 0) next_id = 1; |
| 721 Smi* next_id_smi = Smi::FromInt(next_id); |
| 722 set_last_script_id(next_id_smi); |
| 723 return next_id_smi; |
| 724 } |
| 725 |
| 726 |
| 727 void Heap::SetArgumentsAdaptorDeoptPCOffset(int pc_offset) { |
| 728 DCHECK(arguments_adaptor_deopt_pc_offset() == Smi::FromInt(0)); |
| 729 set_arguments_adaptor_deopt_pc_offset(Smi::FromInt(pc_offset)); |
| 730 } |
| 731 |
| 732 |
| 733 void Heap::SetConstructStubDeoptPCOffset(int pc_offset) { |
| 734 DCHECK(construct_stub_deopt_pc_offset() == Smi::FromInt(0)); |
| 735 set_construct_stub_deopt_pc_offset(Smi::FromInt(pc_offset)); |
| 736 } |
| 737 |
| 738 |
| 739 void Heap::SetGetterStubDeoptPCOffset(int pc_offset) { |
| 740 DCHECK(getter_stub_deopt_pc_offset() == Smi::FromInt(0)); |
| 741 set_getter_stub_deopt_pc_offset(Smi::FromInt(pc_offset)); |
| 742 } |
| 743 |
| 744 |
| 745 void Heap::SetSetterStubDeoptPCOffset(int pc_offset) { |
| 746 DCHECK(setter_stub_deopt_pc_offset() == Smi::FromInt(0)); |
| 747 set_setter_stub_deopt_pc_offset(Smi::FromInt(pc_offset)); |
| 748 } |
| 749 |
| 750 |
673 AlwaysAllocateScope::AlwaysAllocateScope(Isolate* isolate) | 751 AlwaysAllocateScope::AlwaysAllocateScope(Isolate* isolate) |
674 : heap_(isolate->heap()), daf_(isolate) { | 752 : heap_(isolate->heap()), daf_(isolate) { |
675 heap_->always_allocate_scope_depth_++; | 753 heap_->always_allocate_scope_depth_++; |
676 } | 754 } |
677 | 755 |
678 | 756 |
679 AlwaysAllocateScope::~AlwaysAllocateScope() { | 757 AlwaysAllocateScope::~AlwaysAllocateScope() { |
680 heap_->always_allocate_scope_depth_--; | 758 heap_->always_allocate_scope_depth_--; |
681 } | 759 } |
682 | 760 |
(...skipping 24 matching lines...) Expand all Loading... |
707 | 785 |
708 void VerifySmisVisitor::VisitPointers(Object** start, Object** end) { | 786 void VerifySmisVisitor::VisitPointers(Object** start, Object** end) { |
709 for (Object** current = start; current < end; current++) { | 787 for (Object** current = start; current < end; current++) { |
710 CHECK((*current)->IsSmi()); | 788 CHECK((*current)->IsSmi()); |
711 } | 789 } |
712 } | 790 } |
713 } | 791 } |
714 } // namespace v8::internal | 792 } // namespace v8::internal |
715 | 793 |
716 #endif // V8_HEAP_HEAP_INL_H_ | 794 #endif // V8_HEAP_HEAP_INL_H_ |
OLD | NEW |