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

Side by Side Diff: src/assembler.h

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/arm/macro-assembler-arm.cc ('k') | src/assembler.cc » ('j') | 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 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 DEOPT_ID, // Deoptimization inlining id. 419 DEOPT_ID, // Deoptimization inlining id.
420 420
421 // This is not an actual reloc mode, but used to encode a long pc jump that 421 // This is not an actual reloc mode, but used to encode a long pc jump that
422 // cannot be encoded as part of another record. 422 // cannot be encoded as part of another record.
423 PC_JUMP, 423 PC_JUMP,
424 424
425 // Pseudo-types 425 // Pseudo-types
426 NUMBER_OF_MODES, 426 NUMBER_OF_MODES,
427 NONE32, // never recorded 32-bit value 427 NONE32, // never recorded 32-bit value
428 NONE64, // never recorded 64-bit value 428 NONE64, // never recorded 64-bit value
429 NONEINTPTR, // never recorded intptr value
429 CODE_AGE_SEQUENCE, // Not stored in RelocInfo array, used explictly by 430 CODE_AGE_SEQUENCE, // Not stored in RelocInfo array, used explictly by
430 // code aging. 431 // code aging.
431 432
432 FIRST_REAL_RELOC_MODE = CODE_TARGET, 433 FIRST_REAL_RELOC_MODE = CODE_TARGET,
433 LAST_REAL_RELOC_MODE = VENEER_POOL, 434 LAST_REAL_RELOC_MODE = VENEER_POOL,
434 LAST_CODE_ENUM = DEBUGGER_STATEMENT, 435 LAST_CODE_ENUM = DEBUGGER_STATEMENT,
435 LAST_GCED_ENUM = WASM_MEMORY_SIZE_REFERENCE, 436 LAST_GCED_ENUM = WASM_MEMORY_SIZE_REFERENCE,
436 FIRST_SHAREABLE_RELOC_MODE = CELL, 437 FIRST_SHAREABLE_RELOC_MODE = CELL,
437 }; 438 };
438 439
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 static inline bool IsDebugBreakSlotAtCall(Mode mode) { 509 static inline bool IsDebugBreakSlotAtCall(Mode mode) {
509 return mode == DEBUG_BREAK_SLOT_AT_CALL; 510 return mode == DEBUG_BREAK_SLOT_AT_CALL;
510 } 511 }
511 static inline bool IsDebugBreakSlotAtTailCall(Mode mode) { 512 static inline bool IsDebugBreakSlotAtTailCall(Mode mode) {
512 return mode == DEBUG_BREAK_SLOT_AT_TAIL_CALL; 513 return mode == DEBUG_BREAK_SLOT_AT_TAIL_CALL;
513 } 514 }
514 static inline bool IsDebuggerStatement(Mode mode) { 515 static inline bool IsDebuggerStatement(Mode mode) {
515 return mode == DEBUGGER_STATEMENT; 516 return mode == DEBUGGER_STATEMENT;
516 } 517 }
517 static inline bool IsNone(Mode mode) { 518 static inline bool IsNone(Mode mode) {
518 return mode == NONE32 || mode == NONE64; 519 return mode == NONE32 || mode == NONE64 || mode == NONEINTPTR;
519 } 520 }
520 static inline bool IsCodeAgeSequence(Mode mode) { 521 static inline bool IsCodeAgeSequence(Mode mode) {
521 return mode == CODE_AGE_SEQUENCE; 522 return mode == CODE_AGE_SEQUENCE;
522 } 523 }
523 static inline bool IsGeneratorContinuation(Mode mode) { 524 static inline bool IsGeneratorContinuation(Mode mode) {
524 return mode == GENERATOR_CONTINUATION; 525 return mode == GENERATOR_CONTINUATION;
525 } 526 }
526 static inline bool IsWasmMemoryReference(Mode mode) { 527 static inline bool IsWasmMemoryReference(Mode mode) {
527 return mode == WASM_MEMORY_REFERENCE; 528 return mode == WASM_MEMORY_REFERENCE;
528 } 529 }
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
1222 virtual bool NeedsDebugStepCheck() const { return true; } 1223 virtual bool NeedsDebugStepCheck() const { return true; }
1223 }; 1224 };
1224 1225
1225 1226
1226 // ----------------------------------------------------------------------------- 1227 // -----------------------------------------------------------------------------
1227 // Constant pool support 1228 // Constant pool support
1228 1229
1229 class ConstantPoolEntry { 1230 class ConstantPoolEntry {
1230 public: 1231 public:
1231 ConstantPoolEntry() {} 1232 ConstantPoolEntry() {}
1232 ConstantPoolEntry(int position, intptr_t value, bool sharing_ok) 1233 ConstantPoolEntry(int position, intptr_t value, bool sharing_ok,
1234 RelocInfo::Mode rmode)
1233 : position_(position), 1235 : position_(position),
1234 merged_index_(sharing_ok ? SHARING_ALLOWED : SHARING_PROHIBITED), 1236 merged_index_(sharing_ok ? SHARING_ALLOWED : SHARING_PROHIBITED),
1237 rmode_(rmode),
1238 type_(INTPTR),
1235 value_(value) {} 1239 value_(value) {}
1236 ConstantPoolEntry(int position, double value) 1240 ConstantPoolEntry(int position, double value)
1237 : position_(position), merged_index_(SHARING_ALLOWED), value64_(value) {} 1241 : position_(position),
1242 merged_index_(SHARING_ALLOWED),
1243 rmode_(RelocInfo::NONE64),
1244 type_(DOUBLE),
1245 value64_(value) {}
1238 1246
1239 int position() const { return position_; } 1247 int position() const { return position_; }
1240 bool sharing_ok() const { return merged_index_ != SHARING_PROHIBITED; } 1248 bool sharing_ok() const { return merged_index_ != SHARING_PROHIBITED; }
1241 bool is_merged() const { return merged_index_ >= 0; } 1249 bool is_merged() const { return merged_index_ >= 0; }
1242 int merged_index(void) const { 1250 int merged_index(void) const {
1243 DCHECK(is_merged()); 1251 DCHECK(is_merged());
1244 return merged_index_; 1252 return merged_index_;
1245 } 1253 }
1246 void set_merged_index(int index) { 1254 void set_merged_index(int index) {
1247 merged_index_ = index; 1255 merged_index_ = index;
1248 DCHECK(is_merged()); 1256 DCHECK(is_merged());
1249 } 1257 }
1250 int offset(void) const { 1258 int offset(void) const {
1251 DCHECK(merged_index_ >= 0); 1259 DCHECK(merged_index_ >= 0);
1252 return merged_index_; 1260 return merged_index_;
1253 } 1261 }
1254 void set_offset(int offset) { 1262 void set_offset(int offset) {
1255 DCHECK(offset >= 0); 1263 DCHECK(offset >= 0);
1256 merged_index_ = offset; 1264 merged_index_ = offset;
1257 } 1265 }
1258 intptr_t value() const { return value_; } 1266 intptr_t value() const { return value_; }
1259 uint64_t value64() const { return bit_cast<uint64_t>(value64_); } 1267 uint64_t value64() const { return bit_cast<uint64_t>(value64_); }
1268 bool MayBeMergedWith(ConstantPoolEntry& other) const {
1269 return type_ == other.type_ && rmode_ == other.rmode_ &&
1270 (type_ == INTPTR ? value() == other.value()
1271 : value64() == other.value64());
1272 }
1260 1273
1261 enum Type { INTPTR, DOUBLE, NUMBER_OF_TYPES }; 1274 enum Type { INTPTR, DOUBLE, NUMBER_OF_TYPES };
1262 1275
1263 static int size(Type type) { 1276 Type type() const { return type_; }
1277
1278 static int SizeOfType(Type type) {
1264 return (type == INTPTR) ? kPointerSize : kDoubleSize; 1279 return (type == INTPTR) ? kPointerSize : kDoubleSize;
1265 } 1280 }
1266 1281
1282 int size() const { return SizeOfType(type_); }
1283
1267 enum Access { REGULAR, OVERFLOWED }; 1284 enum Access { REGULAR, OVERFLOWED };
1268 1285
1269 private: 1286 private:
1270 int position_; 1287 int position_;
1271 int merged_index_; 1288 int merged_index_;
1289 RelocInfo::Mode rmode_;
1290 Type type_;
1272 union { 1291 union {
1273 intptr_t value_; 1292 intptr_t value_;
1274 double value64_; 1293 double value64_;
1275 }; 1294 };
1276 enum { SHARING_PROHIBITED = -2, SHARING_ALLOWED = -1 }; 1295 enum { SHARING_PROHIBITED = -2, SHARING_ALLOWED = -1 };
1277 }; 1296 };
1278 1297
1279 1298
1280 // ----------------------------------------------------------------------------- 1299 // -----------------------------------------------------------------------------
1281 // Embedded constant pool support 1300 // Embedded constant pool support
1282 1301
1283 class ConstantPoolBuilder BASE_EMBEDDED { 1302 class ConstantPoolBuilder BASE_EMBEDDED {
1284 public: 1303 public:
1285 ConstantPoolBuilder(int ptr_reach_bits, int double_reach_bits); 1304 ConstantPoolBuilder(int ptr_reach_bits, int double_reach_bits);
1286 1305
1287 // Add pointer-sized constant to the embedded constant pool 1306 // Add pointer-sized constant to the embedded constant pool
1288 ConstantPoolEntry::Access AddEntry(int position, intptr_t value, 1307 ConstantPoolEntry::Access AddEntry(
1289 bool sharing_ok) { 1308 int position, intptr_t value, bool sharing_ok,
1290 ConstantPoolEntry entry(position, value, sharing_ok); 1309 RelocInfo::Mode rmode = RelocInfo::NONEINTPTR) {
1291 return AddEntry(entry, ConstantPoolEntry::INTPTR); 1310 ConstantPoolEntry entry(position, value, sharing_ok, rmode);
1311 return AddEntry(entry);
1292 } 1312 }
1293 1313
1294 // Add double constant to the embedded constant pool 1314 // Add double constant to the embedded constant pool
1295 ConstantPoolEntry::Access AddEntry(int position, double value) { 1315 ConstantPoolEntry::Access AddEntry(int position, double value) {
1296 ConstantPoolEntry entry(position, value); 1316 ConstantPoolEntry entry(position, value);
1297 return AddEntry(entry, ConstantPoolEntry::DOUBLE); 1317 return AddEntry(entry);
1298 } 1318 }
1299 1319
1300 // Previews the access type required for the next new entry to be added. 1320 // Previews the access type required for the next new entry to be added.
1301 ConstantPoolEntry::Access NextAccess(ConstantPoolEntry::Type type) const; 1321 ConstantPoolEntry::Access NextAccess(ConstantPoolEntry::Type type) const;
1302 1322
1303 bool IsEmpty() { 1323 bool IsEmpty() {
1304 return info_[ConstantPoolEntry::INTPTR].entries.empty() && 1324 return info_[ConstantPoolEntry::INTPTR].entries.empty() &&
1305 info_[ConstantPoolEntry::INTPTR].shared_entries.empty() && 1325 info_[ConstantPoolEntry::INTPTR].shared_entries.empty() &&
1306 info_[ConstantPoolEntry::DOUBLE].entries.empty() && 1326 info_[ConstantPoolEntry::DOUBLE].entries.empty() &&
1307 info_[ConstantPoolEntry::DOUBLE].shared_entries.empty(); 1327 info_[ConstantPoolEntry::DOUBLE].shared_entries.empty();
1308 } 1328 }
1309 1329
1310 // Emit the constant pool. Invoke only after all entries have been 1330 // Emit the constant pool. Invoke only after all entries have been
1311 // added and all instructions have been emitted. 1331 // added and all instructions have been emitted.
1312 // Returns position of the emitted pool (zero implies no constant pool). 1332 // Returns position of the emitted pool (zero implies no constant pool).
1313 int Emit(Assembler* assm); 1333 int Emit(Assembler* assm);
1314 1334
1315 // Returns the label associated with the start of the constant pool. 1335 // Returns the label associated with the start of the constant pool.
1316 // Linking to this label in the function prologue may provide an 1336 // Linking to this label in the function prologue may provide an
1317 // efficient means of constant pool pointer register initialization 1337 // efficient means of constant pool pointer register initialization
1318 // on some architectures. 1338 // on some architectures.
1319 inline Label* EmittedPosition() { return &emitted_label_; } 1339 inline Label* EmittedPosition() { return &emitted_label_; }
1320 1340
1321 private: 1341 private:
1322 ConstantPoolEntry::Access AddEntry(ConstantPoolEntry& entry, 1342 ConstantPoolEntry::Access AddEntry(ConstantPoolEntry& entry);
1323 ConstantPoolEntry::Type type);
1324 void EmitSharedEntries(Assembler* assm, ConstantPoolEntry::Type type); 1343 void EmitSharedEntries(Assembler* assm, ConstantPoolEntry::Type type);
1325 void EmitGroup(Assembler* assm, ConstantPoolEntry::Access access, 1344 void EmitGroup(Assembler* assm, ConstantPoolEntry::Access access,
1326 ConstantPoolEntry::Type type); 1345 ConstantPoolEntry::Type type);
1327 1346
1328 struct PerTypeEntryInfo { 1347 struct PerTypeEntryInfo {
1329 PerTypeEntryInfo() : regular_count(0), overflow_start(-1) {} 1348 PerTypeEntryInfo() : regular_count(0), overflow_start(-1) {}
1330 bool overflow() const { 1349 bool overflow() const {
1331 return (overflow_start >= 0 && 1350 return (overflow_start >= 0 &&
1332 overflow_start < static_cast<int>(entries.size())); 1351 overflow_start < static_cast<int>(entries.size()));
1333 } 1352 }
1334 int regular_reach_bits; 1353 int regular_reach_bits;
1335 int regular_count; 1354 int regular_count;
1336 int overflow_start; 1355 int overflow_start;
1337 std::vector<ConstantPoolEntry> entries; 1356 std::vector<ConstantPoolEntry> entries;
1338 std::vector<ConstantPoolEntry> shared_entries; 1357 std::vector<ConstantPoolEntry> shared_entries;
1339 }; 1358 };
1340 1359
1341 Label emitted_label_; // Records pc_offset of emitted pool 1360 Label emitted_label_; // Records pc_offset of emitted pool
1342 PerTypeEntryInfo info_[ConstantPoolEntry::NUMBER_OF_TYPES]; 1361 PerTypeEntryInfo info_[ConstantPoolEntry::NUMBER_OF_TYPES];
1343 }; 1362 };
1344 1363
1345 } // namespace internal 1364 } // namespace internal
1346 } // namespace v8 1365 } // namespace v8
1347 #endif // V8_ASSEMBLER_H_ 1366 #endif // V8_ASSEMBLER_H_
OLDNEW
« no previous file with comments | « src/arm/macro-assembler-arm.cc ('k') | src/assembler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698