OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_TYPE_CACHE_H_ | 5 #ifndef V8_TYPE_CACHE_H_ |
6 #define V8_TYPE_CACHE_H_ | 6 #define V8_TYPE_CACHE_H_ |
7 | 7 |
8 #include "src/types.h" | 8 #include "src/types.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
11 namespace internal { | 11 namespace internal { |
12 | 12 |
13 class TypeCache final { | 13 class TypeCache final { |
14 private: | 14 private: |
15 // This has to be first for the initialization magic to work. | 15 // This has to be first for the initialization magic to work. |
| 16 base::AccountingAllocator allocator; |
16 Zone zone_; | 17 Zone zone_; |
17 | 18 |
18 public: | 19 public: |
19 static TypeCache const& Get(); | 20 static TypeCache const& Get(); |
20 | 21 |
21 TypeCache() = default; | 22 TypeCache() : zone_(&allocator) {} |
22 | 23 |
23 Type* const kInt8 = | 24 Type* const kInt8 = |
24 CreateNative(CreateRange<int8_t>(), Type::UntaggedIntegral8()); | 25 CreateNative(CreateRange<int8_t>(), Type::UntaggedIntegral8()); |
25 Type* const kUint8 = | 26 Type* const kUint8 = |
26 CreateNative(CreateRange<uint8_t>(), Type::UntaggedIntegral8()); | 27 CreateNative(CreateRange<uint8_t>(), Type::UntaggedIntegral8()); |
27 Type* const kUint8Clamped = kUint8; | 28 Type* const kUint8Clamped = kUint8; |
28 Type* const kInt16 = | 29 Type* const kInt16 = |
29 CreateNative(CreateRange<int16_t>(), Type::UntaggedIntegral16()); | 30 CreateNative(CreateRange<int16_t>(), Type::UntaggedIntegral16()); |
30 Type* const kUint16 = | 31 Type* const kUint16 = |
31 CreateNative(CreateRange<uint16_t>(), Type::UntaggedIntegral16()); | 32 CreateNative(CreateRange<uint16_t>(), Type::UntaggedIntegral16()); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 return Type::Range(min, max, zone()); | 142 return Type::Range(min, max, zone()); |
142 } | 143 } |
143 | 144 |
144 Zone* zone() { return &zone_; } | 145 Zone* zone() { return &zone_; } |
145 }; | 146 }; |
146 | 147 |
147 } // namespace internal | 148 } // namespace internal |
148 } // namespace v8 | 149 } // namespace v8 |
149 | 150 |
150 #endif // V8_TYPE_CACHE_H_ | 151 #endif // V8_TYPE_CACHE_H_ |
OLD | NEW |