v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
arguments.h
Go to the documentation of this file.
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
3// found in the LICENSE file.
4
5#ifndef V8_OBJECTS_ARGUMENTS_H_
6#define V8_OBJECTS_ARGUMENTS_H_
7
9#include "src/objects/hole.h"
11#include "src/objects/struct.h"
12
13// Has to be the last include (doesn't have include guards):
15
16namespace v8 {
17namespace internal {
18
19class StructBodyDescriptor;
20
21#include "torque-generated/src/objects/arguments-tq.inc"
22
23// Superclass for all objects with instance type {JS_ARGUMENTS_OBJECT_TYPE}
25 : public TorqueGeneratedJSArgumentsObject<JSArgumentsObject, JSObject> {
26 public:
30};
31
32// JSSloppyArgumentsObject is just a JSArgumentsObject with specific initial
33// map. This initial map adds in-object properties for "length" and "callee".
35 : public TorqueGeneratedJSSloppyArgumentsObject<JSSloppyArgumentsObject,
36 JSArgumentsObject> {
37 public:
38 // Indices of in-object properties.
39 static const int kLengthIndex = 0;
40 static const int kCalleeIndex = kLengthIndex + 1;
41
42 private:
44};
45
46// JSStrictArgumentsObject is just a JSArgumentsObject with specific initial
47// map. This initial map adds an in-object property for "length".
49 : public TorqueGeneratedJSStrictArgumentsObject<JSStrictArgumentsObject,
50 JSArgumentsObject> {
51 public:
52 // Indices of in-object properties.
53 static const int kLengthIndex = 0;
55
56 private:
58};
59
60// Representation of a slow alias as part of a sloppy arguments objects.
61// For fast aliases (if HasSloppyArgumentsElements()):
62// - the parameter map contains an index into the context
63// - all attributes of the element have default values
64// For slow aliases (if HasDictionaryArgumentsElements()):
65// - the parameter map contains no fast alias mapping (i.e. the hole)
66// - this struct (in the slow backing store) contains an index into the context
67// - all attributes are available as part if the property details
69 : public TorqueGeneratedAliasedArgumentsEntry<AliasedArgumentsEntry,
70 Struct> {
71 public:
73
75};
76
78 public:
81 static constexpr RootIndex kMapRootIndex =
82 RootIndex::kSloppyArgumentsElementsMap;
83 static constexpr bool kLengthEqualsCapacity = true;
84
88 });
89};
90
91// Helper class to access FAST_ and SLOW_SLOPPY_ARGUMENTS_ELEMENTS, dividing
92// arguments into two types for a given SloppyArgumentsElements object:
93// mapped and unmapped.
94//
95// For clarity SloppyArgumentsElements fields are qualified with "elements."
96// below.
97//
98// Mapped arguments are actual arguments. Unmapped arguments are values added
99// to the arguments object after it was created for the call. Mapped arguments
100// are stored in the context at indexes given by elements.mapped_entries[key].
101// Unmapped arguments are stored as regular indexed properties in the arguments
102// array which can be accessed from elements.arguments.
103//
104// elements.length is min(number_of_actual_arguments,
105// number_of_formal_arguments) for a concrete call to a function.
106//
107// Once a SloppyArgumentsElements is generated, lookup of an argument with index
108// |key| in |elements| works as follows:
109//
110// If key >= elements.length then attempt to look in the unmapped arguments
111// array and return the value at key, missing to the runtime if the unmapped
112// arguments array is not a fixed array or if key >= elements.arguments.length.
113//
114// Otherwise, t = elements.mapped_entries[key]. If t is the hole, then the
115// entry has been deleted from the arguments object, and value is looked up in
116// the unmapped arguments array, as described above. Otherwise, t is a Smi
117// index into the context array specified at elements.context, and the return
118// value is elements.context[t].
119//
120// A graphic representation of a SloppyArgumentsElements object and a
121// corresponding unmapped arguments FixedArray:
122//
123// SloppyArgumentsElements
124// +---+-----------------------+
125// | Context context |
126// +---------------------------+
127// | FixedArray arguments +----+ HOLEY_ELEMENTS
128// +---------------------------+ v-----+-----------+
129// | 0 | Object mapped_entries | | 0 | the_hole |
130// |...| ... | | ... | ... |
131// |n-1| Object mapped_entries | | n-1 | the_hole |
132// +---------------------------+ | n | element_1 |
133// | ... | ... |
134// |n+m-1| element_m |
135// +-----------------+
136//
137// The elements.arguments backing store kind depends on the ElementsKind of
138// the outer JSArgumentsObject:
139// - FAST_SLOPPY_ARGUMENTS_ELEMENTS: HOLEY_ELEMENTS
140// - SLOW_SLOPPY_ARGUMENTS_ELEMENTS: DICTIONARY_ELEMENTS
142 : public TaggedArrayBase<SloppyArgumentsElements,
143 SloppyArgumentsElementsShape> {
144 public:
145 inline Tagged<Context> context() const;
146 inline void set_context(Tagged<Context> value,
148
152
153 // Returns: Smi|TheHole.
155 RelaxedLoadTag) const;
156 inline void set_mapped_entries(int index, Tagged<UnionOf<Smi, Hole>> value);
157 inline void set_mapped_entries(int index, Tagged<UnionOf<Smi, Hole>> value,
159
162
163 class BodyDescriptor;
164};
165
166} // namespace internal
167} // namespace v8
168
170
171#endif // V8_OBJECTS_ARGUMENTS_H_
Address * arguments_
DISALLOW_IMPLICIT_CONSTRUCTORS(JSSloppyArgumentsObject)
DISALLOW_IMPLICIT_CONSTRUCTORS(JSStrictArgumentsObject)
static constexpr RootIndex kMapRootIndex
Definition arguments.h:81
V8_ARRAY_EXTRA_FIELDS({ TaggedMember< Context > context_;TaggedMember< UnionOf< FixedArray, NumberDictionary > > arguments_;})
static constexpr bool kLengthEqualsCapacity
Definition arguments.h:83
void set_arguments(Tagged< UnionOf< FixedArray, NumberDictionary > > value, WriteBarrierMode mode=UPDATE_WRITE_BARRIER)
Tagged< Context > context() const
void set_mapped_entries(int index, Tagged< UnionOf< Smi, Hole > > value)
void set_context(Tagged< Context > value, WriteBarrierMode mode=UPDATE_WRITE_BARRIER)
Tagged< UnionOf< FixedArray, NumberDictionary > > arguments() const
Tagged< UnionOf< Smi, Hole > > mapped_entries(int index, RelaxedLoadTag) const
Handle< Context > context_
@ UPDATE_WRITE_BARRIER
Definition objects.h:55
typename detail::FlattenUnionHelper< Union<>, Ts... >::type UnionOf
Definition union.h:123
V8HeapCompressionSchemeImpl< MainCage > V8HeapCompressionScheme
Definition globals.h:1137
#define DECL_VERIFIER(Name)
#define DECL_PRINTER(Name)
#define TQ_OBJECT_CONSTRUCTORS(Type)