OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <limits> | 5 #include <limits> |
6 | 6 |
7 #include "src/compiler/control-builders.h" | 7 #include "src/compiler/control-builders.h" |
8 #include "src/compiler/generic-node-inl.h" | 8 #include "src/compiler/generic-node-inl.h" |
9 #include "src/compiler/node-properties-inl.h" | 9 #include "src/compiler/node-properties-inl.h" |
10 #include "src/compiler/pipeline.h" | 10 #include "src/compiler/pipeline.h" |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 } | 286 } |
287 | 287 |
288 if (Pipeline::SupportedTarget()) { | 288 if (Pipeline::SupportedTarget()) { |
289 Object* result = t.Call(0); | 289 Object* result = t.Call(0); |
290 Object* false_obj = t.heap()->false_value(); | 290 Object* false_obj = t.heap()->false_value(); |
291 CHECK_EQ(false_obj, result); | 291 CHECK_EQ(false_obj, result); |
292 } | 292 } |
293 } | 293 } |
294 | 294 |
295 | 295 |
296 // TODO(titzer): enable all UI32 -> Tagged checking when inline allocation | 296 bool TODO_INT32_TO_TAGGED_WILL_WORK(int32_t v) { |
297 // works. | 297 // TODO(titzer): enable all UI32 -> Tagged checking when inline allocation |
298 #define TODO_UI32_TO_TAGGED_WILL_WORK(v) Smi::IsValid(static_cast<double>(v)) | 298 // works. |
| 299 return Smi::IsValid(v); |
| 300 } |
| 301 |
| 302 |
| 303 bool TODO_UINT32_TO_TAGGED_WILL_WORK(uint32_t v) { |
| 304 // TODO(titzer): enable all UI32 -> Tagged checking when inline allocation |
| 305 // works. |
| 306 return v <= static_cast<uint32_t>(Smi::kMaxValue); |
| 307 } |
| 308 |
299 | 309 |
300 TEST(RunChangeInt32ToTagged) { | 310 TEST(RunChangeInt32ToTagged) { |
301 ChangesLoweringTester<Object*> t; | 311 ChangesLoweringTester<Object*> t; |
302 int32_t input; | 312 int32_t input; |
303 t.BuildLoadAndLower(t.simplified()->ChangeInt32ToTagged(), | 313 t.BuildLoadAndLower(t.simplified()->ChangeInt32ToTagged(), |
304 t.machine()->Load(kMachineWord32), &input); | 314 t.machine()->Load(kMachineWord32), &input); |
305 | 315 |
306 if (Pipeline::SupportedTarget()) { | 316 if (Pipeline::SupportedTarget()) { |
307 FOR_INT32_INPUTS(i) { | 317 FOR_INT32_INPUTS(i) { |
308 input = *i; | 318 input = *i; |
309 Object* result = t.CallWithPotentialGC<Object>(); | 319 Object* result = t.CallWithPotentialGC<Object>(); |
310 if (TODO_UI32_TO_TAGGED_WILL_WORK(input)) { | 320 if (TODO_INT32_TO_TAGGED_WILL_WORK(input)) { |
311 t.CheckNumber(static_cast<double>(input), result); | 321 t.CheckNumber(static_cast<double>(input), result); |
312 } | 322 } |
313 } | 323 } |
314 } | 324 } |
315 | 325 |
316 if (Pipeline::SupportedTarget()) { | 326 if (Pipeline::SupportedTarget()) { |
317 FOR_INT32_INPUTS(i) { | 327 FOR_INT32_INPUTS(i) { |
318 input = *i; | 328 input = *i; |
319 SimulateFullSpace(CcTest::heap()->new_space()); | 329 SimulateFullSpace(CcTest::heap()->new_space()); |
320 Object* result = t.CallWithPotentialGC<Object>(); | 330 Object* result = t.CallWithPotentialGC<Object>(); |
321 if (TODO_UI32_TO_TAGGED_WILL_WORK(input)) { | 331 if (TODO_INT32_TO_TAGGED_WILL_WORK(input)) { |
322 t.CheckNumber(static_cast<double>(input), result); | 332 t.CheckNumber(static_cast<double>(input), result); |
323 } | 333 } |
324 } | 334 } |
325 } | 335 } |
326 } | 336 } |
327 | 337 |
328 | 338 |
329 TEST(RunChangeUint32ToTagged) { | 339 TEST(RunChangeUint32ToTagged) { |
330 ChangesLoweringTester<Object*> t; | 340 ChangesLoweringTester<Object*> t; |
331 uint32_t input; | 341 uint32_t input; |
332 t.BuildLoadAndLower(t.simplified()->ChangeUint32ToTagged(), | 342 t.BuildLoadAndLower(t.simplified()->ChangeUint32ToTagged(), |
333 t.machine()->Load(kMachineWord32), &input); | 343 t.machine()->Load(kMachineWord32), &input); |
334 | 344 |
335 if (Pipeline::SupportedTarget()) { | 345 if (Pipeline::SupportedTarget()) { |
336 FOR_UINT32_INPUTS(i) { | 346 FOR_UINT32_INPUTS(i) { |
337 input = *i; | 347 input = *i; |
338 Object* result = t.CallWithPotentialGC<Object>(); | 348 Object* result = t.CallWithPotentialGC<Object>(); |
339 double expected = static_cast<double>(input); | 349 double expected = static_cast<double>(input); |
340 if (TODO_UI32_TO_TAGGED_WILL_WORK(input)) { | 350 if (TODO_UINT32_TO_TAGGED_WILL_WORK(input)) { |
341 t.CheckNumber(expected, result); | 351 t.CheckNumber(expected, result); |
342 } | 352 } |
343 } | 353 } |
344 } | 354 } |
345 | 355 |
346 if (Pipeline::SupportedTarget()) { | 356 if (Pipeline::SupportedTarget()) { |
347 FOR_UINT32_INPUTS(i) { | 357 FOR_UINT32_INPUTS(i) { |
348 input = *i; | 358 input = *i; |
349 SimulateFullSpace(CcTest::heap()->new_space()); | 359 SimulateFullSpace(CcTest::heap()->new_space()); |
350 Object* result = t.CallWithPotentialGC<Object>(); | 360 Object* result = t.CallWithPotentialGC<Object>(); |
351 double expected = static_cast<double>(static_cast<uint32_t>(input)); | 361 double expected = static_cast<double>(static_cast<uint32_t>(input)); |
352 if (TODO_UI32_TO_TAGGED_WILL_WORK(input)) { | 362 if (TODO_UINT32_TO_TAGGED_WILL_WORK(input)) { |
353 t.CheckNumber(expected, result); | 363 t.CheckNumber(expected, result); |
354 } | 364 } |
355 } | 365 } |
356 } | 366 } |
357 } | 367 } |
358 | 368 |
359 | 369 |
360 // TODO(titzer): lowering of Float64->Tagged needs inline allocation. | 370 // TODO(titzer): lowering of Float64->Tagged needs inline allocation. |
361 #define TODO_FLOAT64_TO_TAGGED false | 371 #define TODO_FLOAT64_TO_TAGGED false |
362 | 372 |
(...skipping 14 matching lines...) Expand all Loading... |
377 | 387 |
378 if (TODO_FLOAT64_TO_TAGGED && Pipeline::SupportedTarget()) { | 388 if (TODO_FLOAT64_TO_TAGGED && Pipeline::SupportedTarget()) { |
379 FOR_FLOAT64_INPUTS(i) { | 389 FOR_FLOAT64_INPUTS(i) { |
380 input = *i; | 390 input = *i; |
381 SimulateFullSpace(CcTest::heap()->new_space()); | 391 SimulateFullSpace(CcTest::heap()->new_space()); |
382 Object* result = t.CallWithPotentialGC<Object>(); | 392 Object* result = t.CallWithPotentialGC<Object>(); |
383 t.CheckNumber(input, result); | 393 t.CheckNumber(input, result); |
384 } | 394 } |
385 } | 395 } |
386 } | 396 } |
OLD | NEW |