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

Unified Diff: src/value-serializer.cc

Issue 2336973004: ValueDeserializer: Pretenure objects while deserializing large objects. (Closed)
Patch Set: remove the anonymous namespace; it is superfluous here Created 4 years, 3 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 | « src/value-serializer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/value-serializer.cc
diff --git a/src/value-serializer.cc b/src/value-serializer.cc
index 6c3d7e058c2dbf27d35b2b7d2c02ce5faeb55812..dec5e782c7a0c9febd4a19643d24839fb29e21e8 100644
--- a/src/value-serializer.cc
+++ b/src/value-serializer.cc
@@ -18,6 +18,7 @@ namespace v8 {
namespace internal {
static const uint32_t kLatestVersion = 9;
+static const int kPretenureThreshold = 100 * KB;
template <typename T>
static size_t BytesNeededForVarint(T value) {
@@ -751,6 +752,7 @@ ValueDeserializer::ValueDeserializer(Isolate* isolate,
: isolate_(isolate),
position_(data.start()),
end_(data.start() + data.length()),
+ pretenure_(data.length() > kPretenureThreshold ? TENURED : NOT_TENURED),
id_map_(Handle<SeededNumberDictionary>::cast(
isolate->global_handles()->Create(
*SeededNumberDictionary::New(isolate, 0)))) {}
@@ -920,17 +922,19 @@ MaybeHandle<Object> ValueDeserializer::ReadObjectInternal() {
case SerializationTag::kInt32: {
Maybe<int32_t> number = ReadZigZag<int32_t>();
if (number.IsNothing()) return MaybeHandle<Object>();
- return isolate_->factory()->NewNumberFromInt(number.FromJust());
+ return isolate_->factory()->NewNumberFromInt(number.FromJust(),
+ pretenure_);
}
case SerializationTag::kUint32: {
Maybe<uint32_t> number = ReadVarint<uint32_t>();
if (number.IsNothing()) return MaybeHandle<Object>();
- return isolate_->factory()->NewNumberFromUint(number.FromJust());
+ return isolate_->factory()->NewNumberFromUint(number.FromJust(),
+ pretenure_);
}
case SerializationTag::kDouble: {
Maybe<double> number = ReadDouble();
if (number.IsNothing()) return MaybeHandle<Object>();
- return isolate_->factory()->NewNumber(number.FromJust());
+ return isolate_->factory()->NewNumber(number.FromJust(), pretenure_);
}
case SerializationTag::kUtf8String:
return ReadUtf8String();
@@ -984,7 +988,7 @@ MaybeHandle<String> ValueDeserializer::ReadUtf8String() {
!ReadRawBytes(utf8_length).To(&utf8_bytes))
return MaybeHandle<String>();
return isolate_->factory()->NewStringFromUtf8(
- Vector<const char>::cast(utf8_bytes));
+ Vector<const char>::cast(utf8_bytes), pretenure_);
}
MaybeHandle<String> ValueDeserializer::ReadTwoByteString() {
@@ -1000,7 +1004,7 @@ MaybeHandle<String> ValueDeserializer::ReadTwoByteString() {
// string on the heap (regardless of alignment).
Handle<SeqTwoByteString> string;
if (!isolate_->factory()
- ->NewRawTwoByteString(byte_length / sizeof(uc16))
+ ->NewRawTwoByteString(byte_length / sizeof(uc16), pretenure_)
.ToHandle(&string))
return MaybeHandle<String>();
@@ -1017,7 +1021,7 @@ MaybeHandle<JSObject> ValueDeserializer::ReadJSObject() {
uint32_t id = next_id_++;
HandleScope scope(isolate_);
Handle<JSObject> object =
- isolate_->factory()->NewJSObject(isolate_->object_function());
+ isolate_->factory()->NewJSObject(isolate_->object_function(), pretenure_);
AddObjectWithID(id, object);
uint32_t num_properties;
@@ -1042,7 +1046,8 @@ MaybeHandle<JSArray> ValueDeserializer::ReadSparseJSArray() {
uint32_t id = next_id_++;
HandleScope scope(isolate_);
- Handle<JSArray> array = isolate_->factory()->NewJSArray(0);
+ Handle<JSArray> array = isolate_->factory()->NewJSArray(
+ 0, TERMINAL_FAST_ELEMENTS_KIND, pretenure_);
JSArray::SetLength(array, length);
AddObjectWithID(id, array);
@@ -1071,7 +1076,8 @@ MaybeHandle<JSArray> ValueDeserializer::ReadDenseJSArray() {
uint32_t id = next_id_++;
HandleScope scope(isolate_);
Handle<JSArray> array = isolate_->factory()->NewJSArray(
- FAST_HOLEY_ELEMENTS, length, length, INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE);
+ FAST_HOLEY_ELEMENTS, length, length, INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE,
+ pretenure_);
AddObjectWithID(id, array);
Handle<FixedArray> elements(FixedArray::cast(array->elements()), isolate_);
@@ -1116,29 +1122,30 @@ MaybeHandle<JSValue> ValueDeserializer::ReadJSValue(SerializationTag tag) {
Handle<JSValue> value;
switch (tag) {
case SerializationTag::kTrueObject:
- value = Handle<JSValue>::cast(
- isolate_->factory()->NewJSObject(isolate_->boolean_function()));
+ value = Handle<JSValue>::cast(isolate_->factory()->NewJSObject(
+ isolate_->boolean_function(), pretenure_));
value->set_value(isolate_->heap()->true_value());
break;
case SerializationTag::kFalseObject:
- value = Handle<JSValue>::cast(
- isolate_->factory()->NewJSObject(isolate_->boolean_function()));
+ value = Handle<JSValue>::cast(isolate_->factory()->NewJSObject(
+ isolate_->boolean_function(), pretenure_));
value->set_value(isolate_->heap()->false_value());
break;
case SerializationTag::kNumberObject: {
double number;
if (!ReadDouble().To(&number)) return MaybeHandle<JSValue>();
- value = Handle<JSValue>::cast(
- isolate_->factory()->NewJSObject(isolate_->number_function()));
- Handle<Object> number_object = isolate_->factory()->NewNumber(number);
+ value = Handle<JSValue>::cast(isolate_->factory()->NewJSObject(
+ isolate_->number_function(), pretenure_));
+ Handle<Object> number_object =
+ isolate_->factory()->NewNumber(number, pretenure_);
value->set_value(*number_object);
break;
}
case SerializationTag::kStringObject: {
Handle<String> string;
if (!ReadUtf8String().ToHandle(&string)) return MaybeHandle<JSValue>();
- value = Handle<JSValue>::cast(
- isolate_->factory()->NewJSObject(isolate_->string_function()));
+ value = Handle<JSValue>::cast(isolate_->factory()->NewJSObject(
+ isolate_->string_function(), pretenure_));
value->set_value(*string);
break;
}
@@ -1247,7 +1254,8 @@ MaybeHandle<JSArrayBuffer> ValueDeserializer::ReadJSArrayBuffer() {
return MaybeHandle<JSArrayBuffer>();
}
const bool should_initialize = false;
- Handle<JSArrayBuffer> array_buffer = isolate_->factory()->NewJSArrayBuffer();
+ Handle<JSArrayBuffer> array_buffer =
+ isolate_->factory()->NewJSArrayBuffer(SharedFlag::kNotShared, pretenure_);
JSArrayBuffer::SetupAllocatingData(array_buffer, isolate_, byte_length,
should_initialize);
memcpy(array_buffer->backing_store(), position_, byte_length);
@@ -1311,7 +1319,8 @@ MaybeHandle<JSArrayBufferView> ValueDeserializer::ReadJSArrayBufferView(
return MaybeHandle<JSArrayBufferView>();
}
Handle<JSTypedArray> typed_array = isolate_->factory()->NewJSTypedArray(
- external_array_type, buffer, byte_offset, byte_length / element_size);
+ external_array_type, buffer, byte_offset, byte_length / element_size,
+ pretenure_);
AddObjectWithID(id, typed_array);
return typed_array;
}
@@ -1415,8 +1424,8 @@ ValueDeserializer::ReadObjectUsingEntireBufferForLegacyFormat() {
size_t begin_properties =
stack.size() - 2 * static_cast<size_t>(num_properties);
- Handle<JSObject> js_object =
- isolate_->factory()->NewJSObject(isolate_->object_function());
+ Handle<JSObject> js_object = isolate_->factory()->NewJSObject(
+ isolate_->object_function(), pretenure_);
if (num_properties &&
!SetPropertiesFromKeyValuePairs(
isolate_, js_object, &stack[begin_properties], num_properties)
@@ -1440,7 +1449,8 @@ ValueDeserializer::ReadObjectUsingEntireBufferForLegacyFormat() {
return MaybeHandle<Object>();
}
- Handle<JSArray> js_array = isolate_->factory()->NewJSArray(0);
+ Handle<JSArray> js_array = isolate_->factory()->NewJSArray(
+ 0, TERMINAL_FAST_ELEMENTS_KIND, pretenure_);
JSArray::SetLength(js_array, length);
size_t begin_properties =
stack.size() - 2 * static_cast<size_t>(num_properties);
« no previous file with comments | « src/value-serializer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698