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

Side by Side Diff: src/handles.cc

Issue 212673011: Fix property enum cache creation to include only own properties (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-enum-prop-keys-cache-size.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 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 656
657 Handle<Map> map(object->map()); 657 Handle<Map> map(object->map());
658 658
659 if (map->instance_descriptors()->IsEmpty()) { 659 if (map->instance_descriptors()->IsEmpty()) {
660 isolate->counters()->enum_cache_hits()->Increment(); 660 isolate->counters()->enum_cache_hits()->Increment();
661 if (cache_result) map->SetEnumLength(0); 661 if (cache_result) map->SetEnumLength(0);
662 return isolate->factory()->empty_fixed_array(); 662 return isolate->factory()->empty_fixed_array();
663 } 663 }
664 664
665 isolate->counters()->enum_cache_misses()->Increment(); 665 isolate->counters()->enum_cache_misses()->Increment();
666 int num_enum = map->NumberOfDescribedProperties(ALL_DESCRIPTORS, DONT_SHOW); 666 int num_enum = map->NumberOfDescribedProperties(OWN_DESCRIPTORS, DONT_SHOW);
Toon Verwaest 2014/03/27 11:53:39 This valid is already available as own_property_co
667 667
668 Handle<FixedArray> storage = isolate->factory()->NewFixedArray(num_enum); 668 Handle<FixedArray> storage = isolate->factory()->NewFixedArray(num_enum);
669 Handle<FixedArray> indices = isolate->factory()->NewFixedArray(num_enum); 669 Handle<FixedArray> indices = isolate->factory()->NewFixedArray(num_enum);
670 670
671 Handle<DescriptorArray> descs = 671 Handle<DescriptorArray> descs =
672 Handle<DescriptorArray>(object->map()->instance_descriptors(), isolate); 672 Handle<DescriptorArray>(object->map()->instance_descriptors(), isolate);
673 673
674 int real_size = map->NumberOfOwnDescriptors(); 674 int size = map->NumberOfOwnDescriptors();
675 int enum_size = 0;
676 int index = 0; 675 int index = 0;
677 676
678 for (int i = 0; i < descs->number_of_descriptors(); i++) { 677 for (int i = 0; i < size; i++) {
679 PropertyDetails details = descs->GetDetails(i); 678 PropertyDetails details = descs->GetDetails(i);
680 Object* key = descs->GetKey(i); 679 Object* key = descs->GetKey(i);
681 if (!(details.IsDontEnum() || key->IsSymbol())) { 680 if (!(details.IsDontEnum() || key->IsSymbol())) {
682 if (i < real_size) ++enum_size;
683 storage->set(index, key); 681 storage->set(index, key);
684 if (!indices.is_null()) { 682 if (!indices.is_null()) {
685 if (details.type() != FIELD) { 683 if (details.type() != FIELD) {
686 indices = Handle<FixedArray>(); 684 indices = Handle<FixedArray>();
687 } else { 685 } else {
688 int field_index = descs->GetFieldIndex(i); 686 int field_index = descs->GetFieldIndex(i);
689 if (field_index >= map->inobject_properties()) { 687 if (field_index >= map->inobject_properties()) {
690 field_index = -(field_index - map->inobject_properties() + 1); 688 field_index = -(field_index - map->inobject_properties() + 1);
691 } 689 }
692 indices->set(index, Smi::FromInt(field_index)); 690 indices->set(index, Smi::FromInt(field_index));
693 } 691 }
694 } 692 }
695 index++; 693 index++;
696 } 694 }
697 } 695 }
698 ASSERT(index == storage->length()); 696 ASSERT(index == storage->length());
699 697
700 Handle<FixedArray> bridge_storage = 698 Handle<FixedArray> bridge_storage =
701 isolate->factory()->NewFixedArray( 699 isolate->factory()->NewFixedArray(
702 DescriptorArray::kEnumCacheBridgeLength); 700 DescriptorArray::kEnumCacheBridgeLength);
703 DescriptorArray* desc = object->map()->instance_descriptors(); 701 DescriptorArray* desc = object->map()->instance_descriptors();
704 desc->SetEnumCache(*bridge_storage, 702 desc->SetEnumCache(*bridge_storage,
705 *storage, 703 *storage,
706 indices.is_null() ? Object::cast(Smi::FromInt(0)) 704 indices.is_null() ? Object::cast(Smi::FromInt(0))
707 : Object::cast(*indices)); 705 : Object::cast(*indices));
708 if (cache_result) { 706 if (cache_result) {
709 object->map()->SetEnumLength(enum_size); 707 object->map()->SetEnumLength(index);
Toon Verwaest 2014/03/27 11:53:39 use own_property_count here.
710 } 708 }
711 709 return storage;
712 return ReduceFixedArrayTo(storage, enum_size);
713 } else { 710 } else {
714 Handle<NameDictionary> dictionary(object->property_dictionary()); 711 Handle<NameDictionary> dictionary(object->property_dictionary());
715 int length = dictionary->NumberOfEnumElements(); 712 int length = dictionary->NumberOfEnumElements();
716 if (length == 0) { 713 if (length == 0) {
717 return Handle<FixedArray>(isolate->heap()->empty_fixed_array()); 714 return Handle<FixedArray>(isolate->heap()->empty_fixed_array());
718 } 715 }
719 Handle<FixedArray> storage = isolate->factory()->NewFixedArray(length); 716 Handle<FixedArray> storage = isolate->factory()->NewFixedArray(length);
720 dictionary->CopyEnumKeysTo(*storage); 717 dictionary->CopyEnumKeysTo(*storage);
721 return storage; 718 return storage;
722 } 719 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 Handle<Code> code) { 764 Handle<Code> code) {
768 heap->EnsureWeakObjectToCodeTable(); 765 heap->EnsureWeakObjectToCodeTable();
769 Handle<DependentCode> dep(heap->LookupWeakObjectToCodeDependency(*object)); 766 Handle<DependentCode> dep(heap->LookupWeakObjectToCodeDependency(*object));
770 dep = DependentCode::Insert(dep, DependentCode::kWeaklyEmbeddedGroup, code); 767 dep = DependentCode::Insert(dep, DependentCode::kWeaklyEmbeddedGroup, code);
771 CALL_HEAP_FUNCTION_VOID(heap->isolate(), 768 CALL_HEAP_FUNCTION_VOID(heap->isolate(),
772 heap->AddWeakObjectToCodeDependency(*object, *dep)); 769 heap->AddWeakObjectToCodeDependency(*object, *dep));
773 } 770 }
774 771
775 772
776 } } // namespace v8::internal 773 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-enum-prop-keys-cache-size.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698