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

Side by Side Diff: test/cctest/test-assembler-ia32.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: Even less Isolate::Current Created 7 years, 10 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
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 } 54 }
55 55
56 56
57 #define __ assm. 57 #define __ assm.
58 58
59 TEST(AssemblerIa320) { 59 TEST(AssemblerIa320) {
60 InitializeVM(); 60 InitializeVM();
61 v8::HandleScope scope; 61 v8::HandleScope scope;
62 62
63 v8::internal::byte buffer[256]; 63 v8::internal::byte buffer[256];
64 Assembler assm(Isolate::Current(), buffer, sizeof buffer); 64 Isolate* isolate = Isolate::Current();
65 Assembler assm(isolate, buffer, sizeof buffer);
65 66
66 __ mov(eax, Operand(esp, 4)); 67 __ mov(eax, Operand(esp, 4));
67 __ add(eax, Operand(esp, 8)); 68 __ add(eax, Operand(esp, 8));
68 __ ret(0); 69 __ ret(0);
69 70
70 CodeDesc desc; 71 CodeDesc desc;
71 assm.GetCode(&desc); 72 assm.GetCode(&desc);
72 Object* code = HEAP->CreateCode( 73 Object* code = isolate->heap()->CreateCode(
73 desc, 74 desc,
74 Code::ComputeFlags(Code::STUB), 75 Code::ComputeFlags(Code::STUB),
75 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); 76 Handle<Object>(isolate->heap()->undefined_value(),
Michael Starzinger 2013/02/25 10:50:58 Just use "isolate->factory()->undefined_value()" h
Sven Panne 2013/02/25 14:44:43 Done.
77 isolate))->ToObjectChecked();
76 CHECK(code->IsCode()); 78 CHECK(code->IsCode());
77 #ifdef OBJECT_PRINT 79 #ifdef OBJECT_PRINT
78 Code::cast(code)->Print(); 80 Code::cast(code)->Print();
79 #endif 81 #endif
80 F2 f = FUNCTION_CAST<F2>(Code::cast(code)->entry()); 82 F2 f = FUNCTION_CAST<F2>(Code::cast(code)->entry());
81 int res = f(3, 4); 83 int res = f(3, 4);
82 ::printf("f() = %d\n", res); 84 ::printf("f() = %d\n", res);
83 CHECK_EQ(7, res); 85 CHECK_EQ(7, res);
84 } 86 }
85 87
86 88
87 TEST(AssemblerIa321) { 89 TEST(AssemblerIa321) {
88 InitializeVM(); 90 InitializeVM();
89 v8::HandleScope scope; 91 v8::HandleScope scope;
90 92
91 v8::internal::byte buffer[256]; 93 v8::internal::byte buffer[256];
92 Assembler assm(Isolate::Current(), buffer, sizeof buffer); 94 Isolate* isolate = Isolate::Current();
95 Assembler assm(isolate, buffer, sizeof buffer);
93 Label L, C; 96 Label L, C;
94 97
95 __ mov(edx, Operand(esp, 4)); 98 __ mov(edx, Operand(esp, 4));
96 __ xor_(eax, eax); // clear eax 99 __ xor_(eax, eax); // clear eax
97 __ jmp(&C); 100 __ jmp(&C);
98 101
99 __ bind(&L); 102 __ bind(&L);
100 __ add(eax, edx); 103 __ add(eax, edx);
101 __ sub(edx, Immediate(1)); 104 __ sub(edx, Immediate(1));
102 105
103 __ bind(&C); 106 __ bind(&C);
104 __ test(edx, edx); 107 __ test(edx, edx);
105 __ j(not_zero, &L); 108 __ j(not_zero, &L);
106 __ ret(0); 109 __ ret(0);
107 110
108 CodeDesc desc; 111 CodeDesc desc;
109 assm.GetCode(&desc); 112 assm.GetCode(&desc);
110 Object* code = HEAP->CreateCode( 113 Object* code = isolate->heap()->CreateCode(
111 desc, 114 desc,
112 Code::ComputeFlags(Code::STUB), 115 Code::ComputeFlags(Code::STUB),
113 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); 116 Handle<Object>(isolate->heap()->undefined_value(),
117 isolate))->ToObjectChecked();
114 CHECK(code->IsCode()); 118 CHECK(code->IsCode());
115 #ifdef OBJECT_PRINT 119 #ifdef OBJECT_PRINT
116 Code::cast(code)->Print(); 120 Code::cast(code)->Print();
117 #endif 121 #endif
118 F1 f = FUNCTION_CAST<F1>(Code::cast(code)->entry()); 122 F1 f = FUNCTION_CAST<F1>(Code::cast(code)->entry());
119 int res = f(100); 123 int res = f(100);
120 ::printf("f() = %d\n", res); 124 ::printf("f() = %d\n", res);
121 CHECK_EQ(5050, res); 125 CHECK_EQ(5050, res);
122 } 126 }
123 127
124 128
125 TEST(AssemblerIa322) { 129 TEST(AssemblerIa322) {
126 InitializeVM(); 130 InitializeVM();
127 v8::HandleScope scope; 131 v8::HandleScope scope;
128 132
129 v8::internal::byte buffer[256]; 133 v8::internal::byte buffer[256];
130 Assembler assm(Isolate::Current(), buffer, sizeof buffer); 134 Isolate* isolate = Isolate::Current();
135 Assembler assm(isolate, buffer, sizeof buffer);
131 Label L, C; 136 Label L, C;
132 137
133 __ mov(edx, Operand(esp, 4)); 138 __ mov(edx, Operand(esp, 4));
134 __ mov(eax, 1); 139 __ mov(eax, 1);
135 __ jmp(&C); 140 __ jmp(&C);
136 141
137 __ bind(&L); 142 __ bind(&L);
138 __ imul(eax, edx); 143 __ imul(eax, edx);
139 __ sub(edx, Immediate(1)); 144 __ sub(edx, Immediate(1));
140 145
141 __ bind(&C); 146 __ bind(&C);
142 __ test(edx, edx); 147 __ test(edx, edx);
143 __ j(not_zero, &L); 148 __ j(not_zero, &L);
144 __ ret(0); 149 __ ret(0);
145 150
146 // some relocated stuff here, not executed 151 // some relocated stuff here, not executed
147 __ mov(eax, FACTORY->true_value()); 152 __ mov(eax, FACTORY->true_value());
148 __ jmp(NULL, RelocInfo::RUNTIME_ENTRY); 153 __ jmp(NULL, RelocInfo::RUNTIME_ENTRY);
149 154
150 CodeDesc desc; 155 CodeDesc desc;
151 assm.GetCode(&desc); 156 assm.GetCode(&desc);
152 Object* code = HEAP->CreateCode( 157 Object* code = isolate->heap()->CreateCode(
153 desc, 158 desc,
154 Code::ComputeFlags(Code::STUB), 159 Code::ComputeFlags(Code::STUB),
155 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); 160 Handle<Object>(isolate->heap()->undefined_value(),
161 isolate))->ToObjectChecked();
156 CHECK(code->IsCode()); 162 CHECK(code->IsCode());
157 #ifdef OBJECT_PRINT 163 #ifdef OBJECT_PRINT
158 Code::cast(code)->Print(); 164 Code::cast(code)->Print();
159 #endif 165 #endif
160 F1 f = FUNCTION_CAST<F1>(Code::cast(code)->entry()); 166 F1 f = FUNCTION_CAST<F1>(Code::cast(code)->entry());
161 int res = f(10); 167 int res = f(10);
162 ::printf("f() = %d\n", res); 168 ::printf("f() = %d\n", res);
163 CHECK_EQ(3628800, res); 169 CHECK_EQ(3628800, res);
164 } 170 }
165 171
166 172
167 typedef int (*F3)(float x); 173 typedef int (*F3)(float x);
168 174
169 TEST(AssemblerIa323) { 175 TEST(AssemblerIa323) {
170 InitializeVM(); 176 InitializeVM();
171 if (!CpuFeatures::IsSupported(SSE2)) return; 177 if (!CpuFeatures::IsSupported(SSE2)) return;
172 178
173 v8::HandleScope scope; 179 v8::HandleScope scope;
174 180
175 v8::internal::byte buffer[256]; 181 v8::internal::byte buffer[256];
176 Assembler assm(Isolate::Current(), buffer, sizeof buffer); 182 Isolate* isolate = Isolate::Current();
183 Assembler assm(isolate, buffer, sizeof buffer);
177 184
178 CHECK(CpuFeatures::IsSupported(SSE2)); 185 CHECK(CpuFeatures::IsSupported(SSE2));
179 { CpuFeatures::Scope fscope(SSE2); 186 { CpuFeatures::Scope fscope(SSE2);
180 __ cvttss2si(eax, Operand(esp, 4)); 187 __ cvttss2si(eax, Operand(esp, 4));
181 __ ret(0); 188 __ ret(0);
182 } 189 }
183 190
184 CodeDesc desc; 191 CodeDesc desc;
185 assm.GetCode(&desc); 192 assm.GetCode(&desc);
186 Code* code = Code::cast(HEAP->CreateCode( 193 Code* code = Code::cast(isolate->heap()->CreateCode(
187 desc, 194 desc,
188 Code::ComputeFlags(Code::STUB), 195 Code::ComputeFlags(Code::STUB),
189 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked()); 196 Handle<Object>(isolate->heap()->undefined_value(),
197 isolate))->ToObjectChecked());
190 // don't print the code - our disassembler can't handle cvttss2si 198 // don't print the code - our disassembler can't handle cvttss2si
191 // instead print bytes 199 // instead print bytes
192 Disassembler::Dump(stdout, 200 Disassembler::Dump(stdout,
193 code->instruction_start(), 201 code->instruction_start(),
194 code->instruction_start() + code->instruction_size()); 202 code->instruction_start() + code->instruction_size());
195 F3 f = FUNCTION_CAST<F3>(code->entry()); 203 F3 f = FUNCTION_CAST<F3>(code->entry());
196 int res = f(static_cast<float>(-3.1415)); 204 int res = f(static_cast<float>(-3.1415));
197 ::printf("f() = %d\n", res); 205 ::printf("f() = %d\n", res);
198 CHECK_EQ(-3, res); 206 CHECK_EQ(-3, res);
199 } 207 }
200 208
201 209
202 typedef int (*F4)(double x); 210 typedef int (*F4)(double x);
203 211
204 TEST(AssemblerIa324) { 212 TEST(AssemblerIa324) {
205 InitializeVM(); 213 InitializeVM();
206 if (!CpuFeatures::IsSupported(SSE2)) return; 214 if (!CpuFeatures::IsSupported(SSE2)) return;
207 215
208 v8::HandleScope scope; 216 v8::HandleScope scope;
209 217
210 v8::internal::byte buffer[256]; 218 v8::internal::byte buffer[256];
211 Assembler assm(Isolate::Current(), buffer, sizeof buffer); 219 Isolate* isolate = Isolate::Current();
220 Assembler assm(isolate, buffer, sizeof buffer);
212 221
213 CHECK(CpuFeatures::IsSupported(SSE2)); 222 CHECK(CpuFeatures::IsSupported(SSE2));
214 CpuFeatures::Scope fscope(SSE2); 223 CpuFeatures::Scope fscope(SSE2);
215 __ cvttsd2si(eax, Operand(esp, 4)); 224 __ cvttsd2si(eax, Operand(esp, 4));
216 __ ret(0); 225 __ ret(0);
217 226
218 CodeDesc desc; 227 CodeDesc desc;
219 assm.GetCode(&desc); 228 assm.GetCode(&desc);
220 Code* code = Code::cast(HEAP->CreateCode( 229 Code* code = Code::cast(isolate->heap()->CreateCode(
221 desc, 230 desc,
222 Code::ComputeFlags(Code::STUB), 231 Code::ComputeFlags(Code::STUB),
223 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked()); 232 Handle<Object>(isolate->heap()->undefined_value(),
233 isolate))->ToObjectChecked());
224 // don't print the code - our disassembler can't handle cvttsd2si 234 // don't print the code - our disassembler can't handle cvttsd2si
225 // instead print bytes 235 // instead print bytes
226 Disassembler::Dump(stdout, 236 Disassembler::Dump(stdout,
227 code->instruction_start(), 237 code->instruction_start(),
228 code->instruction_start() + code->instruction_size()); 238 code->instruction_start() + code->instruction_size());
229 F4 f = FUNCTION_CAST<F4>(code->entry()); 239 F4 f = FUNCTION_CAST<F4>(code->entry());
230 int res = f(2.718281828); 240 int res = f(2.718281828);
231 ::printf("f() = %d\n", res); 241 ::printf("f() = %d\n", res);
232 CHECK_EQ(2, res); 242 CHECK_EQ(2, res);
233 } 243 }
234 244
235 245
236 static int baz = 42; 246 static int baz = 42;
237 TEST(AssemblerIa325) { 247 TEST(AssemblerIa325) {
238 InitializeVM(); 248 InitializeVM();
239 v8::HandleScope scope; 249 v8::HandleScope scope;
240 250
241 v8::internal::byte buffer[256]; 251 v8::internal::byte buffer[256];
242 Assembler assm(Isolate::Current(), buffer, sizeof buffer); 252 Isolate* isolate = Isolate::Current();
253 Assembler assm(isolate, buffer, sizeof buffer);
243 254
244 __ mov(eax, Operand(reinterpret_cast<intptr_t>(&baz), RelocInfo::NONE32)); 255 __ mov(eax, Operand(reinterpret_cast<intptr_t>(&baz), RelocInfo::NONE32));
245 __ ret(0); 256 __ ret(0);
246 257
247 CodeDesc desc; 258 CodeDesc desc;
248 assm.GetCode(&desc); 259 assm.GetCode(&desc);
249 Code* code = Code::cast(HEAP->CreateCode( 260 Code* code = Code::cast(isolate->heap()->CreateCode(
250 desc, 261 desc,
251 Code::ComputeFlags(Code::STUB), 262 Code::ComputeFlags(Code::STUB),
252 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked()); 263 Handle<Object>(isolate->heap()->undefined_value(),
264 isolate))->ToObjectChecked());
253 F0 f = FUNCTION_CAST<F0>(code->entry()); 265 F0 f = FUNCTION_CAST<F0>(code->entry());
254 int res = f(); 266 int res = f();
255 CHECK_EQ(42, res); 267 CHECK_EQ(42, res);
256 } 268 }
257 269
258 270
259 typedef double (*F5)(double x, double y); 271 typedef double (*F5)(double x, double y);
260 272
261 TEST(AssemblerIa326) { 273 TEST(AssemblerIa326) {
262 InitializeVM(); 274 InitializeVM();
263 if (!CpuFeatures::IsSupported(SSE2)) return; 275 if (!CpuFeatures::IsSupported(SSE2)) return;
264 276
265 v8::HandleScope scope; 277 v8::HandleScope scope;
266 CHECK(CpuFeatures::IsSupported(SSE2)); 278 CHECK(CpuFeatures::IsSupported(SSE2));
267 CpuFeatures::Scope fscope(SSE2); 279 CpuFeatures::Scope fscope(SSE2);
268 v8::internal::byte buffer[256]; 280 v8::internal::byte buffer[256];
269 Assembler assm(Isolate::Current(), buffer, sizeof buffer); 281 Isolate* isolate = Isolate::Current();
282 Assembler assm(isolate, buffer, sizeof buffer);
270 283
271 __ movdbl(xmm0, Operand(esp, 1 * kPointerSize)); 284 __ movdbl(xmm0, Operand(esp, 1 * kPointerSize));
272 __ movdbl(xmm1, Operand(esp, 3 * kPointerSize)); 285 __ movdbl(xmm1, Operand(esp, 3 * kPointerSize));
273 __ addsd(xmm0, xmm1); 286 __ addsd(xmm0, xmm1);
274 __ mulsd(xmm0, xmm1); 287 __ mulsd(xmm0, xmm1);
275 __ subsd(xmm0, xmm1); 288 __ subsd(xmm0, xmm1);
276 __ divsd(xmm0, xmm1); 289 __ divsd(xmm0, xmm1);
277 // Copy xmm0 to st(0) using eight bytes of stack. 290 // Copy xmm0 to st(0) using eight bytes of stack.
278 __ sub(esp, Immediate(8)); 291 __ sub(esp, Immediate(8));
279 __ movdbl(Operand(esp, 0), xmm0); 292 __ movdbl(Operand(esp, 0), xmm0);
280 __ fld_d(Operand(esp, 0)); 293 __ fld_d(Operand(esp, 0));
281 __ add(esp, Immediate(8)); 294 __ add(esp, Immediate(8));
282 __ ret(0); 295 __ ret(0);
283 296
284 CodeDesc desc; 297 CodeDesc desc;
285 assm.GetCode(&desc); 298 assm.GetCode(&desc);
286 Code* code = Code::cast(HEAP->CreateCode( 299 Code* code = Code::cast(isolate->heap()->CreateCode(
287 desc, 300 desc,
288 Code::ComputeFlags(Code::STUB), 301 Code::ComputeFlags(Code::STUB),
289 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked()); 302 Handle<Object>(isolate->heap()->undefined_value(),
303 isolate))->ToObjectChecked());
290 #ifdef DEBUG 304 #ifdef DEBUG
291 ::printf("\n---\n"); 305 ::printf("\n---\n");
292 // don't print the code - our disassembler can't handle SSE instructions 306 // don't print the code - our disassembler can't handle SSE instructions
293 // instead print bytes 307 // instead print bytes
294 Disassembler::Dump(stdout, 308 Disassembler::Dump(stdout,
295 code->instruction_start(), 309 code->instruction_start(),
296 code->instruction_start() + code->instruction_size()); 310 code->instruction_start() + code->instruction_size());
297 #endif 311 #endif
298 F5 f = FUNCTION_CAST<F5>(code->entry()); 312 F5 f = FUNCTION_CAST<F5>(code->entry());
299 double res = f(2.2, 1.1); 313 double res = f(2.2, 1.1);
300 ::printf("f() = %f\n", res); 314 ::printf("f() = %f\n", res);
301 CHECK(2.29 < res && res < 2.31); 315 CHECK(2.29 < res && res < 2.31);
302 } 316 }
303 317
304 318
305 typedef double (*F6)(int x); 319 typedef double (*F6)(int x);
306 320
307 TEST(AssemblerIa328) { 321 TEST(AssemblerIa328) {
308 InitializeVM(); 322 InitializeVM();
309 if (!CpuFeatures::IsSupported(SSE2)) return; 323 if (!CpuFeatures::IsSupported(SSE2)) return;
310 324
311 v8::HandleScope scope; 325 v8::HandleScope scope;
312 CHECK(CpuFeatures::IsSupported(SSE2)); 326 CHECK(CpuFeatures::IsSupported(SSE2));
313 CpuFeatures::Scope fscope(SSE2); 327 CpuFeatures::Scope fscope(SSE2);
314 v8::internal::byte buffer[256]; 328 v8::internal::byte buffer[256];
315 Assembler assm(Isolate::Current(), buffer, sizeof buffer); 329 Isolate* isolate = Isolate::Current();
330 Assembler assm(isolate, buffer, sizeof buffer);
316 __ mov(eax, Operand(esp, 4)); 331 __ mov(eax, Operand(esp, 4));
317 __ cvtsi2sd(xmm0, eax); 332 __ cvtsi2sd(xmm0, eax);
318 // Copy xmm0 to st(0) using eight bytes of stack. 333 // Copy xmm0 to st(0) using eight bytes of stack.
319 __ sub(esp, Immediate(8)); 334 __ sub(esp, Immediate(8));
320 __ movdbl(Operand(esp, 0), xmm0); 335 __ movdbl(Operand(esp, 0), xmm0);
321 __ fld_d(Operand(esp, 0)); 336 __ fld_d(Operand(esp, 0));
322 __ add(esp, Immediate(8)); 337 __ add(esp, Immediate(8));
323 __ ret(0); 338 __ ret(0);
324 CodeDesc desc; 339 CodeDesc desc;
325 assm.GetCode(&desc); 340 assm.GetCode(&desc);
326 Code* code = Code::cast(HEAP->CreateCode( 341 Code* code = Code::cast(isolate->heap()->CreateCode(
327 desc, 342 desc,
328 Code::ComputeFlags(Code::STUB), 343 Code::ComputeFlags(Code::STUB),
329 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked()); 344 Handle<Object>(isolate->heap()->undefined_value(),
345 isolate))->ToObjectChecked());
330 CHECK(code->IsCode()); 346 CHECK(code->IsCode());
331 #ifdef OBJECT_PRINT 347 #ifdef OBJECT_PRINT
332 Code::cast(code)->Print(); 348 Code::cast(code)->Print();
333 #endif 349 #endif
334 F6 f = FUNCTION_CAST<F6>(Code::cast(code)->entry()); 350 F6 f = FUNCTION_CAST<F6>(Code::cast(code)->entry());
335 double res = f(12); 351 double res = f(12);
336 352
337 ::printf("f() = %f\n", res); 353 ::printf("f() = %f\n", res);
338 CHECK(11.99 < res && res < 12.001); 354 CHECK(11.99 < res && res < 12.001);
339 } 355 }
340 356
341 357
342 typedef int (*F7)(double x, double y); 358 typedef int (*F7)(double x, double y);
343 359
344 TEST(AssemblerIa329) { 360 TEST(AssemblerIa329) {
345 InitializeVM(); 361 InitializeVM();
346 v8::HandleScope scope; 362 v8::HandleScope scope;
347 v8::internal::byte buffer[256]; 363 v8::internal::byte buffer[256];
348 MacroAssembler assm(Isolate::Current(), buffer, sizeof buffer); 364 Isolate* isolate = Isolate::Current();
365 MacroAssembler assm(isolate, buffer, sizeof buffer);
349 enum { kEqual = 0, kGreater = 1, kLess = 2, kNaN = 3, kUndefined = 4 }; 366 enum { kEqual = 0, kGreater = 1, kLess = 2, kNaN = 3, kUndefined = 4 };
350 Label equal_l, less_l, greater_l, nan_l; 367 Label equal_l, less_l, greater_l, nan_l;
351 __ fld_d(Operand(esp, 3 * kPointerSize)); 368 __ fld_d(Operand(esp, 3 * kPointerSize));
352 __ fld_d(Operand(esp, 1 * kPointerSize)); 369 __ fld_d(Operand(esp, 1 * kPointerSize));
353 __ FCmp(); 370 __ FCmp();
354 __ j(parity_even, &nan_l); 371 __ j(parity_even, &nan_l);
355 __ j(equal, &equal_l); 372 __ j(equal, &equal_l);
356 __ j(below, &less_l); 373 __ j(below, &less_l);
357 __ j(above, &greater_l); 374 __ j(above, &greater_l);
358 375
(...skipping 12 matching lines...) Expand all
371 __ mov(eax, kLess); 388 __ mov(eax, kLess);
372 __ ret(0); 389 __ ret(0);
373 390
374 __ bind(&nan_l); 391 __ bind(&nan_l);
375 __ mov(eax, kNaN); 392 __ mov(eax, kNaN);
376 __ ret(0); 393 __ ret(0);
377 394
378 395
379 CodeDesc desc; 396 CodeDesc desc;
380 assm.GetCode(&desc); 397 assm.GetCode(&desc);
381 Code* code = Code::cast(HEAP->CreateCode( 398 Code* code = Code::cast(isolate->heap()->CreateCode(
382 desc, 399 desc,
383 Code::ComputeFlags(Code::STUB), 400 Code::ComputeFlags(Code::STUB),
384 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked()); 401 Handle<Object>(isolate->heap()->undefined_value(),
402 isolate))->ToObjectChecked());
385 CHECK(code->IsCode()); 403 CHECK(code->IsCode());
386 #ifdef OBJECT_PRINT 404 #ifdef OBJECT_PRINT
387 Code::cast(code)->Print(); 405 Code::cast(code)->Print();
388 #endif 406 #endif
389 407
390 F7 f = FUNCTION_CAST<F7>(Code::cast(code)->entry()); 408 F7 f = FUNCTION_CAST<F7>(Code::cast(code)->entry());
391 CHECK_EQ(kLess, f(1.1, 2.2)); 409 CHECK_EQ(kLess, f(1.1, 2.2));
392 CHECK_EQ(kEqual, f(2.2, 2.2)); 410 CHECK_EQ(kEqual, f(2.2, 2.2));
393 CHECK_EQ(kGreater, f(3.3, 2.2)); 411 CHECK_EQ(kGreater, f(3.3, 2.2));
394 CHECK_EQ(kNaN, f(OS::nan_value(), 1.1)); 412 CHECK_EQ(kNaN, f(OS::nan_value(), 1.1));
395 } 413 }
396 414
397 415
398 TEST(AssemblerIa3210) { 416 TEST(AssemblerIa3210) {
399 // Test chaining of label usages within instructions (issue 1644). 417 // Test chaining of label usages within instructions (issue 1644).
400 InitializeVM(); 418 InitializeVM();
401 v8::HandleScope scope; 419 v8::HandleScope scope;
402 Assembler assm(Isolate::Current(), NULL, 0); 420 Isolate* isolate = Isolate::Current();
421 Assembler assm(isolate, NULL, 0);
403 422
404 Label target; 423 Label target;
405 __ j(equal, &target); 424 __ j(equal, &target);
406 __ j(not_equal, &target); 425 __ j(not_equal, &target);
407 __ bind(&target); 426 __ bind(&target);
408 __ nop(); 427 __ nop();
409 } 428 }
410 429
411 430
412 TEST(AssemblerMultiByteNop) { 431 TEST(AssemblerMultiByteNop) {
413 InitializeVM(); 432 InitializeVM();
414 v8::HandleScope scope; 433 v8::HandleScope scope;
415 v8::internal::byte buffer[1024]; 434 v8::internal::byte buffer[1024];
416 Assembler assm(Isolate::Current(), buffer, sizeof(buffer)); 435 Isolate* isolate = Isolate::Current();
436 Assembler assm(isolate, buffer, sizeof(buffer));
417 __ push(ebx); 437 __ push(ebx);
418 __ push(ecx); 438 __ push(ecx);
419 __ push(edx); 439 __ push(edx);
420 __ push(edi); 440 __ push(edi);
421 __ push(esi); 441 __ push(esi);
422 __ mov(eax, 1); 442 __ mov(eax, 1);
423 __ mov(ebx, 2); 443 __ mov(ebx, 2);
424 __ mov(ecx, 3); 444 __ mov(ecx, 3);
425 __ mov(edx, 4); 445 __ mov(edx, 4);
426 __ mov(edi, 5); 446 __ mov(edi, 5);
(...skipping 28 matching lines...) Expand all
455 __ mov(eax, 13); 475 __ mov(eax, 13);
456 __ pop(esi); 476 __ pop(esi);
457 __ pop(edi); 477 __ pop(edi);
458 __ pop(edx); 478 __ pop(edx);
459 __ pop(ecx); 479 __ pop(ecx);
460 __ pop(ebx); 480 __ pop(ebx);
461 __ ret(0); 481 __ ret(0);
462 482
463 CodeDesc desc; 483 CodeDesc desc;
464 assm.GetCode(&desc); 484 assm.GetCode(&desc);
465 Code* code = Code::cast(HEAP->CreateCode( 485 Code* code = Code::cast(isolate->heap()->CreateCode(
466 desc, 486 desc,
467 Code::ComputeFlags(Code::STUB), 487 Code::ComputeFlags(Code::STUB),
468 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked()); 488 Handle<Object>(isolate->heap()->undefined_value(),
489 isolate))->ToObjectChecked());
469 CHECK(code->IsCode()); 490 CHECK(code->IsCode());
470 491
471 F0 f = FUNCTION_CAST<F0>(code->entry()); 492 F0 f = FUNCTION_CAST<F0>(code->entry());
472 int res = f(); 493 int res = f();
473 CHECK_EQ(42, res); 494 CHECK_EQ(42, res);
474 } 495 }
475 496
476 497
477 498
478 499
479 #undef __ 500 #undef __
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698