OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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_COMPILER_TYPE_HINT_ANALYZER_H_ | 5 #ifndef V8_INTERPRETER_BYTECODE_REGISTER_ALLOCATOR_H_ |
6 #define V8_COMPILER_TYPE_HINT_ANALYZER_H_ | 6 #define V8_INTERPRETER_BYTECODE_REGISTER_ALLOCATOR_H_ |
7 | 7 |
8 #include "src/compiler/type-hints.h" | |
9 #include "src/handles.h" | |
10 #include "src/zone-containers.h" | 8 #include "src/zone-containers.h" |
11 | 9 |
12 namespace v8 { | 10 namespace v8 { |
13 namespace internal { | 11 namespace internal { |
14 namespace compiler { | 12 namespace interpreter { |
15 | 13 |
16 // The result of analyzing type hints. | 14 class BytecodeArrayBuilder; |
17 class TypeHintAnalysis final : public ZoneObject { | 15 class Register; |
| 16 |
| 17 // A class than allows the instantiator to allocate temporary registers that are |
| 18 // cleaned up when scope is closed. |
| 19 class BytecodeRegisterAllocator { |
18 public: | 20 public: |
19 typedef ZoneMap<TypeFeedbackId, Handle<Code>> Infos; | 21 explicit BytecodeRegisterAllocator(BytecodeArrayBuilder* builder); |
| 22 ~BytecodeRegisterAllocator(); |
| 23 Register NewRegister(); |
20 | 24 |
21 explicit TypeHintAnalysis(Infos const& infos) : infos_(infos) {} | 25 void PrepareForConsecutiveAllocations(size_t count); |
| 26 Register NextConsecutiveRegister(); |
22 | 27 |
23 bool GetBinaryOperationHints(TypeFeedbackId id, | 28 bool RegisterIsAllocatedInThisScope(Register reg) const; |
24 BinaryOperationHints* hints) const; | 29 |
25 bool GetToBooleanHints(TypeFeedbackId id, ToBooleanHints* hints) const; | 30 bool HasConsecutiveAllocations() const { return next_consecutive_count_ > 0; } |
26 | 31 |
27 private: | 32 private: |
28 Infos const infos_; | 33 void* operator new(size_t size); |
| 34 void operator delete(void* p); |
| 35 |
| 36 BytecodeArrayBuilder* builder_; |
| 37 ZoneVector<int> allocated_; |
| 38 int next_consecutive_register_; |
| 39 int next_consecutive_count_; |
| 40 |
| 41 DISALLOW_COPY_AND_ASSIGN(BytecodeRegisterAllocator); |
29 }; | 42 }; |
30 | 43 |
31 | 44 } // namespace interpreter |
32 // The class that performs type hint analysis on the fullcodegen code object. | |
33 class TypeHintAnalyzer final { | |
34 public: | |
35 explicit TypeHintAnalyzer(Zone* zone) : zone_(zone) {} | |
36 | |
37 TypeHintAnalysis* Analyze(Handle<Code> code); | |
38 | |
39 private: | |
40 Zone* zone() const { return zone_; } | |
41 | |
42 Zone* const zone_; | |
43 | |
44 DISALLOW_COPY_AND_ASSIGN(TypeHintAnalyzer); | |
45 }; | |
46 | |
47 } // namespace compiler | |
48 } // namespace internal | 45 } // namespace internal |
49 } // namespace v8 | 46 } // namespace v8 |
50 | 47 |
51 #endif // V8_COMPILER_TYPE_HINT_ANALYZER_H_ | 48 |
| 49 #endif // V8_INTERPRETER_BYTECODE_REGISTER_ALLOCATOR_H_ |
OLD | NEW |