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

Side by Side Diff: src/objects.h

Issue 12213012: Split AccessorInfo into DeclaredAccessorInfo and ExecutableAccessorInfo (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed most feedback Created 7 years, 10 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
« no previous file with comments | « src/mark-compact.cc ('k') | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 // - ExternalString 104 // - ExternalString
105 // - ExternalAsciiString 105 // - ExternalAsciiString
106 // - ExternalTwoByteString 106 // - ExternalTwoByteString
107 // - HeapNumber 107 // - HeapNumber
108 // - Code 108 // - Code
109 // - Map 109 // - Map
110 // - Oddball 110 // - Oddball
111 // - Foreign 111 // - Foreign
112 // - SharedFunctionInfo 112 // - SharedFunctionInfo
113 // - Struct 113 // - Struct
114 // - DeclaredAccessorDescriptor
114 // - AccessorInfo 115 // - AccessorInfo
116 // - DeclaredAccessorInfo
117 // - ExecutableAccessorInfo
115 // - AccessorPair 118 // - AccessorPair
116 // - AccessCheckInfo 119 // - AccessCheckInfo
117 // - InterceptorInfo 120 // - InterceptorInfo
118 // - CallHandlerInfo 121 // - CallHandlerInfo
119 // - TemplateInfo 122 // - TemplateInfo
120 // - FunctionTemplateInfo 123 // - FunctionTemplateInfo
121 // - ObjectTemplateInfo 124 // - ObjectTemplateInfo
122 // - Script 125 // - Script
123 // - SignatureInfo 126 // - SignatureInfo
124 // - TypeSwitchInfo 127 // - TypeSwitchInfo
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 V(EXTERNAL_BYTE_ARRAY_TYPE) \ 284 V(EXTERNAL_BYTE_ARRAY_TYPE) \
282 V(EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE) \ 285 V(EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE) \
283 V(EXTERNAL_SHORT_ARRAY_TYPE) \ 286 V(EXTERNAL_SHORT_ARRAY_TYPE) \
284 V(EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE) \ 287 V(EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE) \
285 V(EXTERNAL_INT_ARRAY_TYPE) \ 288 V(EXTERNAL_INT_ARRAY_TYPE) \
286 V(EXTERNAL_UNSIGNED_INT_ARRAY_TYPE) \ 289 V(EXTERNAL_UNSIGNED_INT_ARRAY_TYPE) \
287 V(EXTERNAL_FLOAT_ARRAY_TYPE) \ 290 V(EXTERNAL_FLOAT_ARRAY_TYPE) \
288 V(EXTERNAL_PIXEL_ARRAY_TYPE) \ 291 V(EXTERNAL_PIXEL_ARRAY_TYPE) \
289 V(FILLER_TYPE) \ 292 V(FILLER_TYPE) \
290 \ 293 \
291 V(ACCESSOR_INFO_TYPE) \ 294 V(DECLARED_ACCESSOR_DESCRIPTOR_TYPE) \
295 V(DECLARED_ACCESSOR_INFO_TYPE) \
296 V(EXECUTABLE_ACCESSOR_INFO_TYPE) \
292 V(ACCESSOR_PAIR_TYPE) \ 297 V(ACCESSOR_PAIR_TYPE) \
293 V(ACCESS_CHECK_INFO_TYPE) \ 298 V(ACCESS_CHECK_INFO_TYPE) \
294 V(INTERCEPTOR_INFO_TYPE) \ 299 V(INTERCEPTOR_INFO_TYPE) \
295 V(CALL_HANDLER_INFO_TYPE) \ 300 V(CALL_HANDLER_INFO_TYPE) \
296 V(FUNCTION_TEMPLATE_INFO_TYPE) \ 301 V(FUNCTION_TEMPLATE_INFO_TYPE) \
297 V(OBJECT_TEMPLATE_INFO_TYPE) \ 302 V(OBJECT_TEMPLATE_INFO_TYPE) \
298 V(SIGNATURE_INFO_TYPE) \ 303 V(SIGNATURE_INFO_TYPE) \
299 V(TYPE_SWITCH_INFO_TYPE) \ 304 V(TYPE_SWITCH_INFO_TYPE) \
300 V(ALLOCATION_SITE_INFO_TYPE) \ 305 V(ALLOCATION_SITE_INFO_TYPE) \
301 V(SCRIPT_TYPE) \ 306 V(SCRIPT_TYPE) \
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 // A struct is a simple object a set of object-valued fields. Including an 439 // A struct is a simple object a set of object-valued fields. Including an
435 // object type in this causes the compiler to generate most of the boilerplate 440 // object type in this causes the compiler to generate most of the boilerplate
436 // code for the class including allocation and garbage collection routines, 441 // code for the class including allocation and garbage collection routines,
437 // casts and predicates. All you need to define is the class, methods and 442 // casts and predicates. All you need to define is the class, methods and
438 // object verification routines. Easy, no? 443 // object verification routines. Easy, no?
439 // 444 //
440 // Note that for subtle reasons related to the ordering or numerical values of 445 // Note that for subtle reasons related to the ordering or numerical values of
441 // type tags, elements in this list have to be added to the INSTANCE_TYPE_LIST 446 // type tags, elements in this list have to be added to the INSTANCE_TYPE_LIST
442 // manually. 447 // manually.
443 #define STRUCT_LIST_ALL(V) \ 448 #define STRUCT_LIST_ALL(V) \
444 V(ACCESSOR_INFO, AccessorInfo, accessor_info) \ 449 V(DECLARED_ACCESSOR_DESCRIPTOR, \
450 DeclaredAccessorDescriptor, \
451 declared_accessor_descriptor) \
452 V(DECLARED_ACCESSOR_INFO, DeclaredAccessorInfo, declared_accessor_info) \
453 V(EXECUTABLE_ACCESSOR_INFO, ExecutableAccessorInfo, executable_accessor_info)\
445 V(ACCESSOR_PAIR, AccessorPair, accessor_pair) \ 454 V(ACCESSOR_PAIR, AccessorPair, accessor_pair) \
446 V(ACCESS_CHECK_INFO, AccessCheckInfo, access_check_info) \ 455 V(ACCESS_CHECK_INFO, AccessCheckInfo, access_check_info) \
447 V(INTERCEPTOR_INFO, InterceptorInfo, interceptor_info) \ 456 V(INTERCEPTOR_INFO, InterceptorInfo, interceptor_info) \
448 V(CALL_HANDLER_INFO, CallHandlerInfo, call_handler_info) \ 457 V(CALL_HANDLER_INFO, CallHandlerInfo, call_handler_info) \
449 V(FUNCTION_TEMPLATE_INFO, FunctionTemplateInfo, function_template_info) \ 458 V(FUNCTION_TEMPLATE_INFO, FunctionTemplateInfo, function_template_info) \
450 V(OBJECT_TEMPLATE_INFO, ObjectTemplateInfo, object_template_info) \ 459 V(OBJECT_TEMPLATE_INFO, ObjectTemplateInfo, object_template_info) \
451 V(SIGNATURE_INFO, SignatureInfo, signature_info) \ 460 V(SIGNATURE_INFO, SignatureInfo, signature_info) \
452 V(TYPE_SWITCH_INFO, TypeSwitchInfo, type_switch_info) \ 461 V(TYPE_SWITCH_INFO, TypeSwitchInfo, type_switch_info) \
453 V(SCRIPT, Script, script) \ 462 V(SCRIPT, Script, script) \
454 V(ALLOCATION_SITE_INFO, AllocationSiteInfo, allocation_site_info) \ 463 V(ALLOCATION_SITE_INFO, AllocationSiteInfo, allocation_site_info) \
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE, 600 EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE,
592 EXTERNAL_INT_ARRAY_TYPE, 601 EXTERNAL_INT_ARRAY_TYPE,
593 EXTERNAL_UNSIGNED_INT_ARRAY_TYPE, 602 EXTERNAL_UNSIGNED_INT_ARRAY_TYPE,
594 EXTERNAL_FLOAT_ARRAY_TYPE, 603 EXTERNAL_FLOAT_ARRAY_TYPE,
595 EXTERNAL_DOUBLE_ARRAY_TYPE, 604 EXTERNAL_DOUBLE_ARRAY_TYPE,
596 EXTERNAL_PIXEL_ARRAY_TYPE, // LAST_EXTERNAL_ARRAY_TYPE 605 EXTERNAL_PIXEL_ARRAY_TYPE, // LAST_EXTERNAL_ARRAY_TYPE
597 FIXED_DOUBLE_ARRAY_TYPE, 606 FIXED_DOUBLE_ARRAY_TYPE,
598 FILLER_TYPE, // LAST_DATA_TYPE 607 FILLER_TYPE, // LAST_DATA_TYPE
599 608
600 // Structs. 609 // Structs.
601 ACCESSOR_INFO_TYPE, 610 DECLARED_ACCESSOR_DESCRIPTOR_TYPE,
611 DECLARED_ACCESSOR_INFO_TYPE,
612 EXECUTABLE_ACCESSOR_INFO_TYPE,
602 ACCESSOR_PAIR_TYPE, 613 ACCESSOR_PAIR_TYPE,
603 ACCESS_CHECK_INFO_TYPE, 614 ACCESS_CHECK_INFO_TYPE,
604 INTERCEPTOR_INFO_TYPE, 615 INTERCEPTOR_INFO_TYPE,
605 CALL_HANDLER_INFO_TYPE, 616 CALL_HANDLER_INFO_TYPE,
606 FUNCTION_TEMPLATE_INFO_TYPE, 617 FUNCTION_TEMPLATE_INFO_TYPE,
607 OBJECT_TEMPLATE_INFO_TYPE, 618 OBJECT_TEMPLATE_INFO_TYPE,
608 SIGNATURE_INFO_TYPE, 619 SIGNATURE_INFO_TYPE,
609 TYPE_SWITCH_INFO_TYPE, 620 TYPE_SWITCH_INFO_TYPE,
610 ALLOCATION_SITE_INFO_TYPE, 621 ALLOCATION_SITE_INFO_TYPE,
611 SCRIPT_TYPE, 622 SCRIPT_TYPE,
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 // Type testing. 930 // Type testing.
920 bool IsObject() { return true; } 931 bool IsObject() { return true; }
921 932
922 #define IS_TYPE_FUNCTION_DECL(type_) inline bool Is##type_(); 933 #define IS_TYPE_FUNCTION_DECL(type_) inline bool Is##type_();
923 OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL) 934 OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL)
924 HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL) 935 HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL)
925 #undef IS_TYPE_FUNCTION_DECL 936 #undef IS_TYPE_FUNCTION_DECL
926 937
927 inline bool IsFixedArrayBase(); 938 inline bool IsFixedArrayBase();
928 inline bool IsExternal(); 939 inline bool IsExternal();
940 inline bool IsAccessorInfo();
929 941
930 // Returns true if this object is an instance of the specified 942 // Returns true if this object is an instance of the specified
931 // function template. 943 // function template.
932 inline bool IsInstanceOf(FunctionTemplateInfo* type); 944 inline bool IsInstanceOf(FunctionTemplateInfo* type);
933 945
934 inline bool IsStruct(); 946 inline bool IsStruct();
935 #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) inline bool Is##Name(); 947 #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) inline bool Is##Name();
936 STRUCT_LIST(DECLARE_STRUCT_PREDICATE) 948 STRUCT_LIST(DECLARE_STRUCT_PREDICATE)
937 #undef DECLARE_STRUCT_PREDICATE 949 #undef DECLARE_STRUCT_PREDICATE
938 950
(...skipping 7378 matching lines...) Expand 10 before | Expand all | Expand 10 after
8317 static const int kInputOffset = kIndexOffset + kPointerSize; 8329 static const int kInputOffset = kIndexOffset + kPointerSize;
8318 static const int kSize = kInputOffset + kPointerSize; 8330 static const int kSize = kInputOffset + kPointerSize;
8319 // Indices of in-object properties. 8331 // Indices of in-object properties.
8320 static const int kIndexIndex = 0; 8332 static const int kIndexIndex = 0;
8321 static const int kInputIndex = 1; 8333 static const int kInputIndex = 1;
8322 private: 8334 private:
8323 DISALLOW_IMPLICIT_CONSTRUCTORS(JSRegExpResult); 8335 DISALLOW_IMPLICIT_CONSTRUCTORS(JSRegExpResult);
8324 }; 8336 };
8325 8337
8326 8338
8327 // An accessor must have a getter, but can have no setter.
8328 //
8329 // When setting a property, V8 searches accessors in prototypes.
8330 // If an accessor was found and it does not have a setter,
8331 // the request is ignored.
8332 //
8333 // If the accessor in the prototype has the READ_ONLY property attribute, then
8334 // a new value is added to the local object when the property is set.
8335 // This shadows the accessor in the prototype.
8336 class AccessorInfo: public Struct { 8339 class AccessorInfo: public Struct {
8337 public: 8340 public:
8338 DECL_ACCESSORS(getter, Object)
8339 DECL_ACCESSORS(setter, Object)
8340 DECL_ACCESSORS(data, Object)
8341 DECL_ACCESSORS(name, Object) 8341 DECL_ACCESSORS(name, Object)
8342 DECL_ACCESSORS(flag, Smi) 8342 DECL_ACCESSORS(flag, Smi)
8343 DECL_ACCESSORS(expected_receiver_type, Object) 8343 DECL_ACCESSORS(expected_receiver_type, Object)
8344 8344
8345 inline bool all_can_read(); 8345 inline bool all_can_read();
8346 inline void set_all_can_read(bool value); 8346 inline void set_all_can_read(bool value);
8347 8347
8348 inline bool all_can_write(); 8348 inline bool all_can_write();
8349 inline void set_all_can_write(bool value); 8349 inline void set_all_can_write(bool value);
8350 8350
8351 inline bool prohibits_overwriting(); 8351 inline bool prohibits_overwriting();
8352 inline void set_prohibits_overwriting(bool value); 8352 inline void set_prohibits_overwriting(bool value);
8353 8353
8354 inline PropertyAttributes property_attributes(); 8354 inline PropertyAttributes property_attributes();
8355 inline void set_property_attributes(PropertyAttributes attributes); 8355 inline void set_property_attributes(PropertyAttributes attributes);
8356 8356
8357 // Checks whether the given receiver is compatible with this accessor. 8357 // Checks whether the given receiver is compatible with this accessor.
8358 inline bool IsCompatibleReceiver(Object* receiver); 8358 inline bool IsCompatibleReceiver(Object* receiver);
8359 8359
8360 static inline AccessorInfo* cast(Object* obj); 8360 static inline AccessorInfo* cast(Object* obj);
8361 8361
8362 // Dispatched behavior. 8362 // Dispatched behavior.
8363 DECLARE_PRINTER(AccessorInfo)
8364 DECLARE_VERIFIER(AccessorInfo) 8363 DECLARE_VERIFIER(AccessorInfo)
8365 8364
8366 static const int kGetterOffset = HeapObject::kHeaderSize; 8365
8367 static const int kSetterOffset = kGetterOffset + kPointerSize; 8366 static const int kNameOffset = HeapObject::kHeaderSize;
8368 static const int kDataOffset = kSetterOffset + kPointerSize;
8369 static const int kNameOffset = kDataOffset + kPointerSize;
8370 static const int kFlagOffset = kNameOffset + kPointerSize; 8367 static const int kFlagOffset = kNameOffset + kPointerSize;
8371 static const int kExpectedReceiverTypeOffset = kFlagOffset + kPointerSize; 8368 static const int kExpectedReceiverTypeOffset = kFlagOffset + kPointerSize;
8372 static const int kSize = kExpectedReceiverTypeOffset + kPointerSize; 8369 static const int kSize = kExpectedReceiverTypeOffset + kPointerSize;
8373 8370
8374 private: 8371 private:
8375 // Bit positions in flag. 8372 // Bit positions in flag.
8376 static const int kAllCanReadBit = 0; 8373 static const int kAllCanReadBit = 0;
8377 static const int kAllCanWriteBit = 1; 8374 static const int kAllCanWriteBit = 1;
8378 static const int kProhibitsOverwritingBit = 2; 8375 static const int kProhibitsOverwritingBit = 2;
8379 class AttributesField: public BitField<PropertyAttributes, 3, 3> {}; 8376 class AttributesField: public BitField<PropertyAttributes, 3, 3> {};
8380 8377
8381 DISALLOW_IMPLICIT_CONSTRUCTORS(AccessorInfo); 8378 DISALLOW_IMPLICIT_CONSTRUCTORS(AccessorInfo);
8382 }; 8379 };
8383 8380
8384 8381
8382 class DeclaredAccessorDescriptor: public Struct {
8383 public:
8384 // TODO(dcarney): Fill out this class.
8385 DECL_ACCESSORS(internal_field, Smi)
8386
8387 static inline DeclaredAccessorDescriptor* cast(Object* obj);
8388
8389 // Dispatched behavior.
8390 DECLARE_PRINTER(DeclaredAccessorDescriptor)
8391 DECLARE_VERIFIER(DeclaredAccessorDescriptor)
8392
8393 static const int kInternalFieldOffset = HeapObject::kHeaderSize;
8394 static const int kSize = kInternalFieldOffset + kPointerSize;
8395
8396 private:
8397 DISALLOW_IMPLICIT_CONSTRUCTORS(DeclaredAccessorDescriptor);
8398 };
8399
8400
8401 class DeclaredAccessorInfo: public AccessorInfo {
8402 public:
8403 DECL_ACCESSORS(descriptor, DeclaredAccessorDescriptor)
8404
8405 static inline DeclaredAccessorInfo* cast(Object* obj);
8406
8407 // Dispatched behavior.
8408 DECLARE_PRINTER(DeclaredAccessorInfo)
8409 DECLARE_VERIFIER(DeclaredAccessorInfo)
8410
8411 static const int kDescriptorOffset = AccessorInfo::kSize;
8412 static const int kSize = kDescriptorOffset + kPointerSize;
8413
8414 private:
8415 DISALLOW_IMPLICIT_CONSTRUCTORS(DeclaredAccessorInfo);
8416 };
8417
8418
8419 // An accessor must have a getter, but can have no setter.
8420 //
8421 // When setting a property, V8 searches accessors in prototypes.
8422 // If an accessor was found and it does not have a setter,
8423 // the request is ignored.
8424 //
8425 // If the accessor in the prototype has the READ_ONLY property attribute, then
8426 // a new value is added to the local object when the property is set.
8427 // This shadows the accessor in the prototype.
8428 class ExecutableAccessorInfo: public AccessorInfo {
8429 public:
8430 DECL_ACCESSORS(getter, Object)
8431 DECL_ACCESSORS(setter, Object)
8432 DECL_ACCESSORS(data, Object)
8433
8434 static inline ExecutableAccessorInfo* cast(Object* obj);
8435
8436 // Dispatched behavior.
8437 DECLARE_PRINTER(ExecutableAccessorInfo)
8438 DECLARE_VERIFIER(ExecutableAccessorInfo)
8439
8440 static const int kGetterOffset = AccessorInfo::kSize;
8441 static const int kSetterOffset = kGetterOffset + kPointerSize;
8442 static const int kDataOffset = kSetterOffset + kPointerSize;
8443 static const int kSize = kDataOffset + kPointerSize;
8444
8445 private:
8446 DISALLOW_IMPLICIT_CONSTRUCTORS(ExecutableAccessorInfo);
8447 };
8448
8449
8385 // Support for JavaScript accessors: A pair of a getter and a setter. Each 8450 // Support for JavaScript accessors: A pair of a getter and a setter. Each
8386 // accessor can either be 8451 // accessor can either be
8387 // * a pointer to a JavaScript function or proxy: a real accessor 8452 // * a pointer to a JavaScript function or proxy: a real accessor
8388 // * undefined: considered an accessor by the spec, too, strangely enough 8453 // * undefined: considered an accessor by the spec, too, strangely enough
8389 // * the hole: an accessor which has not been set 8454 // * the hole: an accessor which has not been set
8390 // * a pointer to a map: a transition used to ensure map sharing 8455 // * a pointer to a map: a transition used to ensure map sharing
8391 class AccessorPair: public Struct { 8456 class AccessorPair: public Struct {
8392 public: 8457 public:
8393 DECL_ACCESSORS(getter, Object) 8458 DECL_ACCESSORS(getter, Object)
8394 DECL_ACCESSORS(setter, Object) 8459 DECL_ACCESSORS(setter, Object)
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
8885 } else { 8950 } else {
8886 value &= ~(1 << bit_position); 8951 value &= ~(1 << bit_position);
8887 } 8952 }
8888 return value; 8953 return value;
8889 } 8954 }
8890 }; 8955 };
8891 8956
8892 } } // namespace v8::internal 8957 } } // namespace v8::internal
8893 8958
8894 #endif // V8_OBJECTS_H_ 8959 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/mark-compact.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698