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 7490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7501 AllocationSiteInfo* info = AllocationSiteInfo::cast( | 7501 AllocationSiteInfo* info = AllocationSiteInfo::cast( |
7502 reinterpret_cast<Object*>(ptr_end + 1)); | 7502 reinterpret_cast<Object*>(ptr_end + 1)); |
7503 return info; | 7503 return info; |
7504 } | 7504 } |
7505 } | 7505 } |
7506 } | 7506 } |
7507 return NULL; | 7507 return NULL; |
7508 } | 7508 } |
7509 | 7509 |
7510 | 7510 |
| 7511 // Heuristic: We only need to create allocation site info if the boilerplate |
| 7512 // elements kind is the initial elements kind. |
| 7513 AllocationSiteMode AllocationSiteInfo::GetMode( |
| 7514 ElementsKind boilerplate_elements_kind) { |
| 7515 if (FLAG_track_allocation_sites && |
| 7516 IsFastSmiElementsKind(boilerplate_elements_kind)) { |
| 7517 return TRACK_ALLOCATION_SITE; |
| 7518 } |
| 7519 |
| 7520 return DONT_TRACK_ALLOCATION_SITE; |
| 7521 } |
| 7522 |
| 7523 |
| 7524 AllocationSiteMode AllocationSiteInfo::GetMode(ElementsKind from, |
| 7525 ElementsKind to) { |
| 7526 if (FLAG_track_allocation_sites && |
| 7527 IsFastSmiElementsKind(from) && |
| 7528 (IsFastObjectElementsKind(to) || IsFastDoubleElementsKind(to))) { |
| 7529 return TRACK_ALLOCATION_SITE; |
| 7530 } |
| 7531 |
| 7532 return DONT_TRACK_ALLOCATION_SITE; |
| 7533 } |
| 7534 |
| 7535 |
7511 uint32_t StringHasher::MakeArrayIndexHash(uint32_t value, int length) { | 7536 uint32_t StringHasher::MakeArrayIndexHash(uint32_t value, int length) { |
7512 // For array indexes mix the length into the hash as an array index could | 7537 // For array indexes mix the length into the hash as an array index could |
7513 // be zero. | 7538 // be zero. |
7514 ASSERT(length > 0); | 7539 ASSERT(length > 0); |
7515 ASSERT(length <= String::kMaxArrayIndexSize); | 7540 ASSERT(length <= String::kMaxArrayIndexSize); |
7516 ASSERT(TenToThe(String::kMaxCachedArrayIndexLength) < | 7541 ASSERT(TenToThe(String::kMaxCachedArrayIndexLength) < |
7517 (1 << String::kArrayIndexValueBits)); | 7542 (1 << String::kArrayIndexValueBits)); |
7518 | 7543 |
7519 value <<= String::kHashShift; | 7544 value <<= String::kHashShift; |
7520 value |= length << String::kArrayIndexHashLengthShift; | 7545 value |= length << String::kArrayIndexHashLengthShift; |
(...skipping 2347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9868 FixedDoubleArray::cast(elements())->set(index, value->Number()); | 9893 FixedDoubleArray::cast(elements())->set(index, value->Number()); |
9869 ValidateElements(); | 9894 ValidateElements(); |
9870 return value; | 9895 return value; |
9871 } | 9896 } |
9872 // Change elements kind from Smi-only to generic FAST if necessary. | 9897 // Change elements kind from Smi-only to generic FAST if necessary. |
9873 if (HasFastSmiElements() && !value->IsSmi()) { | 9898 if (HasFastSmiElements() && !value->IsSmi()) { |
9874 Map* new_map; | 9899 Map* new_map; |
9875 ElementsKind kind = HasFastHoleyElements() | 9900 ElementsKind kind = HasFastHoleyElements() |
9876 ? FAST_HOLEY_ELEMENTS | 9901 ? FAST_HOLEY_ELEMENTS |
9877 : FAST_ELEMENTS; | 9902 : FAST_ELEMENTS; |
| 9903 |
| 9904 MaybeObject* trans = PossiblyTransitionArrayBoilerplate(kind); |
| 9905 if (trans->IsFailure()) return trans; |
| 9906 |
9878 MaybeObject* maybe_new_map = GetElementsTransitionMap(GetIsolate(), | 9907 MaybeObject* maybe_new_map = GetElementsTransitionMap(GetIsolate(), |
9879 kind); | 9908 kind); |
9880 if (!maybe_new_map->To(&new_map)) return maybe_new_map; | 9909 if (!maybe_new_map->To(&new_map)) return maybe_new_map; |
9881 | 9910 |
9882 set_map(new_map); | 9911 set_map(new_map); |
9883 } | 9912 } |
9884 // Increase backing store capacity if that's been decided previously. | 9913 // Increase backing store capacity if that's been decided previously. |
9885 if (new_capacity != capacity) { | 9914 if (new_capacity != capacity) { |
9886 FixedArray* new_elements; | 9915 FixedArray* new_elements; |
9887 SetFastElementsCapacitySmiMode smi_mode = | 9916 SetFastElementsCapacitySmiMode smi_mode = |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10399 ElementsKind to_kind) { | 10428 ElementsKind to_kind) { |
10400 CALL_HEAP_FUNCTION(object->GetIsolate(), | 10429 CALL_HEAP_FUNCTION(object->GetIsolate(), |
10401 object->TransitionElementsKind(to_kind), | 10430 object->TransitionElementsKind(to_kind), |
10402 Object); | 10431 Object); |
10403 } | 10432 } |
10404 | 10433 |
10405 | 10434 |
10406 MaybeObject* JSObject::PossiblyTransitionArrayBoilerplate( | 10435 MaybeObject* JSObject::PossiblyTransitionArrayBoilerplate( |
10407 ElementsKind to_kind) { | 10436 ElementsKind to_kind) { |
10408 MaybeObject* ret = NULL; | 10437 MaybeObject* ret = NULL; |
10409 if (IsJSArray()) { | 10438 if (!FLAG_track_allocation_sites || !IsJSArray()) { |
10410 AllocationSiteInfo* info = AllocationSiteInfo::FindForJSObject(this); | 10439 return ret; |
10411 if (info != NULL) { | 10440 } |
10412 JSObject* payload = JSObject::cast(info->payload()); | 10441 |
10413 if (payload->GetElementsKind() != to_kind) { | 10442 AllocationSiteInfo* info = AllocationSiteInfo::FindForJSObject(this); |
10414 if (IsMoreGeneralElementsKindTransition(payload->GetElementsKind(), | 10443 if (info == NULL) { |
10415 to_kind)) { | 10444 return ret; |
10416 ret = payload->TransitionElementsKind(to_kind); | 10445 } |
10417 } | 10446 |
| 10447 ASSERT(info->payload()->IsJSArray()); |
| 10448 JSArray* payload = JSArray::cast(info->payload()); |
| 10449 ElementsKind kind = payload->GetElementsKind(); |
| 10450 if (IsMoreGeneralElementsKindTransition(kind, to_kind)) { |
| 10451 // If the array is huge, it's not likely to be defined in a local |
| 10452 // function, so we shouldn't make new instances of it very often. |
| 10453 uint32_t length = 0; |
| 10454 CHECK(payload->length()->ToArrayIndex(&length)); |
| 10455 if (length <= 8 * 1024) { |
| 10456 ret = payload->TransitionElementsKind(to_kind); |
| 10457 if (FLAG_trace_track_allocation_sites) { |
| 10458 PrintF( |
| 10459 "AllocationSiteInfo: JSArray %p boilerplate updated %s->%s\n", |
| 10460 reinterpret_cast<void*>(this), |
| 10461 ElementsKindToString(kind), |
| 10462 ElementsKindToString(to_kind)); |
10418 } | 10463 } |
10419 } | 10464 } |
10420 } | 10465 } |
10421 return ret; | 10466 return ret; |
10422 } | 10467 } |
10423 | 10468 |
10424 | 10469 |
10425 MaybeObject* JSObject::TransitionElementsKind(ElementsKind to_kind) { | 10470 MaybeObject* JSObject::TransitionElementsKind(ElementsKind to_kind) { |
10426 ASSERT(!map()->is_observed()); | 10471 ASSERT(!map()->is_observed()); |
10427 ElementsKind from_kind = map()->elements_kind(); | 10472 ElementsKind from_kind = map()->elements_kind(); |
(...skipping 3351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13779 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 13824 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
13780 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 13825 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
13781 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 13826 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
13782 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 13827 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
13783 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 13828 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
13784 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 13829 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
13785 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 13830 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
13786 } | 13831 } |
13787 | 13832 |
13788 } } // namespace v8::internal | 13833 } } // namespace v8::internal |
OLD | NEW |