OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 5390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5401 if (!elements()->IsDictionary()) { | 5401 if (!elements()->IsDictionary()) { |
5402 int length = IsJSArray() | 5402 int length = IsJSArray() |
5403 ? Smi::cast(JSArray::cast(this)->length())->value() | 5403 ? Smi::cast(JSArray::cast(this)->length())->value() |
5404 : elements()->length(); | 5404 : elements()->length(); |
5405 if (length > 0) { | 5405 if (length > 0) { |
5406 int capacity = 0; | 5406 int capacity = 0; |
5407 int used = 0; | 5407 int used = 0; |
5408 GetElementsCapacityAndUsage(&capacity, &used); | 5408 GetElementsCapacityAndUsage(&capacity, &used); |
5409 MaybeObject* maybe_dict = SeededNumberDictionary::Allocate(heap, used); | 5409 MaybeObject* maybe_dict = SeededNumberDictionary::Allocate(heap, used); |
5410 if (!maybe_dict->To(&new_element_dictionary)) return maybe_dict; | 5410 if (!maybe_dict->To(&new_element_dictionary)) return maybe_dict; |
5411 // Make sure that we never go back to fast case. | |
5412 new_element_dictionary->set_requires_slow_elements(); | |
5413 | 5411 |
5414 // Move elements to a dictionary; avoid calling NormalizeElements to avoid | 5412 // Move elements to a dictionary; avoid calling NormalizeElements to avoid |
5415 // unnecessary transitions. | 5413 // unnecessary transitions. |
5416 maybe_dict = CopyFastElementsToDictionary(isolate, elements(), length, | 5414 maybe_dict = CopyFastElementsToDictionary(isolate, elements(), length, |
5417 new_element_dictionary); | 5415 new_element_dictionary); |
5418 if (!maybe_dict->To(&new_element_dictionary)) return maybe_dict; | 5416 if (!maybe_dict->To(&new_element_dictionary)) return maybe_dict; |
5419 | |
5420 // Freeze all the elements in the dictionary. | |
5421 FreezeDictionary(new_element_dictionary); | |
5422 } else { | 5417 } else { |
5423 // No existing elements, use a pre-allocated empty backing store | 5418 // No existing elements, use a pre-allocated empty backing store |
5424 new_element_dictionary = heap->empty_slow_element_dictionary(); | 5419 new_element_dictionary = heap->empty_slow_element_dictionary(); |
5425 } | 5420 } |
5426 } | 5421 } |
5427 | 5422 |
5428 LookupResult result(isolate); | 5423 LookupResult result(isolate); |
5429 map()->LookupTransition(this, heap->frozen_symbol(), &result); | 5424 map()->LookupTransition(this, heap->frozen_symbol(), &result); |
5430 if (result.IsTransition()) { | 5425 if (result.IsTransition()) { |
5431 Map* transition_map = result.GetTransitionTarget(); | 5426 Map* transition_map = result.GetTransitionTarget(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5463 new_map->freeze(); | 5458 new_map->freeze(); |
5464 new_map->set_is_extensible(false); | 5459 new_map->set_is_extensible(false); |
5465 new_map->set_elements_kind(DICTIONARY_ELEMENTS); | 5460 new_map->set_elements_kind(DICTIONARY_ELEMENTS); |
5466 set_map(new_map); | 5461 set_map(new_map); |
5467 | 5462 |
5468 // Freeze dictionary-mode properties | 5463 // Freeze dictionary-mode properties |
5469 FreezeDictionary(property_dictionary()); | 5464 FreezeDictionary(property_dictionary()); |
5470 } | 5465 } |
5471 | 5466 |
5472 ASSERT(map()->has_dictionary_elements()); | 5467 ASSERT(map()->has_dictionary_elements()); |
5473 if (new_element_dictionary != NULL) | 5468 if (new_element_dictionary != NULL) { |
5474 set_elements(new_element_dictionary); | 5469 set_elements(new_element_dictionary); |
| 5470 } |
| 5471 |
| 5472 if (elements() != heap->empty_slow_element_dictionary()) { |
| 5473 SeededNumberDictionary* dictionary = element_dictionary(); |
| 5474 // Make sure we never go back to the fast case |
| 5475 dictionary->set_requires_slow_elements(); |
| 5476 // Freeze all elements in the dictionary |
| 5477 FreezeDictionary(dictionary); |
| 5478 } |
5475 | 5479 |
5476 return this; | 5480 return this; |
5477 } | 5481 } |
5478 | 5482 |
5479 | 5483 |
5480 MUST_USE_RESULT MaybeObject* JSObject::DeepCopy(Isolate* isolate) { | 5484 MUST_USE_RESULT MaybeObject* JSObject::DeepCopy(Isolate* isolate) { |
5481 StackLimitCheck check(isolate); | 5485 StackLimitCheck check(isolate); |
5482 if (check.HasOverflowed()) return isolate->StackOverflow(); | 5486 if (check.HasOverflowed()) return isolate->StackOverflow(); |
5483 | 5487 |
5484 if (map()->is_deprecated()) { | 5488 if (map()->is_deprecated()) { |
(...skipping 10114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15599 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 15603 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
15600 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 15604 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
15601 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 15605 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
15602 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 15606 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
15603 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 15607 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
15604 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 15608 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
15605 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 15609 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
15606 } | 15610 } |
15607 | 15611 |
15608 } } // namespace v8::internal | 15612 } } // namespace v8::internal |
OLD | NEW |