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