OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 int i; | 178 int i; |
179 char c; | 179 char c; |
180 int16_t s; | 180 int16_t s; |
181 } T; | 181 } T; |
182 T t; | 182 T t; |
183 | 183 |
184 Assembler assm(NULL, 0); | 184 Assembler assm(NULL, 0); |
185 Label L, C; | 185 Label L, C; |
186 | 186 |
187 __ mov(ip, Operand(sp)); | 187 __ mov(ip, Operand(sp)); |
188 __ stm(db_w, sp, r4.bit() | fp.bit() | sp.bit() | lr.bit()); | 188 __ stm(db_w, sp, r4.bit() | fp.bit() | lr.bit()); |
189 __ sub(fp, ip, Operand(4)); | 189 __ sub(fp, ip, Operand(4)); |
190 __ mov(r4, Operand(r0)); | 190 __ mov(r4, Operand(r0)); |
191 __ ldr(r0, MemOperand(r4, OFFSET_OF(T, i))); | 191 __ ldr(r0, MemOperand(r4, OFFSET_OF(T, i))); |
192 __ mov(r2, Operand(r0, ASR, 1)); | 192 __ mov(r2, Operand(r0, ASR, 1)); |
193 __ str(r2, MemOperand(r4, OFFSET_OF(T, i))); | 193 __ str(r2, MemOperand(r4, OFFSET_OF(T, i))); |
194 __ ldrsb(r2, MemOperand(r4, OFFSET_OF(T, c))); | 194 __ ldrsb(r2, MemOperand(r4, OFFSET_OF(T, c))); |
195 __ add(r0, r2, Operand(r0)); | 195 __ add(r0, r2, Operand(r0)); |
196 __ mov(r2, Operand(r2, LSL, 2)); | 196 __ mov(r2, Operand(r2, LSL, 2)); |
197 __ strb(r2, MemOperand(r4, OFFSET_OF(T, c))); | 197 __ strb(r2, MemOperand(r4, OFFSET_OF(T, c))); |
198 __ ldrsh(r2, MemOperand(r4, OFFSET_OF(T, s))); | 198 __ ldrsh(r2, MemOperand(r4, OFFSET_OF(T, s))); |
199 __ add(r0, r2, Operand(r0)); | 199 __ add(r0, r2, Operand(r0)); |
200 __ mov(r2, Operand(r2, ASR, 3)); | 200 __ mov(r2, Operand(r2, ASR, 3)); |
201 __ strh(r2, MemOperand(r4, OFFSET_OF(T, s))); | 201 __ strh(r2, MemOperand(r4, OFFSET_OF(T, s))); |
202 __ ldm(ia, sp, r4.bit() | fp.bit() | sp.bit() | pc.bit()); | 202 __ ldm(ia_w, sp, r4.bit() | fp.bit() | pc.bit()); |
203 | 203 |
204 CodeDesc desc; | 204 CodeDesc desc; |
205 assm.GetCode(&desc); | 205 assm.GetCode(&desc); |
206 Object* code = Heap::CreateCode(desc, | 206 Object* code = Heap::CreateCode(desc, |
207 NULL, | 207 NULL, |
208 Code::ComputeFlags(Code::STUB), | 208 Code::ComputeFlags(Code::STUB), |
209 Handle<Object>(Heap::undefined_value())); | 209 Handle<Object>(Heap::undefined_value())); |
210 CHECK(code->IsCode()); | 210 CHECK(code->IsCode()); |
211 #ifdef DEBUG | 211 #ifdef DEBUG |
212 Code::cast(code)->Print(); | 212 Code::cast(code)->Print(); |
213 #endif | 213 #endif |
214 F3 f = FUNCTION_CAST<F3>(Code::cast(code)->entry()); | 214 F3 f = FUNCTION_CAST<F3>(Code::cast(code)->entry()); |
215 t.i = 100000; | 215 t.i = 100000; |
216 t.c = 10; | 216 t.c = 10; |
217 t.s = 1000; | 217 t.s = 1000; |
218 int res = reinterpret_cast<int>(CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0)); | 218 int res = reinterpret_cast<int>(CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0)); |
219 ::printf("f() = %d\n", res); | 219 ::printf("f() = %d\n", res); |
220 CHECK_EQ(101010, res); | 220 CHECK_EQ(101010, res); |
221 CHECK_EQ(100000/2, t.i); | 221 CHECK_EQ(100000/2, t.i); |
222 CHECK_EQ(10*4, t.c); | 222 CHECK_EQ(10*4, t.c); |
223 CHECK_EQ(1000/8, t.s); | 223 CHECK_EQ(1000/8, t.s); |
224 } | 224 } |
225 | 225 |
226 | 226 |
227 #undef __ | 227 #undef __ |
OLD | NEW |