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

Side by Side Diff: include/v8.h

Issue 6597029: [Isolates] Merge r 6300:6500 from bleeding_edge to isolates. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: Created 9 years, 10 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 | « SConstruct ('k') | src/SConscript » ('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 3432 matching lines...) Expand 10 before | Expand all | Expand 10 after
3443 // Tag information for HeapObject. 3443 // Tag information for HeapObject.
3444 const int kHeapObjectTag = 1; 3444 const int kHeapObjectTag = 1;
3445 const int kHeapObjectTagSize = 2; 3445 const int kHeapObjectTagSize = 2;
3446 const intptr_t kHeapObjectTagMask = (1 << kHeapObjectTagSize) - 1; 3446 const intptr_t kHeapObjectTagMask = (1 << kHeapObjectTagSize) - 1;
3447 3447
3448 // Tag information for Smi. 3448 // Tag information for Smi.
3449 const int kSmiTag = 0; 3449 const int kSmiTag = 0;
3450 const int kSmiTagSize = 1; 3450 const int kSmiTagSize = 1;
3451 const intptr_t kSmiTagMask = (1 << kSmiTagSize) - 1; 3451 const intptr_t kSmiTagMask = (1 << kSmiTagSize) - 1;
3452 3452
3453 template <size_t ptr_size> struct SmiConstants; 3453 template <size_t ptr_size> struct SmiTagging;
3454 3454
3455 // Smi constants for 32-bit systems. 3455 // Smi constants for 32-bit systems.
3456 template <> struct SmiConstants<4> { 3456 template <> struct SmiTagging<4> {
3457 static const int kSmiShiftSize = 0; 3457 static const int kSmiShiftSize = 0;
3458 static const int kSmiValueSize = 31; 3458 static const int kSmiValueSize = 31;
3459 static inline int SmiToInt(internal::Object* value) { 3459 static inline int SmiToInt(internal::Object* value) {
3460 int shift_bits = kSmiTagSize + kSmiShiftSize; 3460 int shift_bits = kSmiTagSize + kSmiShiftSize;
3461 // Throw away top 32 bits and shift down (requires >> to be sign extending). 3461 // Throw away top 32 bits and shift down (requires >> to be sign extending).
3462 return static_cast<int>(reinterpret_cast<intptr_t>(value)) >> shift_bits; 3462 return static_cast<int>(reinterpret_cast<intptr_t>(value)) >> shift_bits;
3463 } 3463 }
3464
3465 // For 32-bit systems any 2 bytes aligned pointer can be encoded as smi
3466 // with a plain reinterpret_cast.
3467 static const uintptr_t kEncodablePointerMask = 0x1;
3468 static const int kPointerToSmiShift = 0;
3464 }; 3469 };
3465 3470
3466 // Smi constants for 64-bit systems. 3471 // Smi constants for 64-bit systems.
3467 template <> struct SmiConstants<8> { 3472 template <> struct SmiTagging<8> {
3468 static const int kSmiShiftSize = 31; 3473 static const int kSmiShiftSize = 31;
3469 static const int kSmiValueSize = 32; 3474 static const int kSmiValueSize = 32;
3470 static inline int SmiToInt(internal::Object* value) { 3475 static inline int SmiToInt(internal::Object* value) {
3471 int shift_bits = kSmiTagSize + kSmiShiftSize; 3476 int shift_bits = kSmiTagSize + kSmiShiftSize;
3472 // Shift down and throw away top 32 bits. 3477 // Shift down and throw away top 32 bits.
3473 return static_cast<int>(reinterpret_cast<intptr_t>(value) >> shift_bits); 3478 return static_cast<int>(reinterpret_cast<intptr_t>(value) >> shift_bits);
3474 } 3479 }
3480
3481 // To maximize the range of pointers that can be encoded
3482 // in the available 32 bits, we require them to be 8 bytes aligned.
3483 // This gives 2 ^ (32 + 3) = 32G address space covered.
3484 // It might be not enough to cover stack allocated objects on some platforms.
3485 static const int kPointerAlignment = 3;
3486
3487 static const uintptr_t kEncodablePointerMask =
3488 ~(uintptr_t(0xffffffff) << kPointerAlignment);
3489
3490 static const int kPointerToSmiShift =
3491 kSmiTagSize + kSmiShiftSize - kPointerAlignment;
3475 }; 3492 };
3476 3493
3477 const int kSmiShiftSize = SmiConstants<kApiPointerSize>::kSmiShiftSize; 3494 typedef SmiTagging<kApiPointerSize> PlatformSmiTagging;
3478 const int kSmiValueSize = SmiConstants<kApiPointerSize>::kSmiValueSize; 3495 const int kSmiShiftSize = PlatformSmiTagging::kSmiShiftSize;
3496 const int kSmiValueSize = PlatformSmiTagging::kSmiValueSize;
3497 const uintptr_t kEncodablePointerMask =
3498 PlatformSmiTagging::kEncodablePointerMask;
3499 const int kPointerToSmiShift = PlatformSmiTagging::kPointerToSmiShift;
3479 3500
3480 template <size_t ptr_size> struct InternalConstants; 3501 template <size_t ptr_size> struct InternalConstants;
3481 3502
3482 // Internal constants for 32-bit systems. 3503 // Internal constants for 32-bit systems.
3483 template <> struct InternalConstants<4> { 3504 template <> struct InternalConstants<4> {
3484 static const int kStringResourceOffset = 3 * kApiPointerSize; 3505 static const int kStringResourceOffset = 3 * kApiPointerSize;
3485 }; 3506 };
3486 3507
3487 // Internal constants for 64-bit systems. 3508 // Internal constants for 64-bit systems.
3488 template <> struct InternalConstants<8> { 3509 template <> struct InternalConstants<8> {
(...skipping 27 matching lines...) Expand all
3516 static inline bool HasHeapObjectTag(internal::Object* value) { 3537 static inline bool HasHeapObjectTag(internal::Object* value) {
3517 return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) == 3538 return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) ==
3518 kHeapObjectTag); 3539 kHeapObjectTag);
3519 } 3540 }
3520 3541
3521 static inline bool HasSmiTag(internal::Object* value) { 3542 static inline bool HasSmiTag(internal::Object* value) {
3522 return ((reinterpret_cast<intptr_t>(value) & kSmiTagMask) == kSmiTag); 3543 return ((reinterpret_cast<intptr_t>(value) & kSmiTagMask) == kSmiTag);
3523 } 3544 }
3524 3545
3525 static inline int SmiValue(internal::Object* value) { 3546 static inline int SmiValue(internal::Object* value) {
3526 return SmiConstants<kApiPointerSize>::SmiToInt(value); 3547 return PlatformSmiTagging::SmiToInt(value);
3527 } 3548 }
3528 3549
3529 static inline int GetInstanceType(internal::Object* obj) { 3550 static inline int GetInstanceType(internal::Object* obj) {
3530 typedef internal::Object O; 3551 typedef internal::Object O;
3531 O* map = ReadField<O*>(obj, kHeapObjectMapOffset); 3552 O* map = ReadField<O*>(obj, kHeapObjectMapOffset);
3532 return ReadField<uint8_t>(map, kMapInstanceTypeOffset); 3553 return ReadField<uint8_t>(map, kMapInstanceTypeOffset);
3533 } 3554 }
3534 3555
3556 static inline void* GetExternalPointerFromSmi(internal::Object* value) {
3557 const uintptr_t address = reinterpret_cast<uintptr_t>(value);
3558 return reinterpret_cast<void*>(address >> kPointerToSmiShift);
3559 }
3560
3535 static inline void* GetExternalPointer(internal::Object* obj) { 3561 static inline void* GetExternalPointer(internal::Object* obj) {
3536 if (HasSmiTag(obj)) { 3562 if (HasSmiTag(obj)) {
3537 return obj; 3563 return GetExternalPointerFromSmi(obj);
3538 } else if (GetInstanceType(obj) == kProxyType) { 3564 } else if (GetInstanceType(obj) == kProxyType) {
3539 return ReadField<void*>(obj, kProxyProxyOffset); 3565 return ReadField<void*>(obj, kProxyProxyOffset);
3540 } else { 3566 } else {
3541 return NULL; 3567 return NULL;
3542 } 3568 }
3543 } 3569 }
3544 3570
3545 static inline bool IsExternalTwoByteString(int instance_type) { 3571 static inline bool IsExternalTwoByteString(int instance_type) {
3546 int representation = (instance_type & kFullStringRepresentationMask); 3572 int representation = (instance_type & kFullStringRepresentationMask);
3547 return representation == kExternalTwoByteRepresentationTag; 3573 return representation == kExternalTwoByteRepresentationTag;
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
3907 3933
3908 3934
3909 } // namespace v8 3935 } // namespace v8
3910 3936
3911 3937
3912 #undef V8EXPORT 3938 #undef V8EXPORT
3913 #undef TYPE_CHECK 3939 #undef TYPE_CHECK
3914 3940
3915 3941
3916 #endif // V8_H_ 3942 #endif // V8_H_
OLDNEW
« no previous file with comments | « SConstruct ('k') | src/SConscript » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698