Index: src/ppc/code-stubs-ppc.h |
diff --git a/src/arm/code-stubs-arm.h b/src/ppc/code-stubs-ppc.h |
similarity index 53% |
copy from src/arm/code-stubs-arm.h |
copy to src/ppc/code-stubs-ppc.h |
index ff2a80e676f41b237cc06e71479658da74b53324..a801cdfcbea7ce656f0d982889386643df52cbf8 100644 |
--- a/src/arm/code-stubs-arm.h |
+++ b/src/ppc/code-stubs-ppc.h |
@@ -1,9 +1,12 @@ |
// Copyright 2012 the V8 project authors. All rights reserved. |
+// |
+// Copyright IBM Corp. 2012, 2013. All rights reserved. |
+// |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#ifndef V8_ARM_CODE_STUBS_ARM_H_ |
-#define V8_ARM_CODE_STUBS_ARM_H_ |
+#ifndef V8_PPC_CODE_STUBS_PPC_H_ |
+#define V8_PPC_CODE_STUBS_PPC_H_ |
#include "src/ic-inl.h" |
@@ -14,7 +17,7 @@ namespace internal { |
void ArrayNativeCode(MacroAssembler* masm, Label* call_generic_code); |
-class StoreBufferOverflowStub: public PlatformCodeStub { |
+class StoreBufferOverflowStub : public PlatformCodeStub { |
public: |
StoreBufferOverflowStub(Isolate* isolate, SaveFPRegsMode save_fp) |
: PlatformCodeStub(isolate), save_doubles_(save_fp) {} |
@@ -38,32 +41,28 @@ class StringHelper : public AllStatic { |
// is allowed to spend extra time setting up conditions to make copying |
// faster. Copying of overlapping regions is not supported. |
// Dest register ends at the position after the last character written. |
- static void GenerateCopyCharacters(MacroAssembler* masm, |
- Register dest, |
- Register src, |
- Register count, |
+ static void GenerateCopyCharacters(MacroAssembler* masm, Register dest, |
+ Register src, Register count, |
Register scratch, |
String::Encoding encoding); |
// Generate string hash. |
- static void GenerateHashInit(MacroAssembler* masm, |
- Register hash, |
- Register character); |
+ static void GenerateHashInit(MacroAssembler* masm, Register hash, |
+ Register character, Register scratch); |
- static void GenerateHashAddCharacter(MacroAssembler* masm, |
- Register hash, |
- Register character); |
+ static void GenerateHashAddCharacter(MacroAssembler* masm, Register hash, |
+ Register character, Register scratch); |
- static void GenerateHashGetHash(MacroAssembler* masm, |
- Register hash); |
+ static void GenerateHashGetHash(MacroAssembler* masm, Register hash, |
+ Register scratch); |
private: |
DISALLOW_IMPLICIT_CONSTRUCTORS(StringHelper); |
}; |
-class SubStringStub: public PlatformCodeStub { |
+class SubStringStub : public PlatformCodeStub { |
public: |
explicit SubStringStub(Isolate* isolate) : PlatformCodeStub(isolate) {} |
@@ -75,89 +74,39 @@ class SubStringStub: public PlatformCodeStub { |
}; |
- |
-class StringCompareStub: public PlatformCodeStub { |
+class StringCompareStub : public PlatformCodeStub { |
public: |
- explicit StringCompareStub(Isolate* isolate) : PlatformCodeStub(isolate) { } |
+ explicit StringCompareStub(Isolate* isolate) : PlatformCodeStub(isolate) {} |
// Compares two flat ASCII strings and returns result in r0. |
static void GenerateCompareFlatAsciiStrings(MacroAssembler* masm, |
- Register left, |
- Register right, |
+ Register left, Register right, |
Register scratch1, |
Register scratch2, |
- Register scratch3, |
- Register scratch4); |
+ Register scratch3); |
// Compares two flat ASCII strings for equality and returns result |
// in r0. |
- static void GenerateFlatAsciiStringEquals(MacroAssembler* masm, |
- Register left, |
- Register right, |
- Register scratch1, |
- Register scratch2, |
- Register scratch3); |
+ static void GenerateFlatAsciiStringEquals(MacroAssembler* masm, Register left, |
+ Register right, Register scratch1, |
+ Register scratch2); |
private: |
virtual Major MajorKey() const { return StringCompare; } |
virtual int MinorKey() const { return 0; } |
virtual void Generate(MacroAssembler* masm); |
- static void GenerateAsciiCharsCompareLoop(MacroAssembler* masm, |
- Register left, |
- Register right, |
- Register length, |
+ static void GenerateAsciiCharsCompareLoop(MacroAssembler* masm, Register left, |
+ Register right, Register length, |
Register scratch1, |
- Register scratch2, |
Label* chars_not_equal); |
}; |
-// This stub can convert a signed int32 to a heap number (double). It does |
-// not work for int32s that are in Smi range! No GC occurs during this stub |
-// so you don't have to set up the frame. |
-class WriteInt32ToHeapNumberStub : public PlatformCodeStub { |
- public: |
- WriteInt32ToHeapNumberStub(Isolate* isolate, |
- Register the_int, |
- Register the_heap_number, |
- Register scratch) |
- : PlatformCodeStub(isolate), |
- the_int_(the_int), |
- the_heap_number_(the_heap_number), |
- scratch_(scratch) { } |
- |
- static void GenerateFixedRegStubsAheadOfTime(Isolate* isolate); |
- |
- private: |
- Register the_int_; |
- Register the_heap_number_; |
- Register scratch_; |
- |
- // Minor key encoding in 16 bits. |
- class IntRegisterBits: public BitField<int, 0, 4> {}; |
- class HeapNumberRegisterBits: public BitField<int, 4, 4> {}; |
- class ScratchRegisterBits: public BitField<int, 8, 4> {}; |
- |
- Major MajorKey() const { return WriteInt32ToHeapNumber; } |
- int MinorKey() const { |
- // Encode the parameters in a unique 16 bit value. |
- return IntRegisterBits::encode(the_int_.code()) |
- | HeapNumberRegisterBits::encode(the_heap_number_.code()) |
- | ScratchRegisterBits::encode(scratch_.code()); |
- } |
- |
- void Generate(MacroAssembler* masm); |
-}; |
- |
- |
-class RecordWriteStub: public PlatformCodeStub { |
+class RecordWriteStub : public PlatformCodeStub { |
public: |
- RecordWriteStub(Isolate* isolate, |
- Register object, |
- Register value, |
- Register address, |
- RememberedSetAction remembered_set_action, |
+ RecordWriteStub(Isolate* isolate, Register object, Register value, |
+ Register address, RememberedSetAction remembered_set_action, |
SaveFPRegsMode fp_mode) |
: PlatformCodeStub(isolate), |
object_(object), |
@@ -170,66 +119,63 @@ class RecordWriteStub: public PlatformCodeStub { |
value) { // One scratch reg. |
} |
- enum Mode { |
- STORE_BUFFER_ONLY, |
- INCREMENTAL, |
- INCREMENTAL_COMPACTION |
- }; |
+ enum Mode { STORE_BUFFER_ONLY, INCREMENTAL, INCREMENTAL_COMPACTION }; |
virtual bool SometimesSetsUpAFrame() { return false; } |
static void PatchBranchIntoNop(MacroAssembler* masm, int pos) { |
- masm->instr_at_put(pos, (masm->instr_at(pos) & ~B27) | (B24 | B20)); |
- DCHECK(Assembler::IsTstImmediate(masm->instr_at(pos))); |
+ masm->instr_at_put(pos, (masm->instr_at(pos) & ~kBOfieldMask) | BT); |
+ // roohack DCHECK(Assembler::IsTstImmediate(masm->instr_at(pos))); |
} |
static void PatchNopIntoBranch(MacroAssembler* masm, int pos) { |
- masm->instr_at_put(pos, (masm->instr_at(pos) & ~(B24 | B20)) | B27); |
- DCHECK(Assembler::IsBranch(masm->instr_at(pos))); |
+ masm->instr_at_put(pos, (masm->instr_at(pos) & ~kBOfieldMask) | BF); |
+ // roohack DCHECK(Assembler::IsBranch(masm->instr_at(pos))); |
} |
static Mode GetMode(Code* stub) { |
- Instr first_instruction = Assembler::instr_at(stub->instruction_start()); |
+ Instr first_instruction = |
+ Assembler::instr_at(stub->instruction_start() + Assembler::kInstrSize); |
Instr second_instruction = Assembler::instr_at(stub->instruction_start() + |
- Assembler::kInstrSize); |
+ (Assembler::kInstrSize * 2)); |
- if (Assembler::IsBranch(first_instruction)) { |
+ if (BF == (first_instruction & kBOfieldMask)) { |
return INCREMENTAL; |
} |
- DCHECK(Assembler::IsTstImmediate(first_instruction)); |
+ // roohack DCHECK(Assembler::IsTstImmediate(first_instruction)); |
- if (Assembler::IsBranch(second_instruction)) { |
+ if (BF == (second_instruction & kBOfieldMask)) { |
return INCREMENTAL_COMPACTION; |
} |
- DCHECK(Assembler::IsTstImmediate(second_instruction)); |
+ // roohack DCHECK(Assembler::IsTstImmediate(second_instruction)); |
return STORE_BUFFER_ONLY; |
} |
static void Patch(Code* stub, Mode mode) { |
- MacroAssembler masm(NULL, |
- stub->instruction_start(), |
+ MacroAssembler masm(NULL, stub->instruction_start(), |
stub->instruction_size()); |
switch (mode) { |
case STORE_BUFFER_ONLY: |
DCHECK(GetMode(stub) == INCREMENTAL || |
GetMode(stub) == INCREMENTAL_COMPACTION); |
- PatchBranchIntoNop(&masm, 0); |
+ |
PatchBranchIntoNop(&masm, Assembler::kInstrSize); |
+ PatchBranchIntoNop(&masm, Assembler::kInstrSize * 2); |
break; |
case INCREMENTAL: |
DCHECK(GetMode(stub) == STORE_BUFFER_ONLY); |
- PatchNopIntoBranch(&masm, 0); |
+ PatchNopIntoBranch(&masm, Assembler::kInstrSize); |
break; |
case INCREMENTAL_COMPACTION: |
DCHECK(GetMode(stub) == STORE_BUFFER_ONLY); |
- PatchNopIntoBranch(&masm, Assembler::kInstrSize); |
+ PatchNopIntoBranch(&masm, Assembler::kInstrSize * 2); |
break; |
} |
DCHECK(GetMode(stub) == mode); |
- CpuFeatures::FlushICache(stub->instruction_start(), |
+ CpuFeatures::FlushICache(stub->instruction_start() + Assembler::kInstrSize, |
2 * Assembler::kInstrSize); |
} |
@@ -239,12 +185,8 @@ class RecordWriteStub: public PlatformCodeStub { |
// the caller. |
class RegisterAllocation { |
public: |
- RegisterAllocation(Register object, |
- Register address, |
- Register scratch0) |
- : object_(object), |
- address_(address), |
- scratch0_(scratch0) { |
+ RegisterAllocation(Register object, Register address, Register scratch0) |
+ : object_(object), address_(address), scratch0_(scratch0) { |
DCHECK(!AreAliased(scratch0, object, address, no_reg)); |
scratch1_ = GetRegisterThatIsNotOneOf(object_, address_, scratch0_); |
} |
@@ -256,26 +198,30 @@ class RecordWriteStub: public PlatformCodeStub { |
masm->push(scratch1_); |
} |
- void Restore(MacroAssembler* masm) { |
- masm->pop(scratch1_); |
- } |
+ void Restore(MacroAssembler* masm) { masm->pop(scratch1_); } |
// If we have to call into C then we need to save and restore all caller- |
// saved registers that were not already preserved. The scratch registers |
// will be restored by other means so we don't bother pushing them here. |
void SaveCallerSaveRegisters(MacroAssembler* masm, SaveFPRegsMode mode) { |
- masm->stm(db_w, sp, (kCallerSaved | lr.bit()) & ~scratch1_.bit()); |
+ masm->mflr(r0); |
+ masm->push(r0); |
+ masm->MultiPush(kJSCallerSaved & ~scratch1_.bit()); |
if (mode == kSaveFPRegs) { |
- masm->SaveFPRegs(sp, scratch0_); |
+ // Save all volatile FP registers except d0. |
+ masm->SaveFPRegs(sp, 1, DoubleRegister::kNumVolatileRegisters - 1); |
} |
} |
- inline void RestoreCallerSaveRegisters(MacroAssembler*masm, |
+ inline void RestoreCallerSaveRegisters(MacroAssembler* masm, |
SaveFPRegsMode mode) { |
if (mode == kSaveFPRegs) { |
- masm->RestoreFPRegs(sp, scratch0_); |
+ // Restore all volatile FP registers except d0. |
+ masm->RestoreFPRegs(sp, 1, DoubleRegister::kNumVolatileRegisters - 1); |
} |
- masm->ldm(ia_w, sp, (kCallerSaved | lr.bit()) & ~scratch1_.bit()); |
+ masm->MultiPop(kJSCallerSaved & ~scratch1_.bit()); |
+ masm->pop(r0); |
+ masm->mtlr(r0); |
} |
inline Register object() { return object_; } |
@@ -300,8 +246,7 @@ class RecordWriteStub: public PlatformCodeStub { |
void Generate(MacroAssembler* masm); |
void GenerateIncremental(MacroAssembler* masm, Mode mode); |
void CheckNeedsToInformIncrementalMarker( |
- MacroAssembler* masm, |
- OnNoNeedToInformIncrementalMarker on_no_need, |
+ MacroAssembler* masm, OnNoNeedToInformIncrementalMarker on_no_need, |
Mode mode); |
void InformIncrementalMarker(MacroAssembler* masm); |
@@ -309,21 +254,22 @@ class RecordWriteStub: public PlatformCodeStub { |
int MinorKey() const { |
return ObjectBits::encode(object_.code()) | |
- ValueBits::encode(value_.code()) | |
- AddressBits::encode(address_.code()) | |
- RememberedSetActionBits::encode(remembered_set_action_) | |
- SaveFPRegsModeBits::encode(save_fp_regs_mode_); |
+ ValueBits::encode(value_.code()) | |
+ AddressBits::encode(address_.code()) | |
+ RememberedSetActionBits::encode(remembered_set_action_) | |
+ SaveFPRegsModeBits::encode(save_fp_regs_mode_); |
} |
void Activate(Code* code) { |
code->GetHeap()->incremental_marking()->ActivateGeneratedStub(code); |
} |
- class ObjectBits: public BitField<int, 0, 4> {}; |
- class ValueBits: public BitField<int, 4, 4> {}; |
- class AddressBits: public BitField<int, 8, 4> {}; |
- class RememberedSetActionBits: public BitField<RememberedSetAction, 12, 1> {}; |
- class SaveFPRegsModeBits: public BitField<SaveFPRegsMode, 13, 1> {}; |
+ class ObjectBits : public BitField<int, 0, 5> {}; |
+ class ValueBits : public BitField<int, 5, 5> {}; |
+ class AddressBits : public BitField<int, 10, 5> {}; |
+ class RememberedSetActionBits : public BitField<RememberedSetAction, 15, 1> { |
+ }; |
+ class SaveFPRegsModeBits : public BitField<SaveFPRegsMode, 16, 1> {}; |
Register object_; |
Register value_; |
@@ -340,7 +286,7 @@ class RecordWriteStub: public PlatformCodeStub { |
// keep the code which called into native pinned in the memory. Currently the |
// simplest approach is to generate such stub early enough so it can never be |
// moved by GC |
-class DirectCEntryStub: public PlatformCodeStub { |
+class DirectCEntryStub : public PlatformCodeStub { |
public: |
explicit DirectCEntryStub(Isolate* isolate) : PlatformCodeStub(isolate) {} |
void Generate(MacroAssembler* masm); |
@@ -354,30 +300,23 @@ class DirectCEntryStub: public PlatformCodeStub { |
}; |
-class NameDictionaryLookupStub: public PlatformCodeStub { |
+class NameDictionaryLookupStub : public PlatformCodeStub { |
public: |
enum LookupMode { POSITIVE_LOOKUP, NEGATIVE_LOOKUP }; |
NameDictionaryLookupStub(Isolate* isolate, LookupMode mode) |
- : PlatformCodeStub(isolate), mode_(mode) { } |
+ : PlatformCodeStub(isolate), mode_(mode) {} |
void Generate(MacroAssembler* masm); |
- static void GenerateNegativeLookup(MacroAssembler* masm, |
- Label* miss, |
- Label* done, |
- Register receiver, |
- Register properties, |
- Handle<Name> name, |
+ static void GenerateNegativeLookup(MacroAssembler* masm, Label* miss, |
+ Label* done, Register receiver, |
+ Register properties, Handle<Name> name, |
Register scratch0); |
- static void GeneratePositiveLookup(MacroAssembler* masm, |
- Label* miss, |
- Label* done, |
- Register elements, |
- Register name, |
- Register r0, |
- Register r1); |
+ static void GeneratePositiveLookup(MacroAssembler* masm, Label* miss, |
+ Label* done, Register elements, |
+ Register name, Register r0, Register r1); |
virtual bool SometimesSetsUpAFrame() { return false; } |
@@ -397,25 +336,11 @@ class NameDictionaryLookupStub: public PlatformCodeStub { |
int MinorKey() const { return LookupModeBits::encode(mode_); } |
- class LookupModeBits: public BitField<LookupMode, 0, 1> {}; |
+ class LookupModeBits : public BitField<LookupMode, 0, 1> {}; |
LookupMode mode_; |
}; |
+} |
+} // namespace v8::internal |
- |
-class PlatformInterfaceDescriptor { |
- public: |
- explicit PlatformInterfaceDescriptor( |
- TargetAddressStorageMode storage_mode) |
- : storage_mode_(storage_mode) { } |
- |
- TargetAddressStorageMode storage_mode() { return storage_mode_; } |
- |
- private: |
- TargetAddressStorageMode storage_mode_; |
-}; |
- |
- |
-} } // namespace v8::internal |
- |
-#endif // V8_ARM_CODE_STUBS_ARM_H_ |
+#endif // V8_PPC_CODE_STUBS_PPC_H_ |