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

Unified 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: Don't use extra memory for BytecodeArray in SharedFunctionInfo and add a BytecodeArray test. 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 side-by-side diff with in-line comments
Download patch
« src/types.cc ('K') | « src/types.cc ('k') | tools/v8heapconst.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-heap.cc
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc
index b6b96adcaf36ce924fdcd7c7cc964811f7dc4221..387829bfa5e8d7fe8af7707afc599b9182da9157 100644
--- a/test/cctest/test-heap.cc
+++ b/test/cctest/test-heap.cc
@@ -556,6 +556,47 @@ TEST(DeleteWeakGlobalHandle) {
}
+TEST(BytecodeArray) {
+ static const uint8_t kRawBytes[] = { 0xc3, 0x7e, 0xa5, 0x5a };
+ static const int kFrameSize = 32;
+ static const int kNumberOfLocals = 20;
+
+ CcTest::InitializeVM();
+ Isolate* isolate = CcTest::i_isolate();
+ Heap* heap = isolate->heap();
+ Factory* factory = isolate->factory();
+ HandleScope scope(isolate);
+
+ // Allocate and initialize BytecodeArray
+ Handle<BytecodeArray> array =
+ factory->NewBytecodeArray(sizeof(kRawBytes), kRawBytes);
+
+ array->set_frame_size(kFrameSize);
+ array->set_number_of_locals(kNumberOfLocals);
+
+ CHECK(array->IsBytecodeArray());
+ CHECK_EQ(array->length(), sizeof(kRawBytes));
+
+ for (int i = 0; i < sizeof(kRawBytes); i++) {
+ CHECK_EQ(array->get(i), kRawBytes[i]);
+ CHECK_EQ(array->GetFirstBytecodeAddress()[i], kRawBytes[i]);
+ }
+
+ // Full garbage collection
+ heap->CollectAllGarbage();
+
+ // BytecodeArray should survive
+ CHECK_EQ(array->length(), sizeof(kRawBytes));
+ CHECK_EQ(array->number_of_locals(), kNumberOfLocals);
+ CHECK_EQ(array->frame_size(), kFrameSize);
+
+ for (int i = 0; i < sizeof(kRawBytes); i++) {
+ CHECK_EQ(array->get(i), kRawBytes[i]);
+ CHECK_EQ(array->GetFirstBytecodeAddress()[i], kRawBytes[i]);
+ }
+}
+
+
static const char* not_so_random_string_table[] = {
"abstract",
"boolean",
« src/types.cc ('K') | « src/types.cc ('k') | tools/v8heapconst.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698