OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 1410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1421 String* name, | 1421 String* name, |
1422 PropertyAttributes* attributes); | 1422 PropertyAttributes* attributes); |
1423 Object* GetLazyProperty(Object* receiver, | 1423 Object* GetLazyProperty(Object* receiver, |
1424 LookupResult* result, | 1424 LookupResult* result, |
1425 String* name, | 1425 String* name, |
1426 PropertyAttributes* attributes); | 1426 PropertyAttributes* attributes); |
1427 | 1427 |
1428 // Tells whether this object needs to be loaded. | 1428 // Tells whether this object needs to be loaded. |
1429 inline bool IsLoaded(); | 1429 inline bool IsLoaded(); |
1430 | 1430 |
| 1431 // Returns true if this is an instance of an api function and has |
| 1432 // been modified since it was created. May give false positives. |
| 1433 bool IsDirty(); |
| 1434 |
1431 bool HasProperty(String* name) { | 1435 bool HasProperty(String* name) { |
1432 return GetPropertyAttribute(name) != ABSENT; | 1436 return GetPropertyAttribute(name) != ABSENT; |
1433 } | 1437 } |
1434 | 1438 |
1435 // Can cause a GC if it hits an interceptor. | 1439 // Can cause a GC if it hits an interceptor. |
1436 bool HasLocalProperty(String* name) { | 1440 bool HasLocalProperty(String* name) { |
1437 return GetLocalPropertyAttribute(name) != ABSENT; | 1441 return GetLocalPropertyAttribute(name) != ABSENT; |
1438 } | 1442 } |
1439 | 1443 |
1440 Object* DeleteProperty(String* name, DeleteMode mode); | 1444 Object* DeleteProperty(String* name, DeleteMode mode); |
(...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2509 // Pseudo-kinds. | 2513 // Pseudo-kinds. |
2510 REGEXP = BUILTIN, | 2514 REGEXP = BUILTIN, |
2511 FIRST_IC_KIND = LOAD_IC, | 2515 FIRST_IC_KIND = LOAD_IC, |
2512 LAST_IC_KIND = KEYED_STORE_IC | 2516 LAST_IC_KIND = KEYED_STORE_IC |
2513 }; | 2517 }; |
2514 | 2518 |
2515 enum { | 2519 enum { |
2516 NUMBER_OF_KINDS = KEYED_STORE_IC + 1 | 2520 NUMBER_OF_KINDS = KEYED_STORE_IC + 1 |
2517 }; | 2521 }; |
2518 | 2522 |
2519 // A state indicates that inline cache in this Code object contains | |
2520 // objects or relative instruction addresses. | |
2521 enum ICTargetState { | |
2522 IC_TARGET_IS_ADDRESS, | |
2523 IC_TARGET_IS_OBJECT | |
2524 }; | |
2525 | |
2526 #ifdef ENABLE_DISASSEMBLER | 2523 #ifdef ENABLE_DISASSEMBLER |
2527 // Printing | 2524 // Printing |
2528 static const char* Kind2String(Kind kind); | 2525 static const char* Kind2String(Kind kind); |
2529 static const char* ICState2String(InlineCacheState state); | 2526 static const char* ICState2String(InlineCacheState state); |
2530 static const char* PropertyType2String(PropertyType type); | 2527 static const char* PropertyType2String(PropertyType type); |
2531 void Disassemble(const char* name); | 2528 void Disassemble(const char* name); |
2532 #endif // ENABLE_DISASSEMBLER | 2529 #endif // ENABLE_DISASSEMBLER |
2533 | 2530 |
2534 // [instruction_size]: Size of the native instructions | 2531 // [instruction_size]: Size of the native instructions |
2535 inline int instruction_size(); | 2532 inline int instruction_size(); |
(...skipping 19 matching lines...) Expand all Loading... |
2555 inline int arguments_count(); // Only valid for call IC stubs. | 2552 inline int arguments_count(); // Only valid for call IC stubs. |
2556 | 2553 |
2557 // Testers for IC stub kinds. | 2554 // Testers for IC stub kinds. |
2558 inline bool is_inline_cache_stub(); | 2555 inline bool is_inline_cache_stub(); |
2559 inline bool is_load_stub() { return kind() == LOAD_IC; } | 2556 inline bool is_load_stub() { return kind() == LOAD_IC; } |
2560 inline bool is_keyed_load_stub() { return kind() == KEYED_LOAD_IC; } | 2557 inline bool is_keyed_load_stub() { return kind() == KEYED_LOAD_IC; } |
2561 inline bool is_store_stub() { return kind() == STORE_IC; } | 2558 inline bool is_store_stub() { return kind() == STORE_IC; } |
2562 inline bool is_keyed_store_stub() { return kind() == KEYED_STORE_IC; } | 2559 inline bool is_keyed_store_stub() { return kind() == KEYED_STORE_IC; } |
2563 inline bool is_call_stub() { return kind() == CALL_IC; } | 2560 inline bool is_call_stub() { return kind() == CALL_IC; } |
2564 | 2561 |
2565 // [ic_flag]: State of inline cache targets. The flag is set to the | |
2566 // object variant in ConvertICTargetsFromAddressToObject, and set to | |
2567 // the address variant in ConvertICTargetsFromObjectToAddress. | |
2568 inline ICTargetState ic_flag(); | |
2569 inline void set_ic_flag(ICTargetState value); | |
2570 | |
2571 // [major_key]: For kind STUB, the major key. | 2562 // [major_key]: For kind STUB, the major key. |
2572 inline CodeStub::Major major_key(); | 2563 inline CodeStub::Major major_key(); |
2573 inline void set_major_key(CodeStub::Major major); | 2564 inline void set_major_key(CodeStub::Major major); |
2574 | 2565 |
2575 // Flags operations. | 2566 // Flags operations. |
2576 static inline Flags ComputeFlags(Kind kind, | 2567 static inline Flags ComputeFlags(Kind kind, |
2577 InLoopFlag in_loop = NOT_IN_LOOP, | 2568 InLoopFlag in_loop = NOT_IN_LOOP, |
2578 InlineCacheState ic_state = UNINITIALIZED, | 2569 InlineCacheState ic_state = UNINITIALIZED, |
2579 PropertyType type = NORMAL, | 2570 PropertyType type = NORMAL, |
2580 int argc = -1); | 2571 int argc = -1); |
(...skipping 25 matching lines...) Expand all Loading... |
2606 | 2597 |
2607 // Code entry point. | 2598 // Code entry point. |
2608 inline byte* entry(); | 2599 inline byte* entry(); |
2609 | 2600 |
2610 // Returns true if pc is inside this object's instructions. | 2601 // Returns true if pc is inside this object's instructions. |
2611 inline bool contains(byte* pc); | 2602 inline bool contains(byte* pc); |
2612 | 2603 |
2613 // Returns the address of the scope information. | 2604 // Returns the address of the scope information. |
2614 inline byte* sinfo_start(); | 2605 inline byte* sinfo_start(); |
2615 | 2606 |
2616 // Convert inline cache target from address to code object before GC. | |
2617 void ConvertICTargetsFromAddressToObject(); | |
2618 | |
2619 // Convert inline cache target from code object to address after GC | |
2620 void ConvertICTargetsFromObjectToAddress(); | |
2621 | |
2622 // Relocate the code by delta bytes. Called to signal that this code | 2607 // Relocate the code by delta bytes. Called to signal that this code |
2623 // object has been moved by delta bytes. | 2608 // object has been moved by delta bytes. |
2624 void Relocate(int delta); | 2609 void Relocate(int delta); |
2625 | 2610 |
2626 // Migrate code described by desc. | 2611 // Migrate code described by desc. |
2627 void CopyFrom(const CodeDesc& desc); | 2612 void CopyFrom(const CodeDesc& desc); |
2628 | 2613 |
2629 // Returns the object size for a given body and sinfo size (Used for | 2614 // Returns the object size for a given body and sinfo size (Used for |
2630 // allocation). | 2615 // allocation). |
2631 static int SizeFor(int body_size, int sinfo_size) { | 2616 static int SizeFor(int body_size, int sinfo_size) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2667 static const int kSInfoSizeOffset = kRelocationSizeOffset + kIntSize; | 2652 static const int kSInfoSizeOffset = kRelocationSizeOffset + kIntSize; |
2668 static const int kFlagsOffset = kSInfoSizeOffset + kIntSize; | 2653 static const int kFlagsOffset = kSInfoSizeOffset + kIntSize; |
2669 static const int kKindSpecificFlagsOffset = kFlagsOffset + kIntSize; | 2654 static const int kKindSpecificFlagsOffset = kFlagsOffset + kIntSize; |
2670 // Add padding to align the instruction start following right after | 2655 // Add padding to align the instruction start following right after |
2671 // the Code object header. | 2656 // the Code object header. |
2672 static const int kHeaderSize = | 2657 static const int kHeaderSize = |
2673 (kKindSpecificFlagsOffset + kIntSize + kCodeAlignmentMask) & | 2658 (kKindSpecificFlagsOffset + kIntSize + kCodeAlignmentMask) & |
2674 ~kCodeAlignmentMask; | 2659 ~kCodeAlignmentMask; |
2675 | 2660 |
2676 // Byte offsets within kKindSpecificFlagsOffset. | 2661 // Byte offsets within kKindSpecificFlagsOffset. |
2677 static const int kICFlagOffset = kKindSpecificFlagsOffset + 0; | |
2678 static const int kStubMajorKeyOffset = kKindSpecificFlagsOffset + 1; | 2662 static const int kStubMajorKeyOffset = kKindSpecificFlagsOffset + 1; |
2679 | 2663 |
2680 // Flags layout. | 2664 // Flags layout. |
2681 static const int kFlagsICStateShift = 0; | 2665 static const int kFlagsICStateShift = 0; |
2682 static const int kFlagsICInLoopShift = 3; | 2666 static const int kFlagsICInLoopShift = 3; |
2683 static const int kFlagsKindShift = 4; | 2667 static const int kFlagsKindShift = 4; |
2684 static const int kFlagsTypeShift = 7; | 2668 static const int kFlagsTypeShift = 7; |
2685 static const int kFlagsArgumentsCountShift = 10; | 2669 static const int kFlagsArgumentsCountShift = 10; |
2686 | 2670 |
2687 static const int kFlagsICStateMask = 0x00000007; // 0000000111 | 2671 static const int kFlagsICStateMask = 0x00000007; // 0000000111 |
(...skipping 2111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4799 public: | 4783 public: |
4800 virtual ~ObjectVisitor() {} | 4784 virtual ~ObjectVisitor() {} |
4801 | 4785 |
4802 // Visits a contiguous arrays of pointers in the half-open range | 4786 // Visits a contiguous arrays of pointers in the half-open range |
4803 // [start, end). Any or all of the values may be modified on return. | 4787 // [start, end). Any or all of the values may be modified on return. |
4804 virtual void VisitPointers(Object** start, Object** end) = 0; | 4788 virtual void VisitPointers(Object** start, Object** end) = 0; |
4805 | 4789 |
4806 // To allow lazy clearing of inline caches the visitor has | 4790 // To allow lazy clearing of inline caches the visitor has |
4807 // a rich interface for iterating over Code objects.. | 4791 // a rich interface for iterating over Code objects.. |
4808 | 4792 |
4809 // Called prior to visiting the body of a Code object. | |
4810 virtual void BeginCodeIteration(Code* code); | |
4811 | |
4812 // Visits a code target in the instruction stream. | 4793 // Visits a code target in the instruction stream. |
4813 virtual void VisitCodeTarget(RelocInfo* rinfo); | 4794 virtual void VisitCodeTarget(RelocInfo* rinfo); |
4814 | 4795 |
4815 // Visits a runtime entry in the instruction stream. | 4796 // Visits a runtime entry in the instruction stream. |
4816 virtual void VisitRuntimeEntry(RelocInfo* rinfo) {} | 4797 virtual void VisitRuntimeEntry(RelocInfo* rinfo) {} |
4817 | 4798 |
4818 // Visits a debug call target in the instruction stream. | 4799 // Visits a debug call target in the instruction stream. |
4819 virtual void VisitDebugTarget(RelocInfo* rinfo); | 4800 virtual void VisitDebugTarget(RelocInfo* rinfo); |
4820 | 4801 |
4821 // Called after completing visiting the body of a Code object. | |
4822 virtual void EndCodeIteration(Code* code) {} | |
4823 | |
4824 // Handy shorthand for visiting a single pointer. | 4802 // Handy shorthand for visiting a single pointer. |
4825 virtual void VisitPointer(Object** p) { VisitPointers(p, p + 1); } | 4803 virtual void VisitPointer(Object** p) { VisitPointers(p, p + 1); } |
4826 | 4804 |
4827 // Visits a contiguous arrays of external references (references to the C++ | 4805 // Visits a contiguous arrays of external references (references to the C++ |
4828 // heap) in the half-open range [start, end). Any or all of the values | 4806 // heap) in the half-open range [start, end). Any or all of the values |
4829 // may be modified on return. | 4807 // may be modified on return. |
4830 virtual void VisitExternalReferences(Address* start, Address* end) {} | 4808 virtual void VisitExternalReferences(Address* start, Address* end) {} |
4831 | 4809 |
4832 inline void VisitExternalReference(Address* p) { | 4810 inline void VisitExternalReference(Address* p) { |
4833 VisitExternalReferences(p, p + 1); | 4811 VisitExternalReferences(p, p + 1); |
(...skipping 29 matching lines...) Expand all Loading... |
4863 } else { | 4841 } else { |
4864 value &= ~(1 << bit_position); | 4842 value &= ~(1 << bit_position); |
4865 } | 4843 } |
4866 return value; | 4844 return value; |
4867 } | 4845 } |
4868 }; | 4846 }; |
4869 | 4847 |
4870 } } // namespace v8::internal | 4848 } } // namespace v8::internal |
4871 | 4849 |
4872 #endif // V8_OBJECTS_H_ | 4850 #endif // V8_OBJECTS_H_ |
OLD | NEW |