OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/factory.h" | 5 #include "src/factory.h" |
6 #include "src/isolate.h" | 6 #include "src/isolate.h" |
7 #include "src/objects.h" | 7 #include "src/objects.h" |
8 // FIXME(mstarzinger, marja): This is weird, but required because of the missing | 8 // FIXME(mstarzinger, marja): This is weird, but required because of the missing |
9 // (disallowed) include: src/factory.h -> src/objects-inl.h | 9 // (disallowed) include: src/factory.h -> src/objects-inl.h |
10 #include "src/objects-inl.h" | 10 #include "src/objects-inl.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 code_desc.reloc_size = 0; | 35 code_desc.reloc_size = 0; |
36 code_desc.origin = nullptr; | 36 code_desc.origin = nullptr; |
37 code_desc.unwinding_info = nullptr; | 37 code_desc.unwinding_info = nullptr; |
38 code_desc.unwinding_info_size = 0; | 38 code_desc.unwinding_info_size = 0; |
39 | 39 |
40 Handle<Code> code = CcTest::i_isolate()->factory()->NewCode( | 40 Handle<Code> code = CcTest::i_isolate()->factory()->NewCode( |
41 code_desc, 0, Handle<Object>::null()); | 41 code_desc, 0, Handle<Object>::null()); |
42 | 42 |
43 CHECK(!code->has_unwinding_info()); | 43 CHECK(!code->has_unwinding_info()); |
44 CHECK_EQ(code->instruction_size(), buffer_size); | 44 CHECK_EQ(code->instruction_size(), buffer_size); |
45 CHECK_EQ(memcmp(code->instruction_start(), buffer, buffer_size), 0); | 45 CHECK_EQ(0, memcmp(code->instruction_start(), buffer, buffer_size)); |
46 CHECK_EQ(code->instruction_end() - reinterpret_cast<byte*>(*code), | 46 CHECK_EQ(code->instruction_end() - reinterpret_cast<byte*>(*code), |
47 Code::kHeaderSize + buffer_size - kHeapObjectTag); | 47 Code::kHeaderSize + buffer_size - kHeapObjectTag); |
48 } | 48 } |
49 | 49 |
50 TEST(CodeLayoutWithUnwindingInfo) { | 50 TEST(CodeLayoutWithUnwindingInfo) { |
51 CcTest::InitializeVM(); | 51 CcTest::InitializeVM(); |
52 HandleScope handle_scope(CcTest::i_isolate()); | 52 HandleScope handle_scope(CcTest::i_isolate()); |
53 | 53 |
54 // "Hello, World!" in ASCII. | 54 // "Hello, World!" in ASCII. |
55 byte buffer_array[13] = {0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x2c, 0x20, | 55 byte buffer_array[13] = {0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x2c, 0x20, |
(...skipping 16 matching lines...) Expand all Loading... |
72 code_desc.reloc_size = 0; | 72 code_desc.reloc_size = 0; |
73 code_desc.origin = nullptr; | 73 code_desc.origin = nullptr; |
74 code_desc.unwinding_info = unwinding_info; | 74 code_desc.unwinding_info = unwinding_info; |
75 code_desc.unwinding_info_size = unwinding_info_size; | 75 code_desc.unwinding_info_size = unwinding_info_size; |
76 | 76 |
77 Handle<Code> code = CcTest::i_isolate()->factory()->NewCode( | 77 Handle<Code> code = CcTest::i_isolate()->factory()->NewCode( |
78 code_desc, 0, Handle<Object>::null()); | 78 code_desc, 0, Handle<Object>::null()); |
79 | 79 |
80 CHECK(code->has_unwinding_info()); | 80 CHECK(code->has_unwinding_info()); |
81 CHECK_EQ(code->instruction_size(), buffer_size); | 81 CHECK_EQ(code->instruction_size(), buffer_size); |
82 CHECK_EQ(memcmp(code->instruction_start(), buffer, buffer_size), 0); | 82 CHECK_EQ(0, memcmp(code->instruction_start(), buffer, buffer_size)); |
83 CHECK(IsAligned(code->GetUnwindingInfoSizeOffset(), 8)); | 83 CHECK(IsAligned(code->GetUnwindingInfoSizeOffset(), 8)); |
84 CHECK_EQ(code->unwinding_info_size(), unwinding_info_size); | 84 CHECK_EQ(code->unwinding_info_size(), unwinding_info_size); |
85 CHECK( | 85 CHECK( |
86 IsAligned(reinterpret_cast<uintptr_t>(code->unwinding_info_start()), 8)); | 86 IsAligned(reinterpret_cast<uintptr_t>(code->unwinding_info_start()), 8)); |
87 CHECK_EQ( | 87 CHECK_EQ( |
88 memcmp(code->unwinding_info_start(), unwinding_info, unwinding_info_size), | 88 memcmp(code->unwinding_info_start(), unwinding_info, unwinding_info_size), |
89 0); | 89 0); |
90 CHECK_EQ(code->unwinding_info_end() - reinterpret_cast<byte*>(*code), | 90 CHECK_EQ(code->unwinding_info_end() - reinterpret_cast<byte*>(*code), |
91 Code::kHeaderSize + RoundUp(buffer_size, kInt64Size) + kInt64Size + | 91 Code::kHeaderSize + RoundUp(buffer_size, kInt64Size) + kInt64Size + |
92 unwinding_info_size - kHeapObjectTag); | 92 unwinding_info_size - kHeapObjectTag); |
93 } | 93 } |
OLD | NEW |