| OLD | NEW |
| (Empty) | |
| 1 #include "v8.h" |
| 2 #include "bootstrapper.h" |
| 3 #include "codegen-inl.h" |
| 4 #include "debug.h" |
| 5 #include "parser.h" |
| 6 #include "register-allocator-inl.h" |
| 7 #include "runtime.h" |
| 8 #include "scopes.h" |
| 9 #include "compiler.h" |
| 10 |
| 11 //#include "api.h" |
| 12 #include "mips/simulator-mips.h" |
| 13 //#include "v8threads.h" |
| 14 |
| 15 #include "test-interface-mips.h" |
| 16 |
| 17 |
| 18 namespace v8 { |
| 19 namespace internal { |
| 20 |
| 21 #define __ ACCESS_MASM(masm) |
| 22 |
| 23 void TestMIPSStub::GenerateBody(MacroAssembler* masm) { |
| 24 // The stub is called as a function, and expected to preserve callee-saved |
| 25 // registers. If you don't v8 will raise an error when leaving the simulator. |
| 26 // To do so you can use the following multi_push/pop pseudo-instructions. |
| 27 // __ multi_push(kCalleeSaved | ra.bit()); |
| 28 // __ multi_pop(kCalleeSaved | ra.bit()); |
| 29 |
| 30 // ----- Save callee-saved registers on the stack |
| 31 __ multi_push(kCalleeSaved | ra.bit()); |
| 32 |
| 33 for(int i=0; i< 5; i++) { __ nop(); } // visual helper when disasembling |
| 34 |
| 35 // ----- Test all instructions. |
| 36 |
| 37 // Test lui, ori, and addiu, used in the li pseudo-instruction. |
| 38 // This way we can then safely load registers with chosen values. |
| 39 |
| 40 __ ori(t0, zero_reg, Operand(0)); |
| 41 __ lui(t0, 0x1234); |
| 42 __ ori(t0, t0, Operand(0)); |
| 43 __ ori(t0, t0, Operand(0x0f0f)); |
| 44 __ ori(t0, t0, Operand(0xf0f0)); |
| 45 __ addiu(t1, t0, Operand(1)); |
| 46 __ addiu(t2, t1, Operand(-0x10)); |
| 47 |
| 48 // Load values in temporary registers |
| 49 __ li(t0, Operand(0x1234)); |
| 50 __ li(t1, Operand(0xffff1234)); |
| 51 __ li(t2, Operand(0x4)); |
| 52 __ li(t3, Operand(0x8)); |
| 53 __ li(t4, Operand(0xfffff)); |
| 54 __ li(t5, Operand(0xffffff)); |
| 55 __ li(t6, Operand(0x7fffffff)); |
| 56 __ li(t7, Operand(0xffffffff)); |
| 57 |
| 58 |
| 59 ///// SPECIAL class |
| 60 __ sll(v0, t0, 4); |
| 61 __ sll(v0, t0, 28); |
| 62 __ srl(v0, t0, 4); |
| 63 __ srl(v0, t1, 4); |
| 64 __ sra(v0, t0, 4); |
| 65 __ sra(v0, t1, 4); |
| 66 __ sllv(v0, t1, t2); |
| 67 __ srlv(v0, t0, t2); |
| 68 __ srlv(v0, t1, t2); |
| 69 __ srav(v0, t0, t2); |
| 70 __ srav(v0, t1, t2); |
| 71 |
| 72 __ mfhi(v1); |
| 73 __ mflo(v0); |
| 74 |
| 75 __ add(v0, t0, t2); |
| 76 // __ add(v0, t0, t6); // overflow |
| 77 // __ add(v0, t7, t1); // overflow |
| 78 __ addu(v0, t0, t2); |
| 79 __ addu(v0, t1, t4); |
| 80 __ sub(v1, t0, Operand(t2)); |
| 81 // __ sub(v1, t7, Operand(t0)); // underflow |
| 82 // __ sub(v1, t6, Operand(t7)); // underflow |
| 83 |
| 84 |
| 85 |
| 86 // Return |
| 87 |
| 88 for(int i=0; i< 5; i++) { __ nop(); } // visual helper when disasembling |
| 89 |
| 90 // ----- Restore callee-saved registers on the stack |
| 91 __ multi_pop(kCalleeSaved | ra.bit()); |
| 92 |
| 93 __ Jump(ra); |
| 94 __ nop(); // NOP_ADDED |
| 95 |
| 96 } |
| 97 |
| 98 } } // namespace v8::internal |
| 99 |
| 100 using namespace v8::internal; |
| 101 |
| 102 |
| 103 void TestMIPS1() { |
| 104 |
| 105 typedef unsigned char byte; |
| 106 |
| 107 // Entering JavaScript. |
| 108 VMState state(JS); |
| 109 |
| 110 // Placeholder for return value. |
| 111 Object* value = reinterpret_cast<Object*>(kZapValue); |
| 112 |
| 113 typedef Object* (*JSEntryFunction)( |
| 114 byte* entry, |
| 115 Object* function, |
| 116 Object* receiver, |
| 117 int argc, |
| 118 Object*** args); |
| 119 |
| 120 Handle<Code> code; |
| 121 TestMIPSStub stub; |
| 122 code = stub.GetCode(); |
| 123 |
| 124 { |
| 125 // Save and restore context around invocation and block the |
| 126 // allocation of handles without explicit handle scopes. |
| 127 SaveContext save; |
| 128 NoHandleAllocation na; |
| 129 JSEntryFunction entry = FUNCTION_CAST<JSEntryFunction>(code->entry()); |
| 130 |
| 131 // Call TestMIPSStub generated code. |
| 132 byte* entry_address= NULL; |
| 133 JSFunction* function = NULL; |
| 134 Object* receiver_pointer = NULL; |
| 135 int argc = 0; |
| 136 Object*** args = NULL; |
| 137 value = CALL_GENERATED_CODE(entry, entry_address, function, |
| 138 receiver_pointer, argc, args); |
| 139 } |
| 140 |
| 141 // Check the value returned (in v0). |
| 142 printf("TestMIPSStub returned %#x.\n", (uint32_t)value); |
| 143 |
| 144 } |
| 145 |
| 146 |
| OLD | NEW |