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

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

Issue 1254873002: [interpreter] A couple of minor tweaks to BytecodeArray. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 5 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 | « src/objects-inl.h ('k') | no next file » | 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 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 heap->CollectGarbage(OLD_SPACE); 564 heap->CollectGarbage(OLD_SPACE);
565 565
566 CHECK(WeakPointerCleared); 566 CHECK(WeakPointerCleared);
567 } 567 }
568 568
569 569
570 TEST(BytecodeArray) { 570 TEST(BytecodeArray) {
571 static const uint8_t kRawBytes[] = {0xc3, 0x7e, 0xa5, 0x5a}; 571 static const uint8_t kRawBytes[] = {0xc3, 0x7e, 0xa5, 0x5a};
572 static const int kRawBytesSize = sizeof(kRawBytes); 572 static const int kRawBytesSize = sizeof(kRawBytes);
573 static const int kFrameSize = 32; 573 static const int kFrameSize = 32;
574 static const int kNumberOfLocals = 20;
575 574
576 CcTest::InitializeVM(); 575 CcTest::InitializeVM();
577 Isolate* isolate = CcTest::i_isolate(); 576 Isolate* isolate = CcTest::i_isolate();
578 Heap* heap = isolate->heap(); 577 Heap* heap = isolate->heap();
579 Factory* factory = isolate->factory(); 578 Factory* factory = isolate->factory();
580 HandleScope scope(isolate); 579 HandleScope scope(isolate);
581 580
582 // Allocate and initialize BytecodeArray 581 // Allocate and initialize BytecodeArray
583 Handle<BytecodeArray> array = 582 Handle<BytecodeArray> array =
584 factory->NewBytecodeArray(kRawBytesSize, kRawBytes); 583 factory->NewBytecodeArray(kRawBytesSize, kRawBytes, kFrameSize);
585
586 array->set_frame_size(kFrameSize);
587 array->set_number_of_locals(kNumberOfLocals);
588 584
589 CHECK(array->IsBytecodeArray()); 585 CHECK(array->IsBytecodeArray());
590 CHECK_EQ(array->length(), (int)sizeof(kRawBytes)); 586 CHECK_EQ(array->length(), (int)sizeof(kRawBytes));
587 CHECK_EQ(array->frame_size(), kFrameSize);
591 CHECK_LE(array->address(), array->GetFirstBytecodeAddress()); 588 CHECK_LE(array->address(), array->GetFirstBytecodeAddress());
592 CHECK_GE(array->address() + array->BytecodeArraySize(), 589 CHECK_GE(array->address() + array->BytecodeArraySize(),
593 array->GetFirstBytecodeAddress() + array->length()); 590 array->GetFirstBytecodeAddress() + array->length());
594 for (int i = 0; i < kRawBytesSize; i++) { 591 for (int i = 0; i < kRawBytesSize; i++) {
595 CHECK_EQ(array->GetFirstBytecodeAddress()[i], kRawBytes[i]); 592 CHECK_EQ(array->GetFirstBytecodeAddress()[i], kRawBytes[i]);
596 CHECK_EQ(array->get(i), kRawBytes[i]); 593 CHECK_EQ(array->get(i), kRawBytes[i]);
597 } 594 }
598 595
599 // Full garbage collection 596 // Full garbage collection
600 heap->CollectAllGarbage(); 597 heap->CollectAllGarbage();
601 598
602 // BytecodeArray should survive 599 // BytecodeArray should survive
603 CHECK_EQ(array->length(), kRawBytesSize); 600 CHECK_EQ(array->length(), kRawBytesSize);
604 CHECK_EQ(array->number_of_locals(), kNumberOfLocals);
605 CHECK_EQ(array->frame_size(), kFrameSize); 601 CHECK_EQ(array->frame_size(), kFrameSize);
606 602
607 for (int i = 0; i < kRawBytesSize; i++) { 603 for (int i = 0; i < kRawBytesSize; i++) {
608 CHECK_EQ(array->get(i), kRawBytes[i]); 604 CHECK_EQ(array->get(i), kRawBytes[i]);
609 CHECK_EQ(array->GetFirstBytecodeAddress()[i], kRawBytes[i]); 605 CHECK_EQ(array->GetFirstBytecodeAddress()[i], kRawBytes[i]);
610 } 606 }
611 } 607 }
612 608
613 609
614 static const char* not_so_random_string_table[] = { 610 static const char* not_so_random_string_table[] = {
(...skipping 5431 matching lines...) Expand 10 before | Expand all | Expand 10 after
6046 size_t counter2 = 2000; 6042 size_t counter2 = 2000;
6047 tracer->SampleAllocation(time2, counter2, counter2); 6043 tracer->SampleAllocation(time2, counter2, counter2);
6048 size_t throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); 6044 size_t throughput = tracer->AllocationThroughputInBytesPerMillisecond(100);
6049 CHECK_EQ(2 * (counter2 - counter1) / (time2 - time1), throughput); 6045 CHECK_EQ(2 * (counter2 - counter1) / (time2 - time1), throughput);
6050 int time3 = 1000; 6046 int time3 = 1000;
6051 size_t counter3 = 30000; 6047 size_t counter3 = 30000;
6052 tracer->SampleAllocation(time3, counter3, counter3); 6048 tracer->SampleAllocation(time3, counter3, counter3);
6053 throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); 6049 throughput = tracer->AllocationThroughputInBytesPerMillisecond(100);
6054 CHECK_EQ(2 * (counter3 - counter1) / (time3 - time1), throughput); 6050 CHECK_EQ(2 * (counter3 - counter1) / (time3 - time1), throughput);
6055 } 6051 }
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698