Skip to content

Commit 4baa958

Browse files
rmacnak-googleCommit Queue
authored and
Commit Queue
committed
[vm] Remove overly-narrow NoSafepointScopes.
These NoSafepointScopes are active for only one load/store where there is little need to guard against someone adding an allocation. They have been observed to take up to 15% of program execution in debug builds. TEST=ci Change-Id: I923baa28a3a72decacbfcdec3331ce9c7c620b67 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275540 Reviewed-by: Siva Annamalai <[email protected]> Commit-Queue: Ryan Macnak <[email protected]>
1 parent bd81c8b commit 4baa958

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

runtime/vm/object.h

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10049,7 +10049,6 @@ class OneByteString : public AllStatic {
1004910049

1005010050
static uint16_t CharAt(const String& str, intptr_t index) {
1005110051
ASSERT(str.IsOneByteString());
10052-
NoSafepointScope no_safepoint;
1005310052
return OneByteString::CharAt(static_cast<OneByteStringPtr>(str.ptr()),
1005410053
index);
1005510054
}
@@ -10187,7 +10186,6 @@ class TwoByteString : public AllStatic {
1018710186

1018810187
static uint16_t CharAt(const String& str, intptr_t index) {
1018910188
ASSERT(str.IsTwoByteString());
10190-
NoSafepointScope no_safepoint;
1019110189
return TwoByteString::CharAt(static_cast<TwoByteStringPtr>(str.ptr()),
1019210190
index);
1019310191
}
@@ -10306,7 +10304,6 @@ class ExternalOneByteString : public AllStatic {
1030610304

1030710305
static uint16_t CharAt(const String& str, intptr_t index) {
1030810306
ASSERT(str.IsExternalOneByteString());
10309-
NoSafepointScope no_safepoint;
1031010307
return ExternalOneByteString::CharAt(
1031110308
static_cast<ExternalOneByteStringPtr>(str.ptr()), index);
1031210309
}
@@ -10399,7 +10396,6 @@ class ExternalTwoByteString : public AllStatic {
1039910396

1040010397
static uint16_t CharAt(const String& str, intptr_t index) {
1040110398
ASSERT(str.IsExternalTwoByteString());
10402-
NoSafepointScope no_safepoint;
1040310399
return ExternalTwoByteString::CharAt(
1040410400
static_cast<ExternalTwoByteStringPtr>(str.ptr()), index);
1040510401
}
@@ -11117,12 +11113,16 @@ class TypedDataBase : public PointerBase {
1111711113

1111811114
#define TYPED_GETTER_SETTER(name, type) \
1111911115
type Get##name(intptr_t byte_offset) const { \
11120-
NoSafepointScope no_safepoint; \
11121-
return LoadUnaligned(reinterpret_cast<type*>(DataAddr(byte_offset))); \
11116+
ASSERT(static_cast<uintptr_t>(byte_offset) <= \
11117+
static_cast<uintptr_t>(LengthInBytes()) - sizeof(type)); \
11118+
return LoadUnaligned( \
11119+
reinterpret_cast<type*>(untag()->data_ + byte_offset)); \
1112211120
} \
1112311121
void Set##name(intptr_t byte_offset, type value) const { \
11124-
NoSafepointScope no_safepoint; \
11125-
StoreUnaligned(reinterpret_cast<type*>(DataAddr(byte_offset)), value); \
11122+
ASSERT(static_cast<uintptr_t>(byte_offset) <= \
11123+
static_cast<uintptr_t>(LengthInBytes()) - sizeof(type)); \
11124+
StoreUnaligned(reinterpret_cast<type*>(untag()->data_ + byte_offset), \
11125+
value); \
1112611126
}
1112711127

1112811128
TYPED_GETTER_SETTER(Int8, int8_t)
@@ -11174,14 +11174,16 @@ class TypedData : public TypedDataBase {
1117411174

1117511175
#define TYPED_GETTER_SETTER(name, type) \
1117611176
type Get##name(intptr_t byte_offset) const { \
11177-
ASSERT((byte_offset >= 0) && \
11178-
(byte_offset + static_cast<intptr_t>(sizeof(type)) - 1) < \
11179-
LengthInBytes()); \
11180-
return LoadUnaligned(ReadOnlyDataAddr<type>(byte_offset)); \
11177+
ASSERT(static_cast<uintptr_t>(byte_offset) <= \
11178+
static_cast<uintptr_t>(LengthInBytes()) - sizeof(type)); \
11179+
return LoadUnaligned( \
11180+
reinterpret_cast<const type*>(untag()->data() + byte_offset)); \
1118111181
} \
1118211182
void Set##name(intptr_t byte_offset, type value) const { \
11183-
NoSafepointScope no_safepoint; \
11184-
StoreUnaligned(reinterpret_cast<type*>(DataAddr(byte_offset)), value); \
11183+
ASSERT(static_cast<uintptr_t>(byte_offset) <= \
11184+
static_cast<uintptr_t>(LengthInBytes()) - sizeof(type)); \
11185+
return StoreUnaligned( \
11186+
reinterpret_cast<type*>(untag()->data() + byte_offset), value); \
1118511187
}
1118611188

1118711189
TYPED_GETTER_SETTER(Int8, int8_t)

0 commit comments

Comments
 (0)