OLD | NEW |
---|---|
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 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
480 if (!maybe_store_value->ToObject(&store_value)) return maybe_store_value; | 480 if (!maybe_store_value->ToObject(&store_value)) return maybe_store_value; |
481 } | 481 } |
482 Object* dict; | 482 Object* dict; |
483 { MaybeObject* maybe_dict = | 483 { MaybeObject* maybe_dict = |
484 property_dictionary()->Add(name, store_value, details); | 484 property_dictionary()->Add(name, store_value, details); |
485 if (!maybe_dict->ToObject(&dict)) return maybe_dict; | 485 if (!maybe_dict->ToObject(&dict)) return maybe_dict; |
486 } | 486 } |
487 set_properties(StringDictionary::cast(dict)); | 487 set_properties(StringDictionary::cast(dict)); |
488 return value; | 488 return value; |
489 } | 489 } |
490 // Preserve enumeration index. | 490 |
491 PropertyDetails original_details = property_dictionary()->DetailsAt(entry); | |
492 int enumeration_index; | |
493 // Preserve the enumeration index unless the property was deleted. | |
494 if (original_details.IsDeleted()) { | |
495 enumeration_index = property_dictionary()->NextEnumerationIndex(); | |
496 property_dictionary()->SetNextEnumerationIndex(enumeration_index + 1); | |
497 } else { | |
498 enumeration_index = original_details.dictionary_index(); | |
499 ASSERT(enumeration_index != 0); | |
500 } | |
501 | |
491 details = PropertyDetails( | 502 details = PropertyDetails( |
492 details.attributes(), | 503 details.attributes(), details.type(), enumeration_index); |
493 details.type(), | |
494 property_dictionary()->DetailsAt(entry).dictionary_index()); | |
495 | 504 |
496 if (IsGlobalObject()) { | 505 if (IsGlobalObject()) { |
497 JSGlobalPropertyCell* cell = | 506 JSGlobalPropertyCell* cell = |
498 JSGlobalPropertyCell::cast(property_dictionary()->ValueAt(entry)); | 507 JSGlobalPropertyCell::cast(property_dictionary()->ValueAt(entry)); |
499 cell->set_value(value); | 508 cell->set_value(value); |
500 // Please note we have to update the property details. | 509 // Please note we have to update the property details. |
501 property_dictionary()->DetailsAtPut(entry, details); | 510 property_dictionary()->DetailsAtPut(entry, details); |
502 } else { | 511 } else { |
503 property_dictionary()->SetEntry(entry, name, value, details); | 512 property_dictionary()->SetEntry(entry, name, value, details); |
504 } | 513 } |
(...skipping 8880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9385 Object* element = dictionary->ValueAt(entry); | 9394 Object* element = dictionary->ValueAt(entry); |
9386 PropertyDetails details = dictionary->DetailsAt(entry); | 9395 PropertyDetails details = dictionary->DetailsAt(entry); |
9387 if (details.type() == CALLBACKS && set_mode == SET_PROPERTY) { | 9396 if (details.type() == CALLBACKS && set_mode == SET_PROPERTY) { |
9388 return SetElementWithCallback(element, index, value, this, strict_mode); | 9397 return SetElementWithCallback(element, index, value, this, strict_mode); |
9389 } else { | 9398 } else { |
9390 dictionary->UpdateMaxNumberKey(index); | 9399 dictionary->UpdateMaxNumberKey(index); |
9391 // If a value has not been initialized we allow writing to it even if it | 9400 // If a value has not been initialized we allow writing to it even if it |
9392 // is read-only (a declared const that has not been initialized). If a | 9401 // is read-only (a declared const that has not been initialized). If a |
9393 // value is being defined we skip attribute checks completely. | 9402 // value is being defined we skip attribute checks completely. |
9394 if (set_mode == DEFINE_PROPERTY) { | 9403 if (set_mode == DEFINE_PROPERTY) { |
9404 int enumeration_index; | |
9405 if (details.dictionary_index() == 0 && !(attributes & DONT_ENUM)) { | |
Michael Starzinger
2012/09/12 17:06:55
Why do we check for DONT_ENUM here? Do we do that
Toon Verwaest
2012/09/13 08:46:32
You are right, this code is unnecessary for elemen
| |
9406 enumeration_index = dictionary->NextEnumerationIndex(); | |
9407 dictionary->SetNextEnumerationIndex(enumeration_index + 1); | |
9408 } else { | |
9409 enumeration_index = details.dictionary_index(); | |
9410 } | |
9395 details = PropertyDetails( | 9411 details = PropertyDetails( |
9396 attributes, NORMAL, details.dictionary_index()); | 9412 attributes, NORMAL, enumeration_index); |
9397 dictionary->DetailsAtPut(entry, details); | 9413 dictionary->DetailsAtPut(entry, details); |
9398 } else if (details.IsReadOnly() && !element->IsTheHole()) { | 9414 } else if (details.IsReadOnly() && !element->IsTheHole()) { |
9399 if (strict_mode == kNonStrictMode) { | 9415 if (strict_mode == kNonStrictMode) { |
9400 return isolate->heap()->undefined_value(); | 9416 return isolate->heap()->undefined_value(); |
9401 } else { | 9417 } else { |
9402 Handle<Object> holder(this); | 9418 Handle<Object> holder(this); |
9403 Handle<Object> number = isolate->factory()->NewNumberFromUint(index); | 9419 Handle<Object> number = isolate->factory()->NewNumberFromUint(index); |
9404 Handle<Object> args[2] = { number, holder }; | 9420 Handle<Object> args[2] = { number, holder }; |
9405 Handle<Object> error = | 9421 Handle<Object> error = |
9406 isolate->factory()->NewTypeError("strict_read_only_property", | 9422 isolate->factory()->NewTypeError("strict_read_only_property", |
(...skipping 3805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13212 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 13228 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
13213 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 13229 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
13214 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 13230 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
13215 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 13231 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
13216 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 13232 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
13217 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 13233 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
13218 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 13234 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
13219 } | 13235 } |
13220 | 13236 |
13221 } } // namespace v8::internal | 13237 } } // namespace v8::internal |
OLD | NEW |