Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: test/cctest/test-assembler-arm.cc

Issue 12300018: Made Isolate a mandatory parameter for everything Handle-related. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixed CreateCode calls. Be nicer to MIPS. Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/cctest/test-assembler-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 } 52 }
53 } 53 }
54 54
55 55
56 #define __ assm. 56 #define __ assm.
57 57
58 TEST(0) { 58 TEST(0) {
59 InitializeVM(); 59 InitializeVM();
60 v8::HandleScope scope; 60 v8::HandleScope scope;
61 61
62 Assembler assm(Isolate::Current(), NULL, 0); 62 Isolate* isolate = Isolate::Current();
63 Assembler assm(isolate, NULL, 0);
63 64
64 __ add(r0, r0, Operand(r1)); 65 __ add(r0, r0, Operand(r1));
65 __ mov(pc, Operand(lr)); 66 __ mov(pc, Operand(lr));
66 67
67 CodeDesc desc; 68 CodeDesc desc;
68 assm.GetCode(&desc); 69 assm.GetCode(&desc);
69 Object* code = HEAP->CreateCode( 70 Object* code = isolate->heap()->CreateCode(
70 desc, 71 desc,
71 Code::ComputeFlags(Code::STUB), 72 Code::ComputeFlags(Code::STUB),
72 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); 73 Handle<Code>())->ToObjectChecked();
73 CHECK(code->IsCode()); 74 CHECK(code->IsCode());
74 #ifdef DEBUG 75 #ifdef DEBUG
75 Code::cast(code)->Print(); 76 Code::cast(code)->Print();
76 #endif 77 #endif
77 F2 f = FUNCTION_CAST<F2>(Code::cast(code)->entry()); 78 F2 f = FUNCTION_CAST<F2>(Code::cast(code)->entry());
78 int res = reinterpret_cast<int>(CALL_GENERATED_CODE(f, 3, 4, 0, 0, 0)); 79 int res = reinterpret_cast<int>(CALL_GENERATED_CODE(f, 3, 4, 0, 0, 0));
79 ::printf("f() = %d\n", res); 80 ::printf("f() = %d\n", res);
80 CHECK_EQ(7, res); 81 CHECK_EQ(7, res);
81 } 82 }
82 83
83 84
84 TEST(1) { 85 TEST(1) {
85 InitializeVM(); 86 InitializeVM();
86 v8::HandleScope scope; 87 v8::HandleScope scope;
87 88
88 Assembler assm(Isolate::Current(), NULL, 0); 89 Isolate* isolate = Isolate::Current();
90 Assembler assm(isolate, NULL, 0);
89 Label L, C; 91 Label L, C;
90 92
91 __ mov(r1, Operand(r0)); 93 __ mov(r1, Operand(r0));
92 __ mov(r0, Operand::Zero()); 94 __ mov(r0, Operand::Zero());
93 __ b(&C); 95 __ b(&C);
94 96
95 __ bind(&L); 97 __ bind(&L);
96 __ add(r0, r0, Operand(r1)); 98 __ add(r0, r0, Operand(r1));
97 __ sub(r1, r1, Operand(1)); 99 __ sub(r1, r1, Operand(1));
98 100
99 __ bind(&C); 101 __ bind(&C);
100 __ teq(r1, Operand::Zero()); 102 __ teq(r1, Operand::Zero());
101 __ b(ne, &L); 103 __ b(ne, &L);
102 __ mov(pc, Operand(lr)); 104 __ mov(pc, Operand(lr));
103 105
104 CodeDesc desc; 106 CodeDesc desc;
105 assm.GetCode(&desc); 107 assm.GetCode(&desc);
106 Object* code = HEAP->CreateCode( 108 Object* code = isolate->heap()->CreateCode(
107 desc, 109 desc,
108 Code::ComputeFlags(Code::STUB), 110 Code::ComputeFlags(Code::STUB),
109 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); 111 Handle<Code>())->ToObjectChecked();
110 CHECK(code->IsCode()); 112 CHECK(code->IsCode());
111 #ifdef DEBUG 113 #ifdef DEBUG
112 Code::cast(code)->Print(); 114 Code::cast(code)->Print();
113 #endif 115 #endif
114 F1 f = FUNCTION_CAST<F1>(Code::cast(code)->entry()); 116 F1 f = FUNCTION_CAST<F1>(Code::cast(code)->entry());
115 int res = reinterpret_cast<int>(CALL_GENERATED_CODE(f, 100, 0, 0, 0, 0)); 117 int res = reinterpret_cast<int>(CALL_GENERATED_CODE(f, 100, 0, 0, 0, 0));
116 ::printf("f() = %d\n", res); 118 ::printf("f() = %d\n", res);
117 CHECK_EQ(5050, res); 119 CHECK_EQ(5050, res);
118 } 120 }
119 121
120 122
121 TEST(2) { 123 TEST(2) {
122 InitializeVM(); 124 InitializeVM();
123 v8::HandleScope scope; 125 v8::HandleScope scope;
124 126
125 Assembler assm(Isolate::Current(), NULL, 0); 127 Isolate* isolate = Isolate::Current();
128 Assembler assm(isolate, NULL, 0);
126 Label L, C; 129 Label L, C;
127 130
128 __ mov(r1, Operand(r0)); 131 __ mov(r1, Operand(r0));
129 __ mov(r0, Operand(1)); 132 __ mov(r0, Operand(1));
130 __ b(&C); 133 __ b(&C);
131 134
132 __ bind(&L); 135 __ bind(&L);
133 __ mul(r0, r1, r0); 136 __ mul(r0, r1, r0);
134 __ sub(r1, r1, Operand(1)); 137 __ sub(r1, r1, Operand(1));
135 138
136 __ bind(&C); 139 __ bind(&C);
137 __ teq(r1, Operand::Zero()); 140 __ teq(r1, Operand::Zero());
138 __ b(ne, &L); 141 __ b(ne, &L);
139 __ mov(pc, Operand(lr)); 142 __ mov(pc, Operand(lr));
140 143
141 // some relocated stuff here, not executed 144 // some relocated stuff here, not executed
142 __ RecordComment("dead code, just testing relocations"); 145 __ RecordComment("dead code, just testing relocations");
143 __ mov(r0, Operand(FACTORY->true_value())); 146 __ mov(r0, Operand(FACTORY->true_value()));
144 __ RecordComment("dead code, just testing immediate operands"); 147 __ RecordComment("dead code, just testing immediate operands");
145 __ mov(r0, Operand(-1)); 148 __ mov(r0, Operand(-1));
146 __ mov(r0, Operand(0xFF000000)); 149 __ mov(r0, Operand(0xFF000000));
147 __ mov(r0, Operand(0xF0F0F0F0)); 150 __ mov(r0, Operand(0xF0F0F0F0));
148 __ mov(r0, Operand(0xFFF0FFFF)); 151 __ mov(r0, Operand(0xFFF0FFFF));
149 152
150 CodeDesc desc; 153 CodeDesc desc;
151 assm.GetCode(&desc); 154 assm.GetCode(&desc);
152 Object* code = HEAP->CreateCode( 155 Object* code = isolate->heap()->CreateCode(
153 desc, 156 desc,
154 Code::ComputeFlags(Code::STUB), 157 Code::ComputeFlags(Code::STUB),
155 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); 158 Handle<Code>())->ToObjectChecked();
156 CHECK(code->IsCode()); 159 CHECK(code->IsCode());
157 #ifdef DEBUG 160 #ifdef DEBUG
158 Code::cast(code)->Print(); 161 Code::cast(code)->Print();
159 #endif 162 #endif
160 F1 f = FUNCTION_CAST<F1>(Code::cast(code)->entry()); 163 F1 f = FUNCTION_CAST<F1>(Code::cast(code)->entry());
161 int res = reinterpret_cast<int>(CALL_GENERATED_CODE(f, 10, 0, 0, 0, 0)); 164 int res = reinterpret_cast<int>(CALL_GENERATED_CODE(f, 10, 0, 0, 0, 0));
162 ::printf("f() = %d\n", res); 165 ::printf("f() = %d\n", res);
163 CHECK_EQ(3628800, res); 166 CHECK_EQ(3628800, res);
164 } 167 }
165 168
166 169
167 TEST(3) { 170 TEST(3) {
168 InitializeVM(); 171 InitializeVM();
169 v8::HandleScope scope; 172 v8::HandleScope scope;
170 173
171 typedef struct { 174 typedef struct {
172 int i; 175 int i;
173 char c; 176 char c;
174 int16_t s; 177 int16_t s;
175 } T; 178 } T;
176 T t; 179 T t;
177 180
178 Assembler assm(Isolate::Current(), NULL, 0); 181 Isolate* isolate = Isolate::Current();
182 Assembler assm(isolate, NULL, 0);
179 Label L, C; 183 Label L, C;
180 184
181 __ mov(ip, Operand(sp)); 185 __ mov(ip, Operand(sp));
182 __ stm(db_w, sp, r4.bit() | fp.bit() | lr.bit()); 186 __ stm(db_w, sp, r4.bit() | fp.bit() | lr.bit());
183 __ sub(fp, ip, Operand(4)); 187 __ sub(fp, ip, Operand(4));
184 __ mov(r4, Operand(r0)); 188 __ mov(r4, Operand(r0));
185 __ ldr(r0, MemOperand(r4, OFFSET_OF(T, i))); 189 __ ldr(r0, MemOperand(r4, OFFSET_OF(T, i)));
186 __ mov(r2, Operand(r0, ASR, 1)); 190 __ mov(r2, Operand(r0, ASR, 1));
187 __ str(r2, MemOperand(r4, OFFSET_OF(T, i))); 191 __ str(r2, MemOperand(r4, OFFSET_OF(T, i)));
188 __ ldrsb(r2, MemOperand(r4, OFFSET_OF(T, c))); 192 __ ldrsb(r2, MemOperand(r4, OFFSET_OF(T, c)));
189 __ add(r0, r2, Operand(r0)); 193 __ add(r0, r2, Operand(r0));
190 __ mov(r2, Operand(r2, LSL, 2)); 194 __ mov(r2, Operand(r2, LSL, 2));
191 __ strb(r2, MemOperand(r4, OFFSET_OF(T, c))); 195 __ strb(r2, MemOperand(r4, OFFSET_OF(T, c)));
192 __ ldrsh(r2, MemOperand(r4, OFFSET_OF(T, s))); 196 __ ldrsh(r2, MemOperand(r4, OFFSET_OF(T, s)));
193 __ add(r0, r2, Operand(r0)); 197 __ add(r0, r2, Operand(r0));
194 __ mov(r2, Operand(r2, ASR, 3)); 198 __ mov(r2, Operand(r2, ASR, 3));
195 __ strh(r2, MemOperand(r4, OFFSET_OF(T, s))); 199 __ strh(r2, MemOperand(r4, OFFSET_OF(T, s)));
196 __ ldm(ia_w, sp, r4.bit() | fp.bit() | pc.bit()); 200 __ ldm(ia_w, sp, r4.bit() | fp.bit() | pc.bit());
197 201
198 CodeDesc desc; 202 CodeDesc desc;
199 assm.GetCode(&desc); 203 assm.GetCode(&desc);
200 Object* code = HEAP->CreateCode( 204 Object* code = isolate->heap()->CreateCode(
201 desc, 205 desc,
202 Code::ComputeFlags(Code::STUB), 206 Code::ComputeFlags(Code::STUB),
203 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); 207 Handle<Code>())->ToObjectChecked();
204 CHECK(code->IsCode()); 208 CHECK(code->IsCode());
205 #ifdef DEBUG 209 #ifdef DEBUG
206 Code::cast(code)->Print(); 210 Code::cast(code)->Print();
207 #endif 211 #endif
208 F3 f = FUNCTION_CAST<F3>(Code::cast(code)->entry()); 212 F3 f = FUNCTION_CAST<F3>(Code::cast(code)->entry());
209 t.i = 100000; 213 t.i = 100000;
210 t.c = 10; 214 t.c = 10;
211 t.s = 1000; 215 t.s = 1000;
212 int res = reinterpret_cast<int>(CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0)); 216 int res = reinterpret_cast<int>(CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0));
213 ::printf("f() = %d\n", res); 217 ::printf("f() = %d\n", res);
(...skipping 21 matching lines...) Expand all
235 int i; 239 int i;
236 double m; 240 double m;
237 double n; 241 double n;
238 float x; 242 float x;
239 float y; 243 float y;
240 } T; 244 } T;
241 T t; 245 T t;
242 246
243 // Create a function that accepts &t, and loads, manipulates, and stores 247 // Create a function that accepts &t, and loads, manipulates, and stores
244 // the doubles and floats. 248 // the doubles and floats.
245 Assembler assm(Isolate::Current(), NULL, 0); 249 Isolate* isolate = Isolate::Current();
250 Assembler assm(isolate, NULL, 0);
246 Label L, C; 251 Label L, C;
247 252
248 253
249 if (CpuFeatures::IsSupported(VFP3)) { 254 if (CpuFeatures::IsSupported(VFP3)) {
250 CpuFeatures::Scope scope(VFP3); 255 CpuFeatures::Scope scope(VFP3);
251 256
252 __ mov(ip, Operand(sp)); 257 __ mov(ip, Operand(sp));
253 __ stm(db_w, sp, r4.bit() | fp.bit() | lr.bit()); 258 __ stm(db_w, sp, r4.bit() | fp.bit() | lr.bit());
254 __ sub(fp, ip, Operand(4)); 259 __ sub(fp, ip, Operand(4));
255 260
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 __ vneg(d0, d1); 312 __ vneg(d0, d1);
308 __ vstr(d0, r4, OFFSET_OF(T, m)); 313 __ vstr(d0, r4, OFFSET_OF(T, m));
309 __ vldr(d1, r4, OFFSET_OF(T, n)); 314 __ vldr(d1, r4, OFFSET_OF(T, n));
310 __ vneg(d0, d1); 315 __ vneg(d0, d1);
311 __ vstr(d0, r4, OFFSET_OF(T, n)); 316 __ vstr(d0, r4, OFFSET_OF(T, n));
312 317
313 __ ldm(ia_w, sp, r4.bit() | fp.bit() | pc.bit()); 318 __ ldm(ia_w, sp, r4.bit() | fp.bit() | pc.bit());
314 319
315 CodeDesc desc; 320 CodeDesc desc;
316 assm.GetCode(&desc); 321 assm.GetCode(&desc);
317 Object* code = HEAP->CreateCode( 322 Object* code = isolate->heap()->CreateCode(
318 desc, 323 desc,
319 Code::ComputeFlags(Code::STUB), 324 Code::ComputeFlags(Code::STUB),
320 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); 325 Handle<Code>())->ToObjectChecked();
321 CHECK(code->IsCode()); 326 CHECK(code->IsCode());
322 #ifdef DEBUG 327 #ifdef DEBUG
323 Code::cast(code)->Print(); 328 Code::cast(code)->Print();
324 #endif 329 #endif
325 F3 f = FUNCTION_CAST<F3>(Code::cast(code)->entry()); 330 F3 f = FUNCTION_CAST<F3>(Code::cast(code)->entry());
326 t.a = 1.5; 331 t.a = 1.5;
327 t.b = 2.75; 332 t.b = 2.75;
328 t.c = 17.17; 333 t.c = 17.17;
329 t.d = 0.0; 334 t.d = 0.0;
330 t.e = 0.0; 335 t.e = 0.0;
(...skipping 22 matching lines...) Expand all
353 CHECK_EQ(1.5, t.a); 358 CHECK_EQ(1.5, t.a);
354 } 359 }
355 } 360 }
356 361
357 362
358 TEST(5) { 363 TEST(5) {
359 // Test the ARMv7 bitfield instructions. 364 // Test the ARMv7 bitfield instructions.
360 InitializeVM(); 365 InitializeVM();
361 v8::HandleScope scope; 366 v8::HandleScope scope;
362 367
363 Assembler assm(Isolate::Current(), NULL, 0); 368 Isolate* isolate = Isolate::Current();
369 Assembler assm(isolate, NULL, 0);
364 370
365 if (CpuFeatures::IsSupported(ARMv7)) { 371 if (CpuFeatures::IsSupported(ARMv7)) {
366 CpuFeatures::Scope scope(ARMv7); 372 CpuFeatures::Scope scope(ARMv7);
367 // On entry, r0 = 0xAAAAAAAA = 0b10..10101010. 373 // On entry, r0 = 0xAAAAAAAA = 0b10..10101010.
368 __ ubfx(r0, r0, 1, 12); // 0b00..010101010101 = 0x555 374 __ ubfx(r0, r0, 1, 12); // 0b00..010101010101 = 0x555
369 __ sbfx(r0, r0, 0, 5); // 0b11..111111110101 = -11 375 __ sbfx(r0, r0, 0, 5); // 0b11..111111110101 = -11
370 __ bfc(r0, 1, 3); // 0b11..111111110001 = -15 376 __ bfc(r0, 1, 3); // 0b11..111111110001 = -15
371 __ mov(r1, Operand(7)); 377 __ mov(r1, Operand(7));
372 __ bfi(r0, r1, 3, 3); // 0b11..111111111001 = -7 378 __ bfi(r0, r1, 3, 3); // 0b11..111111111001 = -7
373 __ mov(pc, Operand(lr)); 379 __ mov(pc, Operand(lr));
374 380
375 CodeDesc desc; 381 CodeDesc desc;
376 assm.GetCode(&desc); 382 assm.GetCode(&desc);
377 Object* code = HEAP->CreateCode( 383 Object* code = isolate->heap()->CreateCode(
378 desc, 384 desc,
379 Code::ComputeFlags(Code::STUB), 385 Code::ComputeFlags(Code::STUB),
380 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); 386 Handle<Code>())->ToObjectChecked();
381 CHECK(code->IsCode()); 387 CHECK(code->IsCode());
382 #ifdef DEBUG 388 #ifdef DEBUG
383 Code::cast(code)->Print(); 389 Code::cast(code)->Print();
384 #endif 390 #endif
385 F1 f = FUNCTION_CAST<F1>(Code::cast(code)->entry()); 391 F1 f = FUNCTION_CAST<F1>(Code::cast(code)->entry());
386 int res = reinterpret_cast<int>( 392 int res = reinterpret_cast<int>(
387 CALL_GENERATED_CODE(f, 0xAAAAAAAA, 0, 0, 0, 0)); 393 CALL_GENERATED_CODE(f, 0xAAAAAAAA, 0, 0, 0, 0));
388 ::printf("f() = %d\n", res); 394 ::printf("f() = %d\n", res);
389 CHECK_EQ(-7, res); 395 CHECK_EQ(-7, res);
390 } 396 }
391 } 397 }
392 398
393 399
394 TEST(6) { 400 TEST(6) {
395 // Test saturating instructions. 401 // Test saturating instructions.
396 InitializeVM(); 402 InitializeVM();
397 v8::HandleScope scope; 403 v8::HandleScope scope;
398 404
399 Assembler assm(Isolate::Current(), NULL, 0); 405 Isolate* isolate = Isolate::Current();
406 Assembler assm(isolate, NULL, 0);
400 407
401 if (CpuFeatures::IsSupported(ARMv7)) { 408 if (CpuFeatures::IsSupported(ARMv7)) {
402 CpuFeatures::Scope scope(ARMv7); 409 CpuFeatures::Scope scope(ARMv7);
403 __ usat(r1, 8, Operand(r0)); // Sat 0xFFFF to 0-255 = 0xFF. 410 __ usat(r1, 8, Operand(r0)); // Sat 0xFFFF to 0-255 = 0xFF.
404 __ usat(r2, 12, Operand(r0, ASR, 9)); // Sat (0xFFFF>>9) to 0-4095 = 0x7F. 411 __ usat(r2, 12, Operand(r0, ASR, 9)); // Sat (0xFFFF>>9) to 0-4095 = 0x7F.
405 __ usat(r3, 1, Operand(r0, LSL, 16)); // Sat (0xFFFF<<16) to 0-1 = 0x0. 412 __ usat(r3, 1, Operand(r0, LSL, 16)); // Sat (0xFFFF<<16) to 0-1 = 0x0.
406 __ add(r0, r1, Operand(r2)); 413 __ add(r0, r1, Operand(r2));
407 __ add(r0, r0, Operand(r3)); 414 __ add(r0, r0, Operand(r3));
408 __ mov(pc, Operand(lr)); 415 __ mov(pc, Operand(lr));
409 416
410 CodeDesc desc; 417 CodeDesc desc;
411 assm.GetCode(&desc); 418 assm.GetCode(&desc);
412 Object* code = HEAP->CreateCode( 419 Object* code = isolate->heap()->CreateCode(
413 desc, 420 desc,
414 Code::ComputeFlags(Code::STUB), 421 Code::ComputeFlags(Code::STUB),
415 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); 422 Handle<Code>())->ToObjectChecked();
416 CHECK(code->IsCode()); 423 CHECK(code->IsCode());
417 #ifdef DEBUG 424 #ifdef DEBUG
418 Code::cast(code)->Print(); 425 Code::cast(code)->Print();
419 #endif 426 #endif
420 F1 f = FUNCTION_CAST<F1>(Code::cast(code)->entry()); 427 F1 f = FUNCTION_CAST<F1>(Code::cast(code)->entry());
421 int res = reinterpret_cast<int>( 428 int res = reinterpret_cast<int>(
422 CALL_GENERATED_CODE(f, 0xFFFF, 0, 0, 0, 0)); 429 CALL_GENERATED_CODE(f, 0xFFFF, 0, 0, 0, 0));
423 ::printf("f() = %d\n", res); 430 ::printf("f() = %d\n", res);
424 CHECK_EQ(382, res); 431 CHECK_EQ(382, res);
425 } 432 }
426 } 433 }
427 434
428 435
429 enum VCVTTypes { 436 enum VCVTTypes {
430 s32_f64, 437 s32_f64,
431 u32_f64 438 u32_f64
432 }; 439 };
433 440
434 static void TestRoundingMode(VCVTTypes types, 441 static void TestRoundingMode(VCVTTypes types,
435 VFPRoundingMode mode, 442 VFPRoundingMode mode,
436 double value, 443 double value,
437 int expected, 444 int expected,
438 bool expected_exception = false) { 445 bool expected_exception = false) {
439 InitializeVM(); 446 InitializeVM();
440 v8::HandleScope scope; 447 v8::HandleScope scope;
441 448
442 Assembler assm(Isolate::Current(), NULL, 0); 449 Isolate* isolate = Isolate::Current();
450 Assembler assm(isolate, NULL, 0);
443 451
444 if (CpuFeatures::IsSupported(VFP3)) { 452 if (CpuFeatures::IsSupported(VFP3)) {
445 CpuFeatures::Scope scope(VFP3); 453 CpuFeatures::Scope scope(VFP3);
446 454
447 Label wrong_exception; 455 Label wrong_exception;
448 456
449 __ vmrs(r1); 457 __ vmrs(r1);
450 // Set custom FPSCR. 458 // Set custom FPSCR.
451 __ bic(r2, r1, Operand(kVFPRoundingModeMask | kVFPExceptionMask)); 459 __ bic(r2, r1, Operand(kVFPRoundingModeMask | kVFPExceptionMask));
452 __ orr(r2, r2, Operand(mode)); 460 __ orr(r2, r2, Operand(mode));
(...skipping 25 matching lines...) Expand all
478 __ mov(pc, Operand(lr)); 486 __ mov(pc, Operand(lr));
479 487
480 // The exception behaviour is not what we expected. 488 // The exception behaviour is not what we expected.
481 // Load a special value and return. 489 // Load a special value and return.
482 __ bind(&wrong_exception); 490 __ bind(&wrong_exception);
483 __ mov(r0, Operand(11223344)); 491 __ mov(r0, Operand(11223344));
484 __ mov(pc, Operand(lr)); 492 __ mov(pc, Operand(lr));
485 493
486 CodeDesc desc; 494 CodeDesc desc;
487 assm.GetCode(&desc); 495 assm.GetCode(&desc);
488 Object* code = HEAP->CreateCode( 496 Object* code = isolate->heap()->CreateCode(
489 desc, 497 desc,
490 Code::ComputeFlags(Code::STUB), 498 Code::ComputeFlags(Code::STUB),
491 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); 499 Handle<Code>())->ToObjectChecked();
492 CHECK(code->IsCode()); 500 CHECK(code->IsCode());
493 #ifdef DEBUG 501 #ifdef DEBUG
494 Code::cast(code)->Print(); 502 Code::cast(code)->Print();
495 #endif 503 #endif
496 F1 f = FUNCTION_CAST<F1>(Code::cast(code)->entry()); 504 F1 f = FUNCTION_CAST<F1>(Code::cast(code)->entry());
497 int res = reinterpret_cast<int>( 505 int res = reinterpret_cast<int>(
498 CALL_GENERATED_CODE(f, 0, 0, 0, 0, 0)); 506 CALL_GENERATED_CODE(f, 0, 0, 0, 0, 0));
499 ::printf("res = %d\n", res); 507 ::printf("res = %d\n", res);
500 CHECK_EQ(expected, res); 508 CHECK_EQ(expected, res);
501 } 509 }
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 float d; 643 float d;
636 float e; 644 float e;
637 float f; 645 float f;
638 float g; 646 float g;
639 float h; 647 float h;
640 } F; 648 } F;
641 F f; 649 F f;
642 650
643 // Create a function that uses vldm/vstm to move some double and 651 // Create a function that uses vldm/vstm to move some double and
644 // single precision values around in memory. 652 // single precision values around in memory.
645 Assembler assm(Isolate::Current(), NULL, 0); 653 Isolate* isolate = Isolate::Current();
654 Assembler assm(isolate, NULL, 0);
646 655
647 if (CpuFeatures::IsSupported(VFP2)) { 656 if (CpuFeatures::IsSupported(VFP2)) {
648 CpuFeatures::Scope scope(VFP2); 657 CpuFeatures::Scope scope(VFP2);
649 658
650 __ mov(ip, Operand(sp)); 659 __ mov(ip, Operand(sp));
651 __ stm(db_w, sp, r4.bit() | fp.bit() | lr.bit()); 660 __ stm(db_w, sp, r4.bit() | fp.bit() | lr.bit());
652 __ sub(fp, ip, Operand(4)); 661 __ sub(fp, ip, Operand(4));
653 662
654 __ add(r4, r0, Operand(OFFSET_OF(D, a))); 663 __ add(r4, r0, Operand(OFFSET_OF(D, a)));
655 __ vldm(ia_w, r4, d0, d3); 664 __ vldm(ia_w, r4, d0, d3);
656 __ vldm(ia_w, r4, d4, d7); 665 __ vldm(ia_w, r4, d4, d7);
657 666
658 __ add(r4, r0, Operand(OFFSET_OF(D, a))); 667 __ add(r4, r0, Operand(OFFSET_OF(D, a)));
659 __ vstm(ia_w, r4, d6, d7); 668 __ vstm(ia_w, r4, d6, d7);
660 __ vstm(ia_w, r4, d0, d5); 669 __ vstm(ia_w, r4, d0, d5);
661 670
662 __ add(r4, r1, Operand(OFFSET_OF(F, a))); 671 __ add(r4, r1, Operand(OFFSET_OF(F, a)));
663 __ vldm(ia_w, r4, s0, s3); 672 __ vldm(ia_w, r4, s0, s3);
664 __ vldm(ia_w, r4, s4, s7); 673 __ vldm(ia_w, r4, s4, s7);
665 674
666 __ add(r4, r1, Operand(OFFSET_OF(F, a))); 675 __ add(r4, r1, Operand(OFFSET_OF(F, a)));
667 __ vstm(ia_w, r4, s6, s7); 676 __ vstm(ia_w, r4, s6, s7);
668 __ vstm(ia_w, r4, s0, s5); 677 __ vstm(ia_w, r4, s0, s5);
669 678
670 __ ldm(ia_w, sp, r4.bit() | fp.bit() | pc.bit()); 679 __ ldm(ia_w, sp, r4.bit() | fp.bit() | pc.bit());
671 680
672 CodeDesc desc; 681 CodeDesc desc;
673 assm.GetCode(&desc); 682 assm.GetCode(&desc);
674 Object* code = HEAP->CreateCode( 683 Object* code = isolate->heap()->CreateCode(
675 desc, 684 desc,
676 Code::ComputeFlags(Code::STUB), 685 Code::ComputeFlags(Code::STUB),
677 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); 686 Handle<Code>())->ToObjectChecked();
678 CHECK(code->IsCode()); 687 CHECK(code->IsCode());
679 #ifdef DEBUG 688 #ifdef DEBUG
680 Code::cast(code)->Print(); 689 Code::cast(code)->Print();
681 #endif 690 #endif
682 F4 fn = FUNCTION_CAST<F4>(Code::cast(code)->entry()); 691 F4 fn = FUNCTION_CAST<F4>(Code::cast(code)->entry());
683 d.a = 1.1; 692 d.a = 1.1;
684 d.b = 2.2; 693 d.b = 2.2;
685 d.c = 3.3; 694 d.c = 3.3;
686 d.d = 4.4; 695 d.d = 4.4;
687 d.e = 5.5; 696 d.e = 5.5;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 float d; 755 float d;
747 float e; 756 float e;
748 float f; 757 float f;
749 float g; 758 float g;
750 float h; 759 float h;
751 } F; 760 } F;
752 F f; 761 F f;
753 762
754 // Create a function that uses vldm/vstm to move some double and 763 // Create a function that uses vldm/vstm to move some double and
755 // single precision values around in memory. 764 // single precision values around in memory.
756 Assembler assm(Isolate::Current(), NULL, 0); 765 Isolate* isolate = Isolate::Current();
766 Assembler assm(isolate, NULL, 0);
757 767
758 if (CpuFeatures::IsSupported(VFP2)) { 768 if (CpuFeatures::IsSupported(VFP2)) {
759 CpuFeatures::Scope scope(VFP2); 769 CpuFeatures::Scope scope(VFP2);
760 770
761 __ mov(ip, Operand(sp)); 771 __ mov(ip, Operand(sp));
762 __ stm(db_w, sp, r4.bit() | fp.bit() | lr.bit()); 772 __ stm(db_w, sp, r4.bit() | fp.bit() | lr.bit());
763 __ sub(fp, ip, Operand(4)); 773 __ sub(fp, ip, Operand(4));
764 774
765 __ add(r4, r0, Operand(OFFSET_OF(D, a))); 775 __ add(r4, r0, Operand(OFFSET_OF(D, a)));
766 __ vldm(ia, r4, d0, d3); 776 __ vldm(ia, r4, d0, d3);
(...skipping 12 matching lines...) Expand all
779 789
780 __ add(r4, r1, Operand(OFFSET_OF(F, a))); 790 __ add(r4, r1, Operand(OFFSET_OF(F, a)));
781 __ vstm(ia, r4, s6, s7); 791 __ vstm(ia, r4, s6, s7);
782 __ add(r4, r4, Operand(2 * 4)); 792 __ add(r4, r4, Operand(2 * 4));
783 __ vstm(ia, r4, s0, s5); 793 __ vstm(ia, r4, s0, s5);
784 794
785 __ ldm(ia_w, sp, r4.bit() | fp.bit() | pc.bit()); 795 __ ldm(ia_w, sp, r4.bit() | fp.bit() | pc.bit());
786 796
787 CodeDesc desc; 797 CodeDesc desc;
788 assm.GetCode(&desc); 798 assm.GetCode(&desc);
789 Object* code = HEAP->CreateCode( 799 Object* code = isolate->heap()->CreateCode(
790 desc, 800 desc,
791 Code::ComputeFlags(Code::STUB), 801 Code::ComputeFlags(Code::STUB),
792 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); 802 Handle<Code>())->ToObjectChecked();
793 CHECK(code->IsCode()); 803 CHECK(code->IsCode());
794 #ifdef DEBUG 804 #ifdef DEBUG
795 Code::cast(code)->Print(); 805 Code::cast(code)->Print();
796 #endif 806 #endif
797 F4 fn = FUNCTION_CAST<F4>(Code::cast(code)->entry()); 807 F4 fn = FUNCTION_CAST<F4>(Code::cast(code)->entry());
798 d.a = 1.1; 808 d.a = 1.1;
799 d.b = 2.2; 809 d.b = 2.2;
800 d.c = 3.3; 810 d.c = 3.3;
801 d.d = 4.4; 811 d.d = 4.4;
802 d.e = 5.5; 812 d.e = 5.5;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 float d; 871 float d;
862 float e; 872 float e;
863 float f; 873 float f;
864 float g; 874 float g;
865 float h; 875 float h;
866 } F; 876 } F;
867 F f; 877 F f;
868 878
869 // Create a function that uses vldm/vstm to move some double and 879 // Create a function that uses vldm/vstm to move some double and
870 // single precision values around in memory. 880 // single precision values around in memory.
871 Assembler assm(Isolate::Current(), NULL, 0); 881 Isolate* isolate = Isolate::Current();
882 Assembler assm(isolate, NULL, 0);
872 883
873 if (CpuFeatures::IsSupported(VFP2)) { 884 if (CpuFeatures::IsSupported(VFP2)) {
874 CpuFeatures::Scope scope(VFP2); 885 CpuFeatures::Scope scope(VFP2);
875 886
876 __ mov(ip, Operand(sp)); 887 __ mov(ip, Operand(sp));
877 __ stm(db_w, sp, r4.bit() | fp.bit() | lr.bit()); 888 __ stm(db_w, sp, r4.bit() | fp.bit() | lr.bit());
878 __ sub(fp, ip, Operand(4)); 889 __ sub(fp, ip, Operand(4));
879 890
880 __ add(r4, r0, Operand(OFFSET_OF(D, h) + 8)); 891 __ add(r4, r0, Operand(OFFSET_OF(D, h) + 8));
881 __ vldm(db_w, r4, d4, d7); 892 __ vldm(db_w, r4, d4, d7);
882 __ vldm(db_w, r4, d0, d3); 893 __ vldm(db_w, r4, d0, d3);
883 894
884 __ add(r4, r0, Operand(OFFSET_OF(D, h) + 8)); 895 __ add(r4, r0, Operand(OFFSET_OF(D, h) + 8));
885 __ vstm(db_w, r4, d0, d5); 896 __ vstm(db_w, r4, d0, d5);
886 __ vstm(db_w, r4, d6, d7); 897 __ vstm(db_w, r4, d6, d7);
887 898
888 __ add(r4, r1, Operand(OFFSET_OF(F, h) + 4)); 899 __ add(r4, r1, Operand(OFFSET_OF(F, h) + 4));
889 __ vldm(db_w, r4, s4, s7); 900 __ vldm(db_w, r4, s4, s7);
890 __ vldm(db_w, r4, s0, s3); 901 __ vldm(db_w, r4, s0, s3);
891 902
892 __ add(r4, r1, Operand(OFFSET_OF(F, h) + 4)); 903 __ add(r4, r1, Operand(OFFSET_OF(F, h) + 4));
893 __ vstm(db_w, r4, s0, s5); 904 __ vstm(db_w, r4, s0, s5);
894 __ vstm(db_w, r4, s6, s7); 905 __ vstm(db_w, r4, s6, s7);
895 906
896 __ ldm(ia_w, sp, r4.bit() | fp.bit() | pc.bit()); 907 __ ldm(ia_w, sp, r4.bit() | fp.bit() | pc.bit());
897 908
898 CodeDesc desc; 909 CodeDesc desc;
899 assm.GetCode(&desc); 910 assm.GetCode(&desc);
900 Object* code = HEAP->CreateCode( 911 Object* code = isolate->heap()->CreateCode(
901 desc, 912 desc,
902 Code::ComputeFlags(Code::STUB), 913 Code::ComputeFlags(Code::STUB),
903 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); 914 Handle<Code>())->ToObjectChecked();
904 CHECK(code->IsCode()); 915 CHECK(code->IsCode());
905 #ifdef DEBUG 916 #ifdef DEBUG
906 Code::cast(code)->Print(); 917 Code::cast(code)->Print();
907 #endif 918 #endif
908 F4 fn = FUNCTION_CAST<F4>(Code::cast(code)->entry()); 919 F4 fn = FUNCTION_CAST<F4>(Code::cast(code)->entry());
909 d.a = 1.1; 920 d.a = 1.1;
910 d.b = 2.2; 921 d.b = 2.2;
911 d.c = 3.3; 922 d.c = 3.3;
912 d.d = 4.4; 923 d.d = 4.4;
913 d.e = 5.5; 924 d.e = 5.5;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 int32_t a; 968 int32_t a;
958 int32_t b; 969 int32_t b;
959 int32_t c; 970 int32_t c;
960 int32_t d; 971 int32_t d;
961 } I; 972 } I;
962 I i; 973 I i;
963 974
964 i.a = 0xabcd0001; 975 i.a = 0xabcd0001;
965 i.b = 0xabcd0000; 976 i.b = 0xabcd0000;
966 977
967 Assembler assm(Isolate::Current(), NULL, 0); 978 Isolate* isolate = Isolate::Current();
979 Assembler assm(isolate, NULL, 0);
968 980
969 // Test HeapObject untagging. 981 // Test HeapObject untagging.
970 __ ldr(r1, MemOperand(r0, OFFSET_OF(I, a))); 982 __ ldr(r1, MemOperand(r0, OFFSET_OF(I, a)));
971 __ mov(r1, Operand(r1, ASR, 1), SetCC); 983 __ mov(r1, Operand(r1, ASR, 1), SetCC);
972 __ adc(r1, r1, Operand(r1), LeaveCC, cs); 984 __ adc(r1, r1, Operand(r1), LeaveCC, cs);
973 __ str(r1, MemOperand(r0, OFFSET_OF(I, a))); 985 __ str(r1, MemOperand(r0, OFFSET_OF(I, a)));
974 986
975 __ ldr(r2, MemOperand(r0, OFFSET_OF(I, b))); 987 __ ldr(r2, MemOperand(r0, OFFSET_OF(I, b)));
976 __ mov(r2, Operand(r2, ASR, 1), SetCC); 988 __ mov(r2, Operand(r2, ASR, 1), SetCC);
977 __ adc(r2, r2, Operand(r2), LeaveCC, cs); 989 __ adc(r2, r2, Operand(r2), LeaveCC, cs);
978 __ str(r2, MemOperand(r0, OFFSET_OF(I, b))); 990 __ str(r2, MemOperand(r0, OFFSET_OF(I, b)));
979 991
980 // Test corner cases. 992 // Test corner cases.
981 __ mov(r1, Operand(0xffffffff)); 993 __ mov(r1, Operand(0xffffffff));
982 __ mov(r2, Operand::Zero()); 994 __ mov(r2, Operand::Zero());
983 __ mov(r3, Operand(r1, ASR, 1), SetCC); // Set the carry. 995 __ mov(r3, Operand(r1, ASR, 1), SetCC); // Set the carry.
984 __ adc(r3, r1, Operand(r2)); 996 __ adc(r3, r1, Operand(r2));
985 __ str(r3, MemOperand(r0, OFFSET_OF(I, c))); 997 __ str(r3, MemOperand(r0, OFFSET_OF(I, c)));
986 998
987 __ mov(r1, Operand(0xffffffff)); 999 __ mov(r1, Operand(0xffffffff));
988 __ mov(r2, Operand::Zero()); 1000 __ mov(r2, Operand::Zero());
989 __ mov(r3, Operand(r2, ASR, 1), SetCC); // Unset the carry. 1001 __ mov(r3, Operand(r2, ASR, 1), SetCC); // Unset the carry.
990 __ adc(r3, r1, Operand(r2)); 1002 __ adc(r3, r1, Operand(r2));
991 __ str(r3, MemOperand(r0, OFFSET_OF(I, d))); 1003 __ str(r3, MemOperand(r0, OFFSET_OF(I, d)));
992 1004
993 __ mov(pc, Operand(lr)); 1005 __ mov(pc, Operand(lr));
994 1006
995 CodeDesc desc; 1007 CodeDesc desc;
996 assm.GetCode(&desc); 1008 assm.GetCode(&desc);
997 Object* code = HEAP->CreateCode( 1009 Object* code = isolate->heap()->CreateCode(
998 desc, 1010 desc,
999 Code::ComputeFlags(Code::STUB), 1011 Code::ComputeFlags(Code::STUB),
1000 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); 1012 Handle<Code>())->ToObjectChecked();
1001 CHECK(code->IsCode()); 1013 CHECK(code->IsCode());
1002 #ifdef DEBUG 1014 #ifdef DEBUG
1003 Code::cast(code)->Print(); 1015 Code::cast(code)->Print();
1004 #endif 1016 #endif
1005 F3 f = FUNCTION_CAST<F3>(Code::cast(code)->entry()); 1017 F3 f = FUNCTION_CAST<F3>(Code::cast(code)->entry());
1006 Object* dummy = CALL_GENERATED_CODE(f, &i, 0, 0, 0, 0); 1018 Object* dummy = CALL_GENERATED_CODE(f, &i, 0, 0, 0, 0);
1007 USE(dummy); 1019 USE(dummy);
1008 1020
1009 CHECK_EQ(0xabcd0001, i.a); 1021 CHECK_EQ(0xabcd0001, i.a);
1010 CHECK_EQ(static_cast<int32_t>(0xabcd0000) >> 1, i.b); 1022 CHECK_EQ(static_cast<int32_t>(0xabcd0000) >> 1, i.b);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 double y; 1056 double y;
1045 double z; 1057 double z;
1046 double i; 1058 double i;
1047 double j; 1059 double j;
1048 double k; 1060 double k;
1049 } T; 1061 } T;
1050 T t; 1062 T t;
1051 1063
1052 // Create a function that accepts &t, and loads, manipulates, and stores 1064 // Create a function that accepts &t, and loads, manipulates, and stores
1053 // the doubles and floats. 1065 // the doubles and floats.
1054 Assembler assm(Isolate::Current(), NULL, 0); 1066 Isolate* isolate = Isolate::Current();
1067 Assembler assm(isolate, NULL, 0);
1055 Label L, C; 1068 Label L, C;
1056 1069
1057 1070
1058 if (CpuFeatures::IsSupported(VFP3)) { 1071 if (CpuFeatures::IsSupported(VFP3)) {
1059 CpuFeatures::Scope scope(VFP3); 1072 CpuFeatures::Scope scope(VFP3);
1060 1073
1061 __ stm(db_w, sp, r4.bit() | lr.bit()); 1074 __ stm(db_w, sp, r4.bit() | lr.bit());
1062 1075
1063 // Load a, b, c into d16, d17, d18. 1076 // Load a, b, c into d16, d17, d18.
1064 __ mov(r4, Operand(r0)); 1077 __ mov(r4, Operand(r0));
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 __ mov(r2, Operand(1079146608)); 1121 __ mov(r2, Operand(1079146608));
1109 __ vmov(d22, VmovIndexLo, r1); 1122 __ vmov(d22, VmovIndexLo, r1);
1110 __ vmov(d22, VmovIndexHi, r2); 1123 __ vmov(d22, VmovIndexHi, r2);
1111 __ add(r4, r0, Operand(OFFSET_OF(T, i))); 1124 __ add(r4, r0, Operand(OFFSET_OF(T, i)));
1112 __ vstm(ia_w, r4, d20, d22); 1125 __ vstm(ia_w, r4, d20, d22);
1113 1126
1114 __ ldm(ia_w, sp, r4.bit() | pc.bit()); 1127 __ ldm(ia_w, sp, r4.bit() | pc.bit());
1115 1128
1116 CodeDesc desc; 1129 CodeDesc desc;
1117 assm.GetCode(&desc); 1130 assm.GetCode(&desc);
1118 Object* code = HEAP->CreateCode( 1131 Object* code = isolate->heap()->CreateCode(
1119 desc, 1132 desc,
1120 Code::ComputeFlags(Code::STUB), 1133 Code::ComputeFlags(Code::STUB),
1121 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); 1134 Handle<Code>())->ToObjectChecked();
1122 CHECK(code->IsCode()); 1135 CHECK(code->IsCode());
1123 #ifdef DEBUG 1136 #ifdef DEBUG
1124 Code::cast(code)->Print(); 1137 Code::cast(code)->Print();
1125 #endif 1138 #endif
1126 F3 f = FUNCTION_CAST<F3>(Code::cast(code)->entry()); 1139 F3 f = FUNCTION_CAST<F3>(Code::cast(code)->entry());
1127 t.a = 1.5; 1140 t.a = 1.5;
1128 t.b = 2.75; 1141 t.b = 2.75;
1129 t.c = 17.17; 1142 t.c = 17.17;
1130 t.x = 1.5; 1143 t.x = 1.5;
1131 t.y = 2.75; 1144 t.y = 2.75;
1132 t.z = 17.17; 1145 t.z = 17.17;
1133 Object* dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0); 1146 Object* dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0);
1134 USE(dummy); 1147 USE(dummy);
1135 CHECK_EQ(14.7610017472335499, t.a); 1148 CHECK_EQ(14.7610017472335499, t.a);
1136 CHECK_EQ(3.84200491244266251, t.b); 1149 CHECK_EQ(3.84200491244266251, t.b);
1137 CHECK_EQ(73.8818412254460241, t.c); 1150 CHECK_EQ(73.8818412254460241, t.c);
1138 CHECK_EQ(2.75, t.x); 1151 CHECK_EQ(2.75, t.x);
1139 CHECK_EQ(1.5, t.y); 1152 CHECK_EQ(1.5, t.y);
1140 CHECK_EQ(17.0, t.z); 1153 CHECK_EQ(17.0, t.z);
1141 CHECK_EQ(14.7610017472335499, t.i); 1154 CHECK_EQ(14.7610017472335499, t.i);
1142 CHECK_EQ(16.0, t.j); 1155 CHECK_EQ(16.0, t.j);
1143 CHECK_EQ(73.8818412254460241, t.k); 1156 CHECK_EQ(73.8818412254460241, t.k);
1144 } 1157 }
1145 } 1158 }
1146 1159
1147 #undef __ 1160 #undef __
OLDNEW
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/cctest/test-assembler-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698