| 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 8430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8441 ((set_capacity_mode == kAllowSmiOnlyElements) && | 8441 ((set_capacity_mode == kAllowSmiOnlyElements) && |
| 8442 (elements()->map()->has_fast_smi_only_elements() || | 8442 (elements()->map()->has_fast_smi_only_elements() || |
| 8443 elements() == heap->empty_fixed_array())); | 8443 elements() == heap->empty_fixed_array())); |
| 8444 ElementsKind elements_kind = has_fast_smi_only_elements | 8444 ElementsKind elements_kind = has_fast_smi_only_elements |
| 8445 ? FAST_SMI_ONLY_ELEMENTS | 8445 ? FAST_SMI_ONLY_ELEMENTS |
| 8446 : FAST_ELEMENTS; | 8446 : FAST_ELEMENTS; |
| 8447 MaybeObject* maybe = GetElementsTransitionMap(GetIsolate(), elements_kind); | 8447 MaybeObject* maybe = GetElementsTransitionMap(GetIsolate(), elements_kind); |
| 8448 if (!maybe->To(&new_map)) return maybe; | 8448 if (!maybe->To(&new_map)) return maybe; |
| 8449 } | 8449 } |
| 8450 | 8450 |
| 8451 FixedArrayBase* old_elements_raw = elements(); | 8451 FixedArrayBase* old_elements = elements(); |
| 8452 ElementsKind elements_kind = GetElementsKind(); | 8452 ElementsKind elements_kind = GetElementsKind(); |
| 8453 ElementsAccessor* accessor = ElementsAccessor::ForKind(elements_kind); | 8453 ElementsAccessor* accessor = ElementsAccessor::ForKind(elements_kind); |
| 8454 ElementsKind to_kind = (elements_kind == FAST_SMI_ONLY_ELEMENTS) | 8454 ElementsKind to_kind = (elements_kind == FAST_SMI_ONLY_ELEMENTS) |
| 8455 ? FAST_SMI_ONLY_ELEMENTS | 8455 ? FAST_SMI_ONLY_ELEMENTS |
| 8456 : FAST_ELEMENTS; | 8456 : FAST_ELEMENTS; |
| 8457 // int copy_size = Min(old_elements_raw->length(), new_elements->length()); | 8457 // int copy_size = Min(old_elements_raw->length(), new_elements->length()); |
| 8458 accessor->CopyElements(this, new_elements, to_kind); | 8458 accessor->CopyElements(this, new_elements, to_kind, SKIP_WRITE_BARRIER); |
| 8459 if (elements_kind != NON_STRICT_ARGUMENTS_ELEMENTS) { | 8459 if (elements_kind != NON_STRICT_ARGUMENTS_ELEMENTS) { |
| 8460 set_map_and_elements(new_map, new_elements); | 8460 set_map_and_elements(new_map, new_elements); |
| 8461 } else { | 8461 } else { |
| 8462 FixedArray* parameter_map = FixedArray::cast(old_elements_raw); | 8462 FixedArray* parameter_map = FixedArray::cast(old_elements); |
| 8463 parameter_map->set(1, new_elements); | 8463 parameter_map->set(1, new_elements); |
| 8464 } | 8464 } |
| 8465 | 8465 |
| 8466 if (FLAG_trace_elements_transitions) { | 8466 if (FLAG_trace_elements_transitions) { |
| 8467 PrintElementsTransition(stdout, elements_kind, old_elements_raw, | 8467 PrintElementsTransition(stdout, elements_kind, old_elements, |
| 8468 GetElementsKind(), new_elements); | 8468 GetElementsKind(), new_elements); |
| 8469 } | 8469 } |
| 8470 | 8470 |
| 8471 // Update the length if necessary. | 8471 // Update the length if necessary. |
| 8472 if (IsJSArray()) { | 8472 if (IsJSArray()) { |
| 8473 JSArray::cast(this)->set_length(Smi::FromInt(length)); | 8473 JSArray::cast(this)->set_length(Smi::FromInt(length)); |
| 8474 } | 8474 } |
| 8475 | 8475 |
| 8476 return new_elements; | 8476 return new_elements; |
| 8477 } | 8477 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 8490 if (!maybe_obj->To(&elems)) return maybe_obj; | 8490 if (!maybe_obj->To(&elems)) return maybe_obj; |
| 8491 } | 8491 } |
| 8492 | 8492 |
| 8493 Map* new_map; | 8493 Map* new_map; |
| 8494 { MaybeObject* maybe_obj = | 8494 { MaybeObject* maybe_obj = |
| 8495 GetElementsTransitionMap(heap->isolate(), FAST_DOUBLE_ELEMENTS); | 8495 GetElementsTransitionMap(heap->isolate(), FAST_DOUBLE_ELEMENTS); |
| 8496 if (!maybe_obj->To(&new_map)) return maybe_obj; | 8496 if (!maybe_obj->To(&new_map)) return maybe_obj; |
| 8497 } | 8497 } |
| 8498 | 8498 |
| 8499 FixedArrayBase* old_elements = elements(); | 8499 FixedArrayBase* old_elements = elements(); |
| 8500 ElementsKind elements_kind(GetElementsKind()); | 8500 ElementsKind elements_kind = GetElementsKind(); |
| 8501 AssertNoAllocation no_gc; | 8501 ElementsAccessor* accessor = ElementsAccessor::ForKind(elements_kind); |
| 8502 if (old_elements->length() != 0) { | 8502 accessor->CopyElements(this, elems, FAST_DOUBLE_ELEMENTS, |
| 8503 switch (elements_kind) { | 8503 SKIP_WRITE_BARRIER); |
| 8504 case FAST_SMI_ONLY_ELEMENTS: | 8504 if (elements_kind != NON_STRICT_ARGUMENTS_ELEMENTS) { |
| 8505 case FAST_ELEMENTS: { | 8505 set_map_and_elements(new_map, elems); |
| 8506 elems->Initialize(FixedArray::cast(old_elements)); | 8506 } else { |
| 8507 break; | 8507 FixedArray* parameter_map = FixedArray::cast(old_elements); |
| 8508 } | 8508 parameter_map->set(1, elems); |
| 8509 case FAST_DOUBLE_ELEMENTS: { | |
| 8510 elems->Initialize(FixedDoubleArray::cast(old_elements)); | |
| 8511 break; | |
| 8512 } | |
| 8513 case DICTIONARY_ELEMENTS: { | |
| 8514 elems->Initialize(SeededNumberDictionary::cast(old_elements)); | |
| 8515 break; | |
| 8516 } | |
| 8517 default: | |
| 8518 UNREACHABLE(); | |
| 8519 break; | |
| 8520 } | |
| 8521 } | 8509 } |
| 8522 | 8510 |
| 8523 if (FLAG_trace_elements_transitions) { | 8511 if (FLAG_trace_elements_transitions) { |
| 8524 PrintElementsTransition(stdout, elements_kind, old_elements, | 8512 PrintElementsTransition(stdout, elements_kind, old_elements, |
| 8525 FAST_DOUBLE_ELEMENTS, elems); | 8513 FAST_DOUBLE_ELEMENTS, elems); |
| 8526 } | 8514 } |
| 8527 | 8515 |
| 8528 ASSERT(new_map->has_fast_double_elements()); | |
| 8529 set_map(new_map); | |
| 8530 ASSERT(elems->IsFixedDoubleArray()); | |
| 8531 set_elements(elems); | |
| 8532 | |
| 8533 if (IsJSArray()) { | 8516 if (IsJSArray()) { |
| 8534 JSArray::cast(this)->set_length(Smi::FromInt(length)); | 8517 JSArray::cast(this)->set_length(Smi::FromInt(length)); |
| 8535 } | 8518 } |
| 8536 | 8519 |
| 8537 return this; | 8520 return this; |
| 8538 } | 8521 } |
| 8539 | 8522 |
| 8540 | 8523 |
| 8541 MaybeObject* JSArray::Initialize(int capacity) { | 8524 MaybeObject* JSArray::Initialize(int capacity) { |
| 8542 Heap* heap = GetHeap(); | 8525 Heap* heap = GetHeap(); |
| (...skipping 4413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12956 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 12939 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
| 12957 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 12940 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
| 12958 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 12941 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
| 12959 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 12942 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
| 12960 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 12943 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
| 12961 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 12944 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
| 12962 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 12945 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
| 12963 } | 12946 } |
| 12964 | 12947 |
| 12965 } } // namespace v8::internal | 12948 } } // namespace v8::internal |
| OLD | NEW |