From 39d0b85430751f260f64d08d7c6864edb379598e Mon Sep 17 00:00:00 2001 From: yangguo Date: Tue, 25 Nov 2014 07:29:50 -0800 Subject: [PATCH] Force inline Stirng::GetCharVector<>. R=mvstanton@chromium.org BUG=chromium:436447 Review URL: https://codereview.chromium.org/756983003 Cr-Commit-Position: refs/heads/master@{#25504} --- src/objects-inl.h | 16 ++++++++++++++++ src/objects.cc | 16 ---------------- src/objects.h | 2 +- src/runtime/runtime-uri.cc | 32 ++++++-------------------------- 4 files changed, 23 insertions(+), 43 deletions(-) diff --git a/src/objects-inl.h b/src/objects-inl.h index 9a65e16..9172257 100644 --- a/src/objects-inl.h +++ b/src/objects-inl.h @@ -3581,6 +3581,22 @@ ConsString* String::VisitFlat(Visitor* visitor, } +template <> +inline Vector String::GetCharVector() { + String::FlatContent flat = GetFlatContent(); + DCHECK(flat.IsOneByte()); + return flat.ToOneByteVector(); +} + + +template <> +inline Vector String::GetCharVector() { + String::FlatContent flat = GetFlatContent(); + DCHECK(flat.IsTwoByte()); + return flat.ToUC16Vector(); +} + + uint16_t SeqOneByteString::SeqOneByteStringGet(int index) { DCHECK(index >= 0 && index < length()); return READ_BYTE_FIELD(this, kHeaderSize + index * kCharSize); diff --git a/src/objects.cc b/src/objects.cc index 82ff09b..5262ed6 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -8298,22 +8298,6 @@ String::FlatContent String::GetFlatContent() { } -template <> -Vector String::GetCharVector() { - String::FlatContent flat = GetFlatContent(); - DCHECK(flat.IsOneByte()); - return flat.ToOneByteVector(); -} - - -template <> -Vector String::GetCharVector() { - String::FlatContent flat = GetFlatContent(); - DCHECK(flat.IsTwoByte()); - return flat.ToUC16Vector(); -} - - SmartArrayPointer String::ToCString(AllowNullsFlag allow_nulls, RobustnessFlag robust_flag, int offset, diff --git a/src/objects.h b/src/objects.h index 502d263..664a506 100644 --- a/src/objects.h +++ b/src/objects.h @@ -8815,7 +8815,7 @@ class String: public Name { }; template - Vector GetCharVector(); + INLINE(Vector GetCharVector()); // Get and set the length of the string. inline int length() const; diff --git a/src/runtime/runtime-uri.cc b/src/runtime/runtime-uri.cc index 16e80b5..477071a 100644 --- a/src/runtime/runtime-uri.cc +++ b/src/runtime/runtime-uri.cc @@ -14,26 +14,6 @@ namespace v8 { namespace internal { -template -static INLINE(Vector GetCharVector(Handle string)); - - -template <> -Vector GetCharVector(Handle string) { - String::FlatContent flat = string->GetFlatContent(); - DCHECK(flat.IsOneByte()); - return flat.ToOneByteVector(); -} - - -template <> -Vector GetCharVector(Handle string) { - String::FlatContent flat = string->GetFlatContent(); - DCHECK(flat.IsTwoByte()); - return flat.ToUC16Vector(); -} - - class URIUnescape : public AllStatic { public: template @@ -72,7 +52,7 @@ MaybeHandle URIUnescape::Unescape(Isolate* isolate, { DisallowHeapAllocation no_allocation; StringSearch search(isolate, STATIC_CHAR_VECTOR("%")); - index = search.Search(GetCharVector(source), 0); + index = search.Search(source->GetCharVector(), 0); if (index < 0) return source; } return UnescapeSlow(isolate, source, index); @@ -89,7 +69,7 @@ MaybeHandle URIUnescape::UnescapeSlow(Isolate* isolate, int unescaped_length = 0; { DisallowHeapAllocation no_allocation; - Vector vector = GetCharVector(string); + Vector vector = string->GetCharVector(); for (int i = start_index; i < length; unescaped_length++) { int step; if (UnescapeChar(vector, i, length, &step) > @@ -112,7 +92,7 @@ MaybeHandle URIUnescape::UnescapeSlow(Isolate* isolate, ->NewRawOneByteString(unescaped_length) .ToHandleChecked(); DisallowHeapAllocation no_allocation; - Vector vector = GetCharVector(string); + Vector vector = string->GetCharVector(); for (int i = start_index; i < length; dest_position++) { int step; dest->SeqOneByteStringSet(dest_position, @@ -125,7 +105,7 @@ MaybeHandle URIUnescape::UnescapeSlow(Isolate* isolate, ->NewRawTwoByteString(unescaped_length) .ToHandleChecked(); DisallowHeapAllocation no_allocation; - Vector vector = GetCharVector(string); + Vector vector = string->GetCharVector(); for (int i = start_index; i < length; dest_position++) { int step; dest->SeqTwoByteStringSet(dest_position, @@ -221,7 +201,7 @@ MaybeHandle URIEscape::Escape(Isolate* isolate, Handle string) { { DisallowHeapAllocation no_allocation; - Vector vector = GetCharVector(string); + Vector vector = string->GetCharVector(); for (int i = 0; i < length; i++) { uint16_t c = vector[i]; if (c >= 256) { @@ -249,7 +229,7 @@ MaybeHandle URIEscape::Escape(Isolate* isolate, Handle string) { { DisallowHeapAllocation no_allocation; - Vector vector = GetCharVector(string); + Vector vector = string->GetCharVector(); for (int i = 0; i < length; i++) { uint16_t c = vector[i]; if (c >= 256) { -- 2.7.4