OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 30 matching lines...) Expand all Loading... |
41 // - Smi (immediate small integer) | 41 // - Smi (immediate small integer) |
42 // - Failure (immediate for marking failed operation) | 42 // - Failure (immediate for marking failed operation) |
43 // - HeapObject (superclass for everything allocated in the heap) | 43 // - HeapObject (superclass for everything allocated in the heap) |
44 // - JSObject | 44 // - JSObject |
45 // - JSArray | 45 // - JSArray |
46 // - JSRegExp | 46 // - JSRegExp |
47 // - JSFunction | 47 // - JSFunction |
48 // - GlobalObject | 48 // - GlobalObject |
49 // - JSGlobalObject | 49 // - JSGlobalObject |
50 // - JSBuiltinsObject | 50 // - JSBuiltinsObject |
| 51 // _ JSGlobalProxy |
51 // - JSValue | 52 // - JSValue |
52 // - Script | 53 // - Script |
53 // - Array | 54 // - Array |
54 // - ByteArray | 55 // - ByteArray |
55 // - FixedArray | 56 // - FixedArray |
56 // - DescriptorArray | 57 // - DescriptorArray |
57 // - HashTable | 58 // - HashTable |
58 // - Dictionary | 59 // - Dictionary |
59 // - SymbolTable | 60 // - SymbolTable |
60 // - Context | 61 // - Context |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 V(SIGNATURE_INFO_TYPE) \ | 257 V(SIGNATURE_INFO_TYPE) \ |
257 V(TYPE_SWITCH_INFO_TYPE) \ | 258 V(TYPE_SWITCH_INFO_TYPE) \ |
258 V(DEBUG_INFO_TYPE) \ | 259 V(DEBUG_INFO_TYPE) \ |
259 V(BREAK_POINT_INFO_TYPE) \ | 260 V(BREAK_POINT_INFO_TYPE) \ |
260 V(SCRIPT_TYPE) \ | 261 V(SCRIPT_TYPE) \ |
261 \ | 262 \ |
262 V(JS_VALUE_TYPE) \ | 263 V(JS_VALUE_TYPE) \ |
263 V(JS_OBJECT_TYPE) \ | 264 V(JS_OBJECT_TYPE) \ |
264 V(JS_GLOBAL_OBJECT_TYPE) \ | 265 V(JS_GLOBAL_OBJECT_TYPE) \ |
265 V(JS_BUILTINS_OBJECT_TYPE) \ | 266 V(JS_BUILTINS_OBJECT_TYPE) \ |
| 267 V(JS_GLOBAL_PROXY_TYPE) \ |
266 V(JS_ARRAY_TYPE) \ | 268 V(JS_ARRAY_TYPE) \ |
267 V(JS_REGEXP_TYPE) \ | 269 V(JS_REGEXP_TYPE) \ |
268 \ | 270 \ |
269 V(JS_FUNCTION_TYPE) \ | 271 V(JS_FUNCTION_TYPE) \ |
270 | 272 |
271 | 273 |
272 // Since string types are not consecutive, this macro is used to | 274 // Since string types are not consecutive, this macro is used to |
273 // iterate over them. | 275 // iterate over them. |
274 #define STRING_TYPE_LIST(V) \ | 276 #define STRING_TYPE_LIST(V) \ |
275 V(SHORT_SYMBOL_TYPE, SeqTwoByteString::kHeaderSize, short_symbol) \ | 277 V(SHORT_SYMBOL_TYPE, SeqTwoByteString::kHeaderSize, short_symbol) \ |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 SIGNATURE_INFO_TYPE, | 513 SIGNATURE_INFO_TYPE, |
512 TYPE_SWITCH_INFO_TYPE, | 514 TYPE_SWITCH_INFO_TYPE, |
513 DEBUG_INFO_TYPE, | 515 DEBUG_INFO_TYPE, |
514 BREAK_POINT_INFO_TYPE, | 516 BREAK_POINT_INFO_TYPE, |
515 SCRIPT_TYPE, | 517 SCRIPT_TYPE, |
516 | 518 |
517 JS_VALUE_TYPE, | 519 JS_VALUE_TYPE, |
518 JS_OBJECT_TYPE, | 520 JS_OBJECT_TYPE, |
519 JS_GLOBAL_OBJECT_TYPE, | 521 JS_GLOBAL_OBJECT_TYPE, |
520 JS_BUILTINS_OBJECT_TYPE, | 522 JS_BUILTINS_OBJECT_TYPE, |
| 523 JS_GLOBAL_PROXY_TYPE, |
521 JS_ARRAY_TYPE, | 524 JS_ARRAY_TYPE, |
522 JS_REGEXP_TYPE, | 525 JS_REGEXP_TYPE, |
523 | 526 |
524 JS_FUNCTION_TYPE, | 527 JS_FUNCTION_TYPE, |
525 | 528 |
526 // Pseudo-types | 529 // Pseudo-types |
527 FIRST_NONSTRING_TYPE = MAP_TYPE, | 530 FIRST_NONSTRING_TYPE = MAP_TYPE, |
528 FIRST_TYPE = 0x0, | 531 FIRST_TYPE = 0x0, |
529 LAST_TYPE = JS_FUNCTION_TYPE, | 532 LAST_TYPE = JS_FUNCTION_TYPE, |
530 // Boundaries for testing the type is a JavaScript "object". Note that | 533 // Boundaries for testing the type is a JavaScript "object". Note that |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 inline bool IsJSRegExp(); | 623 inline bool IsJSRegExp(); |
621 inline bool IsHashTable(); | 624 inline bool IsHashTable(); |
622 inline bool IsDictionary(); | 625 inline bool IsDictionary(); |
623 inline bool IsSymbolTable(); | 626 inline bool IsSymbolTable(); |
624 inline bool IsCompilationCacheTable(); | 627 inline bool IsCompilationCacheTable(); |
625 inline bool IsMapCache(); | 628 inline bool IsMapCache(); |
626 inline bool IsPrimitive(); | 629 inline bool IsPrimitive(); |
627 inline bool IsGlobalObject(); | 630 inline bool IsGlobalObject(); |
628 inline bool IsJSGlobalObject(); | 631 inline bool IsJSGlobalObject(); |
629 inline bool IsJSBuiltinsObject(); | 632 inline bool IsJSBuiltinsObject(); |
| 633 inline bool IsJSGlobalProxy(); |
630 inline bool IsUndetectableObject(); | 634 inline bool IsUndetectableObject(); |
631 inline bool IsAccessCheckNeeded(); | 635 inline bool IsAccessCheckNeeded(); |
632 | 636 |
633 // Returns true if this object is an instance of the specified | 637 // Returns true if this object is an instance of the specified |
634 // function template. | 638 // function template. |
635 bool IsInstanceOf(FunctionTemplateInfo* type); | 639 bool IsInstanceOf(FunctionTemplateInfo* type); |
636 | 640 |
637 inline bool IsStruct(); | 641 inline bool IsStruct(); |
638 #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) inline bool Is##Name(); | 642 #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) inline bool Is##Name(); |
639 STRUCT_LIST(DECLARE_STRUCT_PREDICATE) | 643 STRUCT_LIST(DECLARE_STRUCT_PREDICATE) |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1107 // properties is a FixedArray in the fast case, and a Dictionary in the | 1111 // properties is a FixedArray in the fast case, and a Dictionary in the |
1108 // slow case. | 1112 // slow case. |
1109 DECL_ACCESSORS(properties, FixedArray) // Get and set fast properties. | 1113 DECL_ACCESSORS(properties, FixedArray) // Get and set fast properties. |
1110 inline void initialize_properties(); | 1114 inline void initialize_properties(); |
1111 inline bool HasFastProperties(); | 1115 inline bool HasFastProperties(); |
1112 inline Dictionary* property_dictionary(); // Gets slow properties. | 1116 inline Dictionary* property_dictionary(); // Gets slow properties. |
1113 | 1117 |
1114 // [elements]: The elements (properties with names that are integers). | 1118 // [elements]: The elements (properties with names that are integers). |
1115 // elements is a FixedArray in the fast case, and a Dictionary in the slow | 1119 // elements is a FixedArray in the fast case, and a Dictionary in the slow |
1116 // case. | 1120 // case. |
1117 DECL_ACCESSORS(elements, HeapObject) // Get and set fast elements. | 1121 DECL_ACCESSORS(elements, FixedArray) // Get and set fast elements. |
1118 inline void initialize_elements(); | 1122 inline void initialize_elements(); |
1119 inline bool HasFastElements(); | 1123 inline bool HasFastElements(); |
1120 inline Dictionary* element_dictionary(); // Gets slow elements. | 1124 inline Dictionary* element_dictionary(); // Gets slow elements. |
1121 | 1125 |
1122 Object* SetProperty(String* key, | 1126 Object* SetProperty(String* key, |
1123 Object* value, | 1127 Object* value, |
1124 PropertyAttributes attributes); | 1128 PropertyAttributes attributes); |
1125 Object* SetProperty(LookupResult* result, | 1129 Object* SetProperty(LookupResult* result, |
1126 String* key, | 1130 String* key, |
1127 Object* value, | 1131 Object* value, |
(...skipping 1203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2331 inline void set_has_instance_call_handler() { | 2335 inline void set_has_instance_call_handler() { |
2332 set_bit_field(bit_field() | (1 << kHasInstanceCallHandler)); | 2336 set_bit_field(bit_field() | (1 << kHasInstanceCallHandler)); |
2333 } | 2337 } |
2334 | 2338 |
2335 inline bool has_instance_call_handler() { | 2339 inline bool has_instance_call_handler() { |
2336 return ((1 << kHasInstanceCallHandler) & bit_field()) != 0; | 2340 return ((1 << kHasInstanceCallHandler) & bit_field()) != 0; |
2337 } | 2341 } |
2338 | 2342 |
2339 // Tells whether the instance needs security checks when accessing its | 2343 // Tells whether the instance needs security checks when accessing its |
2340 // properties. | 2344 // properties. |
2341 inline void set_needs_access_check() { | 2345 inline void set_is_access_check_needed() { |
2342 set_bit_field(bit_field() | (1 << kNeedsAccessCheck)); | 2346 set_bit_field(bit_field() | (1 << kIsAccessCheckNeeded)); |
2343 } | 2347 } |
2344 | 2348 |
2345 inline bool needs_access_check() { | 2349 inline bool is_access_check_needed() { |
2346 return ((1 << kNeedsAccessCheck) & bit_field()) != 0; | 2350 return ((1 << kIsAccessCheckNeeded) & bit_field()) != 0; |
2347 } | 2351 } |
2348 | 2352 |
2349 // [prototype]: implicit prototype object. | 2353 // [prototype]: implicit prototype object. |
2350 DECL_ACCESSORS(prototype, Object) | 2354 DECL_ACCESSORS(prototype, Object) |
2351 | 2355 |
2352 // [constructor]: points back to the function responsible for this map. | 2356 // [constructor]: points back to the function responsible for this map. |
2353 DECL_ACCESSORS(constructor, Object) | 2357 DECL_ACCESSORS(constructor, Object) |
2354 | 2358 |
2355 // [instance descriptors]: describes the object. | 2359 // [instance descriptors]: describes the object. |
2356 DECL_ACCESSORS(instance_descriptors, DescriptorArray) | 2360 DECL_ACCESSORS(instance_descriptors, DescriptorArray) |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2428 // The byte at position 3 is not in use at the moment. | 2432 // The byte at position 3 is not in use at the moment. |
2429 | 2433 |
2430 // Bit positions for bit field. | 2434 // Bit positions for bit field. |
2431 static const int kUnused = 0; // To be used for marking recently used maps. | 2435 static const int kUnused = 0; // To be used for marking recently used maps. |
2432 static const int kHasNonInstancePrototype = 1; | 2436 static const int kHasNonInstancePrototype = 1; |
2433 static const int kIsHiddenPrototype = 2; | 2437 static const int kIsHiddenPrototype = 2; |
2434 static const int kHasNamedInterceptor = 3; | 2438 static const int kHasNamedInterceptor = 3; |
2435 static const int kHasIndexedInterceptor = 4; | 2439 static const int kHasIndexedInterceptor = 4; |
2436 static const int kIsUndetectable = 5; | 2440 static const int kIsUndetectable = 5; |
2437 static const int kHasInstanceCallHandler = 6; | 2441 static const int kHasInstanceCallHandler = 6; |
2438 static const int kNeedsAccessCheck = 7; | 2442 static const int kIsAccessCheckNeeded = 7; |
2439 private: | 2443 private: |
2440 DISALLOW_IMPLICIT_CONSTRUCTORS(Map); | 2444 DISALLOW_IMPLICIT_CONSTRUCTORS(Map); |
2441 }; | 2445 }; |
2442 | 2446 |
2443 | 2447 |
2444 // An abstract superclass, a marker class really, for simple structure classes. | 2448 // An abstract superclass, a marker class really, for simple structure classes. |
2445 // It doesn't carry much functionality but allows struct classes to me | 2449 // It doesn't carry much functionality but allows struct classes to me |
2446 // identified in the type system. | 2450 // identified in the type system. |
2447 class Struct: public HeapObject { | 2451 class Struct: public HeapObject { |
2448 public: | 2452 public: |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2732 static const int kSize = kLiteralsOffset + kPointerSize; | 2736 static const int kSize = kLiteralsOffset + kPointerSize; |
2733 | 2737 |
2734 // Layout of the literals array. | 2738 // Layout of the literals array. |
2735 static const int kLiteralsPrefixSize = 1; | 2739 static const int kLiteralsPrefixSize = 1; |
2736 static const int kLiteralGlobalContextIndex = 0; | 2740 static const int kLiteralGlobalContextIndex = 0; |
2737 private: | 2741 private: |
2738 DISALLOW_IMPLICIT_CONSTRUCTORS(JSFunction); | 2742 DISALLOW_IMPLICIT_CONSTRUCTORS(JSFunction); |
2739 }; | 2743 }; |
2740 | 2744 |
2741 | 2745 |
| 2746 // JSGlobalProxy's prototype must be a JSGlobalObject or null, |
| 2747 // and the prototype is hidden. JSGlobalProxy always delegates |
| 2748 // property accesses to its prototype if the prototype is not null. |
| 2749 // |
| 2750 // A JSGlobalProxy can be reinitialized which will preserve its identity. |
| 2751 // |
| 2752 // Accessing a JSGlobalProxy requires security check. |
| 2753 |
| 2754 class JSGlobalProxy : public JSObject { |
| 2755 public: |
| 2756 // [context]: the owner global context of this proxy object. |
| 2757 // It is null value if this object is not used by any context. |
| 2758 DECL_ACCESSORS(context, Object) |
| 2759 |
| 2760 // Casting. |
| 2761 static inline JSGlobalProxy* cast(Object* obj); |
| 2762 |
| 2763 // Dispatched behavior. |
| 2764 #ifdef DEBUG |
| 2765 void JSGlobalProxyPrint(); |
| 2766 void JSGlobalProxyVerify(); |
| 2767 #endif |
| 2768 |
| 2769 // Layout description. |
| 2770 static const int kContextOffset = JSObject::kHeaderSize; |
| 2771 static const int kSize = kContextOffset + kPointerSize; |
| 2772 |
| 2773 private: |
| 2774 |
| 2775 DISALLOW_IMPLICIT_CONSTRUCTORS(JSGlobalProxy); |
| 2776 }; |
| 2777 |
| 2778 |
2742 // Forward declaration. | 2779 // Forward declaration. |
2743 class JSBuiltinsObject; | 2780 class JSBuiltinsObject; |
2744 | 2781 |
2745 // Common super class for JavaScript global objects and the special | 2782 // Common super class for JavaScript global objects and the special |
2746 // builtins global objects. | 2783 // builtins global objects. |
2747 class GlobalObject: public JSObject { | 2784 class GlobalObject: public JSObject { |
2748 public: | 2785 public: |
2749 // [builtins]: the object holding the runtime routines written in JS. | 2786 // [builtins]: the object holding the runtime routines written in JS. |
2750 DECL_ACCESSORS(builtins, JSBuiltinsObject) | 2787 DECL_ACCESSORS(builtins, JSBuiltinsObject) |
2751 | 2788 |
2752 // [global context]: the global context corresponding to this global objet. | 2789 // [global context]: the global context corresponding to this global objet. |
2753 DECL_ACCESSORS(global_context, Context) | 2790 DECL_ACCESSORS(global_context, Context) |
2754 | 2791 |
| 2792 // [global receiver]: the global receiver object of the context |
| 2793 DECL_ACCESSORS(global_receiver, JSObject) |
| 2794 |
2755 // Layout description. | 2795 // Layout description. |
2756 static const int kBuiltinsOffset = JSObject::kHeaderSize; | 2796 static const int kBuiltinsOffset = JSObject::kHeaderSize; |
2757 static const int kGlobalContextOffset = kBuiltinsOffset + kPointerSize; | 2797 static const int kGlobalContextOffset = kBuiltinsOffset + kPointerSize; |
2758 static const int kHeaderSize = kGlobalContextOffset + kPointerSize; | 2798 static const int kGlobalReceiverOffset = kGlobalContextOffset + kPointerSize; |
| 2799 static const int kHeaderSize = kGlobalReceiverOffset + kPointerSize; |
2759 | 2800 |
2760 private: | 2801 private: |
2761 friend class AGCCVersionRequiresThisClassToHaveAFriendSoHereItIs; | 2802 friend class AGCCVersionRequiresThisClassToHaveAFriendSoHereItIs; |
2762 | 2803 |
2763 DISALLOW_IMPLICIT_CONSTRUCTORS(GlobalObject); | 2804 DISALLOW_IMPLICIT_CONSTRUCTORS(GlobalObject); |
2764 }; | 2805 }; |
2765 | 2806 |
2766 | 2807 |
2767 // JavaScript global object. | 2808 // JavaScript global object. |
2768 class JSGlobalObject: public GlobalObject { | 2809 class JSGlobalObject: public GlobalObject { |
2769 public: | 2810 public: |
2770 // [security token]: the object being used for security check when accessing | |
2771 // global properties. | |
2772 DECL_ACCESSORS(security_token, Object) | |
2773 | |
2774 // Casting. | 2811 // Casting. |
2775 static inline JSGlobalObject* cast(Object* obj); | 2812 static inline JSGlobalObject* cast(Object* obj); |
2776 | 2813 |
2777 // Dispatched behavior. | 2814 // Dispatched behavior. |
2778 #ifdef DEBUG | 2815 #ifdef DEBUG |
2779 void JSGlobalObjectPrint(); | 2816 void JSGlobalObjectPrint(); |
2780 void JSGlobalObjectVerify(); | 2817 void JSGlobalObjectVerify(); |
2781 #endif | 2818 #endif |
2782 | 2819 |
2783 // Layout description. | 2820 // Layout description. |
2784 static const int kSecurityTokenOffset = GlobalObject::kHeaderSize; | 2821 static const int kSize = GlobalObject::kHeaderSize; |
2785 static const int kSize = kSecurityTokenOffset + kPointerSize; | |
2786 | 2822 |
2787 private: | 2823 private: |
2788 DISALLOW_IMPLICIT_CONSTRUCTORS(JSGlobalObject); | 2824 DISALLOW_IMPLICIT_CONSTRUCTORS(JSGlobalObject); |
2789 }; | 2825 }; |
2790 | 2826 |
2791 | 2827 |
2792 // Builtins global object which holds the runtime routines written in | 2828 // Builtins global object which holds the runtime routines written in |
2793 // JavaScript. | 2829 // JavaScript. |
2794 class JSBuiltinsObject: public GlobalObject { | 2830 class JSBuiltinsObject: public GlobalObject { |
2795 public: | 2831 public: |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3060 static const int kLengthOffset = HeapObject::kHeaderSize; | 3096 static const int kLengthOffset = HeapObject::kHeaderSize; |
3061 static const int kSize = kLengthOffset + kIntSize; | 3097 static const int kSize = kLengthOffset + kIntSize; |
3062 | 3098 |
3063 // Limits on sizes of different types of strings. | 3099 // Limits on sizes of different types of strings. |
3064 static const int kMaxShortStringSize = 255; | 3100 static const int kMaxShortStringSize = 255; |
3065 static const int kMaxMediumStringSize = 65535; | 3101 static const int kMaxMediumStringSize = 65535; |
3066 | 3102 |
3067 static const int kMaxArrayIndexSize = 10; | 3103 static const int kMaxArrayIndexSize = 10; |
3068 | 3104 |
3069 // Max ascii char code. | 3105 // Max ascii char code. |
3070 static const int kMaxAsciiCharCode = 127; | 3106 static const int kMaxAsciiCharCode = unibrow::Utf8::kMaxOneByteChar; |
3071 | 3107 |
3072 // Mask constant for checking if a string has a computed hash code | 3108 // Mask constant for checking if a string has a computed hash code |
3073 // and if it is an array index. The least significant bit indicates | 3109 // and if it is an array index. The least significant bit indicates |
3074 // whether a hash code has been computed. If the hash code has been | 3110 // whether a hash code has been computed. If the hash code has been |
3075 // computed the 2nd bit tells whether the string can be used as an | 3111 // computed the 2nd bit tells whether the string can be used as an |
3076 // array index. | 3112 // array index. |
3077 static const int kHashComputedMask = 1; | 3113 static const int kHashComputedMask = 1; |
3078 static const int kIsArrayIndexMask = 1 << 1; | 3114 static const int kIsArrayIndexMask = 1 << 1; |
3079 static const int kNofLengthBitFields = 2; | 3115 static const int kNofLengthBitFields = 2; |
3080 | 3116 |
(...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4020 } else { | 4056 } else { |
4021 value &= ~(1 << bit_position); | 4057 value &= ~(1 << bit_position); |
4022 } | 4058 } |
4023 return value; | 4059 return value; |
4024 } | 4060 } |
4025 }; | 4061 }; |
4026 | 4062 |
4027 } } // namespace v8::internal | 4063 } } // namespace v8::internal |
4028 | 4064 |
4029 #endif // V8_OBJECTS_H_ | 4065 #endif // V8_OBJECTS_H_ |
OLD | NEW |