OLD | NEW |
1 // Copyright 2017 the V8 project authors. All rights reserved. | 1 // Copyright 2017 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_OBJECTS_ARGUMENTS_H_ | 5 #ifndef V8_OBJECTS_ARGUMENTS_H_ |
6 #define V8_OBJECTS_ARGUMENTS_H_ | 6 #define V8_OBJECTS_ARGUMENTS_H_ |
7 | 7 |
8 #include "src/objects.h" | 8 #include "src/objects.h" |
9 | 9 |
10 // Has to be the last include (doesn't have include guards): | 10 // Has to be the last include (doesn't have include guards): |
11 #include "src/objects/object-macros.h" | 11 #include "src/objects/object-macros.h" |
12 | 12 |
13 namespace v8 { | 13 namespace v8 { |
14 namespace internal { | 14 namespace internal { |
15 | 15 |
16 // Common superclass for JSSloppyArgumentsObject and JSStrictArgumentsObject. | 16 // Common superclass for JSSloppyArgumentsObject and JSStrictArgumentsObject. |
17 class JSArgumentsObject : public JSObject { | 17 class JSArgumentsObject : public JSObject { |
18 public: | 18 public: |
19 // Offsets of object fields. | 19 // Offsets of object fields. |
20 static const int kLengthOffset = JSObject::kHeaderSize; | 20 static const int kLengthOffset = JSObject::kHeaderSize; |
21 static const int kHeaderSize = kLengthOffset + kPointerSize; | 21 static const int kHeaderSize = kLengthOffset + kPointerSize; |
22 // Indices of in-object properties. | 22 // Indices of in-object properties. |
23 static const int kLengthIndex = 0; | 23 static const int kLengthIndex = 0; |
24 | 24 |
25 DECL_ACCESSORS(length, Object) | 25 DECL_ACCESSORS(length, Object) |
26 | 26 |
27 DECLARE_VERIFIER(JSArgumentsObject) | 27 DECL_VERIFIER(JSArgumentsObject) |
28 DECLARE_CAST(JSArgumentsObject) | 28 DECL_CAST(JSArgumentsObject) |
29 | 29 |
30 private: | 30 private: |
31 DISALLOW_IMPLICIT_CONSTRUCTORS(JSArgumentsObject); | 31 DISALLOW_IMPLICIT_CONSTRUCTORS(JSArgumentsObject); |
32 }; | 32 }; |
33 | 33 |
34 // JSSloppyArgumentsObject is just a JSObject with specific initial map. | 34 // JSSloppyArgumentsObject is just a JSObject with specific initial map. |
35 // This initial map adds in-object properties for "length" and "callee". | 35 // This initial map adds in-object properties for "length" and "callee". |
36 class JSSloppyArgumentsObject : public JSArgumentsObject { | 36 class JSSloppyArgumentsObject : public JSArgumentsObject { |
37 public: | 37 public: |
38 // Offsets of object fields. | 38 // Offsets of object fields. |
39 static const int kCalleeOffset = JSArgumentsObject::kHeaderSize; | 39 static const int kCalleeOffset = JSArgumentsObject::kHeaderSize; |
40 static const int kSize = kCalleeOffset + kPointerSize; | 40 static const int kSize = kCalleeOffset + kPointerSize; |
41 // Indices of in-object properties. | 41 // Indices of in-object properties. |
42 static const int kCalleeIndex = kLengthIndex + 1; | 42 static const int kCalleeIndex = kLengthIndex + 1; |
43 | 43 |
44 DECL_ACCESSORS(callee, Object) | 44 DECL_ACCESSORS(callee, Object) |
45 | 45 |
46 DECLARE_VERIFIER(JSSloppyArgumentsObject) | 46 DECL_VERIFIER(JSSloppyArgumentsObject) |
47 DECLARE_CAST(JSSloppyArgumentsObject) | 47 DECL_CAST(JSSloppyArgumentsObject) |
48 | 48 |
49 private: | 49 private: |
50 DISALLOW_IMPLICIT_CONSTRUCTORS(JSSloppyArgumentsObject); | 50 DISALLOW_IMPLICIT_CONSTRUCTORS(JSSloppyArgumentsObject); |
51 }; | 51 }; |
52 | 52 |
53 // JSStrictArgumentsObject is just a JSObject with specific initial map. | 53 // JSStrictArgumentsObject is just a JSObject with specific initial map. |
54 // This initial map adds an in-object property for "length". | 54 // This initial map adds an in-object property for "length". |
55 class JSStrictArgumentsObject : public JSArgumentsObject { | 55 class JSStrictArgumentsObject : public JSArgumentsObject { |
56 public: | 56 public: |
57 // Offsets of object fields. | 57 // Offsets of object fields. |
58 static const int kSize = JSArgumentsObject::kHeaderSize; | 58 static const int kSize = JSArgumentsObject::kHeaderSize; |
59 | 59 |
60 DECLARE_CAST(JSStrictArgumentsObject) | 60 DECL_CAST(JSStrictArgumentsObject) |
61 | 61 |
62 private: | 62 private: |
63 DISALLOW_IMPLICIT_CONSTRUCTORS(JSStrictArgumentsObject); | 63 DISALLOW_IMPLICIT_CONSTRUCTORS(JSStrictArgumentsObject); |
64 }; | 64 }; |
65 | 65 |
66 // Helper class to access FAST_ and SLOW_SLOPPY_ARGUMENTS_ELEMENTS | 66 // Helper class to access FAST_ and SLOW_SLOPPY_ARGUMENTS_ELEMENTS |
67 // | 67 // |
68 // +---+-----------------------+ | 68 // +---+-----------------------+ |
69 // | 0 | Context* context | | 69 // | 0 | Context* context | |
70 // +---------------------------+ | 70 // +---------------------------+ |
(...skipping 20 matching lines...) Expand all Loading... |
91 static const int kArgumentsIndex = 1; | 91 static const int kArgumentsIndex = 1; |
92 static const uint32_t kParameterMapStart = 2; | 92 static const uint32_t kParameterMapStart = 2; |
93 | 93 |
94 inline Context* context(); | 94 inline Context* context(); |
95 inline FixedArray* arguments(); | 95 inline FixedArray* arguments(); |
96 inline void set_arguments(FixedArray* arguments); | 96 inline void set_arguments(FixedArray* arguments); |
97 inline uint32_t parameter_map_length(); | 97 inline uint32_t parameter_map_length(); |
98 inline Object* get_mapped_entry(uint32_t entry); | 98 inline Object* get_mapped_entry(uint32_t entry); |
99 inline void set_mapped_entry(uint32_t entry, Object* object); | 99 inline void set_mapped_entry(uint32_t entry, Object* object); |
100 | 100 |
101 DECLARE_CAST(SloppyArgumentsElements) | 101 DECL_CAST(SloppyArgumentsElements) |
102 #ifdef VERIFY_HEAP | 102 #ifdef VERIFY_HEAP |
103 void SloppyArgumentsElementsVerify(JSSloppyArgumentsObject* holder); | 103 void SloppyArgumentsElementsVerify(JSSloppyArgumentsObject* holder); |
104 #endif | 104 #endif |
105 | 105 |
106 private: | 106 private: |
107 DISALLOW_IMPLICIT_CONSTRUCTORS(SloppyArgumentsElements); | 107 DISALLOW_IMPLICIT_CONSTRUCTORS(SloppyArgumentsElements); |
108 }; | 108 }; |
109 | 109 |
110 // Representation of a slow alias as part of a sloppy arguments objects. | 110 // Representation of a slow alias as part of a sloppy arguments objects. |
111 // For fast aliases (if HasSloppyArgumentsElements()): | 111 // For fast aliases (if HasSloppyArgumentsElements()): |
112 // - the parameter map contains an index into the context | 112 // - the parameter map contains an index into the context |
113 // - all attributes of the element have default values | 113 // - all attributes of the element have default values |
114 // For slow aliases (if HasDictionaryArgumentsElements()): | 114 // For slow aliases (if HasDictionaryArgumentsElements()): |
115 // - the parameter map contains no fast alias mapping (i.e. the hole) | 115 // - the parameter map contains no fast alias mapping (i.e. the hole) |
116 // - this struct (in the slow backing store) contains an index into the context | 116 // - this struct (in the slow backing store) contains an index into the context |
117 // - all attributes are available as part if the property details | 117 // - all attributes are available as part if the property details |
118 class AliasedArgumentsEntry : public Struct { | 118 class AliasedArgumentsEntry : public Struct { |
119 public: | 119 public: |
120 inline int aliased_context_slot() const; | 120 inline int aliased_context_slot() const; |
121 inline void set_aliased_context_slot(int count); | 121 inline void set_aliased_context_slot(int count); |
122 | 122 |
123 DECLARE_CAST(AliasedArgumentsEntry) | 123 DECL_CAST(AliasedArgumentsEntry) |
124 | 124 |
125 // Dispatched behavior. | 125 // Dispatched behavior. |
126 DECLARE_PRINTER(AliasedArgumentsEntry) | 126 DECL_PRINTER(AliasedArgumentsEntry) |
127 DECLARE_VERIFIER(AliasedArgumentsEntry) | 127 DECL_VERIFIER(AliasedArgumentsEntry) |
128 | 128 |
129 static const int kAliasedContextSlot = HeapObject::kHeaderSize; | 129 static const int kAliasedContextSlot = HeapObject::kHeaderSize; |
130 static const int kSize = kAliasedContextSlot + kPointerSize; | 130 static const int kSize = kAliasedContextSlot + kPointerSize; |
131 | 131 |
132 private: | 132 private: |
133 DISALLOW_IMPLICIT_CONSTRUCTORS(AliasedArgumentsEntry); | 133 DISALLOW_IMPLICIT_CONSTRUCTORS(AliasedArgumentsEntry); |
134 }; | 134 }; |
135 | 135 |
136 } // namespace internal | 136 } // namespace internal |
137 } // namespace v8 | 137 } // namespace v8 |
138 | 138 |
139 #include "src/objects/object-macros-undef.h" | 139 #include "src/objects/object-macros-undef.h" |
140 | 140 |
141 #endif // V8_OBJECTS_ARGUMENTS_H_ | 141 #endif // V8_OBJECTS_ARGUMENTS_H_ |
OLD | NEW |