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 5697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5708 | 5708 |
5709 // The returned handle will be used for the object in all | 5709 // The returned handle will be used for the object in all |
5710 // subsequent usages. This allows VisitObject to make a copy | 5710 // subsequent usages. This allows VisitObject to make a copy |
5711 // of the object if desired. | 5711 // of the object if desired. |
5712 virtual Handle<JSObject> VisitObject(Handle<JSObject> object) V8_OVERRIDE { | 5712 virtual Handle<JSObject> VisitObject(Handle<JSObject> object) V8_OVERRIDE { |
5713 // Only create a memento if | 5713 // Only create a memento if |
5714 // 1) we have a JSArray, and | 5714 // 1) we have a JSArray, and |
5715 // 2) the elements kind is palatable | 5715 // 2) the elements kind is palatable |
5716 // 3) allow_mementos is true | 5716 // 3) allow_mementos is true |
5717 Handle<JSObject> copy; | 5717 Handle<JSObject> copy; |
5718 if (site_context()->activated() && | 5718 if (site_context()->ShouldCreateMemento(object)) { |
5719 AllocationSite::CanTrack(object->map()->instance_type()) && | |
5720 AllocationSite::GetMode(object->GetElementsKind()) == | |
5721 TRACK_ALLOCATION_SITE) { | |
5722 copy = JSObject::Copy(object, site_context()->current()); | 5719 copy = JSObject::Copy(object, site_context()->current()); |
5723 } else { | 5720 } else { |
5724 copy = JSObject::Copy(object); | 5721 copy = JSObject::Copy(object); |
5725 } | 5722 } |
5726 | 5723 |
5727 return copy; | 5724 return copy; |
5728 } | 5725 } |
5729 | 5726 |
5730 virtual Handle<JSObject> VisitElementOrProperty( | 5727 virtual Handle<JSObject> VisitElementOrProperty( |
5731 Handle<JSObject> object, | 5728 Handle<JSObject> object, |
(...skipping 3474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9206 } | 9203 } |
9207 | 9204 |
9208 | 9205 |
9209 if (new_length == 0) return heap->isolate()->factory()->empty_string(); | 9206 if (new_length == 0) return heap->isolate()->factory()->empty_string(); |
9210 return string; | 9207 return string; |
9211 } | 9208 } |
9212 | 9209 |
9213 | 9210 |
9214 AllocationMemento* AllocationMemento::FindForJSObject(JSObject* object, | 9211 AllocationMemento* AllocationMemento::FindForJSObject(JSObject* object, |
9215 bool in_GC) { | 9212 bool in_GC) { |
9216 // Currently, AllocationMemento objects are only allocated immediately | 9213 // Currently, AllocationMemento objects are only allocated immediately |
Hannes Payer (out of office)
2013/11/27 10:51:37
Please update this comment.
mvstanton
2013/11/27 13:27:58
Done.
| |
9217 // after JSArrays in NewSpace, and detecting whether a JSArray has one | 9214 // after JSArrays in NewSpace, and detecting whether a JSArray has one |
9218 // involves carefully checking the object immediately after the JSArray | 9215 // involves carefully checking the object immediately after the JSArray |
9219 // (if there is one) to see if it's an AllocationMemento. | 9216 // (if there is one) to see if it's an AllocationMemento. |
9220 if (FLAG_track_allocation_sites && object->GetHeap()->InNewSpace(object)) { | 9217 if (FLAG_track_allocation_sites && object->GetHeap()->InNewSpace(object)) { |
9221 Address ptr_end = (reinterpret_cast<Address>(object) - kHeapObjectTag) + | 9218 Address ptr_end = (reinterpret_cast<Address>(object) - kHeapObjectTag) + |
9222 object->Size(); | 9219 object->Size(); |
9223 Address top; | 9220 Address top; |
9224 if (in_GC) { | 9221 if (in_GC) { |
9225 top = object->GetHeap()->new_space()->FromSpacePageHigh(); | 9222 top = object->GetHeap()->new_space()->FromSpacePageHigh(); |
9226 } else { | 9223 } else { |
9227 top = object->GetHeap()->NewSpaceTop(); | 9224 top = object->GetHeap()->NewSpaceTop(); |
9228 } | 9225 } |
9229 if ((ptr_end + AllocationMemento::kSize) <= top) { | 9226 if ((ptr_end + AllocationMemento::kSize) <= top) { |
9230 // There is room in newspace for allocation info. Do we have some? | 9227 // There is room in newspace for allocation info. Do we have some? |
9231 Map** possible_allocation_memento_map = | 9228 Map** possible_allocation_memento_map = |
9232 reinterpret_cast<Map**>(ptr_end); | 9229 reinterpret_cast<Map**>(ptr_end); |
9233 if (*possible_allocation_memento_map == | 9230 if (*possible_allocation_memento_map == |
9234 object->GetHeap()->allocation_memento_map()) { | 9231 object->GetHeap()->allocation_memento_map()) { |
9235 AllocationMemento* memento = AllocationMemento::cast( | 9232 AllocationMemento* memento = AllocationMemento::cast( |
9236 reinterpret_cast<Object*>(ptr_end + kHeapObjectTag)); | 9233 reinterpret_cast<Object*>(ptr_end + kHeapObjectTag)); |
9237 return memento; | 9234 if (memento->IsValid()) { |
9235 return memento; | |
9236 } | |
9238 } | 9237 } |
9239 } | 9238 } |
9240 } | 9239 } |
9241 return NULL; | 9240 return NULL; |
9242 } | 9241 } |
9243 | 9242 |
9244 | 9243 |
9245 uint32_t StringHasher::MakeArrayIndexHash(uint32_t value, int length) { | 9244 uint32_t StringHasher::MakeArrayIndexHash(uint32_t value, int length) { |
9246 // For array indexes mix the length into the hash as an array index could | 9245 // For array indexes mix the length into the hash as an array index could |
9247 // be zero. | 9246 // be zero. |
(...skipping 3555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12803 } | 12802 } |
12804 | 12803 |
12805 | 12804 |
12806 void JSObject::TransitionElementsKind(Handle<JSObject> object, | 12805 void JSObject::TransitionElementsKind(Handle<JSObject> object, |
12807 ElementsKind to_kind) { | 12806 ElementsKind to_kind) { |
12808 CALL_HEAP_FUNCTION_VOID(object->GetIsolate(), | 12807 CALL_HEAP_FUNCTION_VOID(object->GetIsolate(), |
12809 object->TransitionElementsKind(to_kind)); | 12808 object->TransitionElementsKind(to_kind)); |
12810 } | 12809 } |
12811 | 12810 |
12812 | 12811 |
12812 const double AllocationSite::kPretenureRatio = 0.60; | |
12813 | |
12814 | |
12813 bool AllocationSite::IsNestedSite() { | 12815 bool AllocationSite::IsNestedSite() { |
12814 ASSERT(FLAG_trace_track_allocation_sites); | 12816 ASSERT(FLAG_trace_track_allocation_sites); |
12815 Object* current = GetHeap()->allocation_sites_list(); | 12817 Object* current = GetHeap()->allocation_sites_list(); |
12816 while (current != NULL && current->IsAllocationSite()) { | 12818 while (current != NULL && current->IsAllocationSite()) { |
12817 AllocationSite* current_site = AllocationSite::cast(current); | 12819 AllocationSite* current_site = AllocationSite::cast(current); |
12818 if (current_site->nested_site() == this) { | 12820 if (current_site->nested_site() == this) { |
12819 return true; | 12821 return true; |
12820 } | 12822 } |
12821 current = current_site->weak_next(); | 12823 current = current_site->weak_next(); |
12822 } | 12824 } |
(...skipping 3850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
16673 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16675 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16674 static const char* error_messages_[] = { | 16676 static const char* error_messages_[] = { |
16675 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16677 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16676 }; | 16678 }; |
16677 #undef ERROR_MESSAGES_TEXTS | 16679 #undef ERROR_MESSAGES_TEXTS |
16678 return error_messages_[reason]; | 16680 return error_messages_[reason]; |
16679 } | 16681 } |
16680 | 16682 |
16681 | 16683 |
16682 } } // namespace v8::internal | 16684 } } // namespace v8::internal |
OLD | NEW |