Chromium Code Reviews| 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 1224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1235 String* name, | 1235 String* name, |
| 1236 PropertyAttributes* attributes); | 1236 PropertyAttributes* attributes); |
| 1237 Object* GetPropertyPostInterceptor(JSObject* receiver, | 1237 Object* GetPropertyPostInterceptor(JSObject* receiver, |
| 1238 String* name, | 1238 String* name, |
| 1239 PropertyAttributes* attributes); | 1239 PropertyAttributes* attributes); |
| 1240 Object* GetLazyProperty(Object* receiver, | 1240 Object* GetLazyProperty(Object* receiver, |
| 1241 LookupResult* result, | 1241 LookupResult* result, |
| 1242 String* name, | 1242 String* name, |
| 1243 PropertyAttributes* attributes); | 1243 PropertyAttributes* attributes); |
| 1244 | 1244 |
| 1245 // Tells whether this object needs to be loaded. | |
| 1246 inline bool IsLoaded(); | |
| 1247 | |
| 1245 bool HasProperty(String* name) { | 1248 bool HasProperty(String* name) { |
| 1246 return GetPropertyAttribute(name) != ABSENT; | 1249 return GetPropertyAttribute(name) != ABSENT; |
| 1247 } | 1250 } |
| 1248 | 1251 |
| 1249 bool HasLocalProperty(String* name) { | 1252 bool HasLocalProperty(String* name) { |
| 1250 return GetLocalPropertyAttribute(name) != ABSENT; | 1253 return GetLocalPropertyAttribute(name) != ABSENT; |
| 1251 } | 1254 } |
| 1252 | 1255 |
| 1253 Object* DeleteProperty(String* name); | 1256 Object* DeleteProperty(String* name); |
| 1254 Object* DeleteElement(uint32_t index); | 1257 Object* DeleteElement(uint32_t index); |
| (...skipping 1135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2390 | 2393 |
| 2391 // Tells how many unused property fields are available in the | 2394 // Tells how many unused property fields are available in the |
| 2392 // instance (only used for JSObject in fast mode). | 2395 // instance (only used for JSObject in fast mode). |
| 2393 inline int unused_property_fields(); | 2396 inline int unused_property_fields(); |
| 2394 inline void set_unused_property_fields(int value); | 2397 inline void set_unused_property_fields(int value); |
| 2395 | 2398 |
| 2396 // Bit field. | 2399 // Bit field. |
| 2397 inline byte bit_field(); | 2400 inline byte bit_field(); |
| 2398 inline void set_bit_field(byte value); | 2401 inline void set_bit_field(byte value); |
| 2399 | 2402 |
| 2403 // Bit field 2. | |
| 2404 inline byte bit_field2(); | |
| 2405 inline void set_bit_field2(byte value); | |
| 2406 | |
| 2400 // Tells whether the object in the prototype property will be used | 2407 // Tells whether the object in the prototype property will be used |
| 2401 // for instances created from this function. If the prototype | 2408 // for instances created from this function. If the prototype |
| 2402 // property is set to a value that is not a JSObject, the prototype | 2409 // property is set to a value that is not a JSObject, the prototype |
| 2403 // property will not be used to create instances of the function. | 2410 // property will not be used to create instances of the function. |
| 2404 // See ECMA-262, 13.2.2. | 2411 // See ECMA-262, 13.2.2. |
| 2405 inline void set_non_instance_prototype(bool value); | 2412 inline void set_non_instance_prototype(bool value); |
| 2406 inline bool has_non_instance_prototype(); | 2413 inline bool has_non_instance_prototype(); |
| 2407 | 2414 |
| 2408 // Tells whether the instance with this map should be ignored by the | 2415 // Tells whether the instance with this map should be ignored by the |
| 2409 // __proto__ accessor. | 2416 // __proto__ accessor. |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 2440 // document.all in Firefox & Safari. | 2447 // document.all in Firefox & Safari. |
| 2441 // See https://bugzilla.mozilla.org/show_bug.cgi?id=248549. | 2448 // See https://bugzilla.mozilla.org/show_bug.cgi?id=248549. |
| 2442 inline void set_is_undetectable() { | 2449 inline void set_is_undetectable() { |
| 2443 set_bit_field(bit_field() | (1 << kIsUndetectable)); | 2450 set_bit_field(bit_field() | (1 << kIsUndetectable)); |
| 2444 } | 2451 } |
| 2445 | 2452 |
| 2446 inline bool is_undetectable() { | 2453 inline bool is_undetectable() { |
| 2447 return ((1 << kIsUndetectable) & bit_field()) != 0; | 2454 return ((1 << kIsUndetectable) & bit_field()) != 0; |
| 2448 } | 2455 } |
| 2449 | 2456 |
| 2457 inline void set_needs_loading(bool value) { | |
| 2458 if (value) { | |
| 2459 set_bit_field2(bit_field2() | (1 << kNeedsLoading)); | |
| 2460 } else { | |
| 2461 set_bit_field2(bit_field2() & ~(1 << kNeedsLoading)); | |
| 2462 } | |
| 2463 } | |
| 2464 | |
| 2465 // Does this object or function require a lazily loaded script to be | |
| 2466 // run before being used? | |
| 2467 inline bool needs_loading() { | |
| 2468 return ((1 << kNeedsLoading) & bit_field2()) != 0; | |
| 2469 } | |
| 2470 | |
| 2450 // Tells whether the instance has a call-as-function handler. | 2471 // Tells whether the instance has a call-as-function handler. |
| 2451 inline void set_has_instance_call_handler() { | 2472 inline void set_has_instance_call_handler() { |
| 2452 set_bit_field(bit_field() | (1 << kHasInstanceCallHandler)); | 2473 set_bit_field(bit_field() | (1 << kHasInstanceCallHandler)); |
| 2453 } | 2474 } |
| 2454 | 2475 |
| 2455 inline bool has_instance_call_handler() { | 2476 inline bool has_instance_call_handler() { |
| 2456 return ((1 << kHasInstanceCallHandler) & bit_field()) != 0; | 2477 return ((1 << kHasInstanceCallHandler) & bit_field()) != 0; |
| 2457 } | 2478 } |
| 2458 | 2479 |
| 2459 // Tells whether the instance needs security checks when accessing its | 2480 // Tells whether the instance needs security checks when accessing its |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2543 | 2564 |
| 2544 // Byte offsets within kInstanceSizesOffset. | 2565 // Byte offsets within kInstanceSizesOffset. |
| 2545 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; | 2566 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; |
| 2546 static const int kInObjectPropertiesOffset = kInstanceSizesOffset + 1; | 2567 static const int kInObjectPropertiesOffset = kInstanceSizesOffset + 1; |
| 2547 // The bytes at positions 2 and 3 are not in use at the moment. | 2568 // The bytes at positions 2 and 3 are not in use at the moment. |
| 2548 | 2569 |
| 2549 // Byte offsets within kInstanceAttributesOffset attributes. | 2570 // Byte offsets within kInstanceAttributesOffset attributes. |
| 2550 static const int kInstanceTypeOffset = kInstanceAttributesOffset + 0; | 2571 static const int kInstanceTypeOffset = kInstanceAttributesOffset + 0; |
| 2551 static const int kUnusedPropertyFieldsOffset = kInstanceAttributesOffset + 1; | 2572 static const int kUnusedPropertyFieldsOffset = kInstanceAttributesOffset + 1; |
| 2552 static const int kBitFieldOffset = kInstanceAttributesOffset + 2; | 2573 static const int kBitFieldOffset = kInstanceAttributesOffset + 2; |
| 2553 // The byte at position 3 is not in use at the moment. | 2574 static const int kBitField2Offset = kInstanceAttributesOffset + 3; |
| 2554 | 2575 |
| 2555 // Bit positions for bit field. | 2576 // Bit positions for bit field. |
| 2556 static const int kUnused = 0; // To be used for marking recently used maps. | 2577 static const int kUnused = 0; // To be used for marking recently used maps. |
| 2557 static const int kHasNonInstancePrototype = 1; | 2578 static const int kHasNonInstancePrototype = 1; |
| 2558 static const int kIsHiddenPrototype = 2; | 2579 static const int kIsHiddenPrototype = 2; |
| 2559 static const int kHasNamedInterceptor = 3; | 2580 static const int kHasNamedInterceptor = 3; |
| 2560 static const int kHasIndexedInterceptor = 4; | 2581 static const int kHasIndexedInterceptor = 4; |
| 2561 static const int kIsUndetectable = 5; | 2582 static const int kIsUndetectable = 5; |
| 2562 static const int kHasInstanceCallHandler = 6; | 2583 static const int kHasInstanceCallHandler = 6; |
| 2563 static const int kIsAccessCheckNeeded = 7; | 2584 static const int kIsAccessCheckNeeded = 7; |
| 2585 | |
| 2586 // But positions for but field 2 | |
|
Mads Ager (chromium)
2009/04/23 19:09:25
Bit positions for bit field 2?
Christian Plesner Hansen
2009/04/24 08:11:22
Whoops.
| |
| 2587 static const int kNeedsLoading = 0; | |
| 2588 | |
| 2564 private: | 2589 private: |
| 2565 DISALLOW_IMPLICIT_CONSTRUCTORS(Map); | 2590 DISALLOW_IMPLICIT_CONSTRUCTORS(Map); |
| 2566 }; | 2591 }; |
| 2567 | 2592 |
| 2568 | 2593 |
| 2569 // An abstract superclass, a marker class really, for simple structure classes. | 2594 // An abstract superclass, a marker class really, for simple structure classes. |
| 2570 // It doesn't carry much functionality but allows struct classes to me | 2595 // It doesn't carry much functionality but allows struct classes to me |
| 2571 // identified in the type system. | 2596 // identified in the type system. |
| 2572 class Struct: public HeapObject { | 2597 class Struct: public HeapObject { |
| 2573 public: | 2598 public: |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2670 | 2695 |
| 2671 // [instance class name]: class name for instances. | 2696 // [instance class name]: class name for instances. |
| 2672 DECL_ACCESSORS(instance_class_name, Object) | 2697 DECL_ACCESSORS(instance_class_name, Object) |
| 2673 | 2698 |
| 2674 // [function data]: This field has been added for make benefit the API. | 2699 // [function data]: This field has been added for make benefit the API. |
| 2675 // In the long run we don't want all functions to have this field but | 2700 // In the long run we don't want all functions to have this field but |
| 2676 // we can fix that when we have a better model for storing hidden data | 2701 // we can fix that when we have a better model for storing hidden data |
| 2677 // on objects. | 2702 // on objects. |
| 2678 DECL_ACCESSORS(function_data, Object) | 2703 DECL_ACCESSORS(function_data, Object) |
| 2679 | 2704 |
| 2680 // [lazy load data]: If the function has lazy loading, this field | |
| 2681 // contains contexts and other data needed to load it. | |
| 2682 DECL_ACCESSORS(lazy_load_data, Object) | |
| 2683 | |
| 2684 // [script info]: Script from which the function originates. | 2705 // [script info]: Script from which the function originates. |
| 2685 DECL_ACCESSORS(script, Object) | 2706 DECL_ACCESSORS(script, Object) |
| 2686 | 2707 |
| 2687 // [start_position_and_type]: Field used to store both the source code | 2708 // [start_position_and_type]: Field used to store both the source code |
| 2688 // position, whether or not the function is a function expression, | 2709 // position, whether or not the function is a function expression, |
| 2689 // and whether or not the function is a toplevel function. The two | 2710 // and whether or not the function is a toplevel function. The two |
| 2690 // least significants bit indicates whether the function is an | 2711 // least significants bit indicates whether the function is an |
| 2691 // expression and the rest contains the source code position. | 2712 // expression and the rest contains the source code position. |
| 2692 inline int start_position_and_type(); | 2713 inline int start_position_and_type(); |
| 2693 inline void set_start_position_and_type(int value); | 2714 inline void set_start_position_and_type(int value); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2747 static const int kNameOffset = HeapObject::kHeaderSize; | 2768 static const int kNameOffset = HeapObject::kHeaderSize; |
| 2748 static const int kCodeOffset = kNameOffset + kPointerSize; | 2769 static const int kCodeOffset = kNameOffset + kPointerSize; |
| 2749 static const int kLengthOffset = kCodeOffset + kPointerSize; | 2770 static const int kLengthOffset = kCodeOffset + kPointerSize; |
| 2750 static const int kFormalParameterCountOffset = kLengthOffset + kIntSize; | 2771 static const int kFormalParameterCountOffset = kLengthOffset + kIntSize; |
| 2751 static const int kExpectedNofPropertiesOffset = | 2772 static const int kExpectedNofPropertiesOffset = |
| 2752 kFormalParameterCountOffset + kIntSize; | 2773 kFormalParameterCountOffset + kIntSize; |
| 2753 static const int kInstanceClassNameOffset = | 2774 static const int kInstanceClassNameOffset = |
| 2754 kExpectedNofPropertiesOffset + kIntSize; | 2775 kExpectedNofPropertiesOffset + kIntSize; |
| 2755 static const int kExternalReferenceDataOffset = | 2776 static const int kExternalReferenceDataOffset = |
| 2756 kInstanceClassNameOffset + kPointerSize; | 2777 kInstanceClassNameOffset + kPointerSize; |
| 2757 static const int kLazyLoadDataOffset = | 2778 static const int kScriptOffset = kExternalReferenceDataOffset + kPointerSize; |
| 2758 kExternalReferenceDataOffset + kPointerSize; | |
| 2759 static const int kScriptOffset = kLazyLoadDataOffset + kPointerSize; | |
| 2760 static const int kStartPositionAndTypeOffset = kScriptOffset + kPointerSize; | 2779 static const int kStartPositionAndTypeOffset = kScriptOffset + kPointerSize; |
| 2761 static const int kEndPositionOffset = kStartPositionAndTypeOffset + kIntSize; | 2780 static const int kEndPositionOffset = kStartPositionAndTypeOffset + kIntSize; |
| 2762 static const int kFunctionTokenPositionOffset = kEndPositionOffset + kIntSize; | 2781 static const int kFunctionTokenPositionOffset = kEndPositionOffset + kIntSize; |
| 2763 static const int kDebugInfoOffset = kFunctionTokenPositionOffset + kIntSize; | 2782 static const int kDebugInfoOffset = kFunctionTokenPositionOffset + kIntSize; |
| 2764 static const int kInferredNameOffset = kDebugInfoOffset + kPointerSize; | 2783 static const int kInferredNameOffset = kDebugInfoOffset + kPointerSize; |
| 2765 static const int kSize = kInferredNameOffset + kPointerSize; | 2784 static const int kSize = kInferredNameOffset + kPointerSize; |
| 2766 | 2785 |
| 2767 private: | 2786 private: |
| 2768 // Bit positions in length_and_flg. | 2787 // Bit positions in length_and_flg. |
| 2769 // The least significant bit is used as the flag. | 2788 // The least significant bit is used as the flag. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2802 // when the function is invoked, e.g. foo() or new foo(). See | 2821 // when the function is invoked, e.g. foo() or new foo(). See |
| 2803 // [[Call]] and [[Construct]] description in ECMA-262, section | 2822 // [[Call]] and [[Construct]] description in ECMA-262, section |
| 2804 // 8.6.2, page 27. | 2823 // 8.6.2, page 27. |
| 2805 inline Code* code(); | 2824 inline Code* code(); |
| 2806 inline void set_code(Code* value); | 2825 inline void set_code(Code* value); |
| 2807 | 2826 |
| 2808 // Tells whether this function is a context-independent boilerplate | 2827 // Tells whether this function is a context-independent boilerplate |
| 2809 // function. | 2828 // function. |
| 2810 inline bool IsBoilerplate(); | 2829 inline bool IsBoilerplate(); |
| 2811 | 2830 |
| 2812 // Tells whether this function needs to be loaded. | |
| 2813 inline bool IsLoaded(); | |
| 2814 | |
| 2815 // [literals]: Fixed array holding the materialized literals. | 2831 // [literals]: Fixed array holding the materialized literals. |
| 2816 // | 2832 // |
| 2817 // If the function contains object, regexp or array literals, the | 2833 // If the function contains object, regexp or array literals, the |
| 2818 // literals array prefix contains the object, regexp, and array | 2834 // literals array prefix contains the object, regexp, and array |
| 2819 // function to be used when creating these literals. This is | 2835 // function to be used when creating these literals. This is |
| 2820 // necessary so that we do not dynamically lookup the object, regexp | 2836 // necessary so that we do not dynamically lookup the object, regexp |
| 2821 // or array functions. Performing a dynamic lookup, we might end up | 2837 // or array functions. Performing a dynamic lookup, we might end up |
| 2822 // using the functions from a new context that we should not have | 2838 // using the functions from a new context that we should not have |
| 2823 // access to. | 2839 // access to. |
| 2824 DECL_ACCESSORS(literals, FixedArray) | 2840 DECL_ACCESSORS(literals, FixedArray) |
| (...skipping 1522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4347 } else { | 4363 } else { |
| 4348 value &= ~(1 << bit_position); | 4364 value &= ~(1 << bit_position); |
| 4349 } | 4365 } |
| 4350 return value; | 4366 return value; |
| 4351 } | 4367 } |
| 4352 }; | 4368 }; |
| 4353 | 4369 |
| 4354 } } // namespace v8::internal | 4370 } } // namespace v8::internal |
| 4355 | 4371 |
| 4356 #endif // V8_OBJECTS_H_ | 4372 #endif // V8_OBJECTS_H_ |
| OLD | NEW |