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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 Handle<JSFunction> function = args.at<JSFunction>(1); | 196 Handle<JSFunction> function = args.at<JSFunction>(1); |
197 Handle<Object> type_info = args.at<Object>(2); | 197 Handle<Object> type_info = args.at<Object>(2); |
198 | 198 |
199 JSArray* array = NULL; | 199 JSArray* array = NULL; |
200 bool holey = false; | 200 bool holey = false; |
201 if (caller_args->length() == 1 && (*caller_args)[0]->IsSmi()) { | 201 if (caller_args->length() == 1 && (*caller_args)[0]->IsSmi()) { |
202 int value = Smi::cast((*caller_args)[0])->value(); | 202 int value = Smi::cast((*caller_args)[0])->value(); |
203 holey = (value > 0 && value < JSObject::kInitialMaxFastElementArray); | 203 holey = (value > 0 && value < JSObject::kInitialMaxFastElementArray); |
204 } | 204 } |
205 | 205 |
206 ASSERT(function->has_initial_map()); | |
207 ElementsKind kind = function->initial_map()->elements_kind(); | |
208 if (holey) { | |
209 kind = GetHoleyElementsKind(kind); | |
210 } | |
211 | |
212 MaybeObject* maybe_array; | 206 MaybeObject* maybe_array; |
213 if (*type_info != isolate->heap()->undefined_value()) { | 207 if (*type_info != isolate->heap()->undefined_value()) { |
214 JSGlobalPropertyCell* cell = JSGlobalPropertyCell::cast(*type_info); | 208 JSGlobalPropertyCell* cell = JSGlobalPropertyCell::cast(*type_info); |
215 if (cell->value()->IsSmi()) { | 209 if (cell->value()->IsSmi()) { |
216 Smi* smi = Smi::cast(cell->value()); | 210 Smi* smi = Smi::cast(cell->value()); |
217 ElementsKind to_kind = static_cast<ElementsKind>(smi->value()); | 211 ElementsKind to_kind = static_cast<ElementsKind>(smi->value()); |
218 if (holey && !IsFastHoleyElementsKind(to_kind)) { | 212 if (holey && !IsFastHoleyElementsKind(to_kind)) { |
219 to_kind = GetHoleyElementsKind(to_kind); | 213 to_kind = GetHoleyElementsKind(to_kind); |
220 // Update the allocation site info to reflect the advice alteration. | 214 // Update the allocation site info to reflect the advice alteration. |
221 cell->set_value(Smi::FromInt(to_kind)); | 215 cell->set_value(Smi::FromInt(to_kind)); |
222 } | 216 } |
223 | 217 |
224 AllocationSiteMode mode = AllocationSiteInfo::GetMode(to_kind); | 218 AllocationSiteMode mode = AllocationSiteInfo::GetMode(to_kind); |
225 if (mode == TRACK_ALLOCATION_SITE) { | 219 if (mode == TRACK_ALLOCATION_SITE) { |
226 maybe_array = isolate->heap()->AllocateEmptyJSArrayWithAllocationSite( | 220 maybe_array = isolate->heap()->AllocateEmptyJSArrayWithAllocationSite( |
227 kind, type_info); | 221 to_kind, type_info); |
228 } else { | 222 } else { |
229 maybe_array = isolate->heap()->AllocateEmptyJSArray(kind); | 223 maybe_array = isolate->heap()->AllocateEmptyJSArray(to_kind); |
230 } | 224 } |
231 if (!maybe_array->To(&array)) return maybe_array; | 225 if (!maybe_array->To(&array)) return maybe_array; |
232 } | 226 } |
233 } | 227 } |
234 | 228 |
| 229 ASSERT(function->has_initial_map()); |
| 230 ElementsKind kind = function->initial_map()->elements_kind(); |
| 231 if (holey) { |
| 232 kind = GetHoleyElementsKind(kind); |
| 233 } |
| 234 |
235 if (array == NULL) { | 235 if (array == NULL) { |
236 maybe_array = isolate->heap()->AllocateEmptyJSArray(kind); | 236 maybe_array = isolate->heap()->AllocateEmptyJSArray(kind); |
237 if (!maybe_array->To(&array)) return maybe_array; | 237 if (!maybe_array->To(&array)) return maybe_array; |
238 } | 238 } |
239 | 239 |
240 maybe_array = ArrayConstructInitializeElements(array, caller_args); | 240 maybe_array = ArrayConstructInitializeElements(array, caller_args); |
241 if (maybe_array->IsFailure()) return maybe_array; | 241 if (maybe_array->IsFailure()) return maybe_array; |
242 return array; | 242 return array; |
243 } | 243 } |
244 | 244 |
(...skipping 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1867 return Handle<Code>(code_address); \ | 1867 return Handle<Code>(code_address); \ |
1868 } | 1868 } |
1869 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 1869 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) |
1870 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 1870 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) |
1871 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 1871 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
1872 #undef DEFINE_BUILTIN_ACCESSOR_C | 1872 #undef DEFINE_BUILTIN_ACCESSOR_C |
1873 #undef DEFINE_BUILTIN_ACCESSOR_A | 1873 #undef DEFINE_BUILTIN_ACCESSOR_A |
1874 | 1874 |
1875 | 1875 |
1876 } } // namespace v8::internal | 1876 } } // namespace v8::internal |
OLD | NEW |