Chromium Code Reviews| 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 7884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7895 // that are a multiple of pointer size. | 7895 // that are a multiple of pointer size. |
| 7896 Address end_of_string = address() + string_size; | 7896 Address end_of_string = address() + string_size; |
| 7897 heap->CreateFillerObjectAt(end_of_string, delta); | 7897 heap->CreateFillerObjectAt(end_of_string, delta); |
| 7898 if (Marking::IsBlack(Marking::MarkBitFrom(this))) { | 7898 if (Marking::IsBlack(Marking::MarkBitFrom(this))) { |
| 7899 MemoryChunk::IncrementLiveBytesFromMutator(address(), -delta); | 7899 MemoryChunk::IncrementLiveBytesFromMutator(address(), -delta); |
| 7900 } | 7900 } |
| 7901 return this; | 7901 return this; |
| 7902 } | 7902 } |
| 7903 | 7903 |
| 7904 | 7904 |
| 7905 AllocationSiteInfo* AllocationSiteInfo::FindForJSObject(JSObject* object) { | |
| 7906 // Currently, AllocationSiteInfo objects are only allocated immediately | |
| 7907 // after JSArrays in NewSpace, and detecting whether a JSArray has one | |
| 7908 // involves carefully checking the object immediately after the JSArray | |
| 7909 // (if there is one) to see if it's an AllocationSiteInfo. | |
| 7910 if (FLAG_track_allocation_sites && object->GetHeap()->InNewSpace(object)) { | |
| 7911 Address ptr_end = (reinterpret_cast<Address>(object) - kHeapObjectTag) + | |
| 7912 object->Size(); | |
| 7913 if ((ptr_end + AllocationSiteInfo::kSize) <= | |
| 7914 object->GetHeap()->NewSpaceTop()) { | |
| 7915 // There is room in newspace for allocation info. Do we have some? | |
| 7916 Map** possible_allocation_map = reinterpret_cast<Map**>(ptr_end); | |
|
danno
2013/01/07 08:03:48
nit: perhaps possible_allocation_info_map?
mvstanton
2013/01/07 09:28:41
I went ahead and dogmatically named it possible_al
| |
| 7917 if (*possible_allocation_map == | |
| 7918 object->GetHeap()->allocation_site_info_map()) { | |
| 7919 AllocationSiteInfo* info = AllocationSiteInfo::cast( | |
| 7920 reinterpret_cast<Object*>(ptr_end + 1)); | |
| 7921 return info; | |
| 7922 } | |
| 7923 } | |
| 7924 } | |
| 7925 return NULL; | |
| 7926 } | |
| 7927 | |
| 7928 | |
| 7905 uint32_t StringHasher::MakeArrayIndexHash(uint32_t value, int length) { | 7929 uint32_t StringHasher::MakeArrayIndexHash(uint32_t value, int length) { |
| 7906 // For array indexes mix the length into the hash as an array index could | 7930 // For array indexes mix the length into the hash as an array index could |
| 7907 // be zero. | 7931 // be zero. |
| 7908 ASSERT(length > 0); | 7932 ASSERT(length > 0); |
| 7909 ASSERT(length <= String::kMaxArrayIndexSize); | 7933 ASSERT(length <= String::kMaxArrayIndexSize); |
| 7910 ASSERT(TenToThe(String::kMaxCachedArrayIndexLength) < | 7934 ASSERT(TenToThe(String::kMaxCachedArrayIndexLength) < |
| 7911 (1 << String::kArrayIndexValueBits)); | 7935 (1 << String::kArrayIndexValueBits)); |
| 7912 | 7936 |
| 7913 value <<= String::kHashShift; | 7937 value <<= String::kHashShift; |
| 7914 value |= length << String::kArrayIndexHashLengthShift; | 7938 value |= length << String::kArrayIndexHashLengthShift; |
| (...skipping 2326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10241 } | 10265 } |
| 10242 if (convert_to_slow) { | 10266 if (convert_to_slow) { |
| 10243 MaybeObject* result = NormalizeElements(); | 10267 MaybeObject* result = NormalizeElements(); |
| 10244 if (result->IsFailure()) return result; | 10268 if (result->IsFailure()) return result; |
| 10245 return SetDictionaryElement(index, value, NONE, strict_mode, | 10269 return SetDictionaryElement(index, value, NONE, strict_mode, |
| 10246 check_prototype); | 10270 check_prototype); |
| 10247 } | 10271 } |
| 10248 } | 10272 } |
| 10249 // Convert to fast double elements if appropriate. | 10273 // Convert to fast double elements if appropriate. |
| 10250 if (HasFastSmiElements() && !value->IsSmi() && value->IsNumber()) { | 10274 if (HasFastSmiElements() && !value->IsSmi() && value->IsNumber()) { |
| 10275 // Consider fixing the boilerplate as well if we have one. | |
| 10276 ElementsKind to_kind = IsHoleyElementsKind(elements_kind) | |
| 10277 ? FAST_HOLEY_DOUBLE_ELEMENTS | |
| 10278 : FAST_DOUBLE_ELEMENTS; | |
| 10279 | |
| 10280 MaybeObject* trans = PossiblyTransitionArrayBoilerplate(to_kind); | |
| 10281 if (trans != NULL && trans->IsFailure()) return trans; | |
| 10282 | |
| 10251 MaybeObject* maybe = | 10283 MaybeObject* maybe = |
| 10252 SetFastDoubleElementsCapacityAndLength(new_capacity, array_length); | 10284 SetFastDoubleElementsCapacityAndLength(new_capacity, array_length); |
| 10253 if (maybe->IsFailure()) return maybe; | 10285 if (maybe->IsFailure()) return maybe; |
| 10254 FixedDoubleArray::cast(elements())->set(index, value->Number()); | 10286 FixedDoubleArray::cast(elements())->set(index, value->Number()); |
| 10255 ValidateElements(); | 10287 ValidateElements(); |
| 10256 return value; | 10288 return value; |
| 10257 } | 10289 } |
| 10258 // Change elements kind from Smi-only to generic FAST if necessary. | 10290 // Change elements kind from Smi-only to generic FAST if necessary. |
| 10259 if (HasFastSmiElements() && !value->IsSmi()) { | 10291 if (HasFastSmiElements() && !value->IsSmi()) { |
| 10260 Map* new_map; | 10292 Map* new_map; |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10782 | 10814 |
| 10783 | 10815 |
| 10784 Handle<Object> JSObject::TransitionElementsKind(Handle<JSObject> object, | 10816 Handle<Object> JSObject::TransitionElementsKind(Handle<JSObject> object, |
| 10785 ElementsKind to_kind) { | 10817 ElementsKind to_kind) { |
| 10786 CALL_HEAP_FUNCTION(object->GetIsolate(), | 10818 CALL_HEAP_FUNCTION(object->GetIsolate(), |
| 10787 object->TransitionElementsKind(to_kind), | 10819 object->TransitionElementsKind(to_kind), |
| 10788 Object); | 10820 Object); |
| 10789 } | 10821 } |
| 10790 | 10822 |
| 10791 | 10823 |
| 10824 MaybeObject* JSObject::PossiblyTransitionArrayBoilerplate( | |
| 10825 ElementsKind to_kind) { | |
| 10826 ASSERT(IsJSArray()); | |
| 10827 MaybeObject* ret = NULL; | |
| 10828 AllocationSiteInfo* info = AllocationSiteInfo::FindForJSObject(this); | |
| 10829 if (info != NULL) { | |
| 10830 JSObject* payload = JSObject::cast(info->payload()); | |
| 10831 if (payload->GetElementsKind() != to_kind) { | |
| 10832 if (IsMoreGeneralElementsKindTransition(payload->GetElementsKind(), | |
| 10833 to_kind)) { | |
| 10834 ret = payload->TransitionElementsKind(to_kind); | |
| 10835 if (ret->IsFailure()) return ret; | |
|
danno
2013/01/07 08:03:48
nit: statement above is unnecessary, since you wil
mvstanton
2013/01/07 09:28:41
Done.
| |
| 10836 } | |
| 10837 } | |
| 10838 } | |
| 10839 return ret; | |
| 10840 } | |
| 10841 | |
| 10842 | |
| 10792 MaybeObject* JSObject::TransitionElementsKind(ElementsKind to_kind) { | 10843 MaybeObject* JSObject::TransitionElementsKind(ElementsKind to_kind) { |
| 10793 ASSERT(!map()->is_observed()); | 10844 ASSERT(!map()->is_observed()); |
| 10794 ElementsKind from_kind = map()->elements_kind(); | 10845 ElementsKind from_kind = map()->elements_kind(); |
| 10795 | 10846 |
| 10796 if (IsFastHoleyElementsKind(from_kind)) { | 10847 if (IsFastHoleyElementsKind(from_kind)) { |
| 10797 to_kind = GetHoleyElementsKind(to_kind); | 10848 to_kind = GetHoleyElementsKind(to_kind); |
| 10798 } | 10849 } |
| 10799 | 10850 |
| 10800 if (from_kind == to_kind) return this; | 10851 if (from_kind == to_kind) return this; |
| 10801 | 10852 |
| 10853 MaybeObject* trans = PossiblyTransitionArrayBoilerplate(to_kind); | |
| 10854 if (trans != NULL && trans->IsFailure()) return trans; | |
| 10855 | |
| 10802 Isolate* isolate = GetIsolate(); | 10856 Isolate* isolate = GetIsolate(); |
| 10803 if (elements() == isolate->heap()->empty_fixed_array() || | 10857 if (elements() == isolate->heap()->empty_fixed_array() || |
| 10804 (IsFastSmiOrObjectElementsKind(from_kind) && | 10858 (IsFastSmiOrObjectElementsKind(from_kind) && |
| 10805 IsFastSmiOrObjectElementsKind(to_kind)) || | 10859 IsFastSmiOrObjectElementsKind(to_kind)) || |
| 10806 (from_kind == FAST_DOUBLE_ELEMENTS && | 10860 (from_kind == FAST_DOUBLE_ELEMENTS && |
| 10807 to_kind == FAST_HOLEY_DOUBLE_ELEMENTS)) { | 10861 to_kind == FAST_HOLEY_DOUBLE_ELEMENTS)) { |
| 10808 ASSERT(from_kind != TERMINAL_FAST_ELEMENTS_KIND); | 10862 ASSERT(from_kind != TERMINAL_FAST_ELEMENTS_KIND); |
| 10809 // No change is needed to the elements() buffer, the transition | 10863 // No change is needed to the elements() buffer, the transition |
| 10810 // only requires a map change. | 10864 // only requires a map change. |
| 10811 MaybeObject* maybe_new_map = GetElementsTransitionMap(isolate, to_kind); | 10865 MaybeObject* maybe_new_map = GetElementsTransitionMap(isolate, to_kind); |
| (...skipping 3330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 14142 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 14196 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
| 14143 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 14197 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
| 14144 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 14198 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
| 14145 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 14199 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
| 14146 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 14200 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
| 14147 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 14201 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
| 14148 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 14202 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
| 14149 } | 14203 } |
| 14150 | 14204 |
| 14151 } } // namespace v8::internal | 14205 } } // namespace v8::internal |
| OLD | NEW |