Commit aee471b2 authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[api] Avoid handles for const API functions

Handles are notorious for preventing compiler optimizations. We should
avoid them for simple const functions.

- Mark more API functions const
- Mark more String functions const

Bug: v8:11195, chromium:808503, v8:11263
Change-Id: I9940e85600bc7d19027039d807b3313e2dcccdc7
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2575065Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73159}
parent e3d4d9b4
......@@ -1491,7 +1491,7 @@ class V8_EXPORT UnboundScript {
*/
Local<Script> BindToCurrentContext();
int GetId();
int GetId() const;
Local<Value> GetScriptName();
/**
......@@ -1701,7 +1701,7 @@ class V8_EXPORT Module : public Data {
*
* The module must be a SourceTextModule and must not have a kErrored status.
*/
int ScriptId();
int ScriptId() const;
/**
* Returns whether this module or any of its requested modules is async,
......@@ -3525,12 +3525,12 @@ class V8_EXPORT String : public Name {
/**
* Returns true if this string can be made external.
*/
bool CanMakeExternal();
bool CanMakeExternal() const;
/**
* Returns true if the strings values are equal. Same as JS ==/===.
*/
bool StringEquals(Local<String> str);
bool StringEquals(Local<String> str) const;
/**
* Converts an object to a UTF-8-encoded character array. Useful if
......@@ -4137,7 +4137,7 @@ class V8_EXPORT Object : public Value {
Maybe<bool> SetIntegrityLevel(Local<Context> context, IntegrityLevel level);
/** Gets the number of internal fields for this Object. */
int InternalFieldCount();
int InternalFieldCount() const;
/** Same as above, but works for PersistentBase. */
V8_INLINE static int InternalFieldCount(
......@@ -4247,10 +4247,10 @@ class V8_EXPORT Object : public Value {
Local<Context> context, Local<Name> key);
/** Tests for a named lookup interceptor.*/
bool HasNamedLookupInterceptor();
bool HasNamedLookupInterceptor() const;
/** Tests for an index lookup interceptor.*/
bool HasIndexedLookupInterceptor();
bool HasIndexedLookupInterceptor() const;
/**
* Returns the identity hash for this object. The current implementation
......@@ -4290,12 +4290,12 @@ class V8_EXPORT Object : public Value {
* ObjectTemplate::SetCallAsFunctionHandler method.
* When an Object is callable this method returns true.
*/
bool IsCallable();
bool IsCallable() const;
/**
* True if this object is a constructor.
*/
bool IsConstructor();
bool IsConstructor() const;
/**
* True if this object can carry information relevant to the embedder in its
......@@ -4304,14 +4304,14 @@ class V8_EXPORT Object : public Value {
* V8 automatically adds internal fields at compile time, such as e.g.
* v8::ArrayBuffer.
*/
bool IsApiWrapper();
bool IsApiWrapper() const;
/**
* True if this object was created from an object template which was marked
* as undetectable. See v8::ObjectTemplate::MarkAsUndetectable for more
* information.
*/
bool IsUndetectable();
bool IsUndetectable() const;
/**
* Call an Object as a function if a callback is set by the
......@@ -4370,7 +4370,7 @@ class V8_EXPORT Object : public Value {
*
* See also: v8::ObjectTemplate::SetCodeLike
*/
bool IsCodeLike(Isolate* isolate);
bool IsCodeLike(Isolate* isolate) const;
private:
Object();
......@@ -4868,7 +4868,7 @@ class V8_EXPORT Promise : public Object {
* Returns true if the promise has at least one derived promise, and
* therefore resolve/reject handlers (including default handler).
*/
bool HasHandler();
bool HasHandler() const;
/**
* Returns the content of the [[PromiseResult]] field. The Promise must not
......@@ -4976,7 +4976,7 @@ class V8_EXPORT Proxy : public Object {
public:
Local<Value> GetTarget();
Local<Value> GetHandler();
bool IsRevoked();
bool IsRevoked() const;
void Revoke();
/**
......@@ -7168,7 +7168,7 @@ class V8_EXPORT ObjectTemplate : public Template {
* Gets the number of internal fields for objects generated from
* this template.
*/
int InternalFieldCount();
int InternalFieldCount() const;
/**
* Sets the number of internal fields for objects generated from
......@@ -7179,7 +7179,7 @@ class V8_EXPORT ObjectTemplate : public Template {
/**
* Returns true if the object will be an immutable prototype exotic object.
*/
bool IsImmutableProto();
bool IsImmutableProto() const;
/**
* Makes the ObjectTemplate for an immutable prototype exotic object, with an
......@@ -7197,7 +7197,7 @@ class V8_EXPORT ObjectTemplate : public Template {
* Reference: https://github.com/tc39/proposal-dynamic-code-brand-checks
*/
void SetCodeLike();
bool IsCodeLike();
bool IsCodeLike() const;
V8_INLINE static ObjectTemplate* Cast(Data* data);
......@@ -10735,7 +10735,7 @@ class V8_EXPORT Context : public Data {
* Returns true if code generation from strings is allowed for the context.
* For more details see AllowCodeGenerationFromStrings(bool) documentation.
*/
bool IsCodeGenerationFromStringsAllowed();
bool IsCodeGenerationFromStringsAllowed() const;
/**
* Sets the error description for the exception that is thrown when
......
This diff is collapsed.
......@@ -133,49 +133,51 @@ StringShape::StringShape(InstanceType t) : type_(static_cast<uint32_t>(t)) {
DCHECK_EQ(type_ & kIsNotStringMask, kStringTag);
}
bool StringShape::IsInternalized() {
bool StringShape::IsInternalized() const {
DCHECK(valid());
STATIC_ASSERT(kNotInternalizedTag != 0);
return (type_ & (kIsNotStringMask | kIsNotInternalizedMask)) ==
(kStringTag | kInternalizedTag);
}
bool StringShape::IsCons() {
bool StringShape::IsCons() const {
return (type_ & kStringRepresentationMask) == kConsStringTag;
}
bool StringShape::IsThin() {
bool StringShape::IsThin() const {
return (type_ & kStringRepresentationMask) == kThinStringTag;
}
bool StringShape::IsSliced() {
bool StringShape::IsSliced() const {
return (type_ & kStringRepresentationMask) == kSlicedStringTag;
}
bool StringShape::IsIndirect() {
bool StringShape::IsIndirect() const {
return (type_ & kIsIndirectStringMask) == kIsIndirectStringTag;
}
bool StringShape::IsExternal() {
bool StringShape::IsExternal() const {
return (type_ & kStringRepresentationMask) == kExternalStringTag;
}
bool StringShape::IsSequential() {
bool StringShape::IsSequential() const {
return (type_ & kStringRepresentationMask) == kSeqStringTag;
}
bool StringShape::IsUncachedExternal() {
bool StringShape::IsUncachedExternal() const {
return (type_ & kUncachedExternalStringMask) == kUncachedExternalStringTag;
}
StringRepresentationTag StringShape::representation_tag() {
StringRepresentationTag StringShape::representation_tag() const {
uint32_t tag = (type_ & kStringRepresentationMask);
return static_cast<StringRepresentationTag>(tag);
}
uint32_t StringShape::encoding_tag() { return type_ & kStringEncodingMask; }
uint32_t StringShape::encoding_tag() const {
return type_ & kStringEncodingMask;
}
uint32_t StringShape::full_representation_tag() {
uint32_t StringShape::full_representation_tag() const {
return (type_ & (kStringRepresentationMask | kStringEncodingMask));
}
......@@ -185,15 +187,15 @@ STATIC_ASSERT((kStringRepresentationMask | kStringEncodingMask) ==
STATIC_ASSERT(static_cast<uint32_t>(kStringEncodingMask) ==
Internals::kStringEncodingMask);
bool StringShape::IsSequentialOneByte() {
bool StringShape::IsSequentialOneByte() const {
return full_representation_tag() == (kSeqStringTag | kOneByteStringTag);
}
bool StringShape::IsSequentialTwoByte() {
bool StringShape::IsSequentialTwoByte() const {
return full_representation_tag() == (kSeqStringTag | kTwoByteStringTag);
}
bool StringShape::IsExternalOneByte() {
bool StringShape::IsExternalOneByte() const {
return full_representation_tag() == (kExternalStringTag | kOneByteStringTag);
}
......@@ -202,7 +204,7 @@ STATIC_ASSERT((kExternalStringTag | kOneByteStringTag) ==
STATIC_ASSERT(v8::String::ONE_BYTE_ENCODING == kOneByteStringTag);
bool StringShape::IsExternalTwoByte() {
bool StringShape::IsExternalTwoByte() const {
return full_representation_tag() == (kExternalStringTag | kTwoByteStringTag);
}
......@@ -298,7 +300,7 @@ bool String::IsOneByteRepresentationUnderneath(String string) {
}
}
uc32 FlatStringReader::Get(int index) {
uc32 FlatStringReader::Get(int index) const {
if (is_one_byte_) {
return Get<uint8_t>(index);
} else {
......@@ -307,7 +309,7 @@ uc32 FlatStringReader::Get(int index) {
}
template <typename Char>
Char FlatStringReader::Get(int index) {
Char FlatStringReader::Get(int index) const {
DCHECK_EQ(is_one_byte_, sizeof(Char) == 1);
DCHECK(0 <= index && index < length_);
if (sizeof(Char) == 1) {
......@@ -432,7 +434,7 @@ class SeqSubStringKey final : public StringTableKey {
using SeqOneByteSubStringKey = SeqSubStringKey<SeqOneByteString>;
using SeqTwoByteSubStringKey = SeqSubStringKey<SeqTwoByteString>;
bool String::Equals(String other) {
bool String::Equals(String other) const {
if (other == *this) return true;
if (this->IsInternalizedString() && other.IsInternalizedString()) {
return false;
......@@ -440,6 +442,7 @@ bool String::Equals(String other) {
return SlowEquals(other);
}
// static
bool String::Equals(Isolate* isolate, Handle<String> one, Handle<String> two) {
if (one.is_identical_to(two)) return true;
if (one->IsInternalizedString() && two->IsInternalizedString()) {
......@@ -539,7 +542,7 @@ bool String::IsEqualToImpl(
bool String::IsOneByteEqualTo(Vector<const char> str) { return IsEqualTo(str); }
template <typename Char>
const Char* String::GetChars(const DisallowGarbageCollection& no_gc) {
const Char* String::GetChars(const DisallowGarbageCollection& no_gc) const {
DCHECK(!SharedStringAccessGuardIfNeeded::IsNeeded(*this));
return StringShape(*this).IsExternal()
? CharTraits<Char>::ExternalString::cast(*this).GetChars()
......@@ -549,7 +552,7 @@ const Char* String::GetChars(const DisallowGarbageCollection& no_gc) {
template <typename Char>
const Char* String::GetChars(
const DisallowGarbageCollection& no_gc,
const SharedStringAccessGuardIfNeeded& access_guard) {
const SharedStringAccessGuardIfNeeded& access_guard) const {
return StringShape(*this).IsExternal()
? CharTraits<Char>::ExternalString::cast(*this).GetChars()
: CharTraits<Char>::String::cast(*this).GetChars(no_gc,
......@@ -580,17 +583,17 @@ Handle<String> String::Flatten(LocalIsolate* isolate, Handle<String> string,
return string;
}
uint16_t String::Get(int index, Isolate* isolate) {
uint16_t String::Get(int index, Isolate* isolate) const {
DCHECK(!SharedStringAccessGuardIfNeeded::IsNeeded(*this));
return GetImpl(index);
}
uint16_t String::Get(int index, LocalIsolate* local_isolate) {
uint16_t String::Get(int index, LocalIsolate* local_isolate) const {
SharedStringAccessGuardIfNeeded scope(local_isolate);
return GetImpl(index);
}
uint16_t String::GetImpl(int index) {
uint16_t String::GetImpl(int index) const {
DCHECK(index >= 0 && index < length());
class StringGetDispatcher : public AllStatic {
......@@ -619,12 +622,12 @@ void String::Set(int index, uint16_t value) {
: SeqTwoByteString::cast(*this).SeqTwoByteStringSet(index, value);
}
bool String::IsFlat() {
bool String::IsFlat() const {
if (!StringShape(*this).IsCons()) return true;
return ConsString::cast(*this).second().length() == 0;
}
String String::GetUnderlying() {
String String::GetUnderlying() const {
// Giving direct access to underlying string only makes sense if the
// wrapping string is already flattened.
DCHECK(this->IsFlat());
......@@ -728,7 +731,7 @@ uint32_t String::ToValidIndex(Object number) {
return index;
}
uint8_t SeqOneByteString::Get(int index) {
uint8_t SeqOneByteString::Get(int index) const {
DCHECK(index >= 0 && index < length());
return ReadField<byte>(kHeaderSize + index * kCharSize);
}
......@@ -738,11 +741,12 @@ void SeqOneByteString::SeqOneByteStringSet(int index, uint16_t value) {
WriteField<byte>(kHeaderSize + index * kCharSize, static_cast<byte>(value));
}
Address SeqOneByteString::GetCharsAddress() {
Address SeqOneByteString::GetCharsAddress() const {
return field_address(kHeaderSize);
}
uint8_t* SeqOneByteString::GetChars(const DisallowGarbageCollection& no_gc) {
uint8_t* SeqOneByteString::GetChars(
const DisallowGarbageCollection& no_gc) const {
USE(no_gc);
DCHECK(!SharedStringAccessGuardIfNeeded::IsNeeded(*this));
return reinterpret_cast<uint8_t*>(GetCharsAddress());
......@@ -750,17 +754,17 @@ uint8_t* SeqOneByteString::GetChars(const DisallowGarbageCollection& no_gc) {
uint8_t* SeqOneByteString::GetChars(
const DisallowGarbageCollection& no_gc,
const SharedStringAccessGuardIfNeeded& access_guard) {
const SharedStringAccessGuardIfNeeded& access_guard) const {
USE(no_gc);
USE(access_guard);
return reinterpret_cast<uint8_t*>(GetCharsAddress());
}
Address SeqTwoByteString::GetCharsAddress() {
Address SeqTwoByteString::GetCharsAddress() const {
return field_address(kHeaderSize);
}
uc16* SeqTwoByteString::GetChars(const DisallowGarbageCollection& no_gc) {
uc16* SeqTwoByteString::GetChars(const DisallowGarbageCollection& no_gc) const {
USE(no_gc);
DCHECK(!SharedStringAccessGuardIfNeeded::IsNeeded(*this));
return reinterpret_cast<uc16*>(GetCharsAddress());
......@@ -768,13 +772,13 @@ uc16* SeqTwoByteString::GetChars(const DisallowGarbageCollection& no_gc) {
uc16* SeqTwoByteString::GetChars(
const DisallowGarbageCollection& no_gc,
const SharedStringAccessGuardIfNeeded& access_guard) {
const SharedStringAccessGuardIfNeeded& access_guard) const {
USE(no_gc);
USE(access_guard);
return reinterpret_cast<uc16*>(GetCharsAddress());
}
uint16_t SeqTwoByteString::Get(int index) {
uint16_t SeqTwoByteString::Get(int index) const {
DCHECK(index >= 0 && index < length());
return ReadField<uint16_t>(kHeaderSize + index * kShortSize);
}
......@@ -901,7 +905,7 @@ void ExternalOneByteString::set_resource(
if (resource != nullptr) update_data_cache(isolate);
}
const uint8_t* ExternalOneByteString::GetChars() {
const uint8_t* ExternalOneByteString::GetChars() const {
DisallowGarbageCollection no_gc;
if (is_uncached()) {
if (resource()->IsCacheable()) {
......@@ -923,7 +927,7 @@ const uint8_t* ExternalOneByteString::GetChars() {
return reinterpret_cast<const uint8_t*>(resource()->data());
}
uint8_t ExternalOneByteString::Get(int index) {
uint8_t ExternalOneByteString::Get(int index) const {
DCHECK(index >= 0 && index < length());
return GetChars()[index];
}
......@@ -966,7 +970,7 @@ void ExternalTwoByteString::set_resource(
if (resource != nullptr) update_data_cache(isolate);
}
const uint16_t* ExternalTwoByteString::GetChars() {
const uint16_t* ExternalTwoByteString::GetChars() const {
DisallowGarbageCollection no_gc;
if (is_uncached()) {
if (resource()->IsCacheable()) {
......@@ -988,7 +992,7 @@ const uint16_t* ExternalTwoByteString::GetChars() {
return resource()->data();
}
uint16_t ExternalTwoByteString::Get(int index) {
uint16_t ExternalTwoByteString::Get(int index) const {
DCHECK(index >= 0 && index < length());
return GetChars()[index];
}
......
......@@ -773,7 +773,7 @@ template Handle<FixedArray> String::CalculateLineEnds(LocalIsolate* isolate,
Handle<String> src,
bool include_ending_line);
bool String::SlowEquals(String other) {
bool String::SlowEquals(String other) const {
DisallowGarbageCollection no_gc;
// Fast check: negative check with lengths.
int len = length();
......@@ -825,6 +825,7 @@ bool String::SlowEquals(String other) {
return comparator.Equals(*this, other);
}
// static
bool String::SlowEquals(Isolate* isolate, Handle<String> one,
Handle<String> two) {
// Fast check: negative check with lengths.
......@@ -1437,7 +1438,7 @@ void SeqTwoByteString::clear_padding() {
SizeFor(length()) - data_size);
}
uint16_t ConsString::Get(int index) {
uint16_t ConsString::Get(int index) const {
DCHECK(index >= 0 && index < this->length());
// Check for a flattened cons string
......@@ -1466,9 +1467,11 @@ uint16_t ConsString::Get(int index) {
UNREACHABLE();
}
uint16_t ThinString::Get(int index) { return actual().Get(index); }
uint16_t ThinString::Get(int index) const { return actual().Get(index); }
uint16_t SlicedString::Get(int index) { return parent().Get(offset() + index); }
uint16_t SlicedString::Get(int index) const {
return parent().Get(offset() + index);
}
int ExternalString::ExternalPayloadSize() const {
int length_multiplier = IsTwoByteRepresentation() ? i::kShortSize : kCharSize;
......
......@@ -44,25 +44,25 @@ class StringShape {
inline explicit StringShape(const String s);
inline explicit StringShape(Map s);
inline explicit StringShape(InstanceType t);
inline bool IsSequential();
inline bool IsExternal();
inline bool IsCons();
inline bool IsSliced();
inline bool IsThin();
inline bool IsIndirect();
inline bool IsUncachedExternal();
inline bool IsExternalOneByte();
inline bool IsExternalTwoByte();
inline bool IsSequentialOneByte();
inline bool IsSequentialTwoByte();
inline bool IsInternalized();
inline StringRepresentationTag representation_tag();
inline uint32_t encoding_tag();
inline uint32_t full_representation_tag();
inline bool IsSequential() const;
inline bool IsExternal() const;
inline bool IsCons() const;
inline bool IsSliced() const;
inline bool IsThin() const;
inline bool IsIndirect() const;
inline bool IsUncachedExternal() const;
inline bool IsExternalOneByte() const;
inline bool IsExternalTwoByte() const;
inline bool IsSequentialOneByte() const;
inline bool IsSequentialTwoByte() const;
inline bool IsInternalized() const;
inline StringRepresentationTag representation_tag() const;
inline uint32_t encoding_tag() const;
inline uint32_t full_representation_tag() const;
#ifdef DEBUG
inline uint32_t type() { return type_; }
inline uint32_t type() const { return type_; }
inline void invalidate() { valid_ = false; }
inline bool valid() { return valid_; }
inline bool valid() const { return valid_; }
#else
inline void invalidate() {}
#endif
......@@ -181,13 +181,13 @@ class String : public TorqueGeneratedString<String, Name> {
// SharedStringAccessGuard is not needed (i.e. on the main thread or on
// read-only strings).
template <typename Char>
inline const Char* GetChars(const DisallowGarbageCollection& no_gc);
inline const Char* GetChars(const DisallowGarbageCollection& no_gc) const;
// Get chars from sequential or external strings.
template <typename Char>
inline const Char* GetChars(
const DisallowGarbageCollection& no_gc,
const SharedStringAccessGuardIfNeeded& access_guard);
const SharedStringAccessGuardIfNeeded& access_guard) const;
// Returns the address of the character at an offset into this string.
// Requires: this->IsFlat()
......@@ -217,8 +217,8 @@ class String : public TorqueGeneratedString<String, Name> {
// to this method are not efficient unless the string is flat.
// If it is called from a background thread, the LocalIsolate version should
// be used.
V8_INLINE uint16_t Get(int index, Isolate* isolate = nullptr);
V8_INLINE uint16_t Get(int index, LocalIsolate* local_isolate);
V8_INLINE uint16_t Get(int index, Isolate* isolate = nullptr) const;
V8_INLINE uint16_t Get(int index, LocalIsolate* local_isolate) const;
// ES6 section 7.1.3.1 ToNumber Applied to the String Type
static Handle<Object> ToNumber(Isolate* isolate, Handle<String> subject);
......@@ -253,7 +253,7 @@ class String : public TorqueGeneratedString<String, Name> {
// Returns the parent of a sliced string or first part of a flat cons string.
// Requires: StringShape(this).IsIndirect() && this->IsFlat()
inline String GetUnderlying();
inline String GetUnderlying() const;
// String relational comparison, implemented according to ES6 section 7.2.11
// Abstract Relational Comparison (step 5): The comparison of Strings uses a
......@@ -314,7 +314,7 @@ class String : public TorqueGeneratedString<String, Name> {
int start_index = 0);
// String equality operations.
inline bool Equals(String other);
inline bool Equals(String other) const;
inline static bool Equals(Isolate* isolate, Handle<String> one,
Handle<String> two);
......@@ -412,7 +412,7 @@ class String : public TorqueGeneratedString<String, Name> {
DECL_PRINTER(String)
DECL_VERIFIER(String)
inline bool IsFlat();
inline bool IsFlat() const;
// Max char codes.
static const int32_t kMaxOneByteCharCode = unibrow::Latin1::kMaxChar;
......@@ -534,7 +534,7 @@ class String : public TorqueGeneratedString<String, Name> {
friend class InternalizedStringKey;
// Implementation of the Get() public methods. Do not use directly.
V8_INLINE uint16_t GetImpl(int index);
V8_INLINE uint16_t GetImpl(int index) const;
// Implementation of the IsEqualTo() public methods. Do not use directly.
template <EqualityType kEqType, typename Char>
......@@ -547,7 +547,7 @@ class String : public TorqueGeneratedString<String, Name> {
// Slow case of String::Equals. This implementation works on any strings
// but it is most efficient on strings that are almost flat.
V8_EXPORT_PRIVATE bool SlowEquals(String other);
V8_EXPORT_PRIVATE bool SlowEquals(String other) const;
V8_EXPORT_PRIVATE static bool SlowEquals(Isolate* isolate, Handle<String> one,
Handle<String> two);
......@@ -619,20 +619,21 @@ class SeqOneByteString
using Char = uint8_t;
// Dispatched behavior.
inline uint8_t Get(int index);
inline uint8_t Get(int index) const;
inline void SeqOneByteStringSet(int index, uint16_t value);
// Get the address of the characters in this string.
inline Address GetCharsAddress();
inline Address GetCharsAddress() const;
// Get a pointer to the characters of the string. May only be called when a
// SharedStringAccessGuard is not needed (i.e. on the main thread or on
// read-only strings).
inline uint8_t* GetChars(const DisallowGarbageCollection& no_gc);
inline uint8_t* GetChars(const DisallowGarbageCollection& no_gc) const;
// Get a pointer to the characters of the string.
inline uint8_t* GetChars(const DisallowGarbageCollection& no_gc,
const SharedStringAccessGuardIfNeeded& access_guard);
inline uint8_t* GetChars(
const DisallowGarbageCollection& no_gc,
const SharedStringAccessGuardIfNeeded& access_guard) const;
// Clear uninitialized padding space. This ensures that the snapshot content
// is deterministic.
......@@ -664,20 +665,21 @@ class SeqTwoByteString
using Char = uint16_t;
// Dispatched behavior.
inline uint16_t Get(int index);
inline uint16_t Get(int index) const;
inline void SeqTwoByteStringSet(int index, uint16_t value);
// Get the address of the characters in this string.
inline Address GetCharsAddress();
inline Address GetCharsAddress() const;
// Get a pointer to the characters of the string. May only be called when a
// SharedStringAccessGuard is not needed (i.e. on the main thread or on
// read-only strings).
inline uc16* GetChars(const DisallowGarbageCollection& no_gc);
inline uc16* GetChars(const DisallowGarbageCollection& no_gc) const;
// Get a pointer to the characters of the string.
inline uc16* GetChars(const DisallowGarbageCollection& no_gc,
const SharedStringAccessGuardIfNeeded& access_guard);
inline uc16* GetChars(
const DisallowGarbageCollection& no_gc,
const SharedStringAccessGuardIfNeeded& access_guard) const;
// Clear uninitialized padding space. This ensures that the snapshot content
// is deterministic.
......@@ -720,7 +722,7 @@ class ConsString : public TorqueGeneratedConsString<ConsString, String> {
inline Object unchecked_second();
// Dispatched behavior.
V8_EXPORT_PRIVATE uint16_t Get(int index);
V8_EXPORT_PRIVATE uint16_t Get(int index) const;
// Minimum length for a cons string.
static const int kMinLength = 13;
......@@ -743,7 +745,7 @@ class ThinString : public TorqueGeneratedThinString<ThinString, String> {
public:
DECL_GETTER(unchecked_actual, HeapObject)
V8_EXPORT_PRIVATE uint16_t Get(int index);
V8_EXPORT_PRIVATE uint16_t Get(int index) const;
DECL_VERIFIER(ThinString)
......@@ -769,7 +771,7 @@ class SlicedString : public TorqueGeneratedSlicedString<SlicedString, String> {
inline void set_parent(String parent,
WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
// Dispatched behavior.
V8_EXPORT_PRIVATE uint16_t Get(int index);
V8_EXPORT_PRIVATE uint16_t Get(int index) const;
// Minimum length for a sliced string.
static const int kMinLength = 13;
......@@ -848,10 +850,10 @@ class ExternalOneByteString : public ExternalString {
// which the pointer cache has to be refreshed.
inline void update_data_cache(Isolate* isolate);
inline const uint8_t* GetChars();
inline const uint8_t* GetChars() const;
// Dispatched behavior.
inline uint8_t Get(int index);
inline uint8_t Get(int index) const;
DECL_CAST(ExternalOneByteString)
......@@ -894,10 +896,10 @@ class ExternalTwoByteString : public ExternalString {
// which the pointer cache has to be refreshed.
inline void update_data_cache(Isolate* isolate);
inline const uint16_t* GetChars();
inline const uint16_t* GetChars() const;
// Dispatched behavior.
inline uint16_t Get(int index);
inline uint16_t Get(int index) const;
// For regexp code.
inline const uint16_t* ExternalTwoByteStringGetData(unsigned start);
......@@ -927,9 +929,9 @@ class V8_EXPORT_PRIVATE FlatStringReader : public Relocatable {
public:
FlatStringReader(Isolate* isolate, Handle<String> str);
void PostGarbageCollection() override;
inline uc32 Get(int index);
inline uc32 Get(int index) const;
template <typename Char>
inline Char Get(int index);
inline Char Get(int index) const;
int length() { return length_; }
private:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment