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

Unified Diff: test/cctest/test-constantpool.cc

Issue 183883011: Differentate between code target pointers and heap pointers in constant pools. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 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
« no previous file with comments | « src/objects-visiting-inl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-constantpool.cc
diff --git a/test/cctest/test-constantpool.cc b/test/cctest/test-constantpool.cc
index 9f2436c03436325df7ebfd94dd9a230e84593e1d..e16e45a57d1658518aac9b9aa4e372437fbb9c15 100644
--- a/test/cctest/test-constantpool.cc
+++ b/test/cctest/test-constantpool.cc
@@ -11,6 +11,15 @@
using namespace v8::internal;
+Code* DummyCode(LocalContext* context) {
+ CompileRun("function foo() {};");
+ i::Handle<i::JSFunction> fun = v8::Utils::OpenHandle(
+ *v8::Local<v8::Function>::Cast(
+ (*context)->Global()->Get(v8_str("foo"))));
+ return fun->code();
+}
+
+
TEST(ConstantPool) {
LocalContext context;
Isolate* isolate = CcTest::i_isolate();
@@ -19,32 +28,41 @@ TEST(ConstantPool) {
v8::HandleScope scope(context->GetIsolate());
// Check construction.
- Handle<ConstantPoolArray> array = factory->NewConstantPoolArray(3, 2, 1);
+ Handle<ConstantPoolArray> array = factory->NewConstantPoolArray(3, 1, 2, 1);
CHECK_EQ(array->count_of_int64_entries(), 3);
- CHECK_EQ(array->count_of_ptr_entries(), 2);
+ CHECK_EQ(array->count_of_code_ptr_entries(), 1);
+ CHECK_EQ(array->count_of_heap_ptr_entries(), 2);
CHECK_EQ(array->count_of_int32_entries(), 1);
- CHECK_EQ(array->length(), 6);
+ CHECK_EQ(array->length(), 7);
CHECK_EQ(array->first_int64_index(), 0);
- CHECK_EQ(array->first_ptr_index(), 3);
- CHECK_EQ(array->first_int32_index(), 5);
+ CHECK_EQ(array->first_code_ptr_index(), 3);
+ CHECK_EQ(array->first_heap_ptr_index(), 4);
+ CHECK_EQ(array->first_int32_index(), 6);
// Check getters and setters.
int64_t big_number = V8_2PART_UINT64_C(0x12345678, 9ABCDEF0);
Handle<Object> object = factory->NewHeapNumber(4.0);
+ Code* code = DummyCode(&context);
array->set(0, big_number);
array->set(1, 0.5);
- array->set(3, *object);
- array->set(5, 50);
+ array->set(2, 3e-24);
+ array->set(3, code->entry());
+ array->set(4, code);
+ array->set(5, *object);
+ array->set(6, 50);
CHECK_EQ(array->get_int64_entry(0), big_number);
CHECK_EQ(array->get_int64_entry_as_double(1), 0.5);
- CHECK_EQ(array->get_ptr_entry(3), *object);
- CHECK_EQ(array->get_int32_entry(5), 50);
+ CHECK_EQ(array->get_int64_entry_as_double(2), 3e-24);
+ CHECK_EQ(array->get_code_ptr_entry(3), code->entry());
+ CHECK_EQ(array->get_heap_ptr_entry(4), code);
+ CHECK_EQ(array->get_heap_ptr_entry(5), *object);
+ CHECK_EQ(array->get_int32_entry(6), 50);
// Check pointers are updated on GC.
- Object* old_ptr = array->get_ptr_entry(3);
+ Object* old_ptr = array->get_heap_ptr_entry(5);
CHECK_EQ(*object, old_ptr);
heap->CollectGarbage(NEW_SPACE);
- Object* new_ptr = array->get_ptr_entry(3);
+ Object* new_ptr = array->get_heap_ptr_entry(5);
CHECK_NE(*object, old_ptr);
CHECK_EQ(*object, new_ptr);
}
« no previous file with comments | « src/objects-visiting-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698