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

Side by Side Diff: src/objects.cc

Issue 8082023: Fix map modification in transition tree traversal. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comment by Vyacheslav Egorov. Created 9 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 4456 matching lines...) Expand 10 before | Expand all | Expand 10 after
4467 for (int i = map_or_index->IsSmi() ? Smi::cast(map_or_index)->value() : 0; 4467 for (int i = map_or_index->IsSmi() ? Smi::cast(map_or_index)->value() : 0;
4468 i < contents->length(); 4468 i < contents->length();
4469 i += 2) { 4469 i += 2) {
4470 PropertyDetails details(Smi::cast(contents->get(i + 1))); 4470 PropertyDetails details(Smi::cast(contents->get(i + 1)));
4471 if (details.IsTransition()) { 4471 if (details.IsTransition()) {
4472 // Found a map in the transition array. We record our progress in 4472 // Found a map in the transition array. We record our progress in
4473 // the transition array by recording the current map in the map field 4473 // the transition array by recording the current map in the map field
4474 // of the next map and recording the index in the transition array in 4474 // of the next map and recording the index in the transition array in
4475 // the map field of the array. 4475 // the map field of the array.
4476 Map* next = Map::cast(contents->get(i)); 4476 Map* next = Map::cast(contents->get(i));
4477 next->set_map(current); 4477 next->set_map_unsafe(current);
4478 *map_or_index_field = Smi::FromInt(i + 2); 4478 *map_or_index_field = Smi::FromInt(i + 2);
4479 current = next; 4479 current = next;
4480 map_done = false; 4480 map_done = false;
4481 break; 4481 break;
4482 } 4482 }
4483 } 4483 }
4484 if (!map_done) continue; 4484 if (!map_done) continue;
4485 } else { 4485 } else {
4486 map_or_index_field = NULL; 4486 map_or_index_field = NULL;
4487 } 4487 }
4488 // That was the regular transitions, now for the prototype transitions. 4488 // That was the regular transitions, now for the prototype transitions.
4489 FixedArray* prototype_transitions = 4489 FixedArray* prototype_transitions =
4490 current->unchecked_prototype_transitions(); 4490 current->unchecked_prototype_transitions();
4491 Object** proto_map_or_index_field = 4491 Object** proto_map_or_index_field =
4492 RawField(prototype_transitions, HeapObject::kMapOffset); 4492 RawField(prototype_transitions, HeapObject::kMapOffset);
4493 Object* map_or_index = *proto_map_or_index_field; 4493 Object* map_or_index = *proto_map_or_index_field;
4494 const int start = kProtoTransitionHeaderSize + kProtoTransitionMapOffset; 4494 const int start = kProtoTransitionHeaderSize + kProtoTransitionMapOffset;
4495 int i = map_or_index->IsSmi() ? Smi::cast(map_or_index)->value() : start; 4495 int i = map_or_index->IsSmi() ? Smi::cast(map_or_index)->value() : start;
4496 if (i < prototype_transitions->length()) { 4496 if (i < prototype_transitions->length()) {
4497 // Found a map in the prototype transition array. Record progress in 4497 // Found a map in the prototype transition array. Record progress in
4498 // an analogous way to the regular transitions array above. 4498 // an analogous way to the regular transitions array above.
4499 Object* perhaps_map = prototype_transitions->get(i); 4499 Object* perhaps_map = prototype_transitions->get(i);
4500 if (perhaps_map->IsMap()) { 4500 if (perhaps_map->IsMap()) {
4501 Map* next = Map::cast(perhaps_map); 4501 Map* next = Map::cast(perhaps_map);
4502 next->set_map(current); 4502 next->set_map_unsafe(current);
4503 *proto_map_or_index_field = 4503 *proto_map_or_index_field =
4504 Smi::FromInt(i + kProtoTransitionElementsPerEntry); 4504 Smi::FromInt(i + kProtoTransitionElementsPerEntry);
4505 current = next; 4505 current = next;
4506 continue; 4506 continue;
4507 } 4507 }
4508 } 4508 }
4509 *proto_map_or_index_field = GetHeap()->fixed_array_map(); 4509 *proto_map_or_index_field = GetHeap()->fixed_array_map();
4510 if (map_or_index_field != NULL) { 4510 if (map_or_index_field != NULL) {
4511 *map_or_index_field = GetHeap()->fixed_array_map(); 4511 *map_or_index_field = GetHeap()->fixed_array_map();
4512 } 4512 }
4513 4513
4514 // The callback expects a map to have a real map as its map, so we save 4514 // The callback expects a map to have a real map as its map, so we save
4515 // the map field, which is being used to track the traversal and put the 4515 // the map field, which is being used to track the traversal and put the
4516 // correct map (the meta_map) in place while we do the callback. 4516 // correct map (the meta_map) in place while we do the callback.
4517 Map* prev = current->map(); 4517 Map* prev = current->map();
4518 current->set_map(meta_map); 4518 current->set_map_unsafe(meta_map);
4519 callback(current, data); 4519 callback(current, data);
4520 current = prev; 4520 current = prev;
4521 } 4521 }
4522 } 4522 }
4523 4523
4524 4524
4525 MaybeObject* CodeCache::Update(String* name, Code* code) { 4525 MaybeObject* CodeCache::Update(String* name, Code* code) {
4526 // The number of monomorphic stubs for normal load/store/call IC's can grow to 4526 // The number of monomorphic stubs for normal load/store/call IC's can grow to
4527 // a large number and therefore they need to go into a hash table. They are 4527 // a large number and therefore they need to go into a hash table. They are
4528 // used to load global properties from cells. 4528 // used to load global properties from cells.
(...skipping 7539 matching lines...) Expand 10 before | Expand all | Expand 10 after
12068 if (break_point_objects()->IsUndefined()) return 0; 12068 if (break_point_objects()->IsUndefined()) return 0;
12069 // Single break point. 12069 // Single break point.
12070 if (!break_point_objects()->IsFixedArray()) return 1; 12070 if (!break_point_objects()->IsFixedArray()) return 1;
12071 // Multiple break points. 12071 // Multiple break points.
12072 return FixedArray::cast(break_point_objects())->length(); 12072 return FixedArray::cast(break_point_objects())->length();
12073 } 12073 }
12074 #endif 12074 #endif
12075 12075
12076 12076
12077 } } // namespace v8::internal 12077 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698