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::FindAfterJSObject(JSObject* object) { | |
danno
2013/01/04 08:50:55
How about "FindForJSObject?" FindAfterJSObject imp
mvstanton
2013/01/04 12:07:52
Done.
| |
7906 // Are we in new space and using the allocation site info feature? | |
danno
2013/01/04 08:50:55
nit: the comment seems a little superfluous, since
mvstanton
2013/01/04 12:07:52
Way more useful comment, thx!
| |
7907 if (FLAG_use_allocation_site_info && object->GetHeap()->InNewSpace(object)) { | |
7908 Address ptr_end = (reinterpret_cast<Address>(object) - kHeapObjectTag) + | |
7909 object->Size(); | |
7910 if ((ptr_end + AllocationSiteInfo::kSize) <= | |
7911 object->GetHeap()->NewSpaceTop()) { | |
7912 // There is room in newspace for allocation info. Do we have some? | |
7913 Map** possible_allocation_map = reinterpret_cast<Map**>(ptr_end); | |
7914 if (*possible_allocation_map == | |
7915 object->GetHeap()->allocation_site_info_map()) { | |
7916 AllocationSiteInfo* info = AllocationSiteInfo::cast( | |
7917 reinterpret_cast<Object*>(ptr_end + 1)); | |
7918 return info; | |
7919 } | |
7920 } | |
7921 } | |
7922 return NULL; | |
7923 } | |
7924 | |
7925 | |
7905 uint32_t StringHasher::MakeArrayIndexHash(uint32_t value, int length) { | 7926 uint32_t StringHasher::MakeArrayIndexHash(uint32_t value, int length) { |
7906 // For array indexes mix the length into the hash as an array index could | 7927 // For array indexes mix the length into the hash as an array index could |
7907 // be zero. | 7928 // be zero. |
7908 ASSERT(length > 0); | 7929 ASSERT(length > 0); |
7909 ASSERT(length <= String::kMaxArrayIndexSize); | 7930 ASSERT(length <= String::kMaxArrayIndexSize); |
7910 ASSERT(TenToThe(String::kMaxCachedArrayIndexLength) < | 7931 ASSERT(TenToThe(String::kMaxCachedArrayIndexLength) < |
7911 (1 << String::kArrayIndexValueBits)); | 7932 (1 << String::kArrayIndexValueBits)); |
7912 | 7933 |
7913 value <<= String::kHashShift; | 7934 value <<= String::kHashShift; |
7914 value |= length << String::kArrayIndexHashLengthShift; | 7935 value |= length << String::kArrayIndexHashLengthShift; |
(...skipping 2326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10241 } | 10262 } |
10242 if (convert_to_slow) { | 10263 if (convert_to_slow) { |
10243 MaybeObject* result = NormalizeElements(); | 10264 MaybeObject* result = NormalizeElements(); |
10244 if (result->IsFailure()) return result; | 10265 if (result->IsFailure()) return result; |
10245 return SetDictionaryElement(index, value, NONE, strict_mode, | 10266 return SetDictionaryElement(index, value, NONE, strict_mode, |
10246 check_prototype); | 10267 check_prototype); |
10247 } | 10268 } |
10248 } | 10269 } |
10249 // Convert to fast double elements if appropriate. | 10270 // Convert to fast double elements if appropriate. |
10250 if (HasFastSmiElements() && !value->IsSmi() && value->IsNumber()) { | 10271 if (HasFastSmiElements() && !value->IsSmi() && value->IsNumber()) { |
10272 // Consider fixing the boilerplate as well if we have one. | |
10273 ElementsKind to_kind = IsHoleyElementsKind(elements_kind) | |
10274 ? FAST_HOLEY_DOUBLE_ELEMENTS | |
10275 : FAST_DOUBLE_ELEMENTS; | |
10276 | |
10277 MaybeObject* trans = PossiblyTransitionBoilerplate(to_kind); | |
10278 if (trans != NULL && trans->IsFailure()) return trans; | |
10279 | |
10251 MaybeObject* maybe = | 10280 MaybeObject* maybe = |
10252 SetFastDoubleElementsCapacityAndLength(new_capacity, array_length); | 10281 SetFastDoubleElementsCapacityAndLength(new_capacity, array_length); |
10253 if (maybe->IsFailure()) return maybe; | 10282 if (maybe->IsFailure()) return maybe; |
10254 FixedDoubleArray::cast(elements())->set(index, value->Number()); | 10283 FixedDoubleArray::cast(elements())->set(index, value->Number()); |
10255 ValidateElements(); | 10284 ValidateElements(); |
10256 return value; | 10285 return value; |
10257 } | 10286 } |
10258 // Change elements kind from Smi-only to generic FAST if necessary. | 10287 // Change elements kind from Smi-only to generic FAST if necessary. |
10259 if (HasFastSmiElements() && !value->IsSmi()) { | 10288 if (HasFastSmiElements() && !value->IsSmi()) { |
10260 Map* new_map; | 10289 Map* new_map; |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10782 | 10811 |
10783 | 10812 |
10784 Handle<Object> JSObject::TransitionElementsKind(Handle<JSObject> object, | 10813 Handle<Object> JSObject::TransitionElementsKind(Handle<JSObject> object, |
10785 ElementsKind to_kind) { | 10814 ElementsKind to_kind) { |
10786 CALL_HEAP_FUNCTION(object->GetIsolate(), | 10815 CALL_HEAP_FUNCTION(object->GetIsolate(), |
10787 object->TransitionElementsKind(to_kind), | 10816 object->TransitionElementsKind(to_kind), |
10788 Object); | 10817 Object); |
10789 } | 10818 } |
10790 | 10819 |
10791 | 10820 |
10821 MaybeObject* JSObject::PossiblyTransitionBoilerplate(ElementsKind to_kind) { | |
danno
2013/01/04 08:50:55
Do you want to ASSERT(IsJSArray())? Maybe make the
mvstanton
2013/01/04 12:07:52
Done.
| |
10822 MaybeObject* ret = NULL; | |
10823 // Are we in new space? | |
danno
2013/01/04 08:50:55
nit: comment seems incorrect, the FindAfterJSObjec
mvstanton
2013/01/04 12:07:52
Done.
| |
10824 AllocationSiteInfo* info = AllocationSiteInfo::FindAfterJSObject(this); | |
10825 if (info != NULL) { | |
10826 JSObject* payload = JSObject::cast(info->payload()); | |
10827 if (payload->GetElementsKind() != to_kind) { | |
10828 if (IsMoreGeneralElementsKindTransition(payload->GetElementsKind(), | |
10829 to_kind)) { | |
10830 ret = payload->TransitionElementsKind(to_kind); | |
10831 if (ret->IsFailure()) return ret; | |
10832 } | |
10833 } | |
10834 } | |
10835 return ret; | |
10836 } | |
10837 | |
10838 | |
10792 MaybeObject* JSObject::TransitionElementsKind(ElementsKind to_kind) { | 10839 MaybeObject* JSObject::TransitionElementsKind(ElementsKind to_kind) { |
10793 ASSERT(!map()->is_observed()); | 10840 ASSERT(!map()->is_observed()); |
10794 ElementsKind from_kind = map()->elements_kind(); | 10841 ElementsKind from_kind = map()->elements_kind(); |
10795 | 10842 |
10796 if (IsFastHoleyElementsKind(from_kind)) { | 10843 if (IsFastHoleyElementsKind(from_kind)) { |
10797 to_kind = GetHoleyElementsKind(to_kind); | 10844 to_kind = GetHoleyElementsKind(to_kind); |
10798 } | 10845 } |
10799 | 10846 |
10800 if (from_kind == to_kind) return this; | 10847 if (from_kind == to_kind) return this; |
10801 | 10848 |
10849 MaybeObject* trans = PossiblyTransitionBoilerplate(to_kind); | |
10850 if (trans != NULL && trans->IsFailure()) return trans; | |
10851 | |
10802 Isolate* isolate = GetIsolate(); | 10852 Isolate* isolate = GetIsolate(); |
10803 if (elements() == isolate->heap()->empty_fixed_array() || | 10853 if (elements() == isolate->heap()->empty_fixed_array() || |
10804 (IsFastSmiOrObjectElementsKind(from_kind) && | 10854 (IsFastSmiOrObjectElementsKind(from_kind) && |
10805 IsFastSmiOrObjectElementsKind(to_kind)) || | 10855 IsFastSmiOrObjectElementsKind(to_kind)) || |
10806 (from_kind == FAST_DOUBLE_ELEMENTS && | 10856 (from_kind == FAST_DOUBLE_ELEMENTS && |
10807 to_kind == FAST_HOLEY_DOUBLE_ELEMENTS)) { | 10857 to_kind == FAST_HOLEY_DOUBLE_ELEMENTS)) { |
10808 ASSERT(from_kind != TERMINAL_FAST_ELEMENTS_KIND); | 10858 ASSERT(from_kind != TERMINAL_FAST_ELEMENTS_KIND); |
10809 // No change is needed to the elements() buffer, the transition | 10859 // No change is needed to the elements() buffer, the transition |
10810 // only requires a map change. | 10860 // only requires a map change. |
10811 MaybeObject* maybe_new_map = GetElementsTransitionMap(isolate, to_kind); | 10861 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); | 14192 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
14143 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 14193 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
14144 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 14194 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
14145 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 14195 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
14146 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 14196 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
14147 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 14197 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
14148 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 14198 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
14149 } | 14199 } |
14150 | 14200 |
14151 } } // namespace v8::internal | 14201 } } // namespace v8::internal |
OLD | NEW |