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
3 // found in the LICENSE file.
4 
5 #ifndef V8_COMPILER_ACCESS_BUILDER_H_
6 #define V8_COMPILER_ACCESS_BUILDER_H_
7 
8 #include "src/compiler/simplified-operator.h"
9 
10 namespace v8 {
11 namespace internal {
12 namespace compiler {
13 
14 // This access builder provides a set of static methods constructing commonly
15 // used FieldAccess and ElementAccess descriptors. These descriptors serve as
16 // parameters to simplified load/store operators.
17 class AccessBuilder final : public AllStatic {
18  public:
19   // ===========================================================================
20   // Access to heap object fields and elements (based on tagged pointer).
21 
22   // Provides access to HeapObject::map() field.
23   static FieldAccess ForMap();
24 
25   // Provides access to HeapNumber::value() field.
26   static FieldAccess ForHeapNumberValue();
27 
28   // Provides access to JSObject::properties() field.
29   static FieldAccess ForJSObjectProperties();
30 
31   // Provides access to JSObject::elements() field.
32   static FieldAccess ForJSObjectElements();
33 
34   // Provides access to JSObject inobject property fields.
35   static FieldAccess ForJSObjectInObjectProperty(Handle<Map> map, int index);
36 
37   // Provides access to JSFunction::context() field.
38   static FieldAccess ForJSFunctionContext();
39 
40   // Provides access to JSFunction::shared() field.
41   static FieldAccess ForJSFunctionSharedFunctionInfo();
42 
43   // Provides access to JSArray::length() field.
44   static FieldAccess ForJSArrayLength(ElementsKind elements_kind);
45 
46   // Provides access to JSArrayBuffer::backing_store() field.
47   static FieldAccess ForJSArrayBufferBackingStore();
48 
49   // Provides access to JSArrayBuffer::bit_field() field.
50   static FieldAccess ForJSArrayBufferBitField();
51 
52   // Provides access to JSArrayBufferView::buffer() field.
53   static FieldAccess ForJSArrayBufferViewBuffer();
54 
55   // Provides access to JSDate fields.
56   static FieldAccess ForJSDateField(JSDate::FieldIndex index);
57 
58   // Provides access to JSIteratorResult::done() field.
59   static FieldAccess ForJSIteratorResultDone();
60 
61   // Provides access to JSIteratorResult::value() field.
62   static FieldAccess ForJSIteratorResultValue();
63 
64   // Provides access to JSRegExp::flags() field.
65   static FieldAccess ForJSRegExpFlags();
66 
67   // Provides access to JSRegExp::source() field.
68   static FieldAccess ForJSRegExpSource();
69 
70   // Provides access to FixedArray::length() field.
71   static FieldAccess ForFixedArrayLength();
72 
73   // Provides access to DescriptorArray::enum_cache() field.
74   static FieldAccess ForDescriptorArrayEnumCache();
75 
76   // Provides access to DescriptorArray::enum_cache_bridge_cache() field.
77   static FieldAccess ForDescriptorArrayEnumCacheBridgeCache();
78 
79   // Provides access to Map::bit_field() byte.
80   static FieldAccess ForMapBitField();
81 
82   // Provides access to Map::bit_field3() field.
83   static FieldAccess ForMapBitField3();
84 
85   // Provides access to Map::descriptors() field.
86   static FieldAccess ForMapDescriptors();
87 
88   // Provides access to Map::instance_type() field.
89   static FieldAccess ForMapInstanceType();
90 
91   // Provides access to Map::prototype() field.
92   static FieldAccess ForMapPrototype();
93 
94   // Provides access to String::length() field.
95   static FieldAccess ForStringLength();
96 
97   // Provides access to JSGlobalObject::global_proxy() field.
98   static FieldAccess ForJSGlobalObjectGlobalProxy();
99 
100   // Provides access to JSGlobalObject::native_context() field.
101   static FieldAccess ForJSGlobalObjectNativeContext();
102 
103   // Provides access to JSValue::value() field.
104   static FieldAccess ForValue();
105 
106   // Provides access to arguments object fields.
107   static FieldAccess ForArgumentsLength();
108   static FieldAccess ForArgumentsCallee();
109 
110   // Provides access to FixedArray slots.
111   static FieldAccess ForFixedArraySlot(size_t index);
112 
113   // Provides access to Context slots.
114   static FieldAccess ForContextSlot(size_t index);
115 
116   // Provides access to PropertyCell::value() field.
117   static FieldAccess ForPropertyCellValue();
118   static FieldAccess ForPropertyCellValue(Type* type);
119 
120   // Provides access to SharedFunctionInfo::feedback_vector() field.
121   static FieldAccess ForSharedFunctionInfoTypeFeedbackVector();
122 
123   // Provides access to FixedArray elements.
124   static ElementAccess ForFixedArrayElement();
125 
126   // Provides access to FixedDoubleArray elements.
127   static ElementAccess ForFixedDoubleArrayElement();
128 
129   // Provides access to Fixed{type}TypedArray and External{type}Array elements.
130   static ElementAccess ForTypedArrayElement(ExternalArrayType type,
131                                             bool is_external);
132 
133   // ===========================================================================
134   // Access to global per-isolate variables (based on external reference).
135 
136   // Provides access to the backing store of a StatsCounter.
137   static FieldAccess ForStatsCounter();
138 
139  private:
140   DISALLOW_IMPLICIT_CONSTRUCTORS(AccessBuilder);
141 };
142 
143 }  // namespace compiler
144 }  // namespace internal
145 }  // namespace v8
146 
147 #endif  // V8_COMPILER_ACCESS_BUILDER_H_
148