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

Side by Side Diff: src/globals.h

Issue 100336: Include 64-bit pointer and constant types in include/v8.h.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « include/v8.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 10 matching lines...) Expand all
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #ifndef V8_GLOBALS_H_ 28 #ifndef V8_GLOBALS_H_
29 #define V8_GLOBALS_H_ 29 #define V8_GLOBALS_H_
30 30
31 // -----------------------------------------------------------------------------
32 // Types
33 // Visual Studio C++ is missing the stdint.h header file. Instead we define
34 // standard integer types for Windows here.
35
36 #ifdef _MSC_VER
37 typedef signed char int8_t;
38 typedef unsigned char uint8_t;
39 typedef short int16_t; // NOLINT
40 typedef unsigned short uint16_t; // NOLINT
41 typedef int int32_t;
42 typedef unsigned int uint32_t;
43 typedef __int64 int64_t;
44 typedef unsigned __int64 uint64_t;
45 #else // _MSC_VER
46 #include <stdint.h> // for intptr_t
47 #endif // _MSC_VER
48
49
50 namespace v8 { namespace internal { 31 namespace v8 { namespace internal {
51 32
52 // Support for alternative bool type. This is only enabled if the code is 33 // Support for alternative bool type. This is only enabled if the code is
53 // compiled with USE_MYBOOL defined. This catches some nasty type bugs. 34 // compiled with USE_MYBOOL defined. This catches some nasty type bugs.
54 // For instance, 'bool b = "false";' results in b == true! This is a hidden 35 // For instance, 'bool b = "false";' results in b == true! This is a hidden
55 // source of bugs. 36 // source of bugs.
56 // However, redefining the bool type does have some negative impact on some 37 // However, redefining the bool type does have some negative impact on some
57 // platforms. It gives rise to compiler warnings (i.e. with 38 // platforms. It gives rise to compiler warnings (i.e. with
58 // MSVC) in the API header files when mixing code that uses the standard 39 // MSVC) in the API header files when mixing code that uses the standard
59 // bool with code that uses the redefined version. 40 // bool with code that uses the redefined version.
60 // This does not actually belong in the platform code, but needs to be 41 // This does not actually belong in the platform code, but needs to be
61 // defined here because the platform code uses bool, and platform.h is 42 // defined here because the platform code uses bool, and platform.h is
62 // include very early in the main include file. 43 // include very early in the main include file.
63 44
64 #ifdef USE_MYBOOL 45 #ifdef USE_MYBOOL
65 typedef unsigned int __my_bool__; 46 typedef unsigned int __my_bool__;
66 #define bool __my_bool__ // use 'indirection' to avoid name clashes 47 #define bool __my_bool__ // use 'indirection' to avoid name clashes
67 #endif 48 #endif
68 49
69 typedef uint8_t byte; 50 typedef uint8_t byte;
70 typedef byte* Address; 51 typedef byte* Address;
71 52
53 // Define macros for writing 64-bit constants and pointer-size constants.
54 #ifdef _MSC_VER
55 #define UINT64_C(x) (x ## UI64)
56 #define INT64_C(x) (x ## I64)
57 #else
58 #define UINT64_C(x) (x ## ULL)
59 #define INT64_C(x) (x ## LL)
Dean McNamee 2009/05/04 16:09:52 We should use our own names here. Also, the stdin
60 #endif
61
72 // Code-point values in Unicode 4.0 are 21 bits wide. 62 // Code-point values in Unicode 4.0 are 21 bits wide.
73 typedef uint16_t uc16; 63 typedef uint16_t uc16;
74 typedef signed int uc32; 64 typedef int32_t uc32;
75 65
76 #if defined(V8_ARCH_IA32) || defined(V8_ARCH_X64) 66 #if defined(V8_ARCH_IA32) || defined(V8_ARCH_X64)
77 #define CAN_READ_UNALIGNED 1 67 #define CAN_READ_UNALIGNED 1
78 #endif 68 #endif
79 69
80 // ----------------------------------------------------------------------------- 70 // -----------------------------------------------------------------------------
81 // Constants 71 // Constants
82 72
83 const int KB = 1024; 73 const int KB = 1024;
84 const int MB = KB * KB; 74 const int MB = KB * KB;
85 const int GB = KB * KB * KB; 75 const int GB = KB * KB * KB;
86 const int kMaxInt = 0x7FFFFFFF; 76 const int kMaxInt = 0x7FFFFFFF;
87 const int kMinInt = -kMaxInt - 1; 77 const int kMinInt = -kMaxInt - 1;
88 78
89 const uint32_t kMaxUInt32 = 0xFFFFFFFFu; 79 const uint32_t kMaxUInt32 = 0xFFFFFFFFu;
90 80
91 const int kCharSize = sizeof(char); // NOLINT 81 const int kCharSize = sizeof(char); // NOLINT
92 const int kShortSize = sizeof(short); // NOLINT 82 const int kShortSize = sizeof(short); // NOLINT
93 const int kIntSize = sizeof(int); // NOLINT 83 const int kIntSize = sizeof(int); // NOLINT
94 const int kDoubleSize = sizeof(double); // NOLINT 84 const int kDoubleSize = sizeof(double); // NOLINT
95 const int kPointerSize = sizeof(void*); // NOLINT 85 const int kPointerSize = sizeof(void*); // NOLINT
96 86
87 #ifdef V8_ARCH_X64
iposva 2009/05/04 17:00:55 There are potentially other 64-bit architectures o
88 const int kPointerSizeLog2 = 3;
89 #else
97 const int kPointerSizeLog2 = 2; 90 const int kPointerSizeLog2 = 2;
91 #endif
98 92
99 const int kObjectAlignmentBits = 2; 93 const int kObjectAlignmentBits = kPointerSizeLog2;
100 const int kObjectAlignmentMask = (1 << kObjectAlignmentBits) - 1; 94 const intptr_t kObjectAlignmentMask = (1 << kObjectAlignmentBits) - 1;
101 const int kObjectAlignment = 1 << kObjectAlignmentBits; 95 const intptr_t kObjectAlignment = 1 << kObjectAlignmentBits;
102 96
103 97
104 // Tag information for HeapObject. 98 // Tag information for HeapObject.
105 const int kHeapObjectTag = 1; 99 const int kHeapObjectTag = 1;
106 const int kHeapObjectTagSize = 2; 100 const int kHeapObjectTagSize = 2;
107 const int kHeapObjectTagMask = (1 << kHeapObjectTagSize) - 1; 101 const intptr_t kHeapObjectTagMask = (1 << kHeapObjectTagSize) - 1;
108 102
109 103
110 // Tag information for Smi. 104 // Tag information for Smi.
111 const int kSmiTag = 0; 105 const int kSmiTag = 0;
112 const int kSmiTagSize = 1; 106 const int kSmiTagSize = 1;
113 const int kSmiTagMask = (1 << kSmiTagSize) - 1; 107 const intptr_t kSmiTagMask = (1 << kSmiTagSize) - 1;
114 108
115 109
116 // Tag information for Failure. 110 // Tag information for Failure.
117 const int kFailureTag = 3; 111 const int kFailureTag = 3;
118 const int kFailureTagSize = 2; 112 const int kFailureTagSize = 2;
119 const int kFailureTagMask = (1 << kFailureTagSize) - 1; 113 const intptr_t kFailureTagMask = (1 << kFailureTagSize) - 1;
120 114
121 115
122 const int kBitsPerByte = 8; 116 const int kBitsPerByte = 8;
123 const int kBitsPerByteLog2 = 3; 117 const int kBitsPerByteLog2 = 3;
124 const int kBitsPerPointer = kPointerSize * kBitsPerByte; 118 const int kBitsPerPointer = kPointerSize * kBitsPerByte;
125 const int kBitsPerInt = kIntSize * kBitsPerByte; 119 const int kBitsPerInt = kIntSize * kBitsPerByte;
126 120
127 121
128 // Zap-value: The value used for zapping dead objects. Should be a recognizable 122 // Zap-value: The value used for zapping dead objects.
129 // illegal heap object pointer. 123 // Should be a recognizable hex value tagged as a heap object pointer.
124 #ifdef V8_ARCH_X64
iposva 2009/05/04 17:00:55 ditto!
125 const Address kZapValue =
126 reinterpret_cast<Address>(UINT64_C(0xdeadbeedbeadbeed));
127 const Address kHandleZapValue =
128 reinterpret_cast<Address>(UINT64_C(0x1baddead0baddead));
129 const Address kFromSpaceZapValue =
130 reinterpret_cast<Address>(UINT64_C(0x1beefdad0beefdad));
131 #else
130 const Address kZapValue = reinterpret_cast<Address>(0xdeadbeed); 132 const Address kZapValue = reinterpret_cast<Address>(0xdeadbeed);
131 const Address kHandleZapValue = reinterpret_cast<Address>(0xbaddead); 133 const Address kHandleZapValue = reinterpret_cast<Address>(0xbaddead);
132 const Address kFromSpaceZapValue = reinterpret_cast<Address>(0xbeefdad); 134 const Address kFromSpaceZapValue = reinterpret_cast<Address>(0xbeefdad);
135 #endif
136
133 137
134 // ----------------------------------------------------------------------------- 138 // -----------------------------------------------------------------------------
135 // Forward declarations for frequently used classes 139 // Forward declarations for frequently used classes
136 // (sorted alphabetically) 140 // (sorted alphabetically)
137 141
138 class AccessorInfo; 142 class AccessorInfo;
139 class Allocation; 143 class Allocation;
140 class Arguments; 144 class Arguments;
141 class Assembler; 145 class Assembler;
142 class BreakableStatement; 146 class BreakableStatement;
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 state_tag_count 369 state_tag_count
366 }; 370 };
367 371
368 372
369 // ----------------------------------------------------------------------------- 373 // -----------------------------------------------------------------------------
370 // Macros 374 // Macros
371 375
372 // Testers for test. 376 // Testers for test.
373 377
374 #define HAS_SMI_TAG(value) \ 378 #define HAS_SMI_TAG(value) \
375 ((reinterpret_cast<int>(value) & kSmiTagMask) == kSmiTag) 379 ((reinterpret_cast<intptr_t>(value) & kSmiTagMask) == kSmiTag)
376 380
377 #define HAS_FAILURE_TAG(value) \ 381 #define HAS_FAILURE_TAG(value) \
378 ((reinterpret_cast<int>(value) & kFailureTagMask) == kFailureTag) 382 ((reinterpret_cast<intptr_t>(value) & kFailureTagMask) == kFailureTag)
379 383
380 #define HAS_HEAP_OBJECT_TAG(value) \ 384 #define HAS_HEAP_OBJECT_TAG(value) \
381 ((reinterpret_cast<int>(value) & kHeapObjectTagMask) == kHeapObjectTag) 385 ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) == kHeapObjectTag)
382 386
383 // OBJECT_SIZE_ALIGN returns the value aligned HeapObject size 387 // OBJECT_SIZE_ALIGN returns the value aligned HeapObject size
384 #define OBJECT_SIZE_ALIGN(value) \ 388 #define OBJECT_SIZE_ALIGN(value) \
385 ((value + kObjectAlignmentMask) & ~kObjectAlignmentMask) 389 ((value + kObjectAlignmentMask) & ~kObjectAlignmentMask)
386 390
387 // The expression OFFSET_OF(type, field) computes the byte-offset 391 // The expression OFFSET_OF(type, field) computes the byte-offset
388 // of the specified field relative to the containing type. This 392 // of the specified field relative to the containing type. This
389 // corresponds to 'offsetof' (in stddef.h), except that it doesn't 393 // corresponds to 'offsetof' (in stddef.h), except that it doesn't
390 // use 0 or NULL, which causes a problem with the compiler warnings 394 // use 0 or NULL, which causes a problem with the compiler warnings
391 // we have enabled (which is also why 'offsetof' doesn't seem to work). 395 // we have enabled (which is also why 'offsetof' doesn't seem to work).
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 509
506 Dest dest; 510 Dest dest;
507 memcpy(&dest, &source, sizeof(dest)); 511 memcpy(&dest, &source, sizeof(dest));
508 return dest; 512 return dest;
509 } 513 }
510 514
511 515
512 } } // namespace v8::internal 516 } } // namespace v8::internal
513 517
514 #endif // V8_GLOBALS_H_ 518 #endif // V8_GLOBALS_H_
OLDNEW
« no previous file with comments | « include/v8.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698