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

Unified Diff: src/objects-inl.h

Issue 15739003: Fix unexpected elements transition in JSON.parse (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 7 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 | test/mjsunit/regress/regress-241344.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index 40cb1fdeda173008888fa2a09e5bc725ea24f331..95a0eca6a88ac51a04b2e47b59439a104cc4e9ae 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -1505,9 +1505,19 @@ MaybeObject* JSObject::ResetElements() {
MaybeObject* JSObject::AllocateStorageForMap(Map* map) {
ASSERT(this->map()->inobject_properties() == map->inobject_properties());
- ElementsKind expected_kind = this->map()->elements_kind();
- if (map->elements_kind() != expected_kind) {
- MaybeObject* maybe_map = map->AsElementsKind(expected_kind);
+ ElementsKind obj_kind = this->map()->elements_kind();
+ ElementsKind map_kind = map->elements_kind();
+ if (map_kind != obj_kind) {
+ ElementsKind to_kind = map_kind;
+ if (IsMoreGeneralElementsKindTransition(map_kind, obj_kind) ||
+ IsDictionaryElementsKind(obj_kind)) {
+ to_kind = obj_kind;
+ }
+ MaybeObject* maybe_obj =
+ IsDictionaryElementsKind(to_kind) ? NormalizeElements()
+ : TransitionElementsKind(to_kind);
+ if (maybe_obj->IsFailure()) return maybe_obj;
+ MaybeObject* maybe_map = map->AsElementsKind(to_kind);
if (!maybe_map->To(&map)) return maybe_map;
}
int total_size =
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-241344.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698