Chromium Code Reviews| Index: src/json-parser.h |
| diff --git a/src/json-parser.h b/src/json-parser.h |
| index 74850cae253aab2cabcdc5a7138052e2cf0c84c5..62d0efdd9cc105f5bad4ce48c120530a5c052cb6 100644 |
| --- a/src/json-parser.h |
| +++ b/src/json-parser.h |
| @@ -404,7 +404,13 @@ Handle<Object> JsonParser<seq_ascii>::ParseJsonObject() { |
| JSObject::TransitionToMap(json_object, map); |
| int length = properties.length(); |
| for (int i = 0; i < length; i++) { |
| - json_object->FastPropertyAtPut(i, *properties[i]); |
| + Handle<Object> value = properties[i]; |
| + Representation representation = |
| + map->instance_descriptors()->GetDetails(i).representation(); |
| + if (representation.IsDouble() && value->IsSmi()) { |
| + // TODO(verwaest): Allocate heap number. |
| + } |
| + json_object->FastPropertyAtPut(i, *value); |
| } |
| transitioning = false; |
| } |
| @@ -416,7 +422,16 @@ Handle<Object> JsonParser<seq_ascii>::ParseJsonObject() { |
| if (value.is_null()) return ReportUnexpectedCharacter(); |
| properties.Add(value, zone()); |
| - if (transitioning) continue; |
| + if (transitioning) { |
| + int field = properties.length() - 1; |
| + Representation expected_representation = |
| + map->instance_descriptors()->GetDetails(field).representation(); |
| + if (!value->FitsRepresentation(expected_representation)) { |
| + map = Map::GeneralizeRepresentation( |
| + map, field, value->RequiredRepresentation()); |
|
danno
2013/04/24 15:23:00
OptimalRepresentation
Toon Verwaest
2013/04/25 10:59:38
Done.
|
| + } |
| + continue; |
| + } |
| } else { |
| key = ParseJsonInternalizedString(); |
| if (key.is_null() || c0_ != ':') return ReportUnexpectedCharacter(); |
| @@ -438,7 +453,13 @@ Handle<Object> JsonParser<seq_ascii>::ParseJsonObject() { |
| JSObject::TransitionToMap(json_object, map); |
| int length = properties.length(); |
| for (int i = 0; i < length; i++) { |
| - json_object->FastPropertyAtPut(i, *properties[i]); |
| + Handle<Object> value = properties[i]; |
| + Representation representation = |
| + map->instance_descriptors()->GetDetails(i).representation(); |
| + if (representation.IsDouble() && value->IsSmi()) { |
| + // TODO(verwaest): Allocate heap number. |
| + } |
| + json_object->FastPropertyAtPut(i, *value); |
| } |
| } |
| } |