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

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

Issue 1230753004: [Interpreter] Add BytecodeArray class and add to SharedFunctionInfo. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix pedantic build (take2). Created 5 years, 4 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/types.cc ('k') | tools/v8heapconst.py » ('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 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 560
561 CHECK(!WeakPointerCleared); 561 CHECK(!WeakPointerCleared);
562 562
563 // Mark-compact treats weak reference properly. 563 // Mark-compact treats weak reference properly.
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) {
571 static const uint8_t kRawBytes[] = {0xc3, 0x7e, 0xa5, 0x5a};
572 static const int kRawBytesSize = sizeof(kRawBytes);
573 static const int kFrameSize = 32;
574 static const int kNumberOfLocals = 20;
575
576 CcTest::InitializeVM();
577 Isolate* isolate = CcTest::i_isolate();
578 Heap* heap = isolate->heap();
579 Factory* factory = isolate->factory();
580 HandleScope scope(isolate);
581
582 // Allocate and initialize BytecodeArray
583 Handle<BytecodeArray> array =
584 factory->NewBytecodeArray(kRawBytesSize, kRawBytes);
585
586 array->set_frame_size(kFrameSize);
587 array->set_number_of_locals(kNumberOfLocals);
588
589 CHECK(array->IsBytecodeArray());
590 CHECK_EQ(array->length(), (int)sizeof(kRawBytes));
591 CHECK_LE(array->address(), array->GetFirstBytecodeAddress());
592 CHECK_GE(array->address() + array->BytecodeArraySize(),
593 array->GetFirstBytecodeAddress() + array->length());
594 for (int i = 0; i < kRawBytesSize; i++) {
595 CHECK_EQ(array->GetFirstBytecodeAddress()[i], kRawBytes[i]);
596 CHECK_EQ(array->get(i), kRawBytes[i]);
597 }
598
599 // Full garbage collection
600 heap->CollectAllGarbage();
601
602 // BytecodeArray should survive
603 CHECK_EQ(array->length(), kRawBytesSize);
604 CHECK_EQ(array->number_of_locals(), kNumberOfLocals);
605 CHECK_EQ(array->frame_size(), kFrameSize);
606
607 for (int i = 0; i < kRawBytesSize; i++) {
608 CHECK_EQ(array->get(i), kRawBytes[i]);
609 CHECK_EQ(array->GetFirstBytecodeAddress()[i], kRawBytes[i]);
610 }
611 }
612
613
570 static const char* not_so_random_string_table[] = { 614 static const char* not_so_random_string_table[] = {
571 "abstract", 615 "abstract",
572 "boolean", 616 "boolean",
573 "break", 617 "break",
574 "byte", 618 "byte",
575 "case", 619 "case",
576 "catch", 620 "catch",
577 "char", 621 "char",
578 "class", 622 "class",
579 "const", 623 "const",
(...skipping 5422 matching lines...) Expand 10 before | Expand all | Expand 10 after
6002 size_t counter2 = 2000; 6046 size_t counter2 = 2000;
6003 tracer->SampleAllocation(time2, counter2, counter2); 6047 tracer->SampleAllocation(time2, counter2, counter2);
6004 size_t throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); 6048 size_t throughput = tracer->AllocationThroughputInBytesPerMillisecond(100);
6005 CHECK_EQ(2 * (counter2 - counter1) / (time2 - time1), throughput); 6049 CHECK_EQ(2 * (counter2 - counter1) / (time2 - time1), throughput);
6006 int time3 = 1000; 6050 int time3 = 1000;
6007 size_t counter3 = 30000; 6051 size_t counter3 = 30000;
6008 tracer->SampleAllocation(time3, counter3, counter3); 6052 tracer->SampleAllocation(time3, counter3, counter3);
6009 throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); 6053 throughput = tracer->AllocationThroughputInBytesPerMillisecond(100);
6010 CHECK_EQ(2 * (counter3 - counter1) / (time3 - time1), throughput); 6054 CHECK_EQ(2 * (counter3 - counter1) / (time3 - time1), throughput);
6011 } 6055 }
OLDNEW
« no previous file with comments | « src/types.cc ('k') | tools/v8heapconst.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698