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