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

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: 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 unified diff | Download patch
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 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 549
550 CHECK(!WeakPointerCleared); 550 CHECK(!WeakPointerCleared);
551 551
552 // Mark-compact treats weak reference properly. 552 // Mark-compact treats weak reference properly.
553 heap->CollectGarbage(OLD_SPACE); 553 heap->CollectGarbage(OLD_SPACE);
554 554
555 CHECK(WeakPointerCleared); 555 CHECK(WeakPointerCleared);
556 } 556 }
557 557
558 558
559 TEST(BytecodeArray) {
560 static const uint8_t kRawBytes[] = { 0xc3, 0x7e, 0xa5, 0x5a };
561 static const int kFrameSize = 32;
562 static const int kNumberOfLocals = 20;
563
564 CcTest::InitializeVM();
565 Isolate* isolate = CcTest::i_isolate();
566 Heap* heap = isolate->heap();
567 Factory* factory = isolate->factory();
568 HandleScope scope(isolate);
569
570 // Allocate and initialize BytecodeArray
571 Handle<BytecodeArray> array =
572 factory->NewBytecodeArray(sizeof(kRawBytes), kRawBytes);
573
574 array->set_frame_size(kFrameSize);
575 array->set_number_of_locals(kNumberOfLocals);
576
577 CHECK(array->IsBytecodeArray());
578 CHECK_EQ(array->length(), sizeof(kRawBytes));
579
580 for (int i = 0; i < sizeof(kRawBytes); i++) {
581 CHECK_EQ(array->get(i), kRawBytes[i]);
582 CHECK_EQ(array->GetFirstBytecodeAddress()[i], kRawBytes[i]);
583 }
584
585 // Full garbage collection
586 heap->CollectAllGarbage();
587
588 // BytecodeArray should survive
589 CHECK_EQ(array->length(), sizeof(kRawBytes));
590 CHECK_EQ(array->number_of_locals(), kNumberOfLocals);
591 CHECK_EQ(array->frame_size(), kFrameSize);
592
593 for (int i = 0; i < sizeof(kRawBytes); i++) {
594 CHECK_EQ(array->get(i), kRawBytes[i]);
595 CHECK_EQ(array->GetFirstBytecodeAddress()[i], kRawBytes[i]);
596 }
597 }
598
599
559 static const char* not_so_random_string_table[] = { 600 static const char* not_so_random_string_table[] = {
560 "abstract", 601 "abstract",
561 "boolean", 602 "boolean",
562 "break", 603 "break",
563 "byte", 604 "byte",
564 "case", 605 "case",
565 "catch", 606 "catch",
566 "char", 607 "char",
567 "class", 608 "class",
568 "const", 609 "const",
(...skipping 5484 matching lines...) Expand 10 before | Expand all | Expand 10 after
6053 array->address(), 6094 array->address(),
6054 array->address() + array->Size()); 6095 array->address() + array->Size());
6055 DCHECK(reinterpret_cast<void*>(buffer->Get(1)) == 6096 DCHECK(reinterpret_cast<void*>(buffer->Get(1)) ==
6056 HeapObject::RawField(heap->empty_fixed_array(), 6097 HeapObject::RawField(heap->empty_fixed_array(),
6057 FixedArrayBase::kLengthOffset)); 6098 FixedArrayBase::kLengthOffset));
6058 DCHECK(reinterpret_cast<void*>(buffer->Get(2)) == 6099 DCHECK(reinterpret_cast<void*>(buffer->Get(2)) ==
6059 HeapObject::RawField(heap->empty_fixed_array(), 6100 HeapObject::RawField(heap->empty_fixed_array(),
6060 FixedArrayBase::kLengthOffset)); 6101 FixedArrayBase::kLengthOffset));
6061 delete buffer; 6102 delete buffer;
6062 } 6103 }
OLDNEW
« 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