| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 NumberDictionary::kElementsStartOffset + kPointerSize; | 376 NumberDictionary::kElementsStartOffset + kPointerSize; |
| 377 __ movq(result, FieldOperand(elements, r2, times_pointer_size, kValueOffset)); | 377 __ movq(result, FieldOperand(elements, r2, times_pointer_size, kValueOffset)); |
| 378 } | 378 } |
| 379 | 379 |
| 380 | 380 |
| 381 // One byte opcode for test rax,0xXXXXXXXX. | 381 // One byte opcode for test rax,0xXXXXXXXX. |
| 382 static const byte kTestEaxByte = 0xA9; | 382 static const byte kTestEaxByte = 0xA9; |
| 383 | 383 |
| 384 | 384 |
| 385 static bool PatchInlinedMapCheck(Address address, Object* map) { | 385 static bool PatchInlinedMapCheck(Address address, Object* map) { |
| 386 if (V8::UseCrankshaft()) return false; |
| 387 |
| 386 // Arguments are address of start of call sequence that called | 388 // Arguments are address of start of call sequence that called |
| 387 // the IC, | 389 // the IC, |
| 388 Address test_instruction_address = | 390 Address test_instruction_address = |
| 389 address + Assembler::kCallTargetAddressOffset; | 391 address + Assembler::kCallTargetAddressOffset; |
| 390 // The keyed load has a fast inlined case if the IC call instruction | 392 // The keyed load has a fast inlined case if the IC call instruction |
| 391 // is immediately followed by a test instruction. | 393 // is immediately followed by a test instruction. |
| 392 if (*test_instruction_address != kTestEaxByte) return false; | 394 if (*test_instruction_address != kTestEaxByte) return false; |
| 393 | 395 |
| 394 // Fetch the offset from the test instruction to the map compare | 396 // Fetch the offset from the test instruction to the map compare |
| 395 // instructions (starting with the 64-bit immediate mov of the map | 397 // instructions (starting with the 64-bit immediate mov of the map |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 scratch1, | 743 scratch1, |
| 742 scratch2, | 744 scratch2, |
| 743 result, | 745 result, |
| 744 &miss, // When not a string. | 746 &miss, // When not a string. |
| 745 &miss, // When not a number. | 747 &miss, // When not a number. |
| 746 &miss, // When index out of range. | 748 &miss, // When index out of range. |
| 747 STRING_INDEX_IS_ARRAY_INDEX); | 749 STRING_INDEX_IS_ARRAY_INDEX); |
| 748 char_at_generator.GenerateFast(masm); | 750 char_at_generator.GenerateFast(masm); |
| 749 __ ret(0); | 751 __ ret(0); |
| 750 | 752 |
| 751 ICRuntimeCallHelper call_helper; | 753 StubRuntimeCallHelper call_helper; |
| 752 char_at_generator.GenerateSlow(masm, call_helper); | 754 char_at_generator.GenerateSlow(masm, call_helper); |
| 753 | 755 |
| 754 __ bind(&miss); | 756 __ bind(&miss); |
| 755 GenerateMiss(masm); | 757 GenerateMiss(masm); |
| 756 } | 758 } |
| 757 | 759 |
| 758 | 760 |
| 759 void KeyedLoadIC::GenerateExternalArray(MacroAssembler* masm, | 761 void KeyedLoadIC::GenerateExternalArray(MacroAssembler* masm, |
| 760 ExternalArrayType array_type) { | 762 ExternalArrayType array_type) { |
| 761 // ----------- S t a t e ------------- | 763 // ----------- S t a t e ------------- |
| (...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1695 // ----------------------------------- | 1697 // ----------------------------------- |
| 1696 Label miss; | 1698 Label miss; |
| 1697 | 1699 |
| 1698 StubCompiler::GenerateLoadStringLength(masm, rax, rdx, rbx, &miss); | 1700 StubCompiler::GenerateLoadStringLength(masm, rax, rdx, rbx, &miss); |
| 1699 __ bind(&miss); | 1701 __ bind(&miss); |
| 1700 StubCompiler::GenerateLoadMiss(masm, Code::LOAD_IC); | 1702 StubCompiler::GenerateLoadMiss(masm, Code::LOAD_IC); |
| 1701 } | 1703 } |
| 1702 | 1704 |
| 1703 | 1705 |
| 1704 bool LoadIC::PatchInlinedLoad(Address address, Object* map, int offset) { | 1706 bool LoadIC::PatchInlinedLoad(Address address, Object* map, int offset) { |
| 1707 if (V8::UseCrankshaft()) return false; |
| 1708 |
| 1705 // The address of the instruction following the call. | 1709 // The address of the instruction following the call. |
| 1706 Address test_instruction_address = | 1710 Address test_instruction_address = |
| 1707 address + Assembler::kCallTargetAddressOffset; | 1711 address + Assembler::kCallTargetAddressOffset; |
| 1708 // If the instruction following the call is not a test rax, nothing | 1712 // If the instruction following the call is not a test rax, nothing |
| 1709 // was inlined. | 1713 // was inlined. |
| 1710 if (*test_instruction_address != kTestEaxByte) return false; | 1714 if (*test_instruction_address != kTestEaxByte) return false; |
| 1711 | 1715 |
| 1712 Address delta_address = test_instruction_address + 1; | 1716 Address delta_address = test_instruction_address + 1; |
| 1713 // The delta to the start of the map check instruction. | 1717 // The delta to the start of the map check instruction. |
| 1714 int delta = *reinterpret_cast<int*>(delta_address); | 1718 int delta = *reinterpret_cast<int*>(delta_address); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1737 return false; | 1741 return false; |
| 1738 } | 1742 } |
| 1739 | 1743 |
| 1740 | 1744 |
| 1741 // The offset from the inlined patch site to the start of the inlined | 1745 // The offset from the inlined patch site to the start of the inlined |
| 1742 // store instruction. | 1746 // store instruction. |
| 1743 const int StoreIC::kOffsetToStoreInstruction = 20; | 1747 const int StoreIC::kOffsetToStoreInstruction = 20; |
| 1744 | 1748 |
| 1745 | 1749 |
| 1746 bool StoreIC::PatchInlinedStore(Address address, Object* map, int offset) { | 1750 bool StoreIC::PatchInlinedStore(Address address, Object* map, int offset) { |
| 1751 if (V8::UseCrankshaft()) return false; |
| 1752 |
| 1747 // The address of the instruction following the call. | 1753 // The address of the instruction following the call. |
| 1748 Address test_instruction_address = | 1754 Address test_instruction_address = |
| 1749 address + Assembler::kCallTargetAddressOffset; | 1755 address + Assembler::kCallTargetAddressOffset; |
| 1750 | 1756 |
| 1751 // If the instruction following the call is not a test rax, nothing | 1757 // If the instruction following the call is not a test rax, nothing |
| 1752 // was inlined. | 1758 // was inlined. |
| 1753 if (*test_instruction_address != kTestEaxByte) return false; | 1759 if (*test_instruction_address != kTestEaxByte) return false; |
| 1754 | 1760 |
| 1755 // Extract the encoded deltas from the test rax instruction. | 1761 // Extract the encoded deltas from the test rax instruction. |
| 1756 Address encoded_offsets_address = test_instruction_address + 1; | 1762 Address encoded_offsets_address = test_instruction_address + 1; |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1896 GenerateDictionaryStore(masm, &miss, rbx, rcx, rax, r8, r9); | 1902 GenerateDictionaryStore(masm, &miss, rbx, rcx, rax, r8, r9); |
| 1897 __ IncrementCounter(COUNTERS->store_normal_hit(), 1); | 1903 __ IncrementCounter(COUNTERS->store_normal_hit(), 1); |
| 1898 __ ret(0); | 1904 __ ret(0); |
| 1899 | 1905 |
| 1900 __ bind(&miss); | 1906 __ bind(&miss); |
| 1901 __ IncrementCounter(COUNTERS->store_normal_miss(), 1); | 1907 __ IncrementCounter(COUNTERS->store_normal_miss(), 1); |
| 1902 GenerateMiss(masm); | 1908 GenerateMiss(masm); |
| 1903 } | 1909 } |
| 1904 | 1910 |
| 1905 | 1911 |
| 1912 void StoreIC::GenerateGlobalProxy(MacroAssembler* masm) { |
| 1913 // ----------- S t a t e ------------- |
| 1914 // -- rax : value |
| 1915 // -- rcx : name |
| 1916 // -- rdx : receiver |
| 1917 // -- rsp[0] : return address |
| 1918 // ----------------------------------- |
| 1919 __ pop(rbx); |
| 1920 __ push(rdx); |
| 1921 __ push(rcx); |
| 1922 __ push(rax); |
| 1923 __ push(rbx); |
| 1924 |
| 1925 // Do tail-call to runtime routine. |
| 1926 __ TailCallRuntime(Runtime::kSetProperty, 3, 1); |
| 1927 } |
| 1928 |
| 1929 |
| 1906 #undef __ | 1930 #undef __ |
| 1907 | 1931 |
| 1908 | 1932 |
| 1933 Condition CompareIC::ComputeCondition(Token::Value op) { |
| 1934 switch (op) { |
| 1935 case Token::EQ_STRICT: |
| 1936 case Token::EQ: |
| 1937 return equal; |
| 1938 case Token::LT: |
| 1939 return less; |
| 1940 case Token::GT: |
| 1941 // Reverse left and right operands to obtain ECMA-262 conversion order. |
| 1942 return less; |
| 1943 case Token::LTE: |
| 1944 // Reverse left and right operands to obtain ECMA-262 conversion order. |
| 1945 return greater_equal; |
| 1946 case Token::GTE: |
| 1947 return greater_equal; |
| 1948 default: |
| 1949 UNREACHABLE(); |
| 1950 return no_condition; |
| 1951 } |
| 1952 } |
| 1953 |
| 1954 |
| 1955 void CompareIC::UpdateCaches(Handle<Object> x, Handle<Object> y) { |
| 1956 HandleScope scope; |
| 1957 Handle<Code> rewritten; |
| 1958 #ifdef DEBUG |
| 1959 State previous_state = GetState(); |
| 1960 #endif |
| 1961 State state = TargetState(x, y); |
| 1962 if (state == GENERIC) { |
| 1963 CompareStub stub(GetCondition(), strict(), NO_COMPARE_FLAGS); |
| 1964 rewritten = stub.GetCode(); |
| 1965 } else { |
| 1966 ICCompareStub stub(op_, state); |
| 1967 rewritten = stub.GetCode(); |
| 1968 } |
| 1969 set_target(*rewritten); |
| 1970 |
| 1971 #ifdef DEBUG |
| 1972 if (FLAG_trace_ic) { |
| 1973 PrintF("[CompareIC (%s->%s)#%s]\n", |
| 1974 GetStateName(previous_state), |
| 1975 GetStateName(state), |
| 1976 Token::Name(op_)); |
| 1977 } |
| 1978 #endif |
| 1979 } |
| 1980 |
| 1909 } } // namespace v8::internal | 1981 } } // namespace v8::internal |
| 1910 | 1982 |
| 1911 #endif // V8_TARGET_ARCH_X64 | 1983 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |