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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 isolate->counters()->array_function_runtime()->Increment(); | 202 isolate->counters()->array_function_runtime()->Increment(); |
203 | 203 |
204 JSArray* array; | 204 JSArray* array; |
205 if (CalledAsConstructor(isolate)) { | 205 if (CalledAsConstructor(isolate)) { |
206 array = JSArray::cast((*args)[0]); | 206 array = JSArray::cast((*args)[0]); |
207 // Initialize elements and length in case later allocations fail so that the | 207 // Initialize elements and length in case later allocations fail so that the |
208 // array object is initialized in a valid state. | 208 // array object is initialized in a valid state. |
209 MaybeObject* maybe_array = array->Initialize(0); | 209 MaybeObject* maybe_array = array->Initialize(0); |
210 if (maybe_array->IsFailure()) return maybe_array; | 210 if (maybe_array->IsFailure()) return maybe_array; |
211 | 211 |
212 if (FLAG_optimize_constructed_arrays) { | 212 AllocationSiteInfo* info = AllocationSiteInfo::FindForJSObject(array); |
213 AllocationSiteInfo* info = AllocationSiteInfo::FindForJSObject(array); | 213 ElementsKind to_kind = array->GetElementsKind(); |
214 ElementsKind to_kind = array->GetElementsKind(); | 214 if (info != NULL && info->GetElementsKindPayload(&to_kind)) { |
215 if (info != NULL && info->GetElementsKindPayload(&to_kind)) { | 215 if (IsMoreGeneralElementsKindTransition(array->GetElementsKind(), |
216 if (IsMoreGeneralElementsKindTransition(array->GetElementsKind(), | 216 to_kind)) { |
217 to_kind)) { | 217 // We have advice that we should change the elements kind |
218 // We have advice that we should change the elements kind | 218 if (FLAG_trace_track_allocation_sites) { |
219 if (FLAG_trace_track_allocation_sites) { | 219 PrintF("AllocationSiteInfo: pre-transitioning array %p(%s->%s)\n", |
220 PrintF("AllocationSiteInfo: pre-transitioning array %p(%s->%s)\n", | 220 reinterpret_cast<void*>(array), |
221 reinterpret_cast<void*>(array), | 221 ElementsKindToString(array->GetElementsKind()), |
222 ElementsKindToString(array->GetElementsKind()), | 222 ElementsKindToString(to_kind)); |
223 ElementsKindToString(to_kind)); | 223 } |
224 } | |
225 | 224 |
226 maybe_array = array->TransitionElementsKind(to_kind); | 225 maybe_array = array->TransitionElementsKind(to_kind); |
227 if (maybe_array->IsFailure()) return maybe_array; | 226 if (maybe_array->IsFailure()) return maybe_array; |
228 } | |
229 } | 227 } |
230 } | 228 } |
231 | 229 |
232 if (!FLAG_smi_only_arrays) { | 230 if (!FLAG_smi_only_arrays) { |
233 Context* native_context = isolate->context()->native_context(); | 231 Context* native_context = isolate->context()->native_context(); |
234 if (array->GetElementsKind() == GetInitialFastElementsKind() && | 232 if (array->GetElementsKind() == GetInitialFastElementsKind() && |
235 !native_context->js_array_maps()->IsUndefined()) { | 233 !native_context->js_array_maps()->IsUndefined()) { |
236 FixedArray* map_array = | 234 FixedArray* map_array = |
237 FixedArray::cast(native_context->js_array_maps()); | 235 FixedArray::cast(native_context->js_array_maps()); |
238 array->set_map(Map::cast(map_array-> | 236 array->set_map(Map::cast(map_array-> |
(...skipping 1587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1826 return Handle<Code>(code_address); \ | 1824 return Handle<Code>(code_address); \ |
1827 } | 1825 } |
1828 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 1826 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) |
1829 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 1827 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) |
1830 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 1828 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
1831 #undef DEFINE_BUILTIN_ACCESSOR_C | 1829 #undef DEFINE_BUILTIN_ACCESSOR_C |
1832 #undef DEFINE_BUILTIN_ACCESSOR_A | 1830 #undef DEFINE_BUILTIN_ACCESSOR_A |
1833 | 1831 |
1834 | 1832 |
1835 } } // namespace v8::internal | 1833 } } // namespace v8::internal |
OLD | NEW |