OLD | NEW |
1 // Copyright 2007-2010 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2010 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 static uint32_t Encode(const ExternalReferenceEncoder& encoder, T id) { | 91 static uint32_t Encode(const ExternalReferenceEncoder& encoder, T id) { |
92 return encoder.Encode(AddressOf(id)); | 92 return encoder.Encode(AddressOf(id)); |
93 } | 93 } |
94 | 94 |
95 | 95 |
96 static int make_code(TypeCode type, int id) { | 96 static int make_code(TypeCode type, int id) { |
97 return static_cast<uint32_t>(type) << kReferenceTypeShift | id; | 97 return static_cast<uint32_t>(type) << kReferenceTypeShift | id; |
98 } | 98 } |
99 | 99 |
100 | 100 |
| 101 #ifdef ENABLE_DEBUGGER_SUPPORT |
101 static int register_code(int reg) { | 102 static int register_code(int reg) { |
102 return Debug::k_register_address << kDebugIdShift | reg; | 103 return Debug::k_register_address << kDebugIdShift | reg; |
103 } | 104 } |
| 105 #endif // ENABLE_DEBUGGER_SUPPORT |
104 | 106 |
105 | 107 |
106 TEST(ExternalReferenceEncoder) { | 108 TEST(ExternalReferenceEncoder) { |
107 StatsTable::SetCounterFunction(counter_function); | 109 StatsTable::SetCounterFunction(counter_function); |
108 Heap::Setup(false); | 110 Heap::Setup(false); |
109 ExternalReferenceEncoder encoder; | 111 ExternalReferenceEncoder encoder; |
110 CHECK_EQ(make_code(BUILTIN, Builtins::ArrayCode), | 112 CHECK_EQ(make_code(BUILTIN, Builtins::ArrayCode), |
111 Encode(encoder, Builtins::ArrayCode)); | 113 Encode(encoder, Builtins::ArrayCode)); |
112 CHECK_EQ(make_code(RUNTIME_FUNCTION, Runtime::kAbort), | 114 CHECK_EQ(make_code(RUNTIME_FUNCTION, Runtime::kAbort), |
113 Encode(encoder, Runtime::kAbort)); | 115 Encode(encoder, Runtime::kAbort)); |
114 CHECK_EQ(make_code(IC_UTILITY, IC::kLoadCallbackProperty), | 116 CHECK_EQ(make_code(IC_UTILITY, IC::kLoadCallbackProperty), |
115 Encode(encoder, IC_Utility(IC::kLoadCallbackProperty))); | 117 Encode(encoder, IC_Utility(IC::kLoadCallbackProperty))); |
| 118 #ifdef ENABLE_DEBUGGER_SUPPORT |
116 CHECK_EQ(make_code(DEBUG_ADDRESS, register_code(3)), | 119 CHECK_EQ(make_code(DEBUG_ADDRESS, register_code(3)), |
117 Encode(encoder, Debug_Address(Debug::k_register_address, 3))); | 120 Encode(encoder, Debug_Address(Debug::k_register_address, 3))); |
| 121 #endif // ENABLE_DEBUGGER_SUPPORT |
118 ExternalReference keyed_load_function_prototype = | 122 ExternalReference keyed_load_function_prototype = |
119 ExternalReference(&Counters::keyed_load_function_prototype); | 123 ExternalReference(&Counters::keyed_load_function_prototype); |
120 CHECK_EQ(make_code(STATS_COUNTER, Counters::k_keyed_load_function_prototype), | 124 CHECK_EQ(make_code(STATS_COUNTER, Counters::k_keyed_load_function_prototype), |
121 encoder.Encode(keyed_load_function_prototype.address())); | 125 encoder.Encode(keyed_load_function_prototype.address())); |
122 ExternalReference the_hole_value_location = | 126 ExternalReference the_hole_value_location = |
123 ExternalReference::the_hole_value_location(); | 127 ExternalReference::the_hole_value_location(); |
124 CHECK_EQ(make_code(UNCLASSIFIED, 2), | 128 CHECK_EQ(make_code(UNCLASSIFIED, 2), |
125 encoder.Encode(the_hole_value_location.address())); | 129 encoder.Encode(the_hole_value_location.address())); |
126 ExternalReference stack_limit_address = | 130 ExternalReference stack_limit_address = |
127 ExternalReference::address_of_stack_limit(); | 131 ExternalReference::address_of_stack_limit(); |
128 CHECK_EQ(make_code(UNCLASSIFIED, 4), | 132 CHECK_EQ(make_code(UNCLASSIFIED, 4), |
129 encoder.Encode(stack_limit_address.address())); | 133 encoder.Encode(stack_limit_address.address())); |
130 ExternalReference real_stack_limit_address = | 134 ExternalReference real_stack_limit_address = |
131 ExternalReference::address_of_real_stack_limit(); | 135 ExternalReference::address_of_real_stack_limit(); |
132 CHECK_EQ(make_code(UNCLASSIFIED, 5), | 136 CHECK_EQ(make_code(UNCLASSIFIED, 5), |
133 encoder.Encode(real_stack_limit_address.address())); | 137 encoder.Encode(real_stack_limit_address.address())); |
| 138 #ifdef ENABLE_DEBUGGER_SUPPORT |
134 CHECK_EQ(make_code(UNCLASSIFIED, 15), | 139 CHECK_EQ(make_code(UNCLASSIFIED, 15), |
135 encoder.Encode(ExternalReference::debug_break().address())); | 140 encoder.Encode(ExternalReference::debug_break().address())); |
| 141 #endif // ENABLE_DEBUGGER_SUPPORT |
136 CHECK_EQ(make_code(UNCLASSIFIED, 10), | 142 CHECK_EQ(make_code(UNCLASSIFIED, 10), |
137 encoder.Encode(ExternalReference::new_space_start().address())); | 143 encoder.Encode(ExternalReference::new_space_start().address())); |
138 CHECK_EQ(make_code(UNCLASSIFIED, 3), | 144 CHECK_EQ(make_code(UNCLASSIFIED, 3), |
139 encoder.Encode(ExternalReference::roots_address().address())); | 145 encoder.Encode(ExternalReference::roots_address().address())); |
140 } | 146 } |
141 | 147 |
142 | 148 |
143 TEST(ExternalReferenceDecoder) { | 149 TEST(ExternalReferenceDecoder) { |
144 StatsTable::SetCounterFunction(counter_function); | 150 StatsTable::SetCounterFunction(counter_function); |
145 Heap::Setup(false); | 151 Heap::Setup(false); |
146 ExternalReferenceDecoder decoder; | 152 ExternalReferenceDecoder decoder; |
147 CHECK_EQ(AddressOf(Builtins::ArrayCode), | 153 CHECK_EQ(AddressOf(Builtins::ArrayCode), |
148 decoder.Decode(make_code(BUILTIN, Builtins::ArrayCode))); | 154 decoder.Decode(make_code(BUILTIN, Builtins::ArrayCode))); |
149 CHECK_EQ(AddressOf(Runtime::kAbort), | 155 CHECK_EQ(AddressOf(Runtime::kAbort), |
150 decoder.Decode(make_code(RUNTIME_FUNCTION, Runtime::kAbort))); | 156 decoder.Decode(make_code(RUNTIME_FUNCTION, Runtime::kAbort))); |
151 CHECK_EQ(AddressOf(IC_Utility(IC::kLoadCallbackProperty)), | 157 CHECK_EQ(AddressOf(IC_Utility(IC::kLoadCallbackProperty)), |
152 decoder.Decode(make_code(IC_UTILITY, IC::kLoadCallbackProperty))); | 158 decoder.Decode(make_code(IC_UTILITY, IC::kLoadCallbackProperty))); |
| 159 #ifdef ENABLE_DEBUGGER_SUPPORT |
153 CHECK_EQ(AddressOf(Debug_Address(Debug::k_register_address, 3)), | 160 CHECK_EQ(AddressOf(Debug_Address(Debug::k_register_address, 3)), |
154 decoder.Decode(make_code(DEBUG_ADDRESS, register_code(3)))); | 161 decoder.Decode(make_code(DEBUG_ADDRESS, register_code(3)))); |
| 162 #endif // ENABLE_DEBUGGER_SUPPORT |
155 ExternalReference keyed_load_function = | 163 ExternalReference keyed_load_function = |
156 ExternalReference(&Counters::keyed_load_function_prototype); | 164 ExternalReference(&Counters::keyed_load_function_prototype); |
157 CHECK_EQ(keyed_load_function.address(), | 165 CHECK_EQ(keyed_load_function.address(), |
158 decoder.Decode( | 166 decoder.Decode( |
159 make_code(STATS_COUNTER, | 167 make_code(STATS_COUNTER, |
160 Counters::k_keyed_load_function_prototype))); | 168 Counters::k_keyed_load_function_prototype))); |
161 CHECK_EQ(ExternalReference::the_hole_value_location().address(), | 169 CHECK_EQ(ExternalReference::the_hole_value_location().address(), |
162 decoder.Decode(make_code(UNCLASSIFIED, 2))); | 170 decoder.Decode(make_code(UNCLASSIFIED, 2))); |
163 CHECK_EQ(ExternalReference::address_of_stack_limit().address(), | 171 CHECK_EQ(ExternalReference::address_of_stack_limit().address(), |
164 decoder.Decode(make_code(UNCLASSIFIED, 4))); | 172 decoder.Decode(make_code(UNCLASSIFIED, 4))); |
165 CHECK_EQ(ExternalReference::address_of_real_stack_limit().address(), | 173 CHECK_EQ(ExternalReference::address_of_real_stack_limit().address(), |
166 decoder.Decode(make_code(UNCLASSIFIED, 5))); | 174 decoder.Decode(make_code(UNCLASSIFIED, 5))); |
| 175 #ifdef ENABLE_DEBUGGER_SUPPORT |
167 CHECK_EQ(ExternalReference::debug_break().address(), | 176 CHECK_EQ(ExternalReference::debug_break().address(), |
168 decoder.Decode(make_code(UNCLASSIFIED, 15))); | 177 decoder.Decode(make_code(UNCLASSIFIED, 15))); |
| 178 #endif // ENABLE_DEBUGGER_SUPPORT |
169 CHECK_EQ(ExternalReference::new_space_start().address(), | 179 CHECK_EQ(ExternalReference::new_space_start().address(), |
170 decoder.Decode(make_code(UNCLASSIFIED, 10))); | 180 decoder.Decode(make_code(UNCLASSIFIED, 10))); |
171 } | 181 } |
172 | 182 |
173 | 183 |
174 class FileByteSink : public SnapshotByteSink { | 184 class FileByteSink : public SnapshotByteSink { |
175 public: | 185 public: |
176 explicit FileByteSink(const char* snapshot_file) { | 186 explicit FileByteSink(const char* snapshot_file) { |
177 fp_ = OS::FOpen(snapshot_file, "wb"); | 187 fp_ = OS::FOpen(snapshot_file, "wb"); |
178 file_name_ = snapshot_file; | 188 file_name_ = snapshot_file; |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 TEST(TestThatAlwaysFails) { | 673 TEST(TestThatAlwaysFails) { |
664 bool ArtificialFailure = false; | 674 bool ArtificialFailure = false; |
665 CHECK(ArtificialFailure); | 675 CHECK(ArtificialFailure); |
666 } | 676 } |
667 | 677 |
668 | 678 |
669 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) { | 679 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) { |
670 bool ArtificialFailure2 = false; | 680 bool ArtificialFailure2 = false; |
671 CHECK(ArtificialFailure2); | 681 CHECK(ArtificialFailure2); |
672 } | 682 } |
OLD | NEW |