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 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 for (int i = 0; i < kArraySize; i++) { | 314 for (int i = 0; i < kArraySize; i++) { |
315 CHECK_EQ(src_copy->get(i), dst->get(i)); | 315 CHECK_EQ(src_copy->get(i), dst->get(i)); |
316 } | 316 } |
317 } | 317 } |
318 | 318 |
319 | 319 |
320 TEST(RunLoadFieldFromUntaggedBase) { | 320 TEST(RunLoadFieldFromUntaggedBase) { |
321 Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3)}; | 321 Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3)}; |
322 | 322 |
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 int offset = static_cast<int>(i * sizeof(Smi*)); |
325 i * sizeof(Smi*), // offset | 325 FieldAccess access = {kUntaggedBase, offset, Handle<Name>(), |
326 Handle<Name>(), Type::Integral32(), kMachineTagged}; | 326 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; | 333 if (!Pipeline::SupportedTarget()) continue; |
334 | 334 |
335 for (int j = -5; j <= 5; j++) { | 335 for (int j = -5; j <= 5; j++) { |
336 Smi* expected = Smi::FromInt(j); | 336 Smi* expected = Smi::FromInt(j); |
337 smis[i] = expected; | 337 smis[i] = expected; |
338 CHECK_EQ(expected, t.Call()); | 338 CHECK_EQ(expected, t.Call()); |
339 } | 339 } |
340 } | 340 } |
341 } | 341 } |
342 | 342 |
343 | 343 |
344 TEST(RunStoreFieldToUntaggedBase) { | 344 TEST(RunStoreFieldToUntaggedBase) { |
345 Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3)}; | 345 Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3)}; |
346 | 346 |
347 for (size_t i = 0; i < ARRAY_SIZE(smis); i++) { | 347 for (size_t i = 0; i < ARRAY_SIZE(smis); i++) { |
348 FieldAccess access = {kUntaggedBase, // untagged base | 348 int offset = static_cast<int>(i * sizeof(Smi*)); |
349 i * sizeof(Smi*), // offset | 349 FieldAccess access = {kUntaggedBase, offset, Handle<Name>(), |
350 Handle<Name>(), Type::Integral32(), kMachineTagged}; | 350 Type::Integral32(), kMachineTagged}; |
351 | 351 |
352 SimplifiedGraphBuilderTester<Object*> t(kMachineTagged); | 352 SimplifiedGraphBuilderTester<Object*> t(kMachineTagged); |
353 Node* p0 = t.Parameter(0); | 353 Node* p0 = t.Parameter(0); |
354 t.StoreField(access, t.PointerConstant(smis), p0); | 354 t.StoreField(access, t.PointerConstant(smis), p0); |
355 t.Return(p0); | 355 t.Return(p0); |
356 t.LowerAllNodes(); | 356 t.LowerAllNodes(); |
357 | 357 |
358 if (!Pipeline::SupportedTarget()) continue; | 358 if (!Pipeline::SupportedTarget()) continue; |
359 | 359 |
360 for (int j = -5; j <= 5; j++) { | 360 for (int j = -5; j <= 5; j++) { |
361 Smi* expected = Smi::FromInt(j); | 361 Smi* expected = Smi::FromInt(j); |
362 smis[i] = Smi::FromInt(-100); | 362 smis[i] = Smi::FromInt(-100); |
363 CHECK_EQ(expected, t.Call(expected)); | 363 CHECK_EQ(expected, t.Call(expected)); |
364 CHECK_EQ(expected, smis[i]); | 364 CHECK_EQ(expected, smis[i]); |
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 = i; j < ARRAY_SIZE(smis); j++) { // for element index |
376 ElementAccess access = {kUntaggedBase, // untagged base | 376 int offset = static_cast<int>(i * sizeof(Smi*)); |
377 i * sizeof(Smi*), // header size | 377 ElementAccess access = {kUntaggedBase, offset, Type::Integral32(), |
378 Type::Integral32(), kMachineTagged}; | 378 kMachineTagged}; |
379 | 379 |
380 SimplifiedGraphBuilderTester<Object*> t; | 380 SimplifiedGraphBuilderTester<Object*> t; |
381 Node* load = | 381 Node* load = t.LoadElement(access, t.PointerConstant(smis), |
382 t.LoadElement(access, t.PointerConstant(smis), t.Int32Constant(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), |
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 = i; j < ARRAY_SIZE(smis); j++) { // for element index |
404 ElementAccess access = {kUntaggedBase, // untagged base | 404 int offset = static_cast<int>(i * sizeof(Smi*)); |
405 i * sizeof(Smi*), // header size | 405 ElementAccess access = {kUntaggedBase, offset, Type::Integral32(), |
406 Type::Integral32(), 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), t.Int32Constant(j), p0); | 410 t.StoreElement(access, t.PointerConstant(smis), |
| 411 t.Int32Constant(static_cast<int>(j)), p0); |
411 t.Return(p0); | 412 t.Return(p0); |
412 t.LowerAllNodes(); | 413 t.LowerAllNodes(); |
413 | 414 |
414 if (!Pipeline::SupportedTarget()) continue; | 415 if (!Pipeline::SupportedTarget()) continue; |
415 | 416 |
416 for (int k = -5; k <= 5; k++) { | 417 for (int k = -5; k <= 5; k++) { |
417 Smi* expected = Smi::FromInt(k); | 418 Smi* expected = Smi::FromInt(k); |
418 smis[i + j] = Smi::FromInt(-100); | 419 smis[i + j] = Smi::FromInt(-100); |
419 CHECK_EQ(expected, t.Call(expected)); | 420 CHECK_EQ(expected, t.Call(expected)); |
420 CHECK_EQ(expected, smis[i + j]); | 421 CHECK_EQ(expected, smis[i + j]); |
421 } | 422 } |
422 } | 423 } |
423 } | 424 } |
424 } | 425 } |
OLD | NEW |