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

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: 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
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 7705 matching lines...) Expand 10 before | Expand all | Expand 10 after
8317 static const int kInputOffset = kIndexOffset + kPointerSize; 8328 static const int kInputOffset = kIndexOffset + kPointerSize;
8318 static const int kSize = kInputOffset + kPointerSize; 8329 static const int kSize = kInputOffset + kPointerSize;
8319 // Indices of in-object properties. 8330 // Indices of in-object properties.
8320 static const int kIndexIndex = 0; 8331 static const int kIndexIndex = 0;
8321 static const int kInputIndex = 1; 8332 static const int kInputIndex = 1;
8322 private: 8333 private:
8323 DISALLOW_IMPLICIT_CONSTRUCTORS(JSRegExpResult); 8334 DISALLOW_IMPLICIT_CONSTRUCTORS(JSRegExpResult);
8324 }; 8335 };
8325 8336
8326 8337
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 { 8338 class AccessorInfo: public Struct {
8337 public: 8339 public:
8338 DECL_ACCESSORS(getter, Object)
8339 DECL_ACCESSORS(setter, Object)
8340 DECL_ACCESSORS(data, Object)
8341 DECL_ACCESSORS(name, Object) 8340 DECL_ACCESSORS(name, Object)
8342 DECL_ACCESSORS(flag, Smi) 8341 DECL_ACCESSORS(flag, Smi)
8343 DECL_ACCESSORS(expected_receiver_type, Object) 8342 DECL_ACCESSORS(expected_receiver_type, Object)
8344 8343
8344 // Dispatched behavior.
8345 DECLARE_VERIFIER(AccessorInfo)
8346
8345 inline bool all_can_read(); 8347 inline bool all_can_read();
8346 inline void set_all_can_read(bool value); 8348 inline void set_all_can_read(bool value);
8347 8349
8348 inline bool all_can_write(); 8350 inline bool all_can_write();
8349 inline void set_all_can_write(bool value); 8351 inline void set_all_can_write(bool value);
8350 8352
8351 inline bool prohibits_overwriting(); 8353 inline bool prohibits_overwriting();
8352 inline void set_prohibits_overwriting(bool value); 8354 inline void set_prohibits_overwriting(bool value);
8353 8355
8354 inline PropertyAttributes property_attributes(); 8356 inline PropertyAttributes property_attributes();
8355 inline void set_property_attributes(PropertyAttributes attributes); 8357 inline void set_property_attributes(PropertyAttributes attributes);
8356 8358
8357 // Checks whether the given receiver is compatible with this accessor. 8359 // Checks whether the given receiver is compatible with this accessor.
8358 inline bool IsCompatibleReceiver(Object* receiver); 8360 inline bool IsCompatibleReceiver(Object* receiver);
8359 8361
8360 static inline AccessorInfo* cast(Object* obj); 8362 static const int kNameOffset = HeapObject::kHeaderSize;
8361
8362 // Dispatched behavior.
8363 DECLARE_PRINTER(AccessorInfo)
8364 DECLARE_VERIFIER(AccessorInfo)
8365
8366 static const int kGetterOffset = HeapObject::kHeaderSize;
8367 static const int kSetterOffset = kGetterOffset + kPointerSize;
8368 static const int kDataOffset = kSetterOffset + kPointerSize;
8369 static const int kNameOffset = kDataOffset + kPointerSize;
8370 static const int kFlagOffset = kNameOffset + kPointerSize; 8363 static const int kFlagOffset = kNameOffset + kPointerSize;
8371 static const int kExpectedReceiverTypeOffset = kFlagOffset + kPointerSize; 8364 static const int kExpectedReceiverTypeOffset = kFlagOffset + kPointerSize;
8372 static const int kSize = kExpectedReceiverTypeOffset + kPointerSize; 8365 static const int kSize = kExpectedReceiverTypeOffset + kPointerSize;
8373 8366
8374 private: 8367 private:
8375 // Bit positions in flag. 8368 // Bit positions in flag.
8376 static const int kAllCanReadBit = 0; 8369 static const int kAllCanReadBit = 0;
8377 static const int kAllCanWriteBit = 1; 8370 static const int kAllCanWriteBit = 1;
8378 static const int kProhibitsOverwritingBit = 2; 8371 static const int kProhibitsOverwritingBit = 2;
8379 class AttributesField: public BitField<PropertyAttributes, 3, 3> {}; 8372 class AttributesField: public BitField<PropertyAttributes, 3, 3> {};
8380 8373
8381 DISALLOW_IMPLICIT_CONSTRUCTORS(AccessorInfo); 8374 DISALLOW_IMPLICIT_CONSTRUCTORS(AccessorInfo);
8382 }; 8375 };
8383 8376
8384 8377
8378 class DeclaredAccessorDescriptor: public Struct {
8379 public:
8380 // TODO(dcarney): Fill out this class.
8381 DECL_ACCESSORS(internal_field, Smi)
8382
8383 static inline DeclaredAccessorDescriptor* cast(Object* obj);
8384
8385 // Dispatched behavior.
8386 DECLARE_PRINTER(DeclaredAccessorDescriptor)
8387 DECLARE_VERIFIER(DeclaredAccessorDescriptor)
8388
8389 static const int kInternalFieldOffset = HeapObject::kHeaderSize;
8390 static const int kSize = kInternalFieldOffset + kPointerSize;
8391
8392 private:
8393 DISALLOW_IMPLICIT_CONSTRUCTORS(DeclaredAccessorDescriptor);
8394 };
8395
8396
8397 class DeclaredAccessorInfo: public AccessorInfo {
8398 public:
8399 DECL_ACCESSORS(descriptor, DeclaredAccessorDescriptor)
8400
8401 static inline DeclaredAccessorInfo* cast(Object* obj);
8402
8403 // Dispatched behavior.
8404 DECLARE_PRINTER(DeclaredAccessorInfo)
8405 DECLARE_VERIFIER(DeclaredAccessorInfo)
8406
8407 static const int kDescriptorOffset = AccessorInfo::kSize;
8408 static const int kSize = kDescriptorOffset + kPointerSize;
8409
8410 private:
8411 DISALLOW_IMPLICIT_CONSTRUCTORS(DeclaredAccessorInfo);
8412 };
8413
8414
8415 // An accessor must have a getter, but can have no setter.
8416 //
8417 // When setting a property, V8 searches accessors in prototypes.
8418 // If an accessor was found and it does not have a setter,
8419 // the request is ignored.
8420 //
8421 // If the accessor in the prototype has the READ_ONLY property attribute, then
8422 // a new value is added to the local object when the property is set.
8423 // This shadows the accessor in the prototype.
8424 class ExecutableAccessorInfo: public AccessorInfo {
8425 public:
8426 DECL_ACCESSORS(getter, Object)
8427 DECL_ACCESSORS(setter, Object)
8428 DECL_ACCESSORS(data, Object)
8429
8430 static inline ExecutableAccessorInfo* cast(Object* obj);
8431
8432 // Dispatched behavior.
8433 DECLARE_PRINTER(ExecutableAccessorInfo)
8434 DECLARE_VERIFIER(ExecutableAccessorInfo)
8435
8436 static const int kGetterOffset = AccessorInfo::kSize;
8437 static const int kSetterOffset = kGetterOffset + kPointerSize;
8438 static const int kDataOffset = kSetterOffset + kPointerSize;
8439 static const int kSize = kDataOffset + kPointerSize;
8440
8441 private:
8442 DISALLOW_IMPLICIT_CONSTRUCTORS(ExecutableAccessorInfo);
8443 };
8444
8445
8385 // Support for JavaScript accessors: A pair of a getter and a setter. Each 8446 // Support for JavaScript accessors: A pair of a getter and a setter. Each
8386 // accessor can either be 8447 // accessor can either be
8387 // * a pointer to a JavaScript function or proxy: a real accessor 8448 // * a pointer to a JavaScript function or proxy: a real accessor
8388 // * undefined: considered an accessor by the spec, too, strangely enough 8449 // * undefined: considered an accessor by the spec, too, strangely enough
8389 // * the hole: an accessor which has not been set 8450 // * the hole: an accessor which has not been set
8390 // * a pointer to a map: a transition used to ensure map sharing 8451 // * a pointer to a map: a transition used to ensure map sharing
8391 class AccessorPair: public Struct { 8452 class AccessorPair: public Struct {
8392 public: 8453 public:
8393 DECL_ACCESSORS(getter, Object) 8454 DECL_ACCESSORS(getter, Object)
8394 DECL_ACCESSORS(setter, Object) 8455 DECL_ACCESSORS(setter, Object)
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
8885 } else { 8946 } else {
8886 value &= ~(1 << bit_position); 8947 value &= ~(1 << bit_position);
8887 } 8948 }
8888 return value; 8949 return value;
8889 } 8950 }
8890 }; 8951 };
8891 8952
8892 } } // namespace v8::internal 8953 } } // namespace v8::internal
8893 8954
8894 #endif // V8_OBJECTS_H_ 8955 #endif // V8_OBJECTS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698