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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/objects-visiting-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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 2
3 // Test constant pool array code. 3 // Test constant pool array code.
4 4
5 #include "v8.h" 5 #include "v8.h"
6 6
7 #include "factory.h" 7 #include "factory.h"
8 #include "objects.h" 8 #include "objects.h"
9 #include "cctest.h" 9 #include "cctest.h"
10 10
11 using namespace v8::internal; 11 using namespace v8::internal;
12 12
13 13
14 Code* DummyCode(LocalContext* context) {
15 CompileRun("function foo() {};");
16 i::Handle<i::JSFunction> fun = v8::Utils::OpenHandle(
17 *v8::Local<v8::Function>::Cast(
18 (*context)->Global()->Get(v8_str("foo"))));
19 return fun->code();
20 }
21
22
14 TEST(ConstantPool) { 23 TEST(ConstantPool) {
15 LocalContext context; 24 LocalContext context;
16 Isolate* isolate = CcTest::i_isolate(); 25 Isolate* isolate = CcTest::i_isolate();
17 Heap* heap = isolate->heap(); 26 Heap* heap = isolate->heap();
18 Factory* factory = isolate->factory(); 27 Factory* factory = isolate->factory();
19 v8::HandleScope scope(context->GetIsolate()); 28 v8::HandleScope scope(context->GetIsolate());
20 29
21 // Check construction. 30 // Check construction.
22 Handle<ConstantPoolArray> array = factory->NewConstantPoolArray(3, 2, 1); 31 Handle<ConstantPoolArray> array = factory->NewConstantPoolArray(3, 1, 2, 1);
23 CHECK_EQ(array->count_of_int64_entries(), 3); 32 CHECK_EQ(array->count_of_int64_entries(), 3);
24 CHECK_EQ(array->count_of_ptr_entries(), 2); 33 CHECK_EQ(array->count_of_code_ptr_entries(), 1);
34 CHECK_EQ(array->count_of_heap_ptr_entries(), 2);
25 CHECK_EQ(array->count_of_int32_entries(), 1); 35 CHECK_EQ(array->count_of_int32_entries(), 1);
26 CHECK_EQ(array->length(), 6); 36 CHECK_EQ(array->length(), 7);
27 CHECK_EQ(array->first_int64_index(), 0); 37 CHECK_EQ(array->first_int64_index(), 0);
28 CHECK_EQ(array->first_ptr_index(), 3); 38 CHECK_EQ(array->first_code_ptr_index(), 3);
29 CHECK_EQ(array->first_int32_index(), 5); 39 CHECK_EQ(array->first_heap_ptr_index(), 4);
40 CHECK_EQ(array->first_int32_index(), 6);
30 41
31 // Check getters and setters. 42 // Check getters and setters.
32 int64_t big_number = V8_2PART_UINT64_C(0x12345678, 9ABCDEF0); 43 int64_t big_number = V8_2PART_UINT64_C(0x12345678, 9ABCDEF0);
33 Handle<Object> object = factory->NewHeapNumber(4.0); 44 Handle<Object> object = factory->NewHeapNumber(4.0);
45 Code* code = DummyCode(&context);
34 array->set(0, big_number); 46 array->set(0, big_number);
35 array->set(1, 0.5); 47 array->set(1, 0.5);
36 array->set(3, *object); 48 array->set(2, 3e-24);
37 array->set(5, 50); 49 array->set(3, code->entry());
50 array->set(4, code);
51 array->set(5, *object);
52 array->set(6, 50);
38 CHECK_EQ(array->get_int64_entry(0), big_number); 53 CHECK_EQ(array->get_int64_entry(0), big_number);
39 CHECK_EQ(array->get_int64_entry_as_double(1), 0.5); 54 CHECK_EQ(array->get_int64_entry_as_double(1), 0.5);
40 CHECK_EQ(array->get_ptr_entry(3), *object); 55 CHECK_EQ(array->get_int64_entry_as_double(2), 3e-24);
41 CHECK_EQ(array->get_int32_entry(5), 50); 56 CHECK_EQ(array->get_code_ptr_entry(3), code->entry());
57 CHECK_EQ(array->get_heap_ptr_entry(4), code);
58 CHECK_EQ(array->get_heap_ptr_entry(5), *object);
59 CHECK_EQ(array->get_int32_entry(6), 50);
42 60
43 // Check pointers are updated on GC. 61 // Check pointers are updated on GC.
44 Object* old_ptr = array->get_ptr_entry(3); 62 Object* old_ptr = array->get_heap_ptr_entry(5);
45 CHECK_EQ(*object, old_ptr); 63 CHECK_EQ(*object, old_ptr);
46 heap->CollectGarbage(NEW_SPACE); 64 heap->CollectGarbage(NEW_SPACE);
47 Object* new_ptr = array->get_ptr_entry(3); 65 Object* new_ptr = array->get_heap_ptr_entry(5);
48 CHECK_NE(*object, old_ptr); 66 CHECK_NE(*object, old_ptr);
49 CHECK_EQ(*object, new_ptr); 67 CHECK_EQ(*object, new_ptr);
50 } 68 }
OLDNEW
« 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