Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(269)

Unified Diff: src/factory.cc

Issue 1490193002: Add ExternalStringResourceBase::IsCompressible (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Yang's review Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/v8.h ('k') | src/objects.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/factory.cc
diff --git a/src/factory.cc b/src/factory.cc
index 3a933dd32f6dd362e2a7afa2d0cb5d55c471d3ab..53a3d5d4855e3d81550dea061a6062cf407ef57e 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -670,7 +670,13 @@ MaybeHandle<String> Factory::NewExternalStringFromOneByte(
THROW_NEW_ERROR(isolate(), NewInvalidStringLengthError(), String);
}
- Handle<Map> map = external_one_byte_string_map();
+ Handle<Map> map;
+ if (resource->IsCompressible()) {
+ // TODO(hajimehoshi): Rename this to 'uncached_external_one_byte_string_map'
+ map = short_external_one_byte_string_map();
+ } else {
+ map = external_one_byte_string_map();
+ }
Handle<ExternalOneByteString> external_string =
New<ExternalOneByteString>(map, NEW_SPACE);
external_string->set_length(static_cast<int>(length));
@@ -693,8 +699,15 @@ MaybeHandle<String> Factory::NewExternalStringFromTwoByte(
static const size_t kOneByteCheckLengthLimit = 32;
bool is_one_byte = length <= kOneByteCheckLengthLimit &&
String::IsOneByte(resource->data(), static_cast<int>(length));
- Handle<Map> map = is_one_byte ?
- external_string_with_one_byte_data_map() : external_string_map();
+ Handle<Map> map;
+ if (resource->IsCompressible()) {
+ // TODO(hajimehoshi): Rename these to 'uncached_external_string_...'.
Yang 2016/01/25 08:31:08 Please do not forget this TODO!
+ map = is_one_byte ? short_external_string_with_one_byte_data_map()
+ : short_external_string_map();
+ } else {
+ map = is_one_byte ? external_string_with_one_byte_data_map()
+ : external_string_map();
+ }
Handle<ExternalTwoByteString> external_string =
New<ExternalTwoByteString>(map, NEW_SPACE);
external_string->set_length(static_cast<int>(length));
« no previous file with comments | « include/v8.h ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698