Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(364)

Side by Side Diff: test/cctest/heap/test-heap.cc

Issue 2695653005: Revert of Remove SIMD.js from V8. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/cctest/cctest.gyp ('k') | test/cctest/interpreter/bytecode_expectations/ForOf.golden » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 CHECK_EQ(type, map->instance_type()); 61 CHECK_EQ(type, map->instance_type());
62 CHECK_EQ(instance_size, map->instance_size()); 62 CHECK_EQ(instance_size, map->instance_size());
63 } 63 }
64 64
65 65
66 TEST(HeapMaps) { 66 TEST(HeapMaps) {
67 CcTest::InitializeVM(); 67 CcTest::InitializeVM();
68 Heap* heap = CcTest::heap(); 68 Heap* heap = CcTest::heap();
69 CheckMap(heap->meta_map(), MAP_TYPE, Map::kSize); 69 CheckMap(heap->meta_map(), MAP_TYPE, Map::kSize);
70 CheckMap(heap->heap_number_map(), HEAP_NUMBER_TYPE, HeapNumber::kSize); 70 CheckMap(heap->heap_number_map(), HEAP_NUMBER_TYPE, HeapNumber::kSize);
71 #define SIMD128_TYPE(TYPE, Type, type, lane_count, lane_type) \
72 CheckMap(heap->type##_map(), SIMD128_VALUE_TYPE, Type::kSize);
73 SIMD128_TYPES(SIMD128_TYPE)
74 #undef SIMD128_TYPE
71 CheckMap(heap->fixed_array_map(), FIXED_ARRAY_TYPE, kVariableSizeSentinel); 75 CheckMap(heap->fixed_array_map(), FIXED_ARRAY_TYPE, kVariableSizeSentinel);
72 CheckMap(heap->string_map(), STRING_TYPE, kVariableSizeSentinel); 76 CheckMap(heap->string_map(), STRING_TYPE, kVariableSizeSentinel);
73 } 77 }
74 78
75 static void VerifyStoredPrototypeMap(Isolate* isolate, 79 static void VerifyStoredPrototypeMap(Isolate* isolate,
76 int stored_map_context_index, 80 int stored_map_context_index,
77 int stored_ctor_context_index) { 81 int stored_ctor_context_index) {
78 Handle<Context> context = isolate->native_context(); 82 Handle<Context> context = isolate->native_context();
79 83
80 Handle<Map> this_map(Map::cast(context->get(stored_map_context_index))); 84 Handle<Map> this_map(Map::cast(context->get(stored_map_context_index)));
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 CheckSmi(isolate, 0, "0"); 317 CheckSmi(isolate, 0, "0");
314 CheckSmi(isolate, 42, "42"); 318 CheckSmi(isolate, 42, "42");
315 CheckSmi(isolate, -42, "-42"); 319 CheckSmi(isolate, -42, "-42");
316 320
317 // Check ToString for Numbers 321 // Check ToString for Numbers
318 CheckNumber(isolate, 1.1, "1.1"); 322 CheckNumber(isolate, 1.1, "1.1");
319 323
320 CheckFindCodeObject(isolate); 324 CheckFindCodeObject(isolate);
321 } 325 }
322 326
327
328 template <typename T, typename LANE_TYPE, int LANES>
329 static void CheckSimdValue(T* value, LANE_TYPE lane_values[LANES],
330 LANE_TYPE other_value) {
331 // Check against lane_values, and check that all lanes can be set to
332 // other_value without disturbing the other lanes.
333 for (int i = 0; i < LANES; i++) {
334 CHECK_EQ(lane_values[i], value->get_lane(i));
335 }
336 for (int i = 0; i < LANES; i++) {
337 value->set_lane(i, other_value); // change the value
338 for (int j = 0; j < LANES; j++) {
339 if (i != j)
340 CHECK_EQ(lane_values[j], value->get_lane(j));
341 else
342 CHECK_EQ(other_value, value->get_lane(j));
343 }
344 value->set_lane(i, lane_values[i]); // restore the lane
345 }
346 CHECK(value->BooleanValue()); // SIMD values are 'true'.
347 }
348
349
350 TEST(SimdObjects) {
351 CcTest::InitializeVM();
352 Isolate* isolate = CcTest::i_isolate();
353 Factory* factory = isolate->factory();
354
355 HandleScope sc(isolate);
356
357 // Float32x4
358 {
359 float lanes[4] = {1, 2, 3, 4};
360 float quiet_NaN = std::numeric_limits<float>::quiet_NaN();
361 float signaling_NaN = std::numeric_limits<float>::signaling_NaN();
362
363 Handle<Float32x4> value = factory->NewFloat32x4(lanes);
364 CHECK(value->IsFloat32x4());
365 CheckSimdValue<Float32x4, float, 4>(*value, lanes, 3.14f);
366
367 // Check special lane values.
368 value->set_lane(1, -0.0);
369 CHECK_EQ(-0.0f, value->get_lane(1));
370 CHECK(std::signbit(value->get_lane(1))); // Sign bit should be preserved.
371 value->set_lane(2, quiet_NaN);
372 CHECK(std::isnan(value->get_lane(2)));
373 value->set_lane(3, signaling_NaN);
374 CHECK(std::isnan(value->get_lane(3)));
375
376 #ifdef OBJECT_PRINT
377 // Check value printing.
378 {
379 value = factory->NewFloat32x4(lanes);
380 std::ostringstream os;
381 value->Float32x4Print(os);
382 CHECK_EQ("1, 2, 3, 4", os.str());
383 }
384 {
385 float special_lanes[4] = {0, -0.0, quiet_NaN, signaling_NaN};
386 value = factory->NewFloat32x4(special_lanes);
387 std::ostringstream os;
388 value->Float32x4Print(os);
389 // Value printing doesn't preserve signed zeroes.
390 CHECK_EQ("0, 0, NaN, NaN", os.str());
391 }
392 #endif // OBJECT_PRINT
393 }
394 // Int32x4
395 {
396 int32_t lanes[4] = {1, 2, 3, 4};
397
398 Handle<Int32x4> value = factory->NewInt32x4(lanes);
399 CHECK(value->IsInt32x4());
400 CheckSimdValue<Int32x4, int32_t, 4>(*value, lanes, 3);
401
402 #ifdef OBJECT_PRINT
403 std::ostringstream os;
404 value->Int32x4Print(os);
405 CHECK_EQ("1, 2, 3, 4", os.str());
406 #endif // OBJECT_PRINT
407 }
408 // Uint32x4
409 {
410 uint32_t lanes[4] = {1, 2, 3, 4};
411
412 Handle<Uint32x4> value = factory->NewUint32x4(lanes);
413 CHECK(value->IsUint32x4());
414 CheckSimdValue<Uint32x4, uint32_t, 4>(*value, lanes, 3);
415
416 #ifdef OBJECT_PRINT
417 std::ostringstream os;
418 value->Uint32x4Print(os);
419 CHECK_EQ("1, 2, 3, 4", os.str());
420 #endif // OBJECT_PRINT
421 }
422 // Bool32x4
423 {
424 bool lanes[4] = {true, false, true, false};
425
426 Handle<Bool32x4> value = factory->NewBool32x4(lanes);
427 CHECK(value->IsBool32x4());
428 CheckSimdValue<Bool32x4, bool, 4>(*value, lanes, false);
429
430 #ifdef OBJECT_PRINT
431 std::ostringstream os;
432 value->Bool32x4Print(os);
433 CHECK_EQ("true, false, true, false", os.str());
434 #endif // OBJECT_PRINT
435 }
436 // Int16x8
437 {
438 int16_t lanes[8] = {1, 2, 3, 4, 5, 6, 7, 8};
439
440 Handle<Int16x8> value = factory->NewInt16x8(lanes);
441 CHECK(value->IsInt16x8());
442 CheckSimdValue<Int16x8, int16_t, 8>(*value, lanes, 32767);
443
444 #ifdef OBJECT_PRINT
445 std::ostringstream os;
446 value->Int16x8Print(os);
447 CHECK_EQ("1, 2, 3, 4, 5, 6, 7, 8", os.str());
448 #endif // OBJECT_PRINT
449 }
450 // Uint16x8
451 {
452 uint16_t lanes[8] = {1, 2, 3, 4, 5, 6, 7, 8};
453
454 Handle<Uint16x8> value = factory->NewUint16x8(lanes);
455 CHECK(value->IsUint16x8());
456 CheckSimdValue<Uint16x8, uint16_t, 8>(*value, lanes, 32767);
457
458 #ifdef OBJECT_PRINT
459 std::ostringstream os;
460 value->Uint16x8Print(os);
461 CHECK_EQ("1, 2, 3, 4, 5, 6, 7, 8", os.str());
462 #endif // OBJECT_PRINT
463 }
464 // Bool16x8
465 {
466 bool lanes[8] = {true, false, true, false, true, false, true, false};
467
468 Handle<Bool16x8> value = factory->NewBool16x8(lanes);
469 CHECK(value->IsBool16x8());
470 CheckSimdValue<Bool16x8, bool, 8>(*value, lanes, false);
471
472 #ifdef OBJECT_PRINT
473 std::ostringstream os;
474 value->Bool16x8Print(os);
475 CHECK_EQ("true, false, true, false, true, false, true, false", os.str());
476 #endif // OBJECT_PRINT
477 }
478 // Int8x16
479 {
480 int8_t lanes[16] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
481
482 Handle<Int8x16> value = factory->NewInt8x16(lanes);
483 CHECK(value->IsInt8x16());
484 CheckSimdValue<Int8x16, int8_t, 16>(*value, lanes, 127);
485
486 #ifdef OBJECT_PRINT
487 std::ostringstream os;
488 value->Int8x16Print(os);
489 CHECK_EQ("1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16", os.str());
490 #endif // OBJECT_PRINT
491 }
492 // Uint8x16
493 {
494 uint8_t lanes[16] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
495
496 Handle<Uint8x16> value = factory->NewUint8x16(lanes);
497 CHECK(value->IsUint8x16());
498 CheckSimdValue<Uint8x16, uint8_t, 16>(*value, lanes, 127);
499
500 #ifdef OBJECT_PRINT
501 std::ostringstream os;
502 value->Uint8x16Print(os);
503 CHECK_EQ("1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16", os.str());
504 #endif // OBJECT_PRINT
505 }
506 // Bool8x16
507 {
508 bool lanes[16] = {true, false, true, false, true, false, true, false,
509 true, false, true, false, true, false, true, false};
510
511 Handle<Bool8x16> value = factory->NewBool8x16(lanes);
512 CHECK(value->IsBool8x16());
513 CheckSimdValue<Bool8x16, bool, 16>(*value, lanes, false);
514
515 #ifdef OBJECT_PRINT
516 std::ostringstream os;
517 value->Bool8x16Print(os);
518 CHECK_EQ(
519 "true, false, true, false, true, false, true, false, true, false, "
520 "true, false, true, false, true, false",
521 os.str());
522 #endif // OBJECT_PRINT
523 }
524 }
525
526
323 TEST(Tagging) { 527 TEST(Tagging) {
324 CcTest::InitializeVM(); 528 CcTest::InitializeVM();
325 int request = 24; 529 int request = 24;
326 CHECK_EQ(request, static_cast<int>(OBJECT_POINTER_ALIGN(request))); 530 CHECK_EQ(request, static_cast<int>(OBJECT_POINTER_ALIGN(request)));
327 CHECK(Smi::FromInt(42)->IsSmi()); 531 CHECK(Smi::FromInt(42)->IsSmi());
328 CHECK(Smi::FromInt(Smi::kMinValue)->IsSmi()); 532 CHECK(Smi::FromInt(Smi::kMinValue)->IsSmi());
329 CHECK(Smi::FromInt(Smi::kMaxValue)->IsSmi()); 533 CHECK(Smi::FromInt(Smi::kMaxValue)->IsSmi());
330 } 534 }
331 535
332 536
(...skipping 6406 matching lines...) Expand 10 before | Expand all | Expand 10 after
6739 CHECK(!heap->code_space()->FirstPage()->Contains(code->address())); 6943 CHECK(!heap->code_space()->FirstPage()->Contains(code->address()));
6740 6944
6741 // Ensure it's not in large object space. 6945 // Ensure it's not in large object space.
6742 MemoryChunk* chunk = MemoryChunk::FromAddress(code->address()); 6946 MemoryChunk* chunk = MemoryChunk::FromAddress(code->address());
6743 CHECK(chunk->owner()->identity() != LO_SPACE); 6947 CHECK(chunk->owner()->identity() != LO_SPACE);
6744 CHECK(chunk->NeverEvacuate()); 6948 CHECK(chunk->NeverEvacuate());
6745 } 6949 }
6746 6950
6747 } // namespace internal 6951 } // namespace internal
6748 } // namespace v8 6952 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/cctest.gyp ('k') | test/cctest/interpreter/bytecode_expectations/ForOf.golden » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698