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

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

Issue 22601003: Out-of-line constant pool on Arm: Stage 2 - Introduce ConstantPoolArray object. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Enable pointers to be stored in ConstantPoolArray and add tests Created 7 years, 2 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
OLDNEW
(Empty)
1 // Copyright 2013 the V8 project authors. All rights reserved.
2
3 // Test constant pool array code.
4
5 #include "v8.h"
6
7 #include "factory.h"
8 #include "objects.h"
9 #include "cctest.h"
10
11 using namespace v8::internal;
12
13
14 TEST(ConstantPool) {
15 LocalContext context;
16 Isolate* isolate = CcTest::i_isolate();
17 Heap* heap = isolate->heap();
18 Factory* factory = isolate->factory();
19 v8::HandleScope scope(context->GetIsolate());
20
21 // Check construction.
22 Handle<ConstantPoolArray> array = factory->NewConstantPoolArray(3, 2, 1);
23 CHECK_EQ(array->count_of_int64_entries(), 3);
24 CHECK_EQ(array->count_of_ptr_entries(), 2);
25 CHECK_EQ(array->count_of_int32_entries(), 1);
26 CHECK_EQ(array->length(), 6);
27 CHECK_EQ(array->first_int64_index(), 0);
28 CHECK_EQ(array->first_ptr_index(), 3);
29 CHECK_EQ(array->first_int32_index(), 5);
30
31 // Check getters and setters.
32 int64_t big_number = V8_2PART_UINT64_C(0x12345678, 9ABCDEF0);
33 Handle<Object> object = factory->NewHeapNumber(4.0);
34 array->set(0, big_number);
35 array->set(1, 0.5);
36 array->set(3, *object);
37 array->set(5, 50);
38 CHECK_EQ(array->get_int64_entry(0), big_number);
39 CHECK_EQ(array->get_int64_entry_as_double(1), 0.5);
40 CHECK_EQ(array->get_ptr_entry(3), *object);
41 CHECK_EQ(array->get_int32_entry(5), 50);
42
43 // Check MaybeObject getter.
44 Object* value = array->get(1)->ToObjectChecked();
45 CHECK(value->IsNumber());
46 CHECK_EQ(0.5, value->Number());
47 value = array->get(5)->ToObjectChecked();
48 CHECK(value->IsNumber());
49 CHECK_EQ(50.0, value->Number());
50 value = array->get(3)->ToObjectChecked();
51 CHECK_EQ(*object, value);
52
53 // Check pointers are updated on GC.
54 Object* old_ptr = array->get(3)->ToObjectChecked();
55 CHECK_EQ(*object, old_ptr);
56 heap->CollectGarbage(NEW_SPACE);
57 Object* new_ptr = array->get(3)->ToObjectChecked();
58 CHECK_NE(*object, old_ptr);
59 CHECK_EQ(*object, new_ptr);
60 }
OLDNEW
« src/objects-visiting-inl.h ('K') | « test/cctest/cctest.gyp ('k') | tools/v8heapconst.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698