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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 for (size_t i = 0; i < ARRAY_SIZE(smis); i++) { | 323 for (size_t i = 0; i < ARRAY_SIZE(smis); i++) { |
324 FieldAccess access = {kUntaggedBase, // untagged base | 324 FieldAccess access = {kUntaggedBase, // untagged base |
325 i * sizeof(Smi*), // offset | 325 i * sizeof(Smi*), // offset |
326 Handle<Name>(), Type::Integral32(), kMachineTagged}; | 326 Handle<Name>(), Type::Integral32(), kMachineTagged}; |
327 | 327 |
328 SimplifiedGraphBuilderTester<Object*> t; | 328 SimplifiedGraphBuilderTester<Object*> t; |
329 Node* load = t.LoadField(access, t.PointerConstant(smis)); | 329 Node* load = t.LoadField(access, t.PointerConstant(smis)); |
330 t.Return(load); | 330 t.Return(load); |
331 t.LowerAllNodes(); | 331 t.LowerAllNodes(); |
332 | 332 |
| 333 if (!Pipeline::SupportedTarget()) continue; |
| 334 |
333 for (int j = -5; j <= 5; j++) { | 335 for (int j = -5; j <= 5; j++) { |
334 Smi* expected = Smi::FromInt(j); | 336 Smi* expected = Smi::FromInt(j); |
335 smis[i] = expected; | 337 smis[i] = expected; |
336 CHECK_EQ(expected, t.Call()); | 338 CHECK_EQ(expected, t.Call()); |
337 } | 339 } |
338 } | 340 } |
339 } | 341 } |
340 | 342 |
341 | 343 |
342 TEST(RunStoreFieldToUntaggedBase) { | 344 TEST(RunStoreFieldToUntaggedBase) { |
343 Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3)}; | 345 Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3)}; |
344 | 346 |
345 for (size_t i = 0; i < ARRAY_SIZE(smis); i++) { | 347 for (size_t i = 0; i < ARRAY_SIZE(smis); i++) { |
346 FieldAccess access = {kUntaggedBase, // untagged base | 348 FieldAccess access = {kUntaggedBase, // untagged base |
347 i * sizeof(Smi*), // offset | 349 i * sizeof(Smi*), // offset |
348 Handle<Name>(), Type::Integral32(), kMachineTagged}; | 350 Handle<Name>(), Type::Integral32(), kMachineTagged}; |
349 | 351 |
350 SimplifiedGraphBuilderTester<Object*> t(kMachineTagged); | 352 SimplifiedGraphBuilderTester<Object*> t(kMachineTagged); |
351 Node* p0 = t.Parameter(0); | 353 Node* p0 = t.Parameter(0); |
352 t.StoreField(access, t.PointerConstant(smis), p0); | 354 t.StoreField(access, t.PointerConstant(smis), p0); |
353 t.Return(p0); | 355 t.Return(p0); |
354 t.LowerAllNodes(); | 356 t.LowerAllNodes(); |
355 | 357 |
| 358 if (!Pipeline::SupportedTarget()) continue; |
| 359 |
356 for (int j = -5; j <= 5; j++) { | 360 for (int j = -5; j <= 5; j++) { |
357 Smi* expected = Smi::FromInt(j); | 361 Smi* expected = Smi::FromInt(j); |
358 smis[i] = Smi::FromInt(-100); | 362 smis[i] = Smi::FromInt(-100); |
359 CHECK_EQ(expected, t.Call(expected)); | 363 CHECK_EQ(expected, t.Call(expected)); |
360 CHECK_EQ(expected, smis[i]); | 364 CHECK_EQ(expected, smis[i]); |
361 } | 365 } |
362 } | 366 } |
363 } | 367 } |
364 | 368 |
365 | 369 |
366 TEST(RunLoadElementFromUntaggedBase) { | 370 TEST(RunLoadElementFromUntaggedBase) { |
367 Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3), | 371 Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3), |
368 Smi::FromInt(4), Smi::FromInt(5)}; | 372 Smi::FromInt(4), Smi::FromInt(5)}; |
369 | 373 |
370 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 |
371 for (size_t j = i; j < ARRAY_SIZE(smis); j++) { // for element index | 375 for (size_t j = i; j < ARRAY_SIZE(smis); j++) { // for element index |
372 ElementAccess access = {kUntaggedBase, // untagged base | 376 ElementAccess access = {kUntaggedBase, // untagged base |
373 i * sizeof(Smi*), // header size | 377 i * sizeof(Smi*), // header size |
374 Type::Integral32(), kMachineTagged}; | 378 Type::Integral32(), kMachineTagged}; |
375 | 379 |
376 SimplifiedGraphBuilderTester<Object*> t; | 380 SimplifiedGraphBuilderTester<Object*> t; |
377 Node* load = | 381 Node* load = |
378 t.LoadElement(access, t.PointerConstant(smis), t.Int32Constant(j)); | 382 t.LoadElement(access, t.PointerConstant(smis), t.Int32Constant(j)); |
379 t.Return(load); | 383 t.Return(load); |
380 t.LowerAllNodes(); | 384 t.LowerAllNodes(); |
381 | 385 |
| 386 if (!Pipeline::SupportedTarget()) continue; |
| 387 |
382 for (int k = -5; k <= 5; k++) { | 388 for (int k = -5; k <= 5; k++) { |
383 Smi* expected = Smi::FromInt(k); | 389 Smi* expected = Smi::FromInt(k); |
384 smis[i + j] = expected; | 390 smis[i + j] = expected; |
385 CHECK_EQ(expected, t.Call()); | 391 CHECK_EQ(expected, t.Call()); |
386 } | 392 } |
387 } | 393 } |
388 } | 394 } |
389 } | 395 } |
390 | 396 |
391 | 397 |
392 TEST(RunStoreElementFromUntaggedBase) { | 398 TEST(RunStoreElementFromUntaggedBase) { |
393 Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3), | 399 Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3), |
394 Smi::FromInt(4), Smi::FromInt(5)}; | 400 Smi::FromInt(4), Smi::FromInt(5)}; |
395 | 401 |
396 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 |
397 for (size_t j = i; j < ARRAY_SIZE(smis); j++) { // for element index | 403 for (size_t j = i; j < ARRAY_SIZE(smis); j++) { // for element index |
398 ElementAccess access = {kUntaggedBase, // untagged base | 404 ElementAccess access = {kUntaggedBase, // untagged base |
399 i * sizeof(Smi*), // header size | 405 i * sizeof(Smi*), // header size |
400 Type::Integral32(), kMachineTagged}; | 406 Type::Integral32(), kMachineTagged}; |
401 | 407 |
402 SimplifiedGraphBuilderTester<Object*> t(kMachineTagged); | 408 SimplifiedGraphBuilderTester<Object*> t(kMachineTagged); |
403 Node* p0 = t.Parameter(0); | 409 Node* p0 = t.Parameter(0); |
404 t.StoreElement(access, t.PointerConstant(smis), t.Int32Constant(j), p0); | 410 t.StoreElement(access, t.PointerConstant(smis), t.Int32Constant(j), p0); |
405 t.Return(p0); | 411 t.Return(p0); |
406 t.LowerAllNodes(); | 412 t.LowerAllNodes(); |
407 | 413 |
| 414 if (!Pipeline::SupportedTarget()) continue; |
| 415 |
408 for (int k = -5; k <= 5; k++) { | 416 for (int k = -5; k <= 5; k++) { |
409 Smi* expected = Smi::FromInt(k); | 417 Smi* expected = Smi::FromInt(k); |
410 smis[i + j] = Smi::FromInt(-100); | 418 smis[i + j] = Smi::FromInt(-100); |
411 CHECK_EQ(expected, t.Call(expected)); | 419 CHECK_EQ(expected, t.Call(expected)); |
412 CHECK_EQ(expected, smis[i + j]); | 420 CHECK_EQ(expected, smis[i + j]); |
413 } | 421 } |
414 } | 422 } |
415 } | 423 } |
416 } | 424 } |
OLD | NEW |