Reland "[runtime] Inline SeqOneByteSubStringKey IsMatch and AsHandle"

Original change's description:
> [runtime] Inline SeqOneByteSubStringKey IsMatch and AsHandle
>
> The performance actually matters to JSON parsing and this improves it by a % or
> 2.
>
> In the longer run we should probably share the IsMatch implementation in
> StringTableKey directly and call a virtual GetBytes on the key implementation.
>
> Change-Id: I838a106f9c8c52f0385057a52a8c0b9141ae025b
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1589977
> Commit-Queue: Toon Verwaest <verwaest@chromium.org>
> Auto-Submit: Toon Verwaest <verwaest@chromium.org>
> Reviewed-by: Igor Sheludko <ishell@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#61183}

Change-Id: I3fc73b4d123f193f7c2ce3078b0b030a652efc17
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1596735
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61248}
This commit is contained in:
Toon Verwaest 2019-05-06 15:49:50 +02:00 committed by Commit Bot
parent 8381ea7b29
commit 6c2a4bfb12
2 changed files with 16 additions and 19 deletions

View File

@ -6477,23 +6477,6 @@ class RegExpKey : public HashTableKey {
Smi flags_;
};
Handle<String> SeqOneByteSubStringKey::AsHandle(Isolate* isolate) {
return isolate->factory()->NewOneByteInternalizedSubString(
string_, from_, length_, HashField());
}
bool SeqOneByteSubStringKey::IsMatch(Object object) {
DisallowHeapAllocation no_gc;
String string = String::cast(object);
if (string.length() != length_) return false;
if (string.IsOneByteRepresentation()) {
const uint8_t* data = string.GetChars<uint8_t>(no_gc);
return CompareChars(string_->GetChars(no_gc) + from_, data, length_) == 0;
}
const uint16_t* data = string.GetChars<uint16_t>(no_gc);
return CompareChars(string_->GetChars(no_gc) + from_, data, length_) == 0;
}
// InternalizedStringKey carries a string/internalized-string object as key.
class InternalizedStringKey : public StringTableKey {
public:

View File

@ -260,8 +260,22 @@ class SeqOneByteSubStringKey final : public StringTableKey {
#pragma warning(pop)
#endif
bool IsMatch(Object string) override;
Handle<String> AsHandle(Isolate* isolate) override;
bool IsMatch(Object object) override {
DisallowHeapAllocation no_gc;
String string = String::cast(object);
if (string.length() != length_) return false;
if (string.IsOneByteRepresentation()) {
const uint8_t* data = string.GetChars<uint8_t>(no_gc);
return CompareChars(string_->GetChars(no_gc) + from_, data, length_) == 0;
}
const uint16_t* data = string.GetChars<uint16_t>(no_gc);
return CompareChars(string_->GetChars(no_gc) + from_, data, length_) == 0;
}
Handle<String> AsHandle(Isolate* isolate) override {
return isolate->factory()->NewOneByteInternalizedSubString(
string_, from_, length_, HashField());
}
private:
Handle<SeqOneByteString> string_;