OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <iomanip> | 5 #include <iomanip> |
6 #include <sstream> | 6 #include <sstream> |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/accessors.h" | 10 #include "src/accessors.h" |
(...skipping 12373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12384 if (*dictionary == *new_dictionary) return; | 12384 if (*dictionary == *new_dictionary) return; |
12385 | 12385 |
12386 if (object->HasSloppyArgumentsElements()) { | 12386 if (object->HasSloppyArgumentsElements()) { |
12387 FixedArray::cast(object->elements())->set(1, *new_dictionary); | 12387 FixedArray::cast(object->elements())->set(1, *new_dictionary); |
12388 } else { | 12388 } else { |
12389 object->set_elements(*new_dictionary); | 12389 object->set_elements(*new_dictionary); |
12390 } | 12390 } |
12391 } | 12391 } |
12392 | 12392 |
12393 | 12393 |
12394 void JSObject::SetDictionaryArgumentsElement(Handle<JSObject> object, | |
12395 uint32_t index, | |
12396 Handle<Object> value, | |
12397 PropertyAttributes attributes) { | |
12398 // TODO(verwaest): Handle with the elements accessor. | |
12399 Isolate* isolate = object->GetIsolate(); | |
12400 | |
12401 DCHECK(object->HasDictionaryArgumentsElements()); | |
12402 | |
12403 Handle<FixedArray> parameter_map(FixedArray::cast(object->elements())); | |
12404 uint32_t length = parameter_map->length(); | |
12405 Handle<Object> probe = | |
12406 index < length - 2 | |
12407 ? handle(parameter_map->get(index + 2), isolate) | |
12408 : Handle<Object>::cast(isolate->factory()->the_hole_value()); | |
12409 if (!probe->IsTheHole()) { | |
12410 Handle<Context> context(Context::cast(parameter_map->get(0))); | |
12411 int context_index = Handle<Smi>::cast(probe)->value(); | |
12412 DCHECK(!context->get(context_index)->IsTheHole()); | |
12413 context->set(context_index, *value); | |
12414 | |
12415 DCHECK_NE(NONE, attributes); | |
12416 | |
12417 // Redefining attributes of an aliased element destroys fast aliasing. | |
12418 parameter_map->set_the_hole(index + 2); | |
12419 // For elements that are still writable we re-establish slow aliasing. | |
12420 if ((attributes & READ_ONLY) == 0) { | |
12421 value = isolate->factory()->NewAliasedArgumentsEntry(context_index); | |
12422 } | |
12423 Handle<SeededNumberDictionary> dictionary( | |
12424 SeededNumberDictionary::cast(parameter_map->get(1))); | |
12425 AddDictionaryElement(object, dictionary, index, value, attributes); | |
12426 } else { | |
12427 SetDictionaryElement(object, index, value, attributes); | |
12428 } | |
12429 } | |
12430 | |
12431 | |
12432 void JSObject::SetDictionaryElement(Handle<JSObject> object, uint32_t index, | |
12433 Handle<Object> value, | |
12434 PropertyAttributes attributes) { | |
12435 // TODO(verwaest): Handle with the elements accessor. | |
12436 Isolate* isolate = object->GetIsolate(); | |
12437 | |
12438 // Insert element in the dictionary. | |
12439 Handle<FixedArray> elements(FixedArray::cast(object->elements())); | |
12440 bool is_arguments = | |
12441 (elements->map() == isolate->heap()->sloppy_arguments_elements_map()); | |
12442 | |
12443 DCHECK(object->HasDictionaryElements() || | |
12444 object->HasDictionaryArgumentsElements()); | |
12445 | |
12446 Handle<SeededNumberDictionary> dictionary(is_arguments | |
12447 ? SeededNumberDictionary::cast(elements->get(1)) | |
12448 : SeededNumberDictionary::cast(*elements)); | |
12449 | |
12450 int entry = dictionary->FindEntry(index); | |
12451 DCHECK_NE(SeededNumberDictionary::kNotFound, entry); | |
12452 | |
12453 PropertyDetails details = dictionary->DetailsAt(entry); | |
12454 details = PropertyDetails(attributes, DATA, details.dictionary_index(), | |
12455 PropertyCellType::kNoCell); | |
12456 dictionary->DetailsAtPut(entry, details); | |
12457 | |
12458 // Elements of the arguments object in slow mode might be slow aliases. | |
12459 if (is_arguments) { | |
12460 Handle<Object> element(dictionary->ValueAt(entry), isolate); | |
12461 if (element->IsAliasedArgumentsEntry()) { | |
12462 Handle<AliasedArgumentsEntry> entry = | |
12463 Handle<AliasedArgumentsEntry>::cast(element); | |
12464 Handle<Context> context(Context::cast(elements->get(0))); | |
12465 int context_index = entry->aliased_context_slot(); | |
12466 DCHECK(!context->get(context_index)->IsTheHole()); | |
12467 context->set(context_index, *value); | |
12468 // For elements that are still writable we keep slow aliasing. | |
12469 if (!details.IsReadOnly()) value = element; | |
12470 } | |
12471 } | |
12472 | |
12473 dictionary->ValueAtPut(entry, *value); | |
12474 } | |
12475 | |
12476 | |
12477 // static | 12394 // static |
12478 MaybeHandle<Object> JSReceiver::SetElement(Handle<JSReceiver> object, | 12395 MaybeHandle<Object> JSReceiver::SetElement(Handle<JSReceiver> object, |
12479 uint32_t index, Handle<Object> value, | 12396 uint32_t index, Handle<Object> value, |
12480 LanguageMode language_mode) { | 12397 LanguageMode language_mode) { |
12481 Isolate* isolate = object->GetIsolate(); | 12398 Isolate* isolate = object->GetIsolate(); |
12482 LookupIterator it(isolate, object, index); | 12399 LookupIterator it(isolate, object, index); |
12483 return SetProperty(&it, value, language_mode, MAY_BE_STORE_FROM_KEYED); | 12400 return SetProperty(&it, value, language_mode, MAY_BE_STORE_FROM_KEYED); |
12484 } | 12401 } |
12485 | 12402 |
12486 | 12403 |
(...skipping 3804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16291 Handle<Object> new_value) { | 16208 Handle<Object> new_value) { |
16292 if (cell->value() != *new_value) { | 16209 if (cell->value() != *new_value) { |
16293 cell->set_value(*new_value); | 16210 cell->set_value(*new_value); |
16294 Isolate* isolate = cell->GetIsolate(); | 16211 Isolate* isolate = cell->GetIsolate(); |
16295 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 16212 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
16296 isolate, DependentCode::kPropertyCellChangedGroup); | 16213 isolate, DependentCode::kPropertyCellChangedGroup); |
16297 } | 16214 } |
16298 } | 16215 } |
16299 } // namespace internal | 16216 } // namespace internal |
16300 } // namespace v8 | 16217 } // namespace v8 |
OLD | NEW |