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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
365 } | 365 } |
366 } | 366 } |
367 } | 367 } |
368 | 368 |
369 | 369 |
370 TEST(RunLoadElementFromUntaggedBase) { | 370 TEST(RunLoadElementFromUntaggedBase) { |
371 Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3), | 371 Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3), |
372 Smi::FromInt(4), Smi::FromInt(5)}; | 372 Smi::FromInt(4), Smi::FromInt(5)}; |
373 | 373 |
374 for (size_t i = 0; i < ARRAY_SIZE(smis); i++) { // for header sizes | 374 for (size_t i = 0; i < ARRAY_SIZE(smis); i++) { // for header sizes |
375 for (size_t j = i; j < ARRAY_SIZE(smis); j++) { // for element index | 375 for (size_t j = 0; (i + j) < ARRAY_SIZE(smis); j++) { // for element index |
376 int offset = static_cast<int>(i * sizeof(Smi*)); | 376 int offset = static_cast<int>(i * sizeof(Smi*)); |
377 ElementAccess access = {kUntaggedBase, offset, Type::Integral32(), | 377 ElementAccess access = {kUntaggedBase, offset, Type::Integral32(), |
378 kMachineTagged}; | 378 kMachineTagged}; |
379 | 379 |
380 SimplifiedGraphBuilderTester<Object*> t; | 380 SimplifiedGraphBuilderTester<Object*> t; |
381 Node* load = t.LoadElement(access, t.PointerConstant(smis), | 381 Node* load = t.LoadElement(access, t.PointerConstant(smis), |
382 t.Int32Constant(static_cast<int>(j))); | 382 t.Int32Constant(static_cast<int>(j))); |
383 t.Return(load); | 383 t.Return(load); |
384 t.LowerAllNodes(); | 384 t.LowerAllNodes(); |
385 | 385 |
386 if (!Pipeline::SupportedTarget()) continue; | 386 if (!Pipeline::SupportedTarget()) continue; |
387 | 387 |
388 for (int k = -5; k <= 5; k++) { | 388 for (int k = -5; k <= 5; k++) { |
389 Smi* expected = Smi::FromInt(k); | 389 Smi* expected = Smi::FromInt(k); |
390 smis[i + j] = expected; | 390 smis[i + j] = expected; |
391 CHECK_EQ(expected, t.Call()); | 391 CHECK_EQ(expected, t.Call()); |
392 } | 392 } |
393 } | 393 } |
394 } | 394 } |
395 } | 395 } |
396 | 396 |
397 | 397 |
398 TEST(RunStoreElementFromUntaggedBase) { | 398 TEST(RunStoreElementFromUntaggedBase) { |
399 Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3), | 399 Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3), |
Michael Starzinger
2014/08/04 14:09:58
suggestion: We could memset the array to canary va
| |
400 Smi::FromInt(4), Smi::FromInt(5)}; | 400 Smi::FromInt(4), Smi::FromInt(5)}; |
401 | 401 |
402 for (size_t i = 0; i < ARRAY_SIZE(smis); i++) { // for header sizes | 402 for (size_t i = 0; i < ARRAY_SIZE(smis); i++) { // for header sizes |
403 for (size_t j = i; j < ARRAY_SIZE(smis); j++) { // for element index | 403 for (size_t j = 0; (i + j) < ARRAY_SIZE(smis); j++) { // for element index |
404 int offset = static_cast<int>(i * sizeof(Smi*)); | 404 int offset = static_cast<int>(i * sizeof(Smi*)); |
405 ElementAccess access = {kUntaggedBase, offset, Type::Integral32(), | 405 ElementAccess access = {kUntaggedBase, offset, Type::Integral32(), |
406 kMachineTagged}; | 406 kMachineTagged}; |
407 | 407 |
408 SimplifiedGraphBuilderTester<Object*> t(kMachineTagged); | 408 SimplifiedGraphBuilderTester<Object*> t(kMachineTagged); |
409 Node* p0 = t.Parameter(0); | 409 Node* p0 = t.Parameter(0); |
410 t.StoreElement(access, t.PointerConstant(smis), | 410 t.StoreElement(access, t.PointerConstant(smis), |
411 t.Int32Constant(static_cast<int>(j)), p0); | 411 t.Int32Constant(static_cast<int>(j)), p0); |
412 t.Return(p0); | 412 t.Return(p0); |
413 t.LowerAllNodes(); | 413 t.LowerAllNodes(); |
414 | 414 |
415 if (!Pipeline::SupportedTarget()) continue; | 415 if (!Pipeline::SupportedTarget()) continue; |
416 | 416 |
417 printf("i = %ld, j = %ld\n", i, j); | |
Michael Starzinger
2014/08/04 14:09:58
nit: Looks like a leftover.
| |
417 for (int k = -5; k <= 5; k++) { | 418 for (int k = -5; k <= 5; k++) { |
418 Smi* expected = Smi::FromInt(k); | 419 Smi* expected = Smi::FromInt(k); |
419 smis[i + j] = Smi::FromInt(-100); | 420 smis[i + j] = Smi::FromInt(-100); |
420 CHECK_EQ(expected, t.Call(expected)); | 421 CHECK_EQ(expected, t.Call(expected)); |
421 CHECK_EQ(expected, smis[i + j]); | 422 CHECK_EQ(expected, smis[i + j]); |
422 } | 423 } |
423 } | 424 } |
424 } | 425 } |
425 } | 426 } |
OLD | NEW |