| Index: src/arm/assembler-arm.h
|
| ===================================================================
|
| --- src/arm/assembler-arm.h (revision 8618)
|
| +++ src/arm/assembler-arm.h (working copy)
|
| @@ -167,13 +167,14 @@
|
|
|
| // Double word VFP register.
|
| struct DwVfpRegister {
|
| - // d0 has been excluded from allocation. This is following ia32
|
| - // where xmm0 is excluded. This should be revisited.
|
| - // Currently d0 is used as a scratch register.
|
| - // d1 has also been excluded from allocation to be used as a scratch
|
| - // register as well.
|
| static const int kNumRegisters = 16;
|
| - static const int kNumAllocatableRegisters = 15;
|
| + // A few double registers are reserved: one as a scratch register and one to
|
| + // hold 0.0, that does not fit in the immediate field of vmov instructions.
|
| + // d14: 0.0
|
| + // d15: scratch register.
|
| + static const int kNumReservedRegisters = 2;
|
| + static const int kNumAllocatableRegisters = kNumRegisters -
|
| + kNumReservedRegisters;
|
|
|
| static int ToAllocationIndex(DwVfpRegister reg) {
|
| ASSERT(reg.code() != 0);
|
| @@ -188,6 +189,7 @@
|
| static const char* AllocationIndexToString(int index) {
|
| ASSERT(index >= 0 && index < kNumAllocatableRegisters);
|
| const char* const names[] = {
|
| + "d0",
|
| "d1",
|
| "d2",
|
| "d3",
|
| @@ -200,9 +202,7 @@
|
| "d10",
|
| "d11",
|
| "d12",
|
| - "d13",
|
| - "d14",
|
| - "d15"
|
| + "d13"
|
| };
|
| return names[index];
|
| }
|
| @@ -303,7 +303,12 @@
|
| const DwVfpRegister d14 = { 14 };
|
| const DwVfpRegister d15 = { 15 };
|
|
|
| +// Aliases for double registers.
|
| +const DwVfpRegister kFirstCalleeSavedDoubleReg = d8;
|
| +const DwVfpRegister kLastCalleeSavedDoubleReg = d15;
|
| +const DwVfpRegister kDoubleRegZero = d14;
|
|
|
| +
|
| // Coprocessor register
|
| struct CRegister {
|
| bool is_valid() const { return 0 <= code_ && code_ < 16; }
|
| @@ -373,7 +378,6 @@
|
| INLINE(explicit Operand(int32_t immediate,
|
| RelocInfo::Mode rmode = RelocInfo::NONE));
|
| INLINE(explicit Operand(const ExternalReference& f));
|
| - INLINE(explicit Operand(const char* s));
|
| explicit Operand(Handle<Object> handle);
|
| INLINE(explicit Operand(Smi* value));
|
|
|
| @@ -451,6 +455,7 @@
|
|
|
| Register rn() const { return rn_; }
|
| Register rm() const { return rm_; }
|
| + AddrMode am() const { return am_; }
|
|
|
| bool OffsetIsUint12Encodable() const {
|
| return offset_ >= 0 ? is_uint12(offset_) : is_uint12(-offset_);
|
| @@ -500,6 +505,7 @@
|
| // Enable a specified feature within a scope.
|
| class Scope BASE_EMBEDDED {
|
| #ifdef DEBUG
|
| +
|
| public:
|
| explicit Scope(CpuFeature f) {
|
| unsigned mask = 1u << f;
|
| @@ -519,10 +525,12 @@
|
| isolate_->set_enabled_cpu_features(old_enabled_);
|
| }
|
| }
|
| +
|
| private:
|
| Isolate* isolate_;
|
| unsigned old_enabled_;
|
| #else
|
| +
|
| public:
|
| explicit Scope(CpuFeature f) {}
|
| #endif
|
| @@ -1132,10 +1140,15 @@
|
| void jmp(Label* L) { b(L, al); }
|
|
|
| // Check the code size generated from label to here.
|
| - int InstructionsGeneratedSince(Label* l) {
|
| - return (pc_offset() - l->pos()) / kInstrSize;
|
| + int SizeOfCodeGeneratedSince(Label* label) {
|
| + return pc_offset() - label->pos();
|
| }
|
|
|
| + // Check the number of instructions generated from label to here.
|
| + int InstructionsGeneratedSince(Label* label) {
|
| + return SizeOfCodeGeneratedSince(label) / kInstrSize;
|
| + }
|
| +
|
| // Check whether an immediate fits an addressing mode 1 instruction.
|
| bool ImmediateFitsAddrMode1Instruction(int32_t imm32);
|
|
|
| @@ -1155,10 +1168,6 @@
|
| DISALLOW_IMPLICIT_CONSTRUCTORS(BlockConstPoolScope);
|
| };
|
|
|
| - // Postpone the generation of the constant pool for the specified number of
|
| - // instructions.
|
| - void BlockConstPoolFor(int instructions);
|
| -
|
| // Debugging
|
|
|
| // Mark address of the ExitJSFrame code.
|
| @@ -1218,17 +1227,17 @@
|
| static int GetCmpImmediateRawImmediate(Instr instr);
|
| static bool IsNop(Instr instr, int type = NON_MARKING_NOP);
|
|
|
| - // Buffer size and constant pool distance are checked together at regular
|
| - // intervals of kBufferCheckInterval emitted bytes
|
| - static const int kBufferCheckInterval = 1*KB/2;
|
| // Constants in pools are accessed via pc relative addressing, which can
|
| // reach +/-4KB thereby defining a maximum distance between the instruction
|
| - // and the accessed constant. We satisfy this constraint by limiting the
|
| - // distance between pools.
|
| - static const int kMaxDistBetweenPools = 4*KB - 2*kBufferCheckInterval;
|
| - static const int kMaxNumPRInfo = kMaxDistBetweenPools/kInstrSize;
|
| + // and the accessed constant.
|
| + static const int kMaxDistToPool = 4*KB;
|
| + static const int kMaxNumPendingRelocInfo = kMaxDistToPool/kInstrSize;
|
|
|
| - // Check if is time to emit a constant pool for pending reloc info entries
|
| + // Postpone the generation of the constant pool for the specified number of
|
| + // instructions.
|
| + void BlockConstPoolFor(int instructions);
|
| +
|
| + // Check if is time to emit a constant pool.
|
| void CheckConstPool(bool force_emit, bool require_jump);
|
|
|
| protected:
|
| @@ -1253,19 +1262,38 @@
|
| // Patch branch instruction at pos to branch to given branch target pos
|
| void target_at_put(int pos, int target_pos);
|
|
|
| - // Block the emission of the constant pool before pc_offset
|
| - void BlockConstPoolBefore(int pc_offset) {
|
| - if (no_const_pool_before_ < pc_offset) no_const_pool_before_ = pc_offset;
|
| + // Prevent contant pool emission until EndBlockConstPool is called.
|
| + // Call to this function can be nested but must be followed by an equal
|
| + // number of call to EndBlockConstpool.
|
| + void StartBlockConstPool() {
|
| + if (const_pool_blocked_nesting_++ == 0) {
|
| + // Prevent constant pool checks happening by setting the next check to
|
| + // the biggest possible offset.
|
| + next_buffer_check_ = kMaxInt;
|
| + }
|
| }
|
|
|
| - void StartBlockConstPool() {
|
| - const_pool_blocked_nesting_++;
|
| - }
|
| + // Resume constant pool emission. Need to be called as many time as
|
| + // StartBlockConstPool to have an effect.
|
| void EndBlockConstPool() {
|
| - const_pool_blocked_nesting_--;
|
| + if (--const_pool_blocked_nesting_ == 0) {
|
| + // Check the constant pool hasn't been blocked for too long.
|
| + ASSERT((num_pending_reloc_info_ == 0) ||
|
| + (pc_offset() < (first_const_pool_use_ + kMaxDistToPool)));
|
| + // Two cases:
|
| + // * no_const_pool_before_ >= next_buffer_check_ and the emission is
|
| + // still blocked
|
| + // * no_const_pool_before_ < next_buffer_check_ and the next emit will
|
| + // trigger a check.
|
| + next_buffer_check_ = no_const_pool_before_;
|
| + }
|
| }
|
| - bool is_const_pool_blocked() const { return const_pool_blocked_nesting_ > 0; }
|
|
|
| + bool is_const_pool_blocked() const {
|
| + return (const_pool_blocked_nesting_ > 0) ||
|
| + (pc_offset() < no_const_pool_before_);
|
| + }
|
| +
|
| private:
|
| // Code buffer:
|
| // The buffer into which code and relocation info are generated.
|
| @@ -1298,34 +1326,42 @@
|
| // expensive. By default we only check again once a number of instructions
|
| // has been generated. That also means that the sizing of the buffers is not
|
| // an exact science, and that we rely on some slop to not overrun buffers.
|
| - static const int kCheckConstIntervalInst = 32;
|
| - static const int kCheckConstInterval = kCheckConstIntervalInst * kInstrSize;
|
| + static const int kCheckPoolIntervalInst = 32;
|
| + static const int kCheckPoolInterval = kCheckPoolIntervalInst * kInstrSize;
|
|
|
|
|
| - // Pools are emitted after function return and in dead code at (more or less)
|
| - // regular intervals of kDistBetweenPools bytes
|
| - static const int kDistBetweenPools = 1*KB;
|
| + // Average distance beetween a constant pool and the first instruction
|
| + // accessing the constant pool. Longer distance should result in less I-cache
|
| + // pollution.
|
| + // In practice the distance will be smaller since constant pool emission is
|
| + // forced after function return and sometimes after unconditional branches.
|
| + static const int kAvgDistToPool = kMaxDistToPool - kCheckPoolInterval;
|
|
|
| // Emission of the constant pool may be blocked in some code sequences.
|
| int const_pool_blocked_nesting_; // Block emission if this is not zero.
|
| int no_const_pool_before_; // Block emission before this pc offset.
|
|
|
| - // Keep track of the last emitted pool to guarantee a maximal distance
|
| - int last_const_pool_end_; // pc offset following the last constant pool
|
| + // Keep track of the first instruction requiring a constant pool entry
|
| + // since the previous constant pool was emitted.
|
| + int first_const_pool_use_;
|
|
|
| // Relocation info generation
|
| // Each relocation is encoded as a variable size value
|
| static const int kMaxRelocSize = RelocInfoWriter::kMaxSize;
|
| RelocInfoWriter reloc_info_writer;
|
| +
|
| // Relocation info records are also used during code generation as temporary
|
| // containers for constants and code target addresses until they are emitted
|
| // to the constant pool. These pending relocation info records are temporarily
|
| // 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.
|
| - RelocInfo prinfo_[kMaxNumPRInfo]; // the buffer of pending relocation info
|
| - int num_prinfo_; // number of pending reloc info entries in the buffer
|
|
|
| + // the buffer of pending relocation info
|
| + RelocInfo pending_reloc_info_[kMaxNumPendingRelocInfo];
|
| + // number of pending reloc info entries in the buffer
|
| + int num_pending_reloc_info_;
|
| +
|
| // The bound position, before this we cannot do instruction elimination.
|
| int last_bound_pos_;
|
|
|
|
|