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

Side by Side Diff: src/handles.cc

Issue 149458: Remove the descriptor stream abstractions.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 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
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 Handle<Object> GetHiddenProperties(Handle<JSObject> obj, 282 Handle<Object> GetHiddenProperties(Handle<JSObject> obj,
283 bool create_if_needed) { 283 bool create_if_needed) {
284 Handle<String> key = Factory::hidden_symbol(); 284 Handle<String> key = Factory::hidden_symbol();
285 285
286 if (obj->HasFastProperties()) { 286 if (obj->HasFastProperties()) {
287 // If the object has fast properties, check whether the first slot 287 // If the object has fast properties, check whether the first slot
288 // in the descriptor array matches the hidden symbol. Since the 288 // in the descriptor array matches the hidden symbol. Since the
289 // hidden symbols hash code is zero (and no other string has hash 289 // hidden symbols hash code is zero (and no other string has hash
290 // code zero) it will always occupy the first entry if present. 290 // code zero) it will always occupy the first entry if present.
291 DescriptorArray* descriptors = obj->map()->instance_descriptors(); 291 DescriptorArray* descriptors = obj->map()->instance_descriptors();
292 DescriptorReader r(descriptors, 0); // Explicitly position reader at zero. 292 if ((descriptors->number_of_descriptors() > 0) &&
293 if (!r.eos() && (r.GetKey() == *key) && r.IsProperty()) { 293 (descriptors->GetKey(0) == *key) &&
294 ASSERT(r.type() == FIELD); 294 descriptors->IsProperty(0)) {
295 return Handle<Object>(obj->FastPropertyAt(r.GetFieldIndex())); 295 ASSERT(descriptors->GetType(0) == FIELD);
296 return Handle<Object>(obj->FastPropertyAt(descriptors->GetFieldIndex(0)));
296 } 297 }
297 } 298 }
298 299
299 // Only attempt to find the hidden properties in the local object and not 300 // Only attempt to find the hidden properties in the local object and not
300 // in the prototype chain. Note that HasLocalProperty() can cause a GC in 301 // in the prototype chain. Note that HasLocalProperty() can cause a GC in
301 // the general case in the presence of interceptors. 302 // the general case in the presence of interceptors.
302 if (!obj->HasLocalProperty(*key)) { 303 if (!obj->HasLocalProperty(*key)) {
303 // Hidden properties object not found. Allocate a new hidden properties 304 // Hidden properties object not found. Allocate a new hidden properties
304 // object if requested. Otherwise return the undefined value. 305 // object if requested. Otherwise return the undefined value.
305 if (create_if_needed) { 306 if (create_if_needed) {
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 if (object->HasFastProperties()) { 582 if (object->HasFastProperties()) {
582 if (object->map()->instance_descriptors()->HasEnumCache()) { 583 if (object->map()->instance_descriptors()->HasEnumCache()) {
583 Counters::enum_cache_hits.Increment(); 584 Counters::enum_cache_hits.Increment();
584 DescriptorArray* desc = object->map()->instance_descriptors(); 585 DescriptorArray* desc = object->map()->instance_descriptors();
585 return Handle<FixedArray>(FixedArray::cast(desc->GetEnumCache())); 586 return Handle<FixedArray>(FixedArray::cast(desc->GetEnumCache()));
586 } 587 }
587 Counters::enum_cache_misses.Increment(); 588 Counters::enum_cache_misses.Increment();
588 int num_enum = object->NumberOfEnumProperties(); 589 int num_enum = object->NumberOfEnumProperties();
589 Handle<FixedArray> storage = Factory::NewFixedArray(num_enum); 590 Handle<FixedArray> storage = Factory::NewFixedArray(num_enum);
590 Handle<FixedArray> sort_array = Factory::NewFixedArray(num_enum); 591 Handle<FixedArray> sort_array = Factory::NewFixedArray(num_enum);
591 for (DescriptorReader r(object->map()->instance_descriptors()); 592 Handle<DescriptorArray> descs =
592 !r.eos(); 593 Handle<DescriptorArray>(object->map()->instance_descriptors());
593 r.advance()) { 594 for (int i = 0; i < descs->number_of_descriptors(); i++) {
594 if (r.IsProperty() && !r.IsDontEnum()) { 595 if (descs->IsProperty(i) && !descs->IsDontEnum(i)) {
595 (*storage)->set(index, r.GetKey()); 596 (*storage)->set(index, descs->GetKey(i));
596 (*sort_array)->set(index, Smi::FromInt(r.GetDetails().index())); 597 PropertyDetails details(descs->GetDetails(i));
598 (*sort_array)->set(index, Smi::FromInt(details.index()));
597 index++; 599 index++;
598 } 600 }
599 } 601 }
600 (*storage)->SortPairs(*sort_array, sort_array->length()); 602 (*storage)->SortPairs(*sort_array, sort_array->length());
601 Handle<FixedArray> bridge_storage = 603 Handle<FixedArray> bridge_storage =
602 Factory::NewFixedArray(DescriptorArray::kEnumCacheBridgeLength); 604 Factory::NewFixedArray(DescriptorArray::kEnumCacheBridgeLength);
603 DescriptorArray* desc = object->map()->instance_descriptors(); 605 DescriptorArray* desc = object->map()->instance_descriptors();
604 desc->SetEnumCache(*bridge_storage, *storage); 606 desc->SetEnumCache(*bridge_storage, *storage);
605 ASSERT(storage->length() == index); 607 ASSERT(storage->length() == index);
606 return storage; 608 return storage;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 Handle<Map> new_map = Factory::CopyMapDropTransitions(old_map); 743 Handle<Map> new_map = Factory::CopyMapDropTransitions(old_map);
742 obj->set_map(*new_map); 744 obj->set_map(*new_map);
743 new_map->set_needs_loading(true); 745 new_map->set_needs_loading(true);
744 // Store the lazy loading info in the constructor field. We'll 746 // Store the lazy loading info in the constructor field. We'll
745 // reestablish the constructor from the fixed array after loading. 747 // reestablish the constructor from the fixed array after loading.
746 new_map->set_constructor(*arr); 748 new_map->set_constructor(*arr);
747 ASSERT(!obj->IsLoaded()); 749 ASSERT(!obj->IsLoaded());
748 } 750 }
749 751
750 } } // namespace v8::internal 752 } } // namespace v8::internal
OLDNEW
« src/factory.cc ('K') | « src/factory.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698