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

Side by Side Diff: src/compiler/property-access-info.h

Issue 1416973014: [turbofan] Move PropertyAccessInfo and friends to a separate file. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add missing factory() method. Created 5 years, 1 month 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
« no previous file with comments | « src/compiler/js-native-context-specialization.cc ('k') | src/compiler/property-access-info.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef V8_COMPILER_PROPERTY_ACCESS_INFO_H_
6 #define V8_COMPILER_PROPERTY_ACCESS_INFO_H_
7
8 #include <iosfwd>
9
10 #include "src/field-index.h"
11 #include "src/objects.h"
12 #include "src/zone-containers.h"
13
14 namespace v8 {
15 namespace internal {
16
17 // Forward declarations.
18 class CompilationDependencies;
19 class Factory;
20 class TypeCache;
21
22
23 namespace compiler {
24
25 // Whether we are loading a property or storing to a property.
26 enum class PropertyAccessMode { kLoad, kStore };
27
28 std::ostream& operator<<(std::ostream&, PropertyAccessMode);
29
30
31 // This class encapsulates all information required to access a certain
32 // object property, either on the object itself or on the prototype chain.
33 class PropertyAccessInfo final {
34 public:
35 enum Kind { kInvalid, kDataConstant, kDataField };
36
37 static PropertyAccessInfo DataConstant(Type* receiver_type,
38 Handle<Object> constant,
39 MaybeHandle<JSObject> holder) {
40 return PropertyAccessInfo(holder, constant, receiver_type);
41 }
42 static PropertyAccessInfo DataField(
43 Type* receiver_type, FieldIndex field_index, Type* field_type,
44 MaybeHandle<JSObject> holder = MaybeHandle<JSObject>(),
45 MaybeHandle<Map> transition_map = MaybeHandle<Map>()) {
46 return PropertyAccessInfo(holder, transition_map, field_index, field_type,
47 receiver_type);
48 }
49
50 PropertyAccessInfo();
51
52 bool IsDataConstant() const { return kind() == kDataConstant; }
53 bool IsDataField() const { return kind() == kDataField; }
54
55 Kind kind() const { return kind_; }
56 MaybeHandle<JSObject> holder() const { return holder_; }
57 MaybeHandle<Map> transition_map() const { return transition_map_; }
58 Handle<Object> constant() const { return constant_; }
59 FieldIndex field_index() const { return field_index_; }
60 Type* field_type() const { return field_type_; }
61 Type* receiver_type() const { return receiver_type_; }
62
63 private:
64 PropertyAccessInfo(MaybeHandle<JSObject> holder, Handle<Object> constant,
65 Type* receiver_type);
66 PropertyAccessInfo(MaybeHandle<JSObject> holder,
67 MaybeHandle<Map> transition_map, FieldIndex field_index,
68 Type* field_type, Type* receiver_type);
69
70 Kind kind_;
71 Type* receiver_type_;
72 Handle<Object> constant_;
73 MaybeHandle<Map> transition_map_;
74 MaybeHandle<JSObject> holder_;
75 FieldIndex field_index_;
76 Type* field_type_;
77 };
78
79
80 // Factory class for {PropertyAccessInfo}s.
81 class PropertyAccessInfoFactory final {
82 public:
83 PropertyAccessInfoFactory(CompilationDependencies* dependencies,
84 Handle<Context> native_context, Zone* zone);
85
86 bool ComputePropertyAccessInfo(Handle<Map> map, Handle<Name> name,
87 PropertyAccessMode access_mode,
88 PropertyAccessInfo* access_info);
89 bool ComputePropertyAccessInfos(MapHandleList const& maps, Handle<Name> name,
90 PropertyAccessMode access_mode,
91 ZoneVector<PropertyAccessInfo>* access_infos);
92
93 private:
94 CompilationDependencies* dependencies() const { return dependencies_; }
95 Factory* factory() const;
96 Isolate* isolate() const { return isolate_; }
97 Handle<Context> native_context() const { return native_context_; }
98 Zone* zone() const { return zone_; }
99
100 CompilationDependencies* const dependencies_;
101 Handle<Context> const native_context_;
102 Isolate* const isolate_;
103 TypeCache const& type_cache_;
104 Zone* const zone_;
105
106 DISALLOW_COPY_AND_ASSIGN(PropertyAccessInfoFactory);
107 };
108
109 } // namespace compiler
110 } // namespace internal
111 } // namespace v8
112
113 #endif // V8_COMPILER_PROPERTY_ACCESS_INFO_H_
OLDNEW
« no previous file with comments | « src/compiler/js-native-context-specialization.cc ('k') | src/compiler/property-access-info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698