| 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 2502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2513 // Pseudo-kinds. | 2513 // Pseudo-kinds. |
| 2514 REGEXP = BUILTIN, | 2514 REGEXP = BUILTIN, |
| 2515 FIRST_IC_KIND = LOAD_IC, | 2515 FIRST_IC_KIND = LOAD_IC, |
| 2516 LAST_IC_KIND = KEYED_STORE_IC | 2516 LAST_IC_KIND = KEYED_STORE_IC |
| 2517 }; | 2517 }; |
| 2518 | 2518 |
| 2519 enum { | 2519 enum { |
| 2520 NUMBER_OF_KINDS = KEYED_STORE_IC + 1 | 2520 NUMBER_OF_KINDS = KEYED_STORE_IC + 1 |
| 2521 }; | 2521 }; |
| 2522 | 2522 |
| 2523 // A state indicates that inline cache in this Code object contains | |
| 2524 // objects or relative instruction addresses. | |
| 2525 enum ICTargetState { | |
| 2526 IC_TARGET_IS_ADDRESS, | |
| 2527 IC_TARGET_IS_OBJECT | |
| 2528 }; | |
| 2529 | |
| 2530 #ifdef ENABLE_DISASSEMBLER | 2523 #ifdef ENABLE_DISASSEMBLER |
| 2531 // Printing | 2524 // Printing |
| 2532 static const char* Kind2String(Kind kind); | 2525 static const char* Kind2String(Kind kind); |
| 2533 static const char* ICState2String(InlineCacheState state); | 2526 static const char* ICState2String(InlineCacheState state); |
| 2534 static const char* PropertyType2String(PropertyType type); | 2527 static const char* PropertyType2String(PropertyType type); |
| 2535 void Disassemble(const char* name); | 2528 void Disassemble(const char* name); |
| 2536 #endif // ENABLE_DISASSEMBLER | 2529 #endif // ENABLE_DISASSEMBLER |
| 2537 | 2530 |
| 2538 // [instruction_size]: Size of the native instructions | 2531 // [instruction_size]: Size of the native instructions |
| 2539 inline int instruction_size(); | 2532 inline int instruction_size(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2559 inline int arguments_count(); // Only valid for call IC stubs. | 2552 inline int arguments_count(); // Only valid for call IC stubs. |
| 2560 | 2553 |
| 2561 // Testers for IC stub kinds. | 2554 // Testers for IC stub kinds. |
| 2562 inline bool is_inline_cache_stub(); | 2555 inline bool is_inline_cache_stub(); |
| 2563 inline bool is_load_stub() { return kind() == LOAD_IC; } | 2556 inline bool is_load_stub() { return kind() == LOAD_IC; } |
| 2564 inline bool is_keyed_load_stub() { return kind() == KEYED_LOAD_IC; } | 2557 inline bool is_keyed_load_stub() { return kind() == KEYED_LOAD_IC; } |
| 2565 inline bool is_store_stub() { return kind() == STORE_IC; } | 2558 inline bool is_store_stub() { return kind() == STORE_IC; } |
| 2566 inline bool is_keyed_store_stub() { return kind() == KEYED_STORE_IC; } | 2559 inline bool is_keyed_store_stub() { return kind() == KEYED_STORE_IC; } |
| 2567 inline bool is_call_stub() { return kind() == CALL_IC; } | 2560 inline bool is_call_stub() { return kind() == CALL_IC; } |
| 2568 | 2561 |
| 2569 // [ic_flag]: State of inline cache targets. The flag is set to the | |
| 2570 // object variant in ConvertICTargetsFromAddressToObject, and set to | |
| 2571 // the address variant in ConvertICTargetsFromObjectToAddress. | |
| 2572 inline ICTargetState ic_flag(); | |
| 2573 inline void set_ic_flag(ICTargetState value); | |
| 2574 | |
| 2575 // [major_key]: For kind STUB, the major key. | 2562 // [major_key]: For kind STUB, the major key. |
| 2576 inline CodeStub::Major major_key(); | 2563 inline CodeStub::Major major_key(); |
| 2577 inline void set_major_key(CodeStub::Major major); | 2564 inline void set_major_key(CodeStub::Major major); |
| 2578 | 2565 |
| 2579 // Flags operations. | 2566 // Flags operations. |
| 2580 static inline Flags ComputeFlags(Kind kind, | 2567 static inline Flags ComputeFlags(Kind kind, |
| 2581 InLoopFlag in_loop = NOT_IN_LOOP, | 2568 InLoopFlag in_loop = NOT_IN_LOOP, |
| 2582 InlineCacheState ic_state = UNINITIALIZED, | 2569 InlineCacheState ic_state = UNINITIALIZED, |
| 2583 PropertyType type = NORMAL, | 2570 PropertyType type = NORMAL, |
| 2584 int argc = -1); | 2571 int argc = -1); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2610 | 2597 |
| 2611 // Code entry point. | 2598 // Code entry point. |
| 2612 inline byte* entry(); | 2599 inline byte* entry(); |
| 2613 | 2600 |
| 2614 // Returns true if pc is inside this object's instructions. | 2601 // Returns true if pc is inside this object's instructions. |
| 2615 inline bool contains(byte* pc); | 2602 inline bool contains(byte* pc); |
| 2616 | 2603 |
| 2617 // Returns the address of the scope information. | 2604 // Returns the address of the scope information. |
| 2618 inline byte* sinfo_start(); | 2605 inline byte* sinfo_start(); |
| 2619 | 2606 |
| 2620 // Convert inline cache target from address to code object before GC. | |
| 2621 void ConvertICTargetsFromAddressToObject(); | |
| 2622 | |
| 2623 // Convert inline cache target from code object to address after GC | |
| 2624 void ConvertICTargetsFromObjectToAddress(); | |
| 2625 | |
| 2626 // 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 |
| 2627 // object has been moved by delta bytes. | 2608 // object has been moved by delta bytes. |
| 2628 void Relocate(int delta); | 2609 void Relocate(int delta); |
| 2629 | 2610 |
| 2630 // Migrate code described by desc. | 2611 // Migrate code described by desc. |
| 2631 void CopyFrom(const CodeDesc& desc); | 2612 void CopyFrom(const CodeDesc& desc); |
| 2632 | 2613 |
| 2633 // 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 |
| 2634 // allocation). | 2615 // allocation). |
| 2635 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... |
| 2671 static const int kSInfoSizeOffset = kRelocationSizeOffset + kIntSize; | 2652 static const int kSInfoSizeOffset = kRelocationSizeOffset + kIntSize; |
| 2672 static const int kFlagsOffset = kSInfoSizeOffset + kIntSize; | 2653 static const int kFlagsOffset = kSInfoSizeOffset + kIntSize; |
| 2673 static const int kKindSpecificFlagsOffset = kFlagsOffset + kIntSize; | 2654 static const int kKindSpecificFlagsOffset = kFlagsOffset + kIntSize; |
| 2674 // Add padding to align the instruction start following right after | 2655 // Add padding to align the instruction start following right after |
| 2675 // the Code object header. | 2656 // the Code object header. |
| 2676 static const int kHeaderSize = | 2657 static const int kHeaderSize = |
| 2677 (kKindSpecificFlagsOffset + kIntSize + kCodeAlignmentMask) & | 2658 (kKindSpecificFlagsOffset + kIntSize + kCodeAlignmentMask) & |
| 2678 ~kCodeAlignmentMask; | 2659 ~kCodeAlignmentMask; |
| 2679 | 2660 |
| 2680 // Byte offsets within kKindSpecificFlagsOffset. | 2661 // Byte offsets within kKindSpecificFlagsOffset. |
| 2681 static const int kICFlagOffset = kKindSpecificFlagsOffset + 0; | |
| 2682 static const int kStubMajorKeyOffset = kKindSpecificFlagsOffset + 1; | 2662 static const int kStubMajorKeyOffset = kKindSpecificFlagsOffset + 1; |
| 2683 | 2663 |
| 2684 // Flags layout. | 2664 // Flags layout. |
| 2685 static const int kFlagsICStateShift = 0; | 2665 static const int kFlagsICStateShift = 0; |
| 2686 static const int kFlagsICInLoopShift = 3; | 2666 static const int kFlagsICInLoopShift = 3; |
| 2687 static const int kFlagsKindShift = 4; | 2667 static const int kFlagsKindShift = 4; |
| 2688 static const int kFlagsTypeShift = 7; | 2668 static const int kFlagsTypeShift = 7; |
| 2689 static const int kFlagsArgumentsCountShift = 10; | 2669 static const int kFlagsArgumentsCountShift = 10; |
| 2690 | 2670 |
| 2691 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... |
| 4803 public: | 4783 public: |
| 4804 virtual ~ObjectVisitor() {} | 4784 virtual ~ObjectVisitor() {} |
| 4805 | 4785 |
| 4806 // Visits a contiguous arrays of pointers in the half-open range | 4786 // Visits a contiguous arrays of pointers in the half-open range |
| 4807 // [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. |
| 4808 virtual void VisitPointers(Object** start, Object** end) = 0; | 4788 virtual void VisitPointers(Object** start, Object** end) = 0; |
| 4809 | 4789 |
| 4810 // To allow lazy clearing of inline caches the visitor has | 4790 // To allow lazy clearing of inline caches the visitor has |
| 4811 // a rich interface for iterating over Code objects.. | 4791 // a rich interface for iterating over Code objects.. |
| 4812 | 4792 |
| 4813 // Called prior to visiting the body of a Code object. | |
| 4814 virtual void BeginCodeIteration(Code* code); | |
| 4815 | |
| 4816 // Visits a code target in the instruction stream. | 4793 // Visits a code target in the instruction stream. |
| 4817 virtual void VisitCodeTarget(RelocInfo* rinfo); | 4794 virtual void VisitCodeTarget(RelocInfo* rinfo); |
| 4818 | 4795 |
| 4819 // Visits a runtime entry in the instruction stream. | 4796 // Visits a runtime entry in the instruction stream. |
| 4820 virtual void VisitRuntimeEntry(RelocInfo* rinfo) {} | 4797 virtual void VisitRuntimeEntry(RelocInfo* rinfo) {} |
| 4821 | 4798 |
| 4822 // Visits a debug call target in the instruction stream. | 4799 // Visits a debug call target in the instruction stream. |
| 4823 virtual void VisitDebugTarget(RelocInfo* rinfo); | 4800 virtual void VisitDebugTarget(RelocInfo* rinfo); |
| 4824 | 4801 |
| 4825 // Called after completing visiting the body of a Code object. | |
| 4826 virtual void EndCodeIteration(Code* code) {} | |
| 4827 | |
| 4828 // Handy shorthand for visiting a single pointer. | 4802 // Handy shorthand for visiting a single pointer. |
| 4829 virtual void VisitPointer(Object** p) { VisitPointers(p, p + 1); } | 4803 virtual void VisitPointer(Object** p) { VisitPointers(p, p + 1); } |
| 4830 | 4804 |
| 4831 // Visits a contiguous arrays of external references (references to the C++ | 4805 // Visits a contiguous arrays of external references (references to the C++ |
| 4832 // 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 |
| 4833 // may be modified on return. | 4807 // may be modified on return. |
| 4834 virtual void VisitExternalReferences(Address* start, Address* end) {} | 4808 virtual void VisitExternalReferences(Address* start, Address* end) {} |
| 4835 | 4809 |
| 4836 inline void VisitExternalReference(Address* p) { | 4810 inline void VisitExternalReference(Address* p) { |
| 4837 VisitExternalReferences(p, p + 1); | 4811 VisitExternalReferences(p, p + 1); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 4867 } else { | 4841 } else { |
| 4868 value &= ~(1 << bit_position); | 4842 value &= ~(1 << bit_position); |
| 4869 } | 4843 } |
| 4870 return value; | 4844 return value; |
| 4871 } | 4845 } |
| 4872 }; | 4846 }; |
| 4873 | 4847 |
| 4874 } } // namespace v8::internal | 4848 } } // namespace v8::internal |
| 4875 | 4849 |
| 4876 #endif // V8_OBJECTS_H_ | 4850 #endif // V8_OBJECTS_H_ |
| OLD | NEW |