arguments.h 2.82 KB
Newer Older
1 2 3 4 5 6 7
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_OBJECTS_ARGUMENTS_H_
#define V8_OBJECTS_ARGUMENTS_H_

8
#include "src/objects/fixed-array.h"
9
#include "src/objects/js-objects.h"
10
#include "src/objects/struct.h"
11
#include "torque-generated/field-offsets.h"
12 13 14 15 16 17 18

// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"

namespace v8 {
namespace internal {

19 20
#include "torque-generated/src/objects/arguments-tq.inc"

21
// Superclass for all objects with instance type {JS_ARGUMENTS_OBJECT_TYPE}
22 23
class JSArgumentsObject
    : public TorqueGeneratedJSArgumentsObject<JSArgumentsObject, JSObject> {
24 25
 public:
  DECL_VERIFIER(JSArgumentsObject)
26
  DECL_PRINTER(JSArgumentsObject)
27
  TQ_OBJECT_CONSTRUCTORS(JSArgumentsObject)
28 29
};

30 31 32
// JSSloppyArgumentsObject is just a JSArgumentsObject with specific initial
// map. This initial map adds in-object properties for "length" and "callee".
class JSSloppyArgumentsObject : public JSArgumentsObject {
33
 public:
34
  DEFINE_FIELD_OFFSET_CONSTANTS(
35
      JSArgumentsObject::kHeaderSize,
36
      TORQUE_GENERATED_JS_SLOPPY_ARGUMENTS_OBJECT_FIELDS)
37

38
  // Indices of in-object properties.
39
  static const int kLengthIndex = 0;
40 41 42 43 44 45
  static const int kCalleeIndex = kLengthIndex + 1;

 private:
  DISALLOW_IMPLICIT_CONSTRUCTORS(JSSloppyArgumentsObject);
};

46 47 48
// JSStrictArgumentsObject is just a JSArgumentsObject with specific initial
// map. This initial map adds an in-object property for "length".
class JSStrictArgumentsObject : public JSArgumentsObject {
49
 public:
50
  // Layout description.
51 52 53 54 55 56 57
  DEFINE_FIELD_OFFSET_CONSTANTS(
      JSArgumentsObject::kHeaderSize,
      TORQUE_GENERATED_JS_STRICT_ARGUMENTS_OBJECT_FIELDS)

  // Indices of in-object properties.
  static const int kLengthIndex = 0;
  STATIC_ASSERT(kLengthIndex == JSSloppyArgumentsObject::kLengthIndex);
58 59 60 61 62 63 64 65 66 67 68 69 70

 private:
  DISALLOW_IMPLICIT_CONSTRUCTORS(JSStrictArgumentsObject);
};

// Representation of a slow alias as part of a sloppy arguments objects.
// For fast aliases (if HasSloppyArgumentsElements()):
// - the parameter map contains an index into the context
// - all attributes of the element have default values
// For slow aliases (if HasDictionaryArgumentsElements()):
// - the parameter map contains no fast alias mapping (i.e. the hole)
// - this struct (in the slow backing store) contains an index into the context
// - all attributes are available as part if the property details
71 72 73
class AliasedArgumentsEntry
    : public TorqueGeneratedAliasedArgumentsEntry<AliasedArgumentsEntry,
                                                  Struct> {
74
 public:
75
  TQ_OBJECT_CONSTRUCTORS(AliasedArgumentsEntry)
76 77 78 79 80 81 82 83
};

}  // namespace internal
}  // namespace v8

#include "src/objects/object-macros-undef.h"

#endif  // V8_OBJECTS_ARGUMENTS_H_