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

Side by Side Diff: src/objects.cc

Issue 10802051: Fix corner case when transforming dictionary to fast elements. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 5 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/compiler.cc ('k') | test/mjsunit/regress-2249.js » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 12429 matching lines...) Expand 10 before | Expand all | Expand 10 after
12440 PropertyType type = DetailsAt(i).type(); 12440 PropertyType type = DetailsAt(i).type();
12441 ASSERT(type != FIELD); 12441 ASSERT(type != FIELD);
12442 instance_descriptor_length++; 12442 instance_descriptor_length++;
12443 if (type == NORMAL && 12443 if (type == NORMAL &&
12444 (!value->IsJSFunction() || heap->InNewSpace(value))) { 12444 (!value->IsJSFunction() || heap->InNewSpace(value))) {
12445 number_of_fields += 1; 12445 number_of_fields += 1;
12446 } 12446 }
12447 } 12447 }
12448 } 12448 }
12449 12449
12450 int inobject_props = obj->map()->inobject_properties();
12451
12452 // Allocate new map.
12453 Map* new_map;
12454 MaybeObject* maybe_new_map = obj->map()->CopyDropDescriptors();
12455 if (!maybe_new_map->To(&new_map)) return maybe_new_map;
12456
12457 if (instance_descriptor_length == 0) {
12458 ASSERT_LE(unused_property_fields, inobject_props);
12459 // Transform the object.
12460 new_map->set_unused_property_fields(unused_property_fields);
12461 obj->set_map(new_map);
12462 obj->set_properties(heap->empty_fixed_array());
12463 // Check that it really works.
12464 ASSERT(obj->HasFastProperties());
12465 return obj;
12466 }
12467
12450 // Allocate the instance descriptor. 12468 // Allocate the instance descriptor.
12451 DescriptorArray* descriptors; 12469 DescriptorArray* descriptors;
12452 MaybeObject* maybe_descriptors = 12470 MaybeObject* maybe_descriptors =
12453 DescriptorArray::Allocate(instance_descriptor_length, 12471 DescriptorArray::Allocate(instance_descriptor_length,
12454 DescriptorArray::MAY_BE_SHARED); 12472 DescriptorArray::MAY_BE_SHARED);
12455 if (!maybe_descriptors->To(&descriptors)) { 12473 if (!maybe_descriptors->To(&descriptors)) {
12456 return maybe_descriptors; 12474 return maybe_descriptors;
12457 } 12475 }
12458 12476
12459 FixedArray::WhitenessWitness witness(descriptors); 12477 FixedArray::WhitenessWitness witness(descriptors);
12460 12478
12461 int inobject_props = obj->map()->inobject_properties(); 12479 // Calculate fields to allocate.s
12462 int number_of_allocated_fields = 12480 int number_of_allocated_fields =
12463 number_of_fields + unused_property_fields - inobject_props; 12481 number_of_fields + unused_property_fields - inobject_props;
12464 if (number_of_allocated_fields < 0) { 12482 if (number_of_allocated_fields < 0) {
12465 // There is enough inobject space for all fields (including unused). 12483 // There is enough inobject space for all fields (including unused).
12466 number_of_allocated_fields = 0; 12484 number_of_allocated_fields = 0;
12467 unused_property_fields = inobject_props - number_of_fields; 12485 unused_property_fields = inobject_props - number_of_fields;
12468 } 12486 }
12469 12487
12470 // Allocate the fixed array for the fields. 12488 // Allocate the fixed array for the fields.
12471 FixedArray* fields; 12489 FixedArray* fields;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
12516 descriptors->Set(next_descriptor, &d, witness); 12534 descriptors->Set(next_descriptor, &d, witness);
12517 } else { 12535 } else {
12518 UNREACHABLE(); 12536 UNREACHABLE();
12519 } 12537 }
12520 ++next_descriptor; 12538 ++next_descriptor;
12521 } 12539 }
12522 } 12540 }
12523 ASSERT(current_offset == number_of_fields); 12541 ASSERT(current_offset == number_of_fields);
12524 12542
12525 descriptors->Sort(witness); 12543 descriptors->Sort(witness);
12526 // Allocate new map.
12527 Map* new_map;
12528 MaybeObject* maybe_new_map = obj->map()->CopyDropDescriptors();
12529 if (!maybe_new_map->To(&new_map)) return maybe_new_map;
12530 12544
12545 new_map->set_unused_property_fields(unused_property_fields);
12531 new_map->InitializeDescriptors(descriptors); 12546 new_map->InitializeDescriptors(descriptors);
12532 new_map->set_unused_property_fields(unused_property_fields);
12533 12547
12534 // Transform the object. 12548 // Transform the object.
12535 obj->set_map(new_map); 12549 obj->set_map(new_map);
12536 12550
12537 obj->set_properties(fields); 12551 obj->set_properties(fields);
12538 ASSERT(obj->IsJSObject()); 12552 ASSERT(obj->IsJSObject());
12539 12553
12540 // Check that it really works. 12554 // Check that it really works.
12541 ASSERT(obj->HasFastProperties()); 12555 ASSERT(obj->HasFastProperties());
12542 12556
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
13041 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 13055 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
13042 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); 13056 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER);
13043 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); 13057 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER);
13044 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); 13058 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER);
13045 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); 13059 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER);
13046 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); 13060 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER);
13047 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); 13061 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER);
13048 } 13062 }
13049 13063
13050 } } // namespace v8::internal 13064 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compiler.cc ('k') | test/mjsunit/regress-2249.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698