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

Unified Diff: src/objects.cc

Issue 804993002: Internalize strings being stored into uninitialized property cells (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: addressed comment Created 6 years 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/objects.h ('k') | test/cctest/test-strings.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index c6d5daaa7d42e49a653f9861224aad0a0244b944..5b1d18f8faea1eeec193f324074c985e968921d5 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -3096,7 +3096,7 @@ MaybeHandle<Object> Object::SetDataProperty(LookupIterator* it,
it->PrepareForDataProperty(value);
// Write the property value.
- it->WriteDataValue(value);
+ value = it->WriteDataValue(value);
// Send the change record if there are observers.
if (is_observed && !value->SameValue(*maybe_old.ToHandleChecked())) {
@@ -3152,7 +3152,7 @@ MaybeHandle<Object> Object::AddDataProperty(LookupIterator* it,
JSObject::AddSlowProperty(receiver, it->name(), value, attributes);
} else {
// Write the property value.
- it->WriteDataValue(value);
+ value = it->WriteDataValue(value);
}
// Send the change record if there are observers.
@@ -4039,7 +4039,7 @@ MaybeHandle<Object> JSObject::SetOwnPropertyIgnoreAttributes(
it.ReconfigureDataProperty(value, attributes);
it.PrepareForDataProperty(value);
- it.WriteDataValue(value);
+ value = it.WriteDataValue(value);
if (is_observed) {
RETURN_ON_EXCEPTION(
@@ -4064,7 +4064,7 @@ MaybeHandle<Object> JSObject::SetOwnPropertyIgnoreAttributes(
it.ReconfigureDataProperty(value, attributes);
it.PrepareForDataProperty(value);
- it.WriteDataValue(value);
+ value = it.WriteDataValue(value);
if (is_observed) {
if (old_value->SameValue(*value)) {
@@ -16887,13 +16887,22 @@ Handle<HeapType> PropertyCell::UpdatedType(Handle<PropertyCell> cell,
}
-void PropertyCell::SetValueInferType(Handle<PropertyCell> cell,
- Handle<Object> value) {
+Handle<Object> PropertyCell::SetValueInferType(Handle<PropertyCell> cell,
+ Handle<Object> value) {
+ // Heuristic: if a string is stored in a previously uninitialized
+ // property cell, internalize it.
+ if ((cell->type()->Is(HeapType::None()) ||
+ cell->type()->Is(HeapType::Undefined())) &&
+ value->IsString()) {
+ value = cell->GetIsolate()->factory()->InternalizeString(
+ Handle<String>::cast(value));
+ }
cell->set_value(*value);
if (!HeapType::Any()->Is(cell->type())) {
Handle<HeapType> new_type = UpdatedType(cell, value);
cell->set_type(*new_type);
}
+ return value;
}
« no previous file with comments | « src/objects.h ('k') | test/cctest/test-strings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698