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

Side by Side Diff: src/objects.cc

Issue 10827220: Fix handling of accessors on trunk. This is a combination of (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 8 years, 4 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 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 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 if (details.IsDontDelete()) { 509 if (details.IsDontDelete()) {
510 if (mode != FORCE_DELETION) return GetHeap()->false_value(); 510 if (mode != FORCE_DELETION) return GetHeap()->false_value();
511 // When forced to delete global properties, we have to make a 511 // When forced to delete global properties, we have to make a
512 // map change to invalidate any ICs that think they can load 512 // map change to invalidate any ICs that think they can load
513 // from the DontDelete cell without checking if it contains 513 // from the DontDelete cell without checking if it contains
514 // the hole value. 514 // the hole value.
515 Map* new_map; 515 Map* new_map;
516 MaybeObject* maybe_new_map = map()->CopyDropDescriptors(); 516 MaybeObject* maybe_new_map = map()->CopyDropDescriptors();
517 if (!maybe_new_map->To(&new_map)) return maybe_new_map; 517 if (!maybe_new_map->To(&new_map)) return maybe_new_map;
518 518
519 ASSERT(new_map->is_dictionary_map());
519 set_map(new_map); 520 set_map(new_map);
520 } 521 }
521 JSGlobalPropertyCell* cell = 522 JSGlobalPropertyCell* cell =
522 JSGlobalPropertyCell::cast(dictionary->ValueAt(entry)); 523 JSGlobalPropertyCell::cast(dictionary->ValueAt(entry));
523 cell->set_value(cell->GetHeap()->the_hole_value()); 524 cell->set_value(cell->GetHeap()->the_hole_value());
524 dictionary->DetailsAtPut(entry, details.AsDeleted()); 525 dictionary->DetailsAtPut(entry, details.AsDeleted());
525 } else { 526 } else {
526 Object* deleted = dictionary->DeleteProperty(entry, mode); 527 Object* deleted = dictionary->DeleteProperty(entry, mode);
527 if (deleted == GetHeap()->true_value()) { 528 if (deleted == GetHeap()->true_value()) {
528 FixedArray* new_properties = NULL; 529 FixedArray* new_properties = NULL;
(...skipping 2682 matching lines...) Expand 10 before | Expand all | Expand 10 after
3211 } 3212 }
3212 } 3213 }
3213 #endif 3214 #endif
3214 return result; 3215 return result;
3215 } 3216 }
3216 3217
3217 { MaybeObject* maybe_result = 3218 { MaybeObject* maybe_result =
3218 fast->CopyNormalized(mode, SHARED_NORMALIZED_MAP); 3219 fast->CopyNormalized(mode, SHARED_NORMALIZED_MAP);
3219 if (!maybe_result->ToObject(&result)) return maybe_result; 3220 if (!maybe_result->ToObject(&result)) return maybe_result;
3220 } 3221 }
3222 ASSERT(Map::cast(result)->is_dictionary_map());
3221 set(index, result); 3223 set(index, result);
3222 isolate->counters()->normalized_maps()->Increment(); 3224 isolate->counters()->normalized_maps()->Increment();
3223 3225
3224 return result; 3226 return result;
3225 } 3227 }
3226 3228
3227 3229
3228 void NormalizedMapCache::Clear() { 3230 void NormalizedMapCache::Clear() {
3229 int entries = length(); 3231 int entries = length();
3230 for (int i = 0; i != entries; i++) { 3232 for (int i = 0; i != entries; i++) {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
3336 3338
3337 // Copy the next enumeration index from instance descriptor. 3339 // Copy the next enumeration index from instance descriptor.
3338 int index = map_of_this->instance_descriptors()->NextEnumerationIndex(); 3340 int index = map_of_this->instance_descriptors()->NextEnumerationIndex();
3339 dictionary->SetNextEnumerationIndex(index); 3341 dictionary->SetNextEnumerationIndex(index);
3340 3342
3341 Map* new_map; 3343 Map* new_map;
3342 MaybeObject* maybe_map = 3344 MaybeObject* maybe_map =
3343 current_heap->isolate()->context()->global_context()-> 3345 current_heap->isolate()->context()->global_context()->
3344 normalized_map_cache()->Get(this, mode); 3346 normalized_map_cache()->Get(this, mode);
3345 if (!maybe_map->To(&new_map)) return maybe_map; 3347 if (!maybe_map->To(&new_map)) return maybe_map;
3348 ASSERT(new_map->is_dictionary_map());
3346 3349
3347 // We have now successfully allocated all the necessary objects. 3350 // We have now successfully allocated all the necessary objects.
3348 // Changes can now be made with the guarantee that all of them take effect. 3351 // Changes can now be made with the guarantee that all of them take effect.
3349 3352
3350 // Resize the object in the heap if necessary. 3353 // Resize the object in the heap if necessary.
3351 int new_instance_size = new_map->instance_size(); 3354 int new_instance_size = new_map->instance_size();
3352 int instance_size_delta = map_of_this->instance_size() - new_instance_size; 3355 int instance_size_delta = map_of_this->instance_size() - new_instance_size;
3353 ASSERT(instance_size_delta >= 0); 3356 ASSERT(instance_size_delta >= 0);
3354 current_heap->CreateFillerObjectAt(this->address() + new_instance_size, 3357 current_heap->CreateFillerObjectAt(this->address() + new_instance_size,
3355 instance_size_delta); 3358 instance_size_delta);
(...skipping 1149 matching lines...) Expand 10 before | Expand all | Expand 10 after
4505 // Normalize object to make this operation simple. 4508 // Normalize object to make this operation simple.
4506 MaybeObject* maybe_ok = NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0); 4509 MaybeObject* maybe_ok = NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0);
4507 if (maybe_ok->IsFailure()) return maybe_ok; 4510 if (maybe_ok->IsFailure()) return maybe_ok;
4508 4511
4509 // For the global object allocate a new map to invalidate the global inline 4512 // For the global object allocate a new map to invalidate the global inline
4510 // caches which have a global property cell reference directly in the code. 4513 // caches which have a global property cell reference directly in the code.
4511 if (IsGlobalObject()) { 4514 if (IsGlobalObject()) {
4512 Map* new_map; 4515 Map* new_map;
4513 MaybeObject* maybe_new_map = map()->CopyDropDescriptors(); 4516 MaybeObject* maybe_new_map = map()->CopyDropDescriptors();
4514 if (!maybe_new_map->To(&new_map)) return maybe_new_map; 4517 if (!maybe_new_map->To(&new_map)) return maybe_new_map;
4518 ASSERT(new_map->is_dictionary_map());
4515 4519
4516 set_map(new_map); 4520 set_map(new_map);
4517 // When running crankshaft, changing the map is not enough. We 4521 // When running crankshaft, changing the map is not enough. We
4518 // need to deoptimize all functions that rely on this global 4522 // need to deoptimize all functions that rely on this global
4519 // object. 4523 // object.
4520 Deoptimizer::DeoptimizeGlobalObject(this); 4524 Deoptimizer::DeoptimizeGlobalObject(this);
4521 } 4525 }
4522 4526
4523 // Update the dictionary with the new CALLBACKS property. 4527 // Update the dictionary with the new CALLBACKS property.
4524 PropertyDetails details = PropertyDetails(attributes, CALLBACKS); 4528 PropertyDetails details = PropertyDetails(attributes, CALLBACKS);
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
4866 Map* result; 4870 Map* result;
4867 MaybeObject* maybe_result = RawCopy(new_instance_size); 4871 MaybeObject* maybe_result = RawCopy(new_instance_size);
4868 if (!maybe_result->To(&result)) return maybe_result; 4872 if (!maybe_result->To(&result)) return maybe_result;
4869 4873
4870 if (mode != CLEAR_INOBJECT_PROPERTIES) { 4874 if (mode != CLEAR_INOBJECT_PROPERTIES) {
4871 result->set_inobject_properties(inobject_properties()); 4875 result->set_inobject_properties(inobject_properties());
4872 } 4876 }
4873 4877
4874 result->set_code_cache(code_cache()); 4878 result->set_code_cache(code_cache());
4875 result->set_is_shared(sharing == SHARED_NORMALIZED_MAP); 4879 result->set_is_shared(sharing == SHARED_NORMALIZED_MAP);
4880 result->set_dictionary_map(true);
4876 4881
4877 #ifdef DEBUG 4882 #ifdef DEBUG
4878 if (FLAG_verify_heap && result->is_shared()) { 4883 if (FLAG_verify_heap && result->is_shared()) {
4879 result->SharedMapVerify(); 4884 result->SharedMapVerify();
4880 } 4885 }
4881 #endif 4886 #endif
4882 4887
4883 return result; 4888 return result;
4884 } 4889 }
4885 4890
(...skipping 2437 matching lines...) Expand 10 before | Expand all | Expand 10 after
7323 constructor() == other->constructor() && 7328 constructor() == other->constructor() &&
7324 prototype() == other->prototype() && 7329 prototype() == other->prototype() &&
7325 inobject_properties() == ((mode == CLEAR_INOBJECT_PROPERTIES) ? 7330 inobject_properties() == ((mode == CLEAR_INOBJECT_PROPERTIES) ?
7326 0 : 7331 0 :
7327 other->inobject_properties()) && 7332 other->inobject_properties()) &&
7328 instance_type() == other->instance_type() && 7333 instance_type() == other->instance_type() &&
7329 bit_field() == other->bit_field() && 7334 bit_field() == other->bit_field() &&
7330 bit_field2() == other->bit_field2() && 7335 bit_field2() == other->bit_field2() &&
7331 static_cast<uint32_t>(bit_field3()) == 7336 static_cast<uint32_t>(bit_field3()) ==
7332 LastAddedBits::update( 7337 LastAddedBits::update(
7333 IsShared::update(other->bit_field3(), true), 7338 IsShared::update(DictionaryMap::update(other->bit_field3(), true),
7339 true),
7334 kNoneAdded); 7340 kNoneAdded);
7335 } 7341 }
7336 7342
7337 7343
7338 void JSFunction::JSFunctionIterateBody(int object_size, ObjectVisitor* v) { 7344 void JSFunction::JSFunctionIterateBody(int object_size, ObjectVisitor* v) {
7339 // Iterate over all fields in the body but take care in dealing with 7345 // Iterate over all fields in the body but take care in dealing with
7340 // the code entry. 7346 // the code entry.
7341 IteratePointers(v, kPropertiesOffset, kCodeEntryOffset); 7347 IteratePointers(v, kPropertiesOffset, kCodeEntryOffset);
7342 v->VisitCodeEntry(this->address() + kCodeEntryOffset); 7348 v->VisitCodeEntry(this->address() + kCodeEntryOffset);
7343 IteratePointers(v, kCodeEntryOffset + kPointerSize, object_size); 7349 IteratePointers(v, kCodeEntryOffset + kPointerSize, object_size);
(...skipping 5222 matching lines...) Expand 10 before | Expand all | Expand 10 after
12566 } 12572 }
12567 } 12573 }
12568 } 12574 }
12569 12575
12570 int inobject_props = obj->map()->inobject_properties(); 12576 int inobject_props = obj->map()->inobject_properties();
12571 12577
12572 // Allocate new map. 12578 // Allocate new map.
12573 Map* new_map; 12579 Map* new_map;
12574 MaybeObject* maybe_new_map = obj->map()->CopyDropDescriptors(); 12580 MaybeObject* maybe_new_map = obj->map()->CopyDropDescriptors();
12575 if (!maybe_new_map->To(&new_map)) return maybe_new_map; 12581 if (!maybe_new_map->To(&new_map)) return maybe_new_map;
12582 new_map->set_dictionary_map(false);
12576 12583
12577 if (instance_descriptor_length == 0) { 12584 if (instance_descriptor_length == 0) {
12578 ASSERT_LE(unused_property_fields, inobject_props); 12585 ASSERT_LE(unused_property_fields, inobject_props);
12579 // Transform the object. 12586 // Transform the object.
12580 new_map->set_unused_property_fields(inobject_props); 12587 new_map->set_unused_property_fields(inobject_props);
12581 obj->set_map(new_map); 12588 obj->set_map(new_map);
12582 obj->set_properties(heap->empty_fixed_array()); 12589 obj->set_properties(heap->empty_fixed_array());
12583 // Check that it really works. 12590 // Check that it really works.
12584 ASSERT(obj->HasFastProperties()); 12591 ASSERT(obj->HasFastProperties());
12585 return obj; 12592 return obj;
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
13174 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 13181 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
13175 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); 13182 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER);
13176 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); 13183 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER);
13177 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); 13184 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER);
13178 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); 13185 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER);
13179 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); 13186 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER);
13180 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); 13187 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER);
13181 } 13188 }
13182 13189
13183 } } // namespace v8::internal 13190 } } // 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