Skip to content

Commit

Permalink
Merged: [ptr-compr] Fix decompression functions in v8-internal.h
Browse files Browse the repository at this point in the history
Revision: 8738ab8

BUG=v8:10198,v8:9706,chromium:1045034
NOTRY=true
NOPRESUBMIT=true
NOTREECHECKS=true
R=ulan@chromium.org

Change-Id: Ieeca890abf68f15a4a73834fbef3e0677fd799b0
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2056851
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/branch-heads/8.0@{v8#39}
Cr-Branched-From: 69827db-refs/heads/8.0.426@{v8#2}
Cr-Branched-From: 2fe1552-refs/heads/master@{#65318}
  • Loading branch information
isheludko committed Feb 14, 2020
1 parent a24b6e6 commit 023e237
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
18 changes: 7 additions & 11 deletions include/v8-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,9 @@ class Internals {
V8_INLINE static internal::Address ReadTaggedPointerField(
internal::Address heap_object_ptr, int offset) {
#ifdef V8_COMPRESS_POINTERS
int32_t value = ReadRawField<int32_t>(heap_object_ptr, offset);
uint32_t value = ReadRawField<uint32_t>(heap_object_ptr, offset);
internal::Address root = GetRootFromOnHeapAddress(heap_object_ptr);
return root + static_cast<internal::Address>(static_cast<intptr_t>(value));
return root + static_cast<internal::Address>(static_cast<uintptr_t>(value));
#else
return ReadRawField<internal::Address>(heap_object_ptr, offset);
#endif
Expand All @@ -319,8 +319,8 @@ class Internals {
V8_INLINE static internal::Address ReadTaggedSignedField(
internal::Address heap_object_ptr, int offset) {
#ifdef V8_COMPRESS_POINTERS
int32_t value = ReadRawField<int32_t>(heap_object_ptr, offset);
return static_cast<internal::Address>(static_cast<intptr_t>(value));
uint32_t value = ReadRawField<uint32_t>(heap_object_ptr, offset);
return static_cast<internal::Address>(static_cast<uintptr_t>(value));
#else
return ReadRawField<internal::Address>(heap_object_ptr, offset);
#endif
Expand All @@ -337,13 +337,9 @@ class Internals {
}

V8_INLINE static internal::Address DecompressTaggedAnyField(
internal::Address heap_object_ptr, int32_t value) {
internal::Address root_mask = static_cast<internal::Address>(
-static_cast<intptr_t>(value & kSmiTagMask));
internal::Address root_or_zero =
root_mask & GetRootFromOnHeapAddress(heap_object_ptr);
return root_or_zero +
static_cast<internal::Address>(static_cast<intptr_t>(value));
internal::Address heap_object_ptr, uint32_t value) {
internal::Address root = GetRootFromOnHeapAddress(heap_object_ptr);
return root + static_cast<internal::Address>(static_cast<uintptr_t>(value));
}
#endif // V8_COMPRESS_POINTERS
};
Expand Down
4 changes: 2 additions & 2 deletions include/v8.h
Original file line number Diff line number Diff line change
Expand Up @@ -11064,7 +11064,7 @@ Local<Value> Object::GetInternalField(int index) {
#ifdef V8_COMPRESS_POINTERS
// We read the full pointer value and then decompress it in order to avoid
// dealing with potential endiannes issues.
value = I::DecompressTaggedAnyField(obj, static_cast<int32_t>(value));
value = I::DecompressTaggedAnyField(obj, static_cast<uint32_t>(value));
#endif
internal::Isolate* isolate =
internal::IsolateFromNeverReadOnlySpaceObject(obj);
Expand Down Expand Up @@ -11709,7 +11709,7 @@ Local<Value> Context::GetEmbedderData(int index) {
// We read the full pointer value and then decompress it in order to avoid
// dealing with potential endiannes issues.
value =
I::DecompressTaggedAnyField(embedder_data, static_cast<int32_t>(value));
I::DecompressTaggedAnyField(embedder_data, static_cast<uint32_t>(value));
#endif
internal::Isolate* isolate = internal::IsolateFromNeverReadOnlySpaceObject(
*reinterpret_cast<A*>(this));
Expand Down

0 comments on commit 023e237

Please sign in to comment.