| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 12298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12309 } | 12309 } |
| 12310 | 12310 |
| 12311 AllocationSiteInfo* info = AllocationSiteInfo::FindForJSObject(this); | 12311 AllocationSiteInfo* info = AllocationSiteInfo::FindForJSObject(this); |
| 12312 if (info == NULL || !info->IsValid()) { | 12312 if (info == NULL || !info->IsValid()) { |
| 12313 return this; | 12313 return this; |
| 12314 } | 12314 } |
| 12315 | 12315 |
| 12316 // Walk through to the Allocation Site | 12316 // Walk through to the Allocation Site |
| 12317 AllocationSite* site = info->GetAllocationSite(); | 12317 AllocationSite* site = info->GetAllocationSite(); |
| 12318 if (site->IsLiteralSite()) { | 12318 if (site->IsLiteralSite()) { |
| 12319 JSArray* payload = JSArray::cast(site->payload()); | 12319 JSArray* transition_info = JSArray::cast(site->transition_info()); |
| 12320 ElementsKind kind = payload->GetElementsKind(); | 12320 ElementsKind kind = transition_info->GetElementsKind(); |
| 12321 if (AllocationSite::GetMode(kind, to_kind) == TRACK_ALLOCATION_SITE) { | 12321 if (AllocationSite::GetMode(kind, to_kind) == TRACK_ALLOCATION_SITE) { |
| 12322 // If the array is huge, it's not likely to be defined in a local | 12322 // If the array is huge, it's not likely to be defined in a local |
| 12323 // function, so we shouldn't make new instances of it very often. | 12323 // function, so we shouldn't make new instances of it very often. |
| 12324 uint32_t length = 0; | 12324 uint32_t length = 0; |
| 12325 CHECK(payload->length()->ToArrayIndex(&length)); | 12325 CHECK(transition_info->length()->ToArrayIndex(&length)); |
| 12326 if (length <= AllocationSite::kMaximumArrayBytesToPretransition) { | 12326 if (length <= AllocationSite::kMaximumArrayBytesToPretransition) { |
| 12327 if (FLAG_trace_track_allocation_sites) { | 12327 if (FLAG_trace_track_allocation_sites) { |
| 12328 PrintF( | 12328 PrintF( |
| 12329 "AllocationSite: JSArray %p boilerplate updated %s->%s\n", | 12329 "AllocationSite: JSArray %p boilerplate updated %s->%s\n", |
| 12330 reinterpret_cast<void*>(this), | 12330 reinterpret_cast<void*>(this), |
| 12331 ElementsKindToString(kind), | 12331 ElementsKindToString(kind), |
| 12332 ElementsKindToString(to_kind)); | 12332 ElementsKindToString(to_kind)); |
| 12333 } | 12333 } |
| 12334 return payload->TransitionElementsKind(to_kind); | 12334 return transition_info->TransitionElementsKind(to_kind); |
| 12335 } | 12335 } |
| 12336 } | 12336 } |
| 12337 } else { | 12337 } else { |
| 12338 ElementsKind kind = site->GetElementsKindPayload(); | 12338 ElementsKind kind = site->GetElementsKind(); |
| 12339 if (AllocationSite::GetMode(kind, to_kind) == TRACK_ALLOCATION_SITE) { | 12339 if (AllocationSite::GetMode(kind, to_kind) == TRACK_ALLOCATION_SITE) { |
| 12340 if (FLAG_trace_track_allocation_sites) { | 12340 if (FLAG_trace_track_allocation_sites) { |
| 12341 PrintF("AllocationSite: JSArray %p site updated %s->%s\n", | 12341 PrintF("AllocationSite: JSArray %p site updated %s->%s\n", |
| 12342 reinterpret_cast<void*>(this), | 12342 reinterpret_cast<void*>(this), |
| 12343 ElementsKindToString(kind), | 12343 ElementsKindToString(kind), |
| 12344 ElementsKindToString(to_kind)); | 12344 ElementsKindToString(to_kind)); |
| 12345 } | 12345 } |
| 12346 site->set_payload(Smi::FromInt(to_kind)); | 12346 site->set_transition_info(Smi::FromInt(to_kind)); |
| 12347 } | 12347 } |
| 12348 } | 12348 } |
| 12349 return this; | 12349 return this; |
| 12350 } | 12350 } |
| 12351 | 12351 |
| 12352 | 12352 |
| 12353 MaybeObject* JSObject::TransitionElementsKind(ElementsKind to_kind) { | 12353 MaybeObject* JSObject::TransitionElementsKind(ElementsKind to_kind) { |
| 12354 ASSERT(!map()->is_observed()); | 12354 ASSERT(!map()->is_observed()); |
| 12355 ElementsKind from_kind = map()->elements_kind(); | 12355 ElementsKind from_kind = map()->elements_kind(); |
| 12356 | 12356 |
| (...skipping 3457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15814 void PropertyCell::set_type(Type* type, WriteBarrierMode ignored) { | 15814 void PropertyCell::set_type(Type* type, WriteBarrierMode ignored) { |
| 15815 ASSERT(IsPropertyCell()); | 15815 ASSERT(IsPropertyCell()); |
| 15816 set_type_raw(type, ignored); | 15816 set_type_raw(type, ignored); |
| 15817 } | 15817 } |
| 15818 | 15818 |
| 15819 | 15819 |
| 15820 Type* PropertyCell::UpdateType(Handle<PropertyCell> cell, | 15820 Type* PropertyCell::UpdateType(Handle<PropertyCell> cell, |
| 15821 Handle<Object> value) { | 15821 Handle<Object> value) { |
| 15822 Isolate* isolate = cell->GetIsolate(); | 15822 Isolate* isolate = cell->GetIsolate(); |
| 15823 Handle<Type> old_type(cell->type(), isolate); | 15823 Handle<Type> old_type(cell->type(), isolate); |
| 15824 Handle<Type> new_type((value->IsSmi() || value->IsJSFunction() || | 15824 Handle<Type> new_type((value->IsSmi() || value->IsUndefined()) |
| 15825 value->IsUndefined()) | |
| 15826 ? Type::Constant(value, isolate) | 15825 ? Type::Constant(value, isolate) |
| 15827 : Type::Any(), isolate); | 15826 : Type::Any(), isolate); |
| 15828 | 15827 |
| 15829 if (new_type->Is(old_type)) { | 15828 if (new_type->Is(old_type)) { |
| 15830 return *old_type; | 15829 return *old_type; |
| 15831 } | 15830 } |
| 15832 | 15831 |
| 15833 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 15832 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
| 15834 isolate, DependentCode::kPropertyCellChangedGroup); | 15833 isolate, DependentCode::kPropertyCellChangedGroup); |
| 15835 | 15834 |
| 15836 if (old_type->Is(Type::None()) || old_type->Is(Type::Undefined())) { | 15835 if (old_type->Is(Type::None()) || old_type->Is(Type::Undefined())) { |
| 15837 return *new_type; | 15836 return *new_type; |
| 15838 } | 15837 } |
| 15839 | 15838 |
| 15840 return Type::Any(); | 15839 return Type::Any(); |
| 15841 } | 15840 } |
| 15842 | 15841 |
| 15843 | 15842 |
| 15844 MaybeObject* PropertyCell::SetValueInferType(Object* value, | 15843 MaybeObject* PropertyCell::SetValueInferType(Object* value, |
| 15845 WriteBarrierMode ignored) { | 15844 WriteBarrierMode ignored) { |
| 15846 set_value(value, ignored); | 15845 set_value(value, ignored); |
| 15847 if (!Type::Any()->Is(type())) { | 15846 if (!Type::Any()->Is(type())) { |
| 15848 IdempotentPointerToHandleCodeTrampoline trampoline(GetIsolate()); | 15847 IdempotentPointerToHandleCodeTrampoline trampoline(GetIsolate()); |
| 15849 MaybeObject* maybe_type = trampoline.CallWithReturnValue( | 15848 MaybeObject* maybe_type = trampoline.CallWithReturnValue( |
| 15850 &PropertyCell::UpdateType, | 15849 &PropertyCell::UpdateType, |
| 15851 Handle<PropertyCell>(this), | 15850 Handle<PropertyCell>(this), |
| 15852 Handle<Object>(value, GetIsolate())); | 15851 Handle<Object>(value, GetIsolate())); |
| 15853 if (maybe_type->IsFailure()) return maybe_type; | 15852 Type* new_type = NULL; |
| 15854 Type* new_type = static_cast<Type*>(maybe_type); | 15853 if (!maybe_type->To(&new_type)) return maybe_type; |
| 15855 set_type(new_type); | 15854 set_type(new_type); |
| 15856 } | 15855 } |
| 15857 return value; | 15856 return value; |
| 15858 } | 15857 } |
| 15859 | 15858 |
| 15860 | 15859 |
| 15861 void PropertyCell::AddDependentCompilationInfo(CompilationInfo* info) { | 15860 void PropertyCell::AddDependentCompilationInfo(CompilationInfo* info) { |
| 15862 Handle<DependentCode> dep(dependent_code()); | 15861 Handle<DependentCode> dep(dependent_code()); |
| 15863 Handle<DependentCode> codes = | 15862 Handle<DependentCode> codes = |
| 15864 DependentCode::Insert(dep, DependentCode::kPropertyCellChangedGroup, | 15863 DependentCode::Insert(dep, DependentCode::kPropertyCellChangedGroup, |
| 15865 info->object_wrapper()); | 15864 info->object_wrapper()); |
| 15866 if (*codes != dependent_code()) set_dependent_code(*codes); | 15865 if (*codes != dependent_code()) set_dependent_code(*codes); |
| 15867 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( | 15866 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( |
| 15868 Handle<HeapObject>(this), info->zone()); | 15867 Handle<HeapObject>(this), info->zone()); |
| 15869 } | 15868 } |
| 15870 | 15869 |
| 15871 | 15870 |
| 15872 void PropertyCell::AddDependentCode(Handle<Code> code) { | 15871 void PropertyCell::AddDependentCode(Handle<Code> code) { |
| 15873 Handle<DependentCode> codes = DependentCode::Insert( | 15872 Handle<DependentCode> codes = DependentCode::Insert( |
| 15874 Handle<DependentCode>(dependent_code()), | 15873 Handle<DependentCode>(dependent_code()), |
| 15875 DependentCode::kPropertyCellChangedGroup, code); | 15874 DependentCode::kPropertyCellChangedGroup, code); |
| 15876 if (*codes != dependent_code()) set_dependent_code(*codes); | 15875 if (*codes != dependent_code()) set_dependent_code(*codes); |
| 15877 } | 15876 } |
| 15878 | 15877 |
| 15879 | 15878 |
| 15880 } } // namespace v8::internal | 15879 } } // namespace v8::internal |
| OLD | NEW |