OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 | 2 |
3 #include <stdlib.h> | 3 #include <stdlib.h> |
4 | 4 |
5 #include "v8.h" | 5 #include "v8.h" |
6 | 6 |
7 #include "execution.h" | 7 #include "execution.h" |
8 #include "factory.h" | 8 #include "factory.h" |
9 #include "macro-assembler.h" | 9 #include "macro-assembler.h" |
10 #include "global-handles.h" | 10 #include "global-handles.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 // Test FindCodeObject | 70 // Test FindCodeObject |
71 #define __ assm. | 71 #define __ assm. |
72 | 72 |
73 Assembler assm(NULL, 0); | 73 Assembler assm(NULL, 0); |
74 | 74 |
75 __ nop(); // supported on all architectures | 75 __ nop(); // supported on all architectures |
76 | 76 |
77 CodeDesc desc; | 77 CodeDesc desc; |
78 assm.GetCode(&desc); | 78 assm.GetCode(&desc); |
79 Object* code = Heap::CreateCode(desc, | 79 Object* code = Heap::CreateCode(desc, |
80 NULL, | |
81 Code::ComputeFlags(Code::STUB), | 80 Code::ComputeFlags(Code::STUB), |
82 Handle<Object>(Heap::undefined_value())); | 81 Handle<Object>(Heap::undefined_value())); |
83 CHECK(code->IsCode()); | 82 CHECK(code->IsCode()); |
84 | 83 |
85 HeapObject* obj = HeapObject::cast(code); | 84 HeapObject* obj = HeapObject::cast(code); |
86 Address obj_addr = obj->address(); | 85 Address obj_addr = obj->address(); |
87 | 86 |
88 for (int i = 0; i < obj->Size(); i += kPointerSize) { | 87 for (int i = 0; i < obj->Size(); i += kPointerSize) { |
89 Object* found = Heap::FindCodeObject(obj_addr + i); | 88 Object* found = Heap::FindCodeObject(obj_addr + i); |
90 CHECK_EQ(code, found); | 89 CHECK_EQ(code, found); |
91 } | 90 } |
92 | 91 |
93 Object* copy = Heap::CreateCode(desc, | 92 Object* copy = Heap::CreateCode(desc, |
94 NULL, | |
95 Code::ComputeFlags(Code::STUB), | 93 Code::ComputeFlags(Code::STUB), |
96 Handle<Object>(Heap::undefined_value())); | 94 Handle<Object>(Heap::undefined_value())); |
97 CHECK(copy->IsCode()); | 95 CHECK(copy->IsCode()); |
98 HeapObject* obj_copy = HeapObject::cast(copy); | 96 HeapObject* obj_copy = HeapObject::cast(copy); |
99 Object* not_right = Heap::FindCodeObject(obj_copy->address() + | 97 Object* not_right = Heap::FindCodeObject(obj_copy->address() + |
100 obj_copy->Size() / 2); | 98 obj_copy->Size() / 2); |
101 CHECK(not_right != code); | 99 CHECK(not_right != code); |
102 } | 100 } |
103 | 101 |
104 | 102 |
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
991 Heap::CollectAllGarbage(true); | 989 Heap::CollectAllGarbage(true); |
992 Heap::CollectAllGarbage(true); | 990 Heap::CollectAllGarbage(true); |
993 Heap::CollectAllGarbage(true); | 991 Heap::CollectAllGarbage(true); |
994 | 992 |
995 // foo should no longer be in the compilation cache | 993 // foo should no longer be in the compilation cache |
996 CHECK(!function->shared()->is_compiled()); | 994 CHECK(!function->shared()->is_compiled()); |
997 // Call foo to get it recompiled. | 995 // Call foo to get it recompiled. |
998 CompileRun("foo()"); | 996 CompileRun("foo()"); |
999 CHECK(function->shared()->is_compiled()); | 997 CHECK(function->shared()->is_compiled()); |
1000 } | 998 } |
OLD | NEW |