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 9265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9276 MaybeObject* JSObject::SetFastElementsCapacityAndLength( | 9276 MaybeObject* JSObject::SetFastElementsCapacityAndLength( |
9277 int capacity, | 9277 int capacity, |
9278 int length, | 9278 int length, |
9279 SetFastElementsCapacitySmiMode smi_mode) { | 9279 SetFastElementsCapacitySmiMode smi_mode) { |
9280 Heap* heap = GetHeap(); | 9280 Heap* heap = GetHeap(); |
9281 // We should never end in here with a pixel or external array. | 9281 // We should never end in here with a pixel or external array. |
9282 ASSERT(!HasExternalArrayElements()); | 9282 ASSERT(!HasExternalArrayElements()); |
9283 | 9283 |
9284 // Allocate a new fast elements backing store. | 9284 // Allocate a new fast elements backing store. |
9285 FixedArray* new_elements; | 9285 FixedArray* new_elements; |
9286 { MaybeObject* maybe = heap->AllocateFixedArrayWithHoles(capacity); | 9286 MaybeObject* maybe = heap->AllocateUninitializedFixedArray(capacity); |
9287 if (!maybe->To(&new_elements)) return maybe; | 9287 if (!maybe->To(&new_elements)) return maybe; |
9288 } | |
9289 | 9288 |
9290 ElementsKind elements_kind = GetElementsKind(); | 9289 ElementsKind elements_kind = GetElementsKind(); |
9291 ElementsKind new_elements_kind; | 9290 ElementsKind new_elements_kind; |
9292 // The resized array has FAST_*_SMI_ELEMENTS if the capacity mode forces it, | 9291 // The resized array has FAST_*_SMI_ELEMENTS if the capacity mode forces it, |
9293 // or if it's allowed and the old elements array contained only SMIs. | 9292 // or if it's allowed and the old elements array contained only SMIs. |
9294 bool has_fast_smi_elements = | 9293 bool has_fast_smi_elements = |
9295 (smi_mode == kForceSmiElements) || | 9294 (smi_mode == kForceSmiElements) || |
9296 ((smi_mode == kAllowSmiElements) && HasFastSmiElements()); | 9295 ((smi_mode == kAllowSmiElements) && HasFastSmiElements()); |
9297 if (has_fast_smi_elements) { | 9296 if (has_fast_smi_elements) { |
9298 if (IsHoleyElementsKind(elements_kind)) { | 9297 if (IsHoleyElementsKind(elements_kind)) { |
9299 new_elements_kind = FAST_HOLEY_SMI_ELEMENTS; | 9298 new_elements_kind = FAST_HOLEY_SMI_ELEMENTS; |
9300 } else { | 9299 } else { |
9301 new_elements_kind = FAST_SMI_ELEMENTS; | 9300 new_elements_kind = FAST_SMI_ELEMENTS; |
9302 } | 9301 } |
9303 } else { | 9302 } else { |
9304 if (IsHoleyElementsKind(elements_kind)) { | 9303 if (IsHoleyElementsKind(elements_kind)) { |
9305 new_elements_kind = FAST_HOLEY_ELEMENTS; | 9304 new_elements_kind = FAST_HOLEY_ELEMENTS; |
9306 } else { | 9305 } else { |
9307 new_elements_kind = FAST_ELEMENTS; | 9306 new_elements_kind = FAST_ELEMENTS; |
9308 } | 9307 } |
9309 } | 9308 } |
9310 FixedArrayBase* old_elements = elements(); | 9309 FixedArrayBase* old_elements = elements(); |
9311 ElementsAccessor* accessor = ElementsAccessor::ForKind(elements_kind); | 9310 ElementsAccessor* accessor = ElementsAccessor::ForKind(elements_kind); |
9312 { MaybeObject* maybe_obj = | 9311 MaybeObject* maybe_obj = |
9313 accessor->CopyElements(this, new_elements, new_elements_kind); | 9312 accessor->CopyElements(this, new_elements, new_elements_kind); |
9314 if (maybe_obj->IsFailure()) return maybe_obj; | 9313 if (maybe_obj->IsFailure()) return maybe_obj; |
9315 } | 9314 |
9316 if (elements_kind != NON_STRICT_ARGUMENTS_ELEMENTS) { | 9315 if (elements_kind != NON_STRICT_ARGUMENTS_ELEMENTS) { |
9317 Map* new_map = map(); | 9316 Map* new_map = map(); |
9318 if (new_elements_kind != elements_kind) { | 9317 if (new_elements_kind != elements_kind) { |
9319 MaybeObject* maybe = | 9318 MaybeObject* maybe = |
9320 GetElementsTransitionMap(GetIsolate(), new_elements_kind); | 9319 GetElementsTransitionMap(GetIsolate(), new_elements_kind); |
9321 if (!maybe->To(&new_map)) return maybe; | 9320 if (!maybe->To(&new_map)) return maybe; |
9322 } | 9321 } |
9323 ValidateElements(); | 9322 ValidateElements(); |
9324 set_map_and_elements(new_map, new_elements); | 9323 set_map_and_elements(new_map, new_elements); |
9325 } else { | 9324 } else { |
(...skipping 4559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13885 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 13884 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
13886 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 13885 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
13887 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 13886 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
13888 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 13887 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
13889 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 13888 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
13890 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 13889 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
13891 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 13890 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
13892 } | 13891 } |
13893 | 13892 |
13894 } } // namespace v8::internal | 13893 } } // namespace v8::internal |
OLD | NEW |