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

Unified Diff: src/json-parser.h

Issue 14146005: Track representations of fields (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add test for tracking fields Created 7 years, 8 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/ic.cc ('k') | 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 74850cae253aab2cabcdc5a7138052e2cf0c84c5..78c1a7a4e0ddb5e90e756bf80b7d8eefff880253 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->OptimalRepresentation());
+ }
+ 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);
}
}
}
« no previous file with comments | « src/ic.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698