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 9858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9869 FixedDoubleArray::cast(elements())->set(index, value->Number()); | 9869 FixedDoubleArray::cast(elements())->set(index, value->Number()); |
| 9870 ValidateElements(); | 9870 ValidateElements(); |
| 9871 return value; | 9871 return value; |
| 9872 } | 9872 } |
| 9873 // Change elements kind from Smi-only to generic FAST if necessary. | 9873 // Change elements kind from Smi-only to generic FAST if necessary. |
| 9874 if (HasFastSmiElements() && !value->IsSmi()) { | 9874 if (HasFastSmiElements() && !value->IsSmi()) { |
| 9875 Map* new_map; | 9875 Map* new_map; |
| 9876 ElementsKind kind = HasFastHoleyElements() | 9876 ElementsKind kind = HasFastHoleyElements() |
| 9877 ? FAST_HOLEY_ELEMENTS | 9877 ? FAST_HOLEY_ELEMENTS |
| 9878 : FAST_ELEMENTS; | 9878 : FAST_ELEMENTS; |
| 9879 | |
| 9880 MaybeObject* trans = PossiblyTransitionArrayBoilerplate(kind); | |
| 9881 if (trans->IsFailure()) return trans; | |
| 9882 | |
| 9879 MaybeObject* maybe_new_map = GetElementsTransitionMap(GetIsolate(), | 9883 MaybeObject* maybe_new_map = GetElementsTransitionMap(GetIsolate(), |
| 9880 kind); | 9884 kind); |
| 9881 if (!maybe_new_map->To(&new_map)) return maybe_new_map; | 9885 if (!maybe_new_map->To(&new_map)) return maybe_new_map; |
| 9882 | 9886 |
| 9883 set_map(new_map); | 9887 set_map(new_map); |
| 9884 } | 9888 } |
| 9885 // Increase backing store capacity if that's been decided previously. | 9889 // Increase backing store capacity if that's been decided previously. |
| 9886 if (new_capacity != capacity) { | 9890 if (new_capacity != capacity) { |
| 9887 FixedArray* new_elements; | 9891 FixedArray* new_elements; |
| 9888 SetFastElementsCapacitySmiMode smi_mode = | 9892 SetFastElementsCapacitySmiMode smi_mode = |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10400 ElementsKind to_kind) { | 10404 ElementsKind to_kind) { |
| 10401 CALL_HEAP_FUNCTION(object->GetIsolate(), | 10405 CALL_HEAP_FUNCTION(object->GetIsolate(), |
| 10402 object->TransitionElementsKind(to_kind), | 10406 object->TransitionElementsKind(to_kind), |
| 10403 Object); | 10407 Object); |
| 10404 } | 10408 } |
| 10405 | 10409 |
| 10406 | 10410 |
| 10407 MaybeObject* JSObject::PossiblyTransitionArrayBoilerplate( | 10411 MaybeObject* JSObject::PossiblyTransitionArrayBoilerplate( |
| 10408 ElementsKind to_kind) { | 10412 ElementsKind to_kind) { |
| 10409 MaybeObject* ret = NULL; | 10413 MaybeObject* ret = NULL; |
| 10410 if (IsJSArray()) { | 10414 if (!FLAG_track_allocation_sites || !IsJSArray()) { |
| 10411 AllocationSiteInfo* info = AllocationSiteInfo::FindForJSObject(this); | 10415 return ret; |
| 10412 if (info != NULL) { | 10416 } |
| 10413 JSObject* payload = JSObject::cast(info->payload()); | 10417 |
| 10414 if (payload->GetElementsKind() != to_kind) { | 10418 AllocationSiteInfo* info = AllocationSiteInfo::FindForJSObject(this); |
| 10415 if (IsMoreGeneralElementsKindTransition(payload->GetElementsKind(), | 10419 if (info == NULL) { |
| 10416 to_kind)) { | 10420 return ret; |
| 10417 ret = payload->TransitionElementsKind(to_kind); | 10421 } |
| 10422 | |
| 10423 if (info->payload()->IsJSArray()) { | |
|
danno
2013/01/10 22:58:59
You might not need this additional checks yet if y
mvstanton
2013/01/11 13:43:01
Ah, this if is a relic (or forebearer?) of the cha
| |
| 10424 JSArray* payload = JSArray::cast(info->payload()); | |
| 10425 ElementsKind kind = payload->GetElementsKind(); | |
| 10426 if (IsMoreGeneralElementsKindTransition(kind, to_kind)) { | |
| 10427 // If the array is huge, it's not likely to be defined in a local | |
| 10428 // function, so we shouldn't make new instances of it very often. | |
| 10429 uint32_t length = 0; | |
| 10430 CHECK(payload->length()->ToArrayIndex(&length)); | |
| 10431 if (length <= 8*1024) { | |
| 10432 ret = payload->TransitionElementsKind(to_kind); | |
| 10433 if (FLAG_trace_track_allocation_sites) { | |
| 10434 PrintF( | |
| 10435 "AllocationSiteInfo: JSArray %p boilerplate updated %s->%s\n", | |
| 10436 reinterpret_cast<void*>(this), | |
| 10437 ElementsKindToString(kind), | |
| 10438 ElementsKindToString(to_kind)); | |
| 10418 } | 10439 } |
| 10419 } | 10440 } |
| 10420 } | 10441 } |
| 10421 } | 10442 } |
| 10422 return ret; | 10443 return ret; |
| 10423 } | 10444 } |
| 10424 | 10445 |
| 10425 | 10446 |
| 10426 MaybeObject* JSObject::TransitionElementsKind(ElementsKind to_kind) { | 10447 MaybeObject* JSObject::TransitionElementsKind(ElementsKind to_kind) { |
| 10427 ASSERT(!map()->is_observed()); | 10448 ASSERT(!map()->is_observed()); |
| (...skipping 3352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 13780 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 13801 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
| 13781 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 13802 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
| 13782 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 13803 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
| 13783 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 13804 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
| 13784 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 13805 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
| 13785 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 13806 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
| 13786 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 13807 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
| 13787 } | 13808 } |
| 13788 | 13809 |
| 13789 } } // namespace v8::internal | 13810 } } // namespace v8::internal |
| OLD | NEW |