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

Side by Side Diff: include/v8.h

Issue 196139: X64: Convert smis to holding 32 bits of payload. (Closed)
Patch Set: Addressed review comments. Forwarded to head. Created 11 years, 2 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
« no previous file with comments | « SConstruct ('k') | src/api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2007-2009 the V8 project authors. All rights reserved. 1 // Copyright 2007-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 2701 matching lines...) Expand 10 before | Expand all | Expand 10 after
2712 2712
2713 2713
2714 namespace internal { 2714 namespace internal {
2715 2715
2716 2716
2717 // Tag information for HeapObject. 2717 // Tag information for HeapObject.
2718 const int kHeapObjectTag = 1; 2718 const int kHeapObjectTag = 1;
2719 const int kHeapObjectTagSize = 2; 2719 const int kHeapObjectTagSize = 2;
2720 const intptr_t kHeapObjectTagMask = (1 << kHeapObjectTagSize) - 1; 2720 const intptr_t kHeapObjectTagMask = (1 << kHeapObjectTagSize) - 1;
2721 2721
2722 2722 #ifdef V8_LONG_SMI
2723 #ifndef V8_TARGET_ARCH_X64
2724 #error "Large smis on non-64-bit platform."
2725 #endif
2723 // Tag information for Smi. 2726 // Tag information for Smi.
2724 const int kSmiTag = 0; 2727 const int kSmiTag = 0;
2725 const int kSmiTagSize = 1; 2728 const int kSmiTagSize = 1;
2726 const intptr_t kSmiTagMask = (1 << kSmiTagSize) - 1; 2729 const intptr_t kSmiTagMask = (1 << kSmiTagSize) - 1;
2727 2730 const int kSmiShiftSize = 31;
2731 const int kSmiValueSize = 32;
2732 #else
2733 // Tag information for Smi.
2734 const int kSmiTag = 0;
2735 const int kSmiTagSize = 1;
2736 const intptr_t kSmiTagMask = (1 << kSmiTagSize) - 1;
2737 const int kSmiShiftSize = 0;
2738 const int kSmiValueSize = 31;
2739 #endif
2728 2740
2729 /** 2741 /**
2730 * This class exports constants and functionality from within v8 that 2742 * This class exports constants and functionality from within v8 that
2731 * is necessary to implement inline functions in the v8 api. Don't 2743 * is necessary to implement inline functions in the v8 api. Don't
2732 * depend on functions and constants defined here. 2744 * depend on functions and constants defined here.
2733 */ 2745 */
2734 class Internals { 2746 class Internals {
2735 public: 2747 public:
2736 2748
2737 // These values match non-compiler-dependent values defined within 2749 // These values match non-compiler-dependent values defined within
(...skipping 16 matching lines...) Expand all
2754 static inline bool HasHeapObjectTag(internal::Object* value) { 2766 static inline bool HasHeapObjectTag(internal::Object* value) {
2755 return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) == 2767 return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) ==
2756 kHeapObjectTag); 2768 kHeapObjectTag);
2757 } 2769 }
2758 2770
2759 static inline bool HasSmiTag(internal::Object* value) { 2771 static inline bool HasSmiTag(internal::Object* value) {
2760 return ((reinterpret_cast<intptr_t>(value) & kSmiTagMask) == kSmiTag); 2772 return ((reinterpret_cast<intptr_t>(value) & kSmiTagMask) == kSmiTag);
2761 } 2773 }
2762 2774
2763 static inline int SmiValue(internal::Object* value) { 2775 static inline int SmiValue(internal::Object* value) {
2764 return static_cast<int>(reinterpret_cast<intptr_t>(value)) >> kSmiTagSize; 2776 #ifdef V8_LONG_SMI
2777 int shift_bits = kSmiTagSize + kSmiShiftSize;
2778 // Shift down and throw away top 32 bits.
2779 return static_cast<int>(reinterpret_cast<intptr_t>(value) >> shift_bits);
2780 #else
2781 int shift_bits = kSmiTagSize + kSmiShiftSize;
2782 // Throw away top 32 bits and shift down (requires >> to be sign extending).
2783 return static_cast<int>(reinterpret_cast<intptr_t>(value)) >> shift_bits;
2784 #endif
2765 } 2785 }
2766 2786
2767 static inline bool IsExternalTwoByteString(int instance_type) { 2787 static inline bool IsExternalTwoByteString(int instance_type) {
2768 int representation = (instance_type & kFullStringRepresentationMask); 2788 int representation = (instance_type & kFullStringRepresentationMask);
2769 return representation == kExternalTwoByteRepresentationTag; 2789 return representation == kExternalTwoByteRepresentationTag;
2770 } 2790 }
2771 2791
2772 template <typename T> 2792 template <typename T>
2773 static inline T ReadField(Object* ptr, int offset) { 2793 static inline T ReadField(Object* ptr, int offset) {
2774 uint8_t* addr = reinterpret_cast<uint8_t*>(ptr) + offset - kHeapObjectTag; 2794 uint8_t* addr = reinterpret_cast<uint8_t*>(ptr) + offset - kHeapObjectTag;
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
3102 3122
3103 } // namespace v8 3123 } // namespace v8
3104 3124
3105 3125
3106 #undef V8EXPORT 3126 #undef V8EXPORT
3107 #undef V8EXPORT_INLINE 3127 #undef V8EXPORT_INLINE
3108 #undef TYPE_CHECK 3128 #undef TYPE_CHECK
3109 3129
3110 3130
3111 #endif // V8_H_ 3131 #endif // V8_H_
OLDNEW
« no previous file with comments | « SConstruct ('k') | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698