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

Side by Side Diff: src/objects.h

Issue 23604020: Initial prototype of object layout generation. Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 6015 matching lines...) Expand 10 before | Expand all | Expand 10 after
6026 // An abstract superclass, a marker class really, for simple structure classes. 6026 // An abstract superclass, a marker class really, for simple structure classes.
6027 // It doesn't carry much functionality but allows struct classes to be 6027 // It doesn't carry much functionality but allows struct classes to be
6028 // identified in the type system. 6028 // identified in the type system.
6029 class Struct: public HeapObject { 6029 class Struct: public HeapObject {
6030 public: 6030 public:
6031 inline void InitializeBody(int object_size); 6031 inline void InitializeBody(int object_size);
6032 static inline Struct* cast(Object* that); 6032 static inline Struct* cast(Object* that);
6033 }; 6033 };
6034 6034
6035 6035
6036 // A simple one-element struct, useful where smis need to be boxed.
6037 class Box : public Struct {
6038 public:
6039 // [value]: the boxed contents.
6040 DECL_ACCESSORS(value, Object)
6041
6042 static inline Box* cast(Object* obj);
6043
6044 // Dispatched behavior.
6045 DECLARE_PRINTER(Box)
6046 DECLARE_VERIFIER(Box)
6047
6048 static const int kValueOffset = HeapObject::kHeaderSize;
6049 static const int kSize = kValueOffset + kPointerSize;
6050
6051 private:
6052 DISALLOW_IMPLICIT_CONSTRUCTORS(Box);
6053 };
6054
6055
6056 // Script describes a script which has been added to the VM. 6036 // Script describes a script which has been added to the VM.
6057 class Script: public Struct { 6037 class Script: public Struct {
6058 public: 6038 public:
6059 // Script types. 6039 // Script types.
6060 enum Type { 6040 enum Type {
6061 TYPE_NATIVE = 0, 6041 TYPE_NATIVE = 0,
6062 TYPE_EXTENSION = 1, 6042 TYPE_EXTENSION = 1,
6063 TYPE_NORMAL = 2 6043 TYPE_NORMAL = 2
6064 }; 6044 };
6065 6045
(...skipping 1839 matching lines...) Expand 10 before | Expand all | Expand 10 after
7905 7885
7906 // Returns NULL if no AllocationMemento is available for object. 7886 // Returns NULL if no AllocationMemento is available for object.
7907 static AllocationMemento* FindForJSObject(JSObject* object); 7887 static AllocationMemento* FindForJSObject(JSObject* object);
7908 static inline AllocationMemento* cast(Object* obj); 7888 static inline AllocationMemento* cast(Object* obj);
7909 7889
7910 private: 7890 private:
7911 DISALLOW_IMPLICIT_CONSTRUCTORS(AllocationMemento); 7891 DISALLOW_IMPLICIT_CONSTRUCTORS(AllocationMemento);
7912 }; 7892 };
7913 7893
7914 7894
7915 // Representation of a slow alias as part of a non-strict arguments objects.
7916 // For fast aliases (if HasNonStrictArgumentsElements()):
7917 // - the parameter map contains an index into the context
7918 // - all attributes of the element have default values
7919 // For slow aliases (if HasDictionaryArgumentsElements()):
7920 // - the parameter map contains no fast alias mapping (i.e. the hole)
7921 // - this struct (in the slow backing store) contains an index into the context
7922 // - all attributes are available as part if the property details
7923 class AliasedArgumentsEntry: public Struct {
7924 public:
7925 inline int aliased_context_slot();
7926 inline void set_aliased_context_slot(int count);
7927
7928 static inline AliasedArgumentsEntry* cast(Object* obj);
7929
7930 // Dispatched behavior.
7931 DECLARE_PRINTER(AliasedArgumentsEntry)
7932 DECLARE_VERIFIER(AliasedArgumentsEntry)
7933
7934 static const int kAliasedContextSlot = HeapObject::kHeaderSize;
7935 static const int kSize = kAliasedContextSlot + kPointerSize;
7936
7937 private:
7938 DISALLOW_IMPLICIT_CONSTRUCTORS(AliasedArgumentsEntry);
7939 };
7940
7941
7942 enum AllowNullsFlag {ALLOW_NULLS, DISALLOW_NULLS}; 7895 enum AllowNullsFlag {ALLOW_NULLS, DISALLOW_NULLS};
7943 enum RobustnessFlag {ROBUST_STRING_TRAVERSAL, FAST_STRING_TRAVERSAL}; 7896 enum RobustnessFlag {ROBUST_STRING_TRAVERSAL, FAST_STRING_TRAVERSAL};
7944 7897
7945 7898
7946 class StringHasher { 7899 class StringHasher {
7947 public: 7900 public:
7948 explicit inline StringHasher(int length, uint32_t seed); 7901 explicit inline StringHasher(int length, uint32_t seed);
7949 7902
7950 template <typename schar> 7903 template <typename schar>
7951 static inline uint32_t HashSequentialString(const schar* chars, 7904 static inline uint32_t HashSequentialString(const schar* chars,
(...skipping 1706 matching lines...) Expand 10 before | Expand all | Expand 10 after
9658 DECLARE_VERIFIER(DeclaredAccessorDescriptor) 9611 DECLARE_VERIFIER(DeclaredAccessorDescriptor)
9659 9612
9660 static const int kSerializedDataOffset = HeapObject::kHeaderSize; 9613 static const int kSerializedDataOffset = HeapObject::kHeaderSize;
9661 static const int kSize = kSerializedDataOffset + kPointerSize; 9614 static const int kSize = kSerializedDataOffset + kPointerSize;
9662 9615
9663 private: 9616 private:
9664 DISALLOW_IMPLICIT_CONSTRUCTORS(DeclaredAccessorDescriptor); 9617 DISALLOW_IMPLICIT_CONSTRUCTORS(DeclaredAccessorDescriptor);
9665 }; 9618 };
9666 9619
9667 9620
9668 class DeclaredAccessorInfo: public AccessorInfo {
9669 public:
9670 DECL_ACCESSORS(descriptor, DeclaredAccessorDescriptor)
9671
9672 static inline DeclaredAccessorInfo* cast(Object* obj);
9673
9674 // Dispatched behavior.
9675 DECLARE_PRINTER(DeclaredAccessorInfo)
9676 DECLARE_VERIFIER(DeclaredAccessorInfo)
9677
9678 static const int kDescriptorOffset = AccessorInfo::kSize;
9679 static const int kSize = kDescriptorOffset + kPointerSize;
9680
9681 private:
9682 DISALLOW_IMPLICIT_CONSTRUCTORS(DeclaredAccessorInfo);
9683 };
9684
9685
9686 // An accessor must have a getter, but can have no setter.
9687 //
9688 // When setting a property, V8 searches accessors in prototypes.
9689 // If an accessor was found and it does not have a setter,
9690 // the request is ignored.
9691 //
9692 // If the accessor in the prototype has the READ_ONLY property attribute, then
9693 // a new value is added to the local object when the property is set.
9694 // This shadows the accessor in the prototype.
9695 class ExecutableAccessorInfo: public AccessorInfo {
9696 public:
9697 DECL_ACCESSORS(getter, Object)
9698 DECL_ACCESSORS(setter, Object)
9699 DECL_ACCESSORS(data, Object)
9700
9701 static inline ExecutableAccessorInfo* cast(Object* obj);
9702
9703 // Dispatched behavior.
9704 DECLARE_PRINTER(ExecutableAccessorInfo)
9705 DECLARE_VERIFIER(ExecutableAccessorInfo)
9706
9707 static const int kGetterOffset = AccessorInfo::kSize;
9708 static const int kSetterOffset = kGetterOffset + kPointerSize;
9709 static const int kDataOffset = kSetterOffset + kPointerSize;
9710 static const int kSize = kDataOffset + kPointerSize;
9711
9712 private:
9713 DISALLOW_IMPLICIT_CONSTRUCTORS(ExecutableAccessorInfo);
9714 };
9715
9716
9717 // Support for JavaScript accessors: A pair of a getter and a setter. Each 9621 // Support for JavaScript accessors: A pair of a getter and a setter. Each
9718 // accessor can either be 9622 // accessor can either be
9719 // * a pointer to a JavaScript function or proxy: a real accessor 9623 // * a pointer to a JavaScript function or proxy: a real accessor
9720 // * undefined: considered an accessor by the spec, too, strangely enough 9624 // * undefined: considered an accessor by the spec, too, strangely enough
9721 // * the hole: an accessor which has not been set 9625 // * the hole: an accessor which has not been set
9722 // * a pointer to a map: a transition used to ensure map sharing 9626 // * a pointer to a map: a transition used to ensure map sharing
9723 // access_flags provides the ability to override access checks on access check 9627 // access_flags provides the ability to override access checks on access check
9724 // failure. 9628 // failure.
9725 class AccessorPair: public Struct { 9629 class AccessorPair: public Struct {
9726 public: 9630 public:
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
9868 9772
9869 static const int kTagOffset = HeapObject::kHeaderSize; 9773 static const int kTagOffset = HeapObject::kHeaderSize;
9870 static const int kPropertyListOffset = kTagOffset + kPointerSize; 9774 static const int kPropertyListOffset = kTagOffset + kPointerSize;
9871 static const int kHeaderSize = kPropertyListOffset + kPointerSize; 9775 static const int kHeaderSize = kPropertyListOffset + kPointerSize;
9872 9776
9873 private: 9777 private:
9874 DISALLOW_IMPLICIT_CONSTRUCTORS(TemplateInfo); 9778 DISALLOW_IMPLICIT_CONSTRUCTORS(TemplateInfo);
9875 }; 9779 };
9876 9780
9877 9781
9878 class FunctionTemplateInfo: public TemplateInfo {
9879 public:
9880 DECL_ACCESSORS(serial_number, Object)
9881 DECL_ACCESSORS(call_code, Object)
9882 DECL_ACCESSORS(property_accessors, Object)
9883 DECL_ACCESSORS(prototype_template, Object)
9884 DECL_ACCESSORS(parent_template, Object)
9885 DECL_ACCESSORS(named_property_handler, Object)
9886 DECL_ACCESSORS(indexed_property_handler, Object)
9887 DECL_ACCESSORS(instance_template, Object)
9888 DECL_ACCESSORS(class_name, Object)
9889 DECL_ACCESSORS(signature, Object)
9890 DECL_ACCESSORS(instance_call_handler, Object)
9891 DECL_ACCESSORS(access_check_info, Object)
9892 DECL_ACCESSORS(flag, Smi)
9893
9894 inline int length();
9895 inline void set_length(int value);
9896
9897 // Following properties use flag bits.
9898 DECL_BOOLEAN_ACCESSORS(hidden_prototype)
9899 DECL_BOOLEAN_ACCESSORS(undetectable)
9900 // If the bit is set, object instances created by this function
9901 // requires access check.
9902 DECL_BOOLEAN_ACCESSORS(needs_access_check)
9903 DECL_BOOLEAN_ACCESSORS(read_only_prototype)
9904 DECL_BOOLEAN_ACCESSORS(remove_prototype)
9905
9906 static inline FunctionTemplateInfo* cast(Object* obj);
9907
9908 // Dispatched behavior.
9909 DECLARE_PRINTER(FunctionTemplateInfo)
9910 DECLARE_VERIFIER(FunctionTemplateInfo)
9911
9912 static const int kSerialNumberOffset = TemplateInfo::kHeaderSize;
9913 static const int kCallCodeOffset = kSerialNumberOffset + kPointerSize;
9914 static const int kPropertyAccessorsOffset = kCallCodeOffset + kPointerSize;
9915 static const int kPrototypeTemplateOffset =
9916 kPropertyAccessorsOffset + kPointerSize;
9917 static const int kParentTemplateOffset =
9918 kPrototypeTemplateOffset + kPointerSize;
9919 static const int kNamedPropertyHandlerOffset =
9920 kParentTemplateOffset + kPointerSize;
9921 static const int kIndexedPropertyHandlerOffset =
9922 kNamedPropertyHandlerOffset + kPointerSize;
9923 static const int kInstanceTemplateOffset =
9924 kIndexedPropertyHandlerOffset + kPointerSize;
9925 static const int kClassNameOffset = kInstanceTemplateOffset + kPointerSize;
9926 static const int kSignatureOffset = kClassNameOffset + kPointerSize;
9927 static const int kInstanceCallHandlerOffset = kSignatureOffset + kPointerSize;
9928 static const int kAccessCheckInfoOffset =
9929 kInstanceCallHandlerOffset + kPointerSize;
9930 static const int kFlagOffset = kAccessCheckInfoOffset + kPointerSize;
9931 static const int kLengthOffset = kFlagOffset + kPointerSize;
9932 static const int kSize = kLengthOffset + kPointerSize;
9933
9934 private:
9935 // Bit position in the flag, from least significant bit position.
9936 static const int kHiddenPrototypeBit = 0;
9937 static const int kUndetectableBit = 1;
9938 static const int kNeedsAccessCheckBit = 2;
9939 static const int kReadOnlyPrototypeBit = 3;
9940 static const int kRemovePrototypeBit = 4;
9941
9942 DISALLOW_IMPLICIT_CONSTRUCTORS(FunctionTemplateInfo);
9943 };
9944
9945
9946 class ObjectTemplateInfo: public TemplateInfo {
9947 public:
9948 DECL_ACCESSORS(constructor, Object)
9949 DECL_ACCESSORS(internal_field_count, Object)
9950
9951 static inline ObjectTemplateInfo* cast(Object* obj);
9952
9953 // Dispatched behavior.
9954 DECLARE_PRINTER(ObjectTemplateInfo)
9955 DECLARE_VERIFIER(ObjectTemplateInfo)
9956
9957 static const int kConstructorOffset = TemplateInfo::kHeaderSize;
9958 static const int kInternalFieldCountOffset =
9959 kConstructorOffset + kPointerSize;
9960 static const int kSize = kInternalFieldCountOffset + kPointerSize;
9961 };
9962
9963
9964 class SignatureInfo: public Struct {
9965 public:
9966 DECL_ACCESSORS(receiver, Object)
9967 DECL_ACCESSORS(args, Object)
9968
9969 static inline SignatureInfo* cast(Object* obj);
9970
9971 // Dispatched behavior.
9972 DECLARE_PRINTER(SignatureInfo)
9973 DECLARE_VERIFIER(SignatureInfo)
9974
9975 static const int kReceiverOffset = Struct::kHeaderSize;
9976 static const int kArgsOffset = kReceiverOffset + kPointerSize;
9977 static const int kSize = kArgsOffset + kPointerSize;
9978
9979 private:
9980 DISALLOW_IMPLICIT_CONSTRUCTORS(SignatureInfo);
9981 };
9982
9983
9984 class TypeSwitchInfo: public Struct {
9985 public:
9986 DECL_ACCESSORS(types, Object)
9987
9988 static inline TypeSwitchInfo* cast(Object* obj);
9989
9990 // Dispatched behavior.
9991 DECLARE_PRINTER(TypeSwitchInfo)
9992 DECLARE_VERIFIER(TypeSwitchInfo)
9993
9994 static const int kTypesOffset = Struct::kHeaderSize;
9995 static const int kSize = kTypesOffset + kPointerSize;
9996 };
9997
9998
9999 #ifdef ENABLE_DEBUGGER_SUPPORT 9782 #ifdef ENABLE_DEBUGGER_SUPPORT
10000 // The DebugInfo class holds additional information for a function being 9783 // The DebugInfo class holds additional information for a function being
10001 // debugged. 9784 // debugged.
10002 class DebugInfo: public Struct { 9785 class DebugInfo: public Struct {
10003 public: 9786 public:
10004 // The shared function info for the source being debugged. 9787 // The shared function info for the source being debugged.
10005 DECL_ACCESSORS(shared, SharedFunctionInfo) 9788 DECL_ACCESSORS(shared, SharedFunctionInfo)
10006 // Code object for the original code. 9789 // Code object for the original code.
10007 DECL_ACCESSORS(original_code, Code) 9790 DECL_ACCESSORS(original_code, Code)
10008 // Code object for the patched code. This code object is the code object 9791 // Code object for the patched code. This code object is the code object
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
10096 static const int kBreakPointObjectsIndex = 9879 static const int kBreakPointObjectsIndex =
10097 kStatementPositionIndex + kPointerSize; 9880 kStatementPositionIndex + kPointerSize;
10098 static const int kSize = kBreakPointObjectsIndex + kPointerSize; 9881 static const int kSize = kBreakPointObjectsIndex + kPointerSize;
10099 9882
10100 private: 9883 private:
10101 DISALLOW_IMPLICIT_CONSTRUCTORS(BreakPointInfo); 9884 DISALLOW_IMPLICIT_CONSTRUCTORS(BreakPointInfo);
10102 }; 9885 };
10103 #endif // ENABLE_DEBUGGER_SUPPORT 9886 #endif // ENABLE_DEBUGGER_SUPPORT
10104 9887
10105 9888
9889 // Include automatically generated object descriptions here, after all
9890 // necessary base classes and helper macros have been declared.
9891 #include "objects-gen.h"
9892
9893
10106 #undef DECL_BOOLEAN_ACCESSORS 9894 #undef DECL_BOOLEAN_ACCESSORS
10107 #undef DECL_ACCESSORS 9895 #undef DECL_ACCESSORS
10108 #undef DECLARE_VERIFIER 9896 #undef DECLARE_VERIFIER
10109 9897
10110 #define VISITOR_SYNCHRONIZATION_TAGS_LIST(V) \ 9898 #define VISITOR_SYNCHRONIZATION_TAGS_LIST(V) \
10111 V(kStringTable, "string_table", "(Internalized strings)") \ 9899 V(kStringTable, "string_table", "(Internalized strings)") \
10112 V(kExternalStringsTable, "external_strings_table", "(External strings)") \ 9900 V(kExternalStringsTable, "external_strings_table", "(External strings)") \
10113 V(kStrongRootList, "strong_root_list", "(Strong roots)") \ 9901 V(kStrongRootList, "strong_root_list", "(Strong roots)") \
10114 V(kInternalizedString, "internalized_string", "(Internal string)") \ 9902 V(kInternalizedString, "internalized_string", "(Internal string)") \
10115 V(kBootstrapper, "bootstrapper", "(Bootstrapper)") \ 9903 V(kBootstrapper, "bootstrapper", "(Bootstrapper)") \
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
10233 } else { 10021 } else {
10234 value &= ~(1 << bit_position); 10022 value &= ~(1 << bit_position);
10235 } 10023 }
10236 return value; 10024 return value;
10237 } 10025 }
10238 }; 10026 };
10239 10027
10240 } } // namespace v8::internal 10028 } } // namespace v8::internal
10241 10029
10242 #endif // V8_OBJECTS_H_ 10030 #endif // V8_OBJECTS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698