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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 PrintF("Setting AllocationSite (%p, %p) transition_info %p\n", | 76 PrintF("Setting AllocationSite (%p, %p) transition_info %p\n", |
77 static_cast<void*>(*top()), | 77 static_cast<void*>(*top()), |
78 static_cast<void*>(*scope_site), | 78 static_cast<void*>(*scope_site), |
79 static_cast<void*>(*object)); | 79 static_cast<void*>(*object)); |
80 } | 80 } |
81 } | 81 } |
82 } | 82 } |
83 } | 83 } |
84 | 84 |
85 | 85 |
| 86 bool AllocationSiteUsageContext::ShouldCreateMemento(Handle<JSObject> object) { |
| 87 if (activated_) { |
| 88 if (AllocationSite::CanTrack(object->map()->instance_type())) { |
| 89 if (!FLAG_allocation_site_pretenuring) { |
| 90 ASSERT(object->IsJSArray()); |
| 91 if (AllocationSite::GetMode(object->GetElementsKind()) == |
| 92 TRACK_ALLOCATION_SITE) { |
| 93 if (FLAG_trace_creation_allocation_sites) { |
| 94 PrintF("*** Creating Memento for JSArray %p\n", |
| 95 static_cast<void*>(*object)); |
| 96 } |
| 97 return true; |
| 98 } |
| 99 } else { |
| 100 ASSERT(FLAG_allocation_site_pretenuring); |
| 101 if (FLAG_trace_creation_allocation_sites) { |
| 102 PrintF("*** Creating Memento for JSObject/JSArray %p\n", |
| 103 static_cast<void*>(*object)); |
| 104 } |
| 105 return true; |
| 106 } |
| 107 } |
| 108 } |
| 109 return false; |
| 110 } |
| 111 |
| 112 |
86 Handle<AllocationSite> AllocationSiteUsageContext::EnterNewScope() { | 113 Handle<AllocationSite> AllocationSiteUsageContext::EnterNewScope() { |
87 if (top().is_null()) { | 114 if (top().is_null()) { |
88 InitializeTraversal(top_site_); | 115 InitializeTraversal(top_site_); |
89 } else { | 116 } else { |
90 // Advance current site | 117 // Advance current site |
91 Object* nested_site = current()->nested_site(); | 118 Object* nested_site = current()->nested_site(); |
92 // Something is wrong if we advance to the end of the list here. | 119 // Something is wrong if we advance to the end of the list here. |
93 ASSERT(nested_site->IsAllocationSite()); | 120 ASSERT(nested_site->IsAllocationSite()); |
94 update_current_site(AllocationSite::cast(nested_site)); | 121 update_current_site(AllocationSite::cast(nested_site)); |
95 } | 122 } |
96 return Handle<AllocationSite>(*current(), isolate()); | 123 return Handle<AllocationSite>(*current(), isolate()); |
97 } | 124 } |
98 | 125 |
99 | 126 |
100 void AllocationSiteUsageContext::ExitScope( | 127 void AllocationSiteUsageContext::ExitScope( |
101 Handle<AllocationSite> scope_site, | 128 Handle<AllocationSite> scope_site, |
102 Handle<JSObject> object) { | 129 Handle<JSObject> object) { |
103 // This assert ensures that we are pointing at the right sub-object in a | 130 // This assert ensures that we are pointing at the right sub-object in a |
104 // recursive walk of a nested literal. | 131 // recursive walk of a nested literal. |
105 ASSERT(object.is_null() || *object == scope_site->transition_info()); | 132 ASSERT(object.is_null() || *object == scope_site->transition_info()); |
106 } | 133 } |
107 | 134 |
108 } } // namespace v8::internal | 135 } } // namespace v8::internal |
OLD | NEW |