| 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 4778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4789 | 4789 |
| 4790 __ Bind(&skip_to_incremental_noncompacting); | 4790 __ Bind(&skip_to_incremental_noncompacting); |
| 4791 GenerateIncremental(masm, INCREMENTAL); | 4791 GenerateIncremental(masm, INCREMENTAL); |
| 4792 | 4792 |
| 4793 __ Bind(&skip_to_incremental_compacting); | 4793 __ Bind(&skip_to_incremental_compacting); |
| 4794 GenerateIncremental(masm, INCREMENTAL_COMPACTION); | 4794 GenerateIncremental(masm, INCREMENTAL_COMPACTION); |
| 4795 } | 4795 } |
| 4796 | 4796 |
| 4797 | 4797 |
| 4798 void StoreArrayLiteralElementStub::Generate(MacroAssembler* masm) { | 4798 void StoreArrayLiteralElementStub::Generate(MacroAssembler* masm) { |
| 4799 // TODO(all): Possible optimisations in this function: | |
| 4800 // 1. Merge CheckFastElements and CheckFastSmiElements, so that the map | |
| 4801 // bitfield is loaded only once. | |
| 4802 // 2. Refactor the Ldr/Add sequence at the start of fast_elements and | |
| 4803 // smi_element. | |
| 4804 | |
| 4805 // x0 value element value to store | 4799 // x0 value element value to store |
| 4806 // x3 index_smi element index as smi | 4800 // x3 index_smi element index as smi |
| 4807 // sp[0] array_index_smi array literal index in function as smi | 4801 // sp[0] array_index_smi array literal index in function as smi |
| 4808 // sp[1] array array literal | 4802 // sp[1] array array literal |
| 4809 | 4803 |
| 4810 Register value = x0; | 4804 Register value = x0; |
| 4811 Register index_smi = x3; | 4805 Register index_smi = x3; |
| 4812 | 4806 |
| 4813 Register array = x1; | 4807 Register array = x1; |
| 4814 Register array_map = x2; | 4808 Register array_map = x2; |
| 4815 Register array_index_smi = x4; | 4809 Register array_index_smi = x4; |
| 4816 __ PeekPair(array_index_smi, array, 0); | 4810 __ PeekPair(array_index_smi, array, 0); |
| 4817 __ Ldr(array_map, FieldMemOperand(array, JSObject::kMapOffset)); | 4811 __ Ldr(array_map, FieldMemOperand(array, JSObject::kMapOffset)); |
| 4818 | 4812 |
| 4819 Label double_elements, smi_element, fast_elements, slow_elements; | 4813 Label double_elements, smi_element, fast_elements, slow_elements; |
| 4820 __ CheckFastElements(array_map, x10, &double_elements); | 4814 Register bitfield2 = x10; |
| 4815 __ Ldrb(bitfield2, FieldMemOperand(array_map, Map::kBitField2Offset)); |
| 4816 |
| 4817 // Jump if array's ElementsKind is not FAST*_SMI_ELEMENTS, FAST_ELEMENTS or |
| 4818 // FAST_HOLEY_ELEMENTS. |
| 4819 STATIC_ASSERT(FAST_SMI_ELEMENTS == 0); |
| 4820 STATIC_ASSERT(FAST_HOLEY_SMI_ELEMENTS == 1); |
| 4821 STATIC_ASSERT(FAST_ELEMENTS == 2); |
| 4822 STATIC_ASSERT(FAST_HOLEY_ELEMENTS == 3); |
| 4823 __ Cmp(bitfield2, Map::kMaximumBitField2FastHoleyElementValue); |
| 4824 __ B(hi, &double_elements); |
| 4825 |
| 4821 __ JumpIfSmi(value, &smi_element); | 4826 __ JumpIfSmi(value, &smi_element); |
| 4822 __ CheckFastSmiElements(array_map, x10, &fast_elements); | 4827 |
| 4828 // Jump if array's ElementsKind is not FAST_ELEMENTS or FAST_HOLEY_ELEMENTS. |
| 4829 __ Tbnz(bitfield2, MaskToBit(FAST_ELEMENTS << Map::kElementsKindShift), |
| 4830 &fast_elements); |
| 4823 | 4831 |
| 4824 // Store into the array literal requires an elements transition. Call into | 4832 // Store into the array literal requires an elements transition. Call into |
| 4825 // the runtime. | 4833 // the runtime. |
| 4826 __ Bind(&slow_elements); | 4834 __ Bind(&slow_elements); |
| 4827 __ Push(array, index_smi, value); | 4835 __ Push(array, index_smi, value); |
| 4828 __ Ldr(x10, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 4836 __ Ldr(x10, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
| 4829 __ Ldr(x11, FieldMemOperand(x10, JSFunction::kLiteralsOffset)); | 4837 __ Ldr(x11, FieldMemOperand(x10, JSFunction::kLiteralsOffset)); |
| 4830 __ Push(x11, array_index_smi); | 4838 __ Push(x11, array_index_smi); |
| 4831 __ TailCallRuntime(Runtime::kStoreArrayLiteralElement, 5, 1); | 4839 __ TailCallRuntime(Runtime::kStoreArrayLiteralElement, 5, 1); |
| 4832 | 4840 |
| (...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5538 __ Bind(&unexpected_map); | 5546 __ Bind(&unexpected_map); |
| 5539 __ Abort(kUnexpectedInitialMapForArrayFunction); | 5547 __ Abort(kUnexpectedInitialMapForArrayFunction); |
| 5540 __ Bind(&map_ok); | 5548 __ Bind(&map_ok); |
| 5541 } | 5549 } |
| 5542 | 5550 |
| 5543 Register kind = w3; | 5551 Register kind = w3; |
| 5544 // Figure out the right elements kind | 5552 // Figure out the right elements kind |
| 5545 __ Ldr(x10, FieldMemOperand(constructor, | 5553 __ Ldr(x10, FieldMemOperand(constructor, |
| 5546 JSFunction::kPrototypeOrInitialMapOffset)); | 5554 JSFunction::kPrototypeOrInitialMapOffset)); |
| 5547 | 5555 |
| 5548 // TODO(jbramley): Add a helper function to read elements kind from an | 5556 // Retrieve elements_kind from map. |
| 5549 // existing map. | 5557 __ LoadElementsKindFromMap(kind, x10); |
| 5550 // Load the map's "bit field 2" into result. | |
| 5551 __ Ldr(kind, FieldMemOperand(x10, Map::kBitField2Offset)); | |
| 5552 // Retrieve elements_kind from bit field 2. | |
| 5553 __ Ubfx(kind, kind, Map::kElementsKindShift, Map::kElementsKindBitCount); | |
| 5554 | 5558 |
| 5555 if (FLAG_debug_code) { | 5559 if (FLAG_debug_code) { |
| 5556 Label done; | 5560 Label done; |
| 5557 __ Cmp(x3, FAST_ELEMENTS); | 5561 __ Cmp(x3, FAST_ELEMENTS); |
| 5558 __ Ccmp(x3, FAST_HOLEY_ELEMENTS, ZFlag, ne); | 5562 __ Ccmp(x3, FAST_HOLEY_ELEMENTS, ZFlag, ne); |
| 5559 __ Assert(eq, kInvalidElementsKindForInternalArrayOrInternalPackedArray); | 5563 __ Assert(eq, kInvalidElementsKindForInternalArrayOrInternalPackedArray); |
| 5560 } | 5564 } |
| 5561 | 5565 |
| 5562 Label fast_elements_case; | 5566 Label fast_elements_case; |
| 5563 __ CompareAndBranch(kind, FAST_ELEMENTS, eq, &fast_elements_case); | 5567 __ CompareAndBranch(kind, FAST_ELEMENTS, eq, &fast_elements_case); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5722 MemOperand(fp, 6 * kPointerSize), | 5726 MemOperand(fp, 6 * kPointerSize), |
| 5723 NULL); | 5727 NULL); |
| 5724 } | 5728 } |
| 5725 | 5729 |
| 5726 | 5730 |
| 5727 #undef __ | 5731 #undef __ |
| 5728 | 5732 |
| 5729 } } // namespace v8::internal | 5733 } } // namespace v8::internal |
| 5730 | 5734 |
| 5731 #endif // V8_TARGET_ARCH_A64 | 5735 #endif // V8_TARGET_ARCH_A64 |
| OLD | NEW |