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_H_ | 5 #ifndef V8_HEAP_HEAP_H_ |
6 #define V8_HEAP_HEAP_H_ | 6 #define V8_HEAP_HEAP_H_ |
7 | 7 |
8 #include <cmath> | 8 #include <cmath> |
9 #include <map> | 9 #include <map> |
10 | 10 |
(...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1016 | 1016 |
1017 #define SYMBOL_ACCESSOR(name, description) inline Symbol* name(); | 1017 #define SYMBOL_ACCESSOR(name, description) inline Symbol* name(); |
1018 PUBLIC_SYMBOL_LIST(SYMBOL_ACCESSOR) | 1018 PUBLIC_SYMBOL_LIST(SYMBOL_ACCESSOR) |
1019 WELL_KNOWN_SYMBOL_LIST(SYMBOL_ACCESSOR) | 1019 WELL_KNOWN_SYMBOL_LIST(SYMBOL_ACCESSOR) |
1020 #undef SYMBOL_ACCESSOR | 1020 #undef SYMBOL_ACCESSOR |
1021 | 1021 |
1022 Object* root(RootListIndex index) { return roots_[index]; } | 1022 Object* root(RootListIndex index) { return roots_[index]; } |
1023 Handle<Object> root_handle(RootListIndex index) { | 1023 Handle<Object> root_handle(RootListIndex index) { |
1024 return Handle<Object>(&roots_[index]); | 1024 return Handle<Object>(&roots_[index]); |
1025 } | 1025 } |
| 1026 template <typename T> |
| 1027 bool IsRootHandle(Handle<T> handle, RootListIndex* index) const { |
| 1028 Object** const handle_location = bit_cast<Object**>(handle.address()); |
| 1029 if (handle_location >= &roots_[kRootListLength]) return false; |
| 1030 if (handle_location < &roots_[0]) return false; |
| 1031 *index = static_cast<RootListIndex>(handle_location - &roots_[0]); |
| 1032 return true; |
| 1033 } |
1026 | 1034 |
1027 // Generated code can embed this address to get access to the roots. | 1035 // Generated code can embed this address to get access to the roots. |
1028 Object** roots_array_start() { return roots_; } | 1036 Object** roots_array_start() { return roots_; } |
1029 | 1037 |
1030 // Sets the stub_cache_ (only used when expanding the dictionary). | 1038 // Sets the stub_cache_ (only used when expanding the dictionary). |
1031 void SetRootCodeStubs(UnseededNumberDictionary* value) { | 1039 void SetRootCodeStubs(UnseededNumberDictionary* value) { |
1032 roots_[kCodeStubsRootIndex] = value; | 1040 roots_[kCodeStubsRootIndex] = value; |
1033 } | 1041 } |
1034 | 1042 |
1035 void SetRootMaterializedObjects(FixedArray* objects) { | 1043 void SetRootMaterializedObjects(FixedArray* objects) { |
(...skipping 1602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2638 } | 2646 } |
2639 | 2647 |
2640 private: | 2648 private: |
2641 Heap* heap_; | 2649 Heap* heap_; |
2642 }; | 2650 }; |
2643 | 2651 |
2644 } // namespace internal | 2652 } // namespace internal |
2645 } // namespace v8 | 2653 } // namespace v8 |
2646 | 2654 |
2647 #endif // V8_HEAP_HEAP_H_ | 2655 #endif // V8_HEAP_HEAP_H_ |
OLD | NEW |