Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: src/assembler.cc

Issue 2039233005: Consider reloc info mode when merging constant pool entries Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/assembler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 1994-2006 Sun Microsystems Inc. 1 // Copyright (c) 1994-2006 Sun Microsystems Inc.
2 // All Rights Reserved. 2 // All Rights Reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // - Redistributions of source code must retain the above copyright notice, 8 // - Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer. 9 // this list of conditions and the following disclaimer.
10 // 10 //
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 #endif 812 #endif
813 813
814 814
815 #ifdef ENABLE_DISASSEMBLER 815 #ifdef ENABLE_DISASSEMBLER
816 const char* RelocInfo::RelocModeName(RelocInfo::Mode rmode) { 816 const char* RelocInfo::RelocModeName(RelocInfo::Mode rmode) {
817 switch (rmode) { 817 switch (rmode) {
818 case NONE32: 818 case NONE32:
819 return "no reloc 32"; 819 return "no reloc 32";
820 case NONE64: 820 case NONE64:
821 return "no reloc 64"; 821 return "no reloc 64";
822 case NONEINTPTR:
823 return "no reloc intptr";
822 case EMBEDDED_OBJECT: 824 case EMBEDDED_OBJECT:
823 return "embedded object"; 825 return "embedded object";
824 case DEBUGGER_STATEMENT: 826 case DEBUGGER_STATEMENT:
825 return "debugger statement"; 827 return "debugger statement";
826 case CODE_TARGET: 828 case CODE_TARGET:
827 return "code target"; 829 return "code target";
828 case CODE_TARGET_WITH_ID: 830 case CODE_TARGET_WITH_ID:
829 return "code target with id"; 831 return "code target with id";
830 case CELL: 832 case CELL:
831 return "property cell"; 833 return "property cell";
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 case VENEER_POOL: 961 case VENEER_POOL:
960 case DEBUG_BREAK_SLOT_AT_POSITION: 962 case DEBUG_BREAK_SLOT_AT_POSITION:
961 case DEBUG_BREAK_SLOT_AT_RETURN: 963 case DEBUG_BREAK_SLOT_AT_RETURN:
962 case DEBUG_BREAK_SLOT_AT_CALL: 964 case DEBUG_BREAK_SLOT_AT_CALL:
963 case DEBUG_BREAK_SLOT_AT_TAIL_CALL: 965 case DEBUG_BREAK_SLOT_AT_TAIL_CALL:
964 case GENERATOR_CONTINUATION: 966 case GENERATOR_CONTINUATION:
965 case WASM_MEMORY_REFERENCE: 967 case WASM_MEMORY_REFERENCE:
966 case WASM_MEMORY_SIZE_REFERENCE: 968 case WASM_MEMORY_SIZE_REFERENCE:
967 case NONE32: 969 case NONE32:
968 case NONE64: 970 case NONE64:
971 case NONEINTPTR:
969 break; 972 break;
970 case NUMBER_OF_MODES: 973 case NUMBER_OF_MODES:
971 case PC_JUMP: 974 case PC_JUMP:
972 UNREACHABLE(); 975 UNREACHABLE();
973 break; 976 break;
974 case CODE_AGE_SEQUENCE: 977 case CODE_AGE_SEQUENCE:
975 DCHECK(Code::IsYoungSequence(isolate, pc_) || code_age_stub()->IsCode()); 978 DCHECK(Code::IsYoungSequence(isolate, pc_) || code_age_stub()->IsCode());
976 break; 979 break;
977 } 980 }
978 } 981 }
(...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after
1911 } else { 1914 } else {
1912 DCHECK(type == ConstantPoolEntry::INTPTR); 1915 DCHECK(type == ConstantPoolEntry::INTPTR);
1913 if (!is_uintn(ptr_offset, info.regular_reach_bits)) { 1916 if (!is_uintn(ptr_offset, info.regular_reach_bits)) {
1914 return ConstantPoolEntry::OVERFLOWED; 1917 return ConstantPoolEntry::OVERFLOWED;
1915 } 1918 }
1916 } 1919 }
1917 1920
1918 return ConstantPoolEntry::REGULAR; 1921 return ConstantPoolEntry::REGULAR;
1919 } 1922 }
1920 1923
1921
1922 ConstantPoolEntry::Access ConstantPoolBuilder::AddEntry( 1924 ConstantPoolEntry::Access ConstantPoolBuilder::AddEntry(
1923 ConstantPoolEntry& entry, ConstantPoolEntry::Type type) { 1925 ConstantPoolEntry& entry) {
1924 DCHECK(!emitted_label_.is_bound()); 1926 DCHECK(!emitted_label_.is_bound());
1925 PerTypeEntryInfo& info = info_[type]; 1927 PerTypeEntryInfo& info = info_[entry.type()];
1926 const int entry_size = ConstantPoolEntry::size(type);
1927 bool merged = false; 1928 bool merged = false;
1928 1929
1929 if (entry.sharing_ok()) { 1930 if (entry.sharing_ok()) {
1930 // Try to merge entries 1931 // Try to merge entries
1931 std::vector<ConstantPoolEntry>::iterator it = info.shared_entries.begin(); 1932 std::vector<ConstantPoolEntry>::iterator it = info.shared_entries.begin();
1932 int end = static_cast<int>(info.shared_entries.size()); 1933 int end = static_cast<int>(info.shared_entries.size());
1933 for (int i = 0; i < end; i++, it++) { 1934 for (int i = 0; i < end; i++, it++) {
1934 if ((entry_size == kPointerSize) ? entry.value() == it->value() 1935 if (entry.MayBeMergedWith(*it)) {
1935 : entry.value64() == it->value64()) {
1936 // Merge with found entry. 1936 // Merge with found entry.
1937 entry.set_merged_index(i); 1937 entry.set_merged_index(i);
1938 merged = true; 1938 merged = true;
1939 break; 1939 break;
1940 } 1940 }
1941 } 1941 }
1942 } 1942 }
1943 1943
1944 // By definition, merged entries have regular access. 1944 // By definition, merged entries have regular access.
1945 DCHECK(!merged || entry.merged_index() < info.regular_count); 1945 DCHECK(!merged || entry.merged_index() < info.regular_count);
1946 ConstantPoolEntry::Access access = 1946 ConstantPoolEntry::Access access =
1947 (merged ? ConstantPoolEntry::REGULAR : NextAccess(type)); 1947 (merged ? ConstantPoolEntry::REGULAR : NextAccess(entry.type()));
1948 1948
1949 // Enforce an upper bound on search time by limiting the search to 1949 // Enforce an upper bound on search time by limiting the search to
1950 // unique sharable entries which fit in the regular section. 1950 // unique sharable entries which fit in the regular section.
1951 if (entry.sharing_ok() && !merged && access == ConstantPoolEntry::REGULAR) { 1951 if (entry.sharing_ok() && !merged && access == ConstantPoolEntry::REGULAR) {
1952 info.shared_entries.push_back(entry); 1952 info.shared_entries.push_back(entry);
1953 } else { 1953 } else {
1954 info.entries.push_back(entry); 1954 info.entries.push_back(entry);
1955 } 1955 }
1956 1956
1957 // We're done if we found a match or have already triggered the 1957 // We're done if we found a match or have already triggered the
1958 // overflow state. 1958 // overflow state.
1959 if (merged || info.overflow()) return access; 1959 if (merged || info.overflow()) return access;
1960 1960
1961 if (access == ConstantPoolEntry::REGULAR) { 1961 if (access == ConstantPoolEntry::REGULAR) {
1962 info.regular_count++; 1962 info.regular_count++;
1963 } else { 1963 } else {
1964 info.overflow_start = static_cast<int>(info.entries.size()) - 1; 1964 info.overflow_start = static_cast<int>(info.entries.size()) - 1;
1965 } 1965 }
1966 1966
1967 return access; 1967 return access;
1968 } 1968 }
1969 1969
1970 1970
1971 void ConstantPoolBuilder::EmitSharedEntries(Assembler* assm, 1971 void ConstantPoolBuilder::EmitSharedEntries(Assembler* assm,
1972 ConstantPoolEntry::Type type) { 1972 ConstantPoolEntry::Type type) {
1973 PerTypeEntryInfo& info = info_[type]; 1973 PerTypeEntryInfo& info = info_[type];
1974 std::vector<ConstantPoolEntry>& shared_entries = info.shared_entries; 1974 std::vector<ConstantPoolEntry>& shared_entries = info.shared_entries;
1975 const int entry_size = ConstantPoolEntry::size(type); 1975 const int entry_size = ConstantPoolEntry::SizeOfType(type);
1976 int base = emitted_label_.pos(); 1976 int base = emitted_label_.pos();
1977 DCHECK(base > 0); 1977 DCHECK(base > 0);
1978 int shared_end = static_cast<int>(shared_entries.size()); 1978 int shared_end = static_cast<int>(shared_entries.size());
1979 std::vector<ConstantPoolEntry>::iterator shared_it = shared_entries.begin(); 1979 std::vector<ConstantPoolEntry>::iterator shared_it = shared_entries.begin();
1980 for (int i = 0; i < shared_end; i++, shared_it++) { 1980 for (int i = 0; i < shared_end; i++, shared_it++) {
1981 int offset = assm->pc_offset() - base; 1981 int offset = assm->pc_offset() - base;
1982 shared_it->set_offset(offset); // Save offset for merged entries. 1982 shared_it->set_offset(offset); // Save offset for merged entries.
1983 if (entry_size == kPointerSize) { 1983 if (entry_size == kPointerSize) {
1984 assm->dp(shared_it->value()); 1984 assm->dp(shared_it->value());
1985 } else { 1985 } else {
1986 assm->dq(shared_it->value64()); 1986 assm->dq(shared_it->value64());
1987 } 1987 }
1988 DCHECK(is_uintn(offset, info.regular_reach_bits)); 1988 DCHECK(is_uintn(offset, info.regular_reach_bits));
1989 1989
1990 // Patch load sequence with correct offset. 1990 // Patch load sequence with correct offset.
1991 assm->PatchConstantPoolAccessInstruction(shared_it->position(), offset, 1991 assm->PatchConstantPoolAccessInstruction(shared_it->position(), offset,
1992 ConstantPoolEntry::REGULAR, type); 1992 ConstantPoolEntry::REGULAR, type);
1993 } 1993 }
1994 } 1994 }
1995 1995
1996 1996
1997 void ConstantPoolBuilder::EmitGroup(Assembler* assm, 1997 void ConstantPoolBuilder::EmitGroup(Assembler* assm,
1998 ConstantPoolEntry::Access access, 1998 ConstantPoolEntry::Access access,
1999 ConstantPoolEntry::Type type) { 1999 ConstantPoolEntry::Type type) {
2000 PerTypeEntryInfo& info = info_[type]; 2000 PerTypeEntryInfo& info = info_[type];
2001 const bool overflow = info.overflow(); 2001 const bool overflow = info.overflow();
2002 std::vector<ConstantPoolEntry>& entries = info.entries; 2002 std::vector<ConstantPoolEntry>& entries = info.entries;
2003 std::vector<ConstantPoolEntry>& shared_entries = info.shared_entries; 2003 std::vector<ConstantPoolEntry>& shared_entries = info.shared_entries;
2004 const int entry_size = ConstantPoolEntry::size(type); 2004 const int entry_size = ConstantPoolEntry::SizeOfType(type);
2005 int base = emitted_label_.pos(); 2005 int base = emitted_label_.pos();
2006 DCHECK(base > 0); 2006 DCHECK(base > 0);
2007 int begin; 2007 int begin;
2008 int end; 2008 int end;
2009 2009
2010 if (access == ConstantPoolEntry::REGULAR) { 2010 if (access == ConstantPoolEntry::REGULAR) {
2011 // Emit any shared entries first 2011 // Emit any shared entries first
2012 EmitSharedEntries(assm, type); 2012 EmitSharedEntries(assm, type);
2013 } 2013 }
2014 2014
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
2117 2117
2118 2118
2119 void Assembler::DataAlign(int m) { 2119 void Assembler::DataAlign(int m) {
2120 DCHECK(m >= 2 && base::bits::IsPowerOfTwo32(m)); 2120 DCHECK(m >= 2 && base::bits::IsPowerOfTwo32(m));
2121 while ((pc_offset() & (m - 1)) != 0) { 2121 while ((pc_offset() & (m - 1)) != 0) {
2122 db(0); 2122 db(0);
2123 } 2123 }
2124 } 2124 }
2125 } // namespace internal 2125 } // namespace internal
2126 } // namespace v8 2126 } // namespace v8
OLDNEW
« no previous file with comments | « src/assembler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698