Index: src/arm/assembler-arm.h |
=================================================================== |
--- src/arm/assembler-arm.h (revision 7890) |
+++ src/arm/assembler-arm.h (working copy) |
@@ -1159,6 +1159,60 @@ |
// instructions. |
void BlockConstPoolFor(int instructions); |
+ // This class is used to reduce the amount of code generated at deoptimization |
+ // check sites in the optimized code. |
+ // When the LCodeGen generates a deoptimization check (with |
+ // LCodeGen::DeoptimizeIf()), a DeoptJumpEntry is stored in a buffer until a |
+ // deoptimization jump table is emitted. |
+ // |
+ // deoptimization jump tables are emitted along with constant pools. (See |
+ // Assembler::CheckConstPool().) |
+ // When generating a deoptimization jump table, code will be generated for |
+ // each registered DeoptJumpEntry to jump to the code handling the |
+ // deoptimization. |
+ // |
+ // deopt check k: bcond offset_to_table_check_k // Almost never taken. |
+ // [... more code ...] |
+ // |
+ // [ Constant pool |
+ // [ Deoptimization jump table |
+ // deopt jump table + 0x0: ldr pc, relocated_entry_for_check_0 |
+ // deopt jump table + 0x4: ldr pc, relocated_entry_for_check_1 |
+ // [...] ldr pc, ... |
+ // deopt jump table + n * 0x4: ldr pc, relocated_entry_for_check_n |
+ // ] |
+ // [ Constant pool entries |
+ // [... standard constant pool entries ...] |
+ // [... additional constant pool entries for the deopt jump table ...] |
+ // ] |
+ // ] |
+ |
+ class DeoptJumpEntry BASE_EMBEDDED { |
+ public: |
+ DeoptJumpEntry() {} |
+ DeoptJumpEntry(int pc_offset, Condition cond, Address entry) |
+ : pc_offset_(pc_offset), cond_(cond), entry_(entry) { |
+ } |
+ |
+ int pc_offset() { return pc_offset_; } |
+ Condition cond() { return cond_; } |
+ Address entry() { return entry_; } |
+ |
+ // The size of the code generated for each DeoptJumpEntry in the |
+ // deoptimization jump table. |
+ static const int kJumpCodeSize = kInstrSize; |
+ static const int kAdditionalRelocInfoSize = kPointerSize; |
+ static const int kTotalSize = kJumpCodeSize + kAdditionalRelocInfoSize; |
+ |
+ private: |
+ int pc_offset_; // Offset from the start of the buffer. |
+ Condition cond_; |
+ Address entry_; // The address to jump to to deoptimize. |
+ }; |
+ |
+ // Record deoptimization entry for current pc_. |
+ void RecordDeoptJumpEntry(Address entry, Condition cond); |
+ |
// Debugging |
// Mark address of the ExitJSFrame code. |
@@ -1217,8 +1271,10 @@ |
static Register GetCmpImmediateRegister(Instr instr); |
static int GetCmpImmediateRawImmediate(Instr instr); |
static bool IsNop(Instr instr, int type = NON_MARKING_NOP); |
+ static bool IsBkpt(Instr instr, int code); |
- // Check if is time to emit a constant pool for pending reloc info entries |
+ // Check if it is time to emit a constant pool for pending reloc info entries. |
+ // This will also emit the deoptimization jump table if necessary. |
void CheckConstPool(bool force_emit, bool require_jump); |
protected: |
@@ -1322,10 +1378,18 @@ |
// stored in a separate buffer until a constant pool is emitted. |
// If every instruction in a long sequence is accessing the pool, we need one |
// pending relocation entry per instruction. |
- static const int kMaxNumPRInfo = kMaxDistBetweenPools/kInstrSize; |
+ static const int kMaxNumPRInfo = kMaxDistBetweenPools / kInstrSize; |
RelocInfo prinfo_[kMaxNumPRInfo]; // the buffer of pending relocation info |
int num_prinfo_; // number of pending reloc info entries in the buffer |
+ // See comments about class DeoptJumpEntry. |
+ static const int kMaxNumDeoptJumpEntries = |
+ kMaxDistBetweenPools / DeoptJumpEntry::kTotalSize; |
+ // The buffer of pending deoptimization jump entries. |
+ DeoptJumpEntry deopt_jump_entries_[kMaxNumDeoptJumpEntries]; |
+ // Number of pending deoptimization jump entries. |
+ int num_deopt_jump_entries_; |
+ |
// The bound position, before this we cannot do instruction elimination. |
int last_bound_pos_; |