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

Unified Diff: src/json-parser.h

Issue 982793002: Don't double-allocate mutable heap numbers in the json parser. This removes some stupidity when com… (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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 | « no previous file | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/json-parser.h
diff --git a/src/json-parser.h b/src/json-parser.h
index 4cf52574b54655a9000651db6391f38bd9cf9450..b9a98d4b604a176011416580ecb8e65cbd7e0434 100644
--- a/src/json-parser.h
+++ b/src/json-parser.h
@@ -300,6 +300,7 @@ Handle<Object> JsonParser<seq_one_byte>::ParseJsonObject() {
Handle<JSObject> json_object =
factory()->NewJSObject(object_constructor(), pretenure_);
Handle<Map> map(json_object->map());
+ int descriptor = 0;
ZoneList<Handle<Object> > properties(8, zone());
DCHECK_EQ(c0_, '{');
@@ -382,18 +383,15 @@ Handle<Object> JsonParser<seq_one_byte>::ParseJsonObject() {
if (value.is_null()) return ReportUnexpectedCharacter();
if (transitioning) {
- int descriptor = map->NumberOfOwnDescriptors();
PropertyDetails details =
target->instance_descriptors()->GetDetails(descriptor);
Representation expected_representation = details.representation();
if (value->FitsRepresentation(expected_representation)) {
- if (expected_representation.IsDouble()) {
- value = Object::NewStorageFor(isolate(), value,
- expected_representation);
- } else if (expected_representation.IsHeapObject() &&
- !target->instance_descriptors()->GetFieldType(
- descriptor)->NowContains(value)) {
+ if (expected_representation.IsHeapObject() &&
+ !target->instance_descriptors()
+ ->GetFieldType(descriptor)
+ ->NowContains(value)) {
Handle<HeapType> value_type(value->OptimalType(
isolate(), expected_representation));
Map::GeneralizeFieldType(target, descriptor,
@@ -403,6 +401,7 @@ Handle<Object> JsonParser<seq_one_byte>::ParseJsonObject() {
descriptor)->NowContains(value));
properties.Add(value, zone());
map = target;
+ descriptor++;
continue;
} else {
transitioning = false;
@@ -444,30 +443,11 @@ void JsonParser<seq_one_byte>::CommitStateToJsonObject(
DCHECK(!json_object->map()->is_dictionary_map());
DisallowHeapAllocation no_gc;
- Factory* factory = isolate()->factory();
- // If the |json_object|'s map is exactly the same as |map| then the
- // |properties| values correspond to the |map| and nothing more has to be
- // done. But if the |json_object|'s map is different then we have to
- // iterate descriptors to ensure that properties still correspond to the
- // map.
- bool slow_case = json_object->map() != *map;
- DescriptorArray* descriptors = NULL;
int length = properties->length();
- if (slow_case) {
- descriptors = json_object->map()->instance_descriptors();
- DCHECK(json_object->map()->NumberOfOwnDescriptors() == length);
- }
for (int i = 0; i < length; i++) {
Handle<Object> value = (*properties)[i];
- if (slow_case && value->IsMutableHeapNumber() &&
- !descriptors->GetDetails(i).representation().IsDouble()) {
- // Turn mutable heap numbers into immutable if the field representation
- // is not double.
- HeapNumber::cast(*value)->set_map(*factory->heap_number_map());
- }
- FieldIndex index = FieldIndex::ForPropertyIndex(*map, i);
- json_object->FastPropertyAtPut(index, *value);
+ json_object->WriteToField(i, *value);
}
}
« no previous file with comments | « no previous file | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698