| 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 | |
| 102 static int register_code(int reg) { | |
| 103 return Debug::k_register_address << kDebugIdShift | reg; | |
| 104 } | |
| 105 #endif // ENABLE_DEBUGGER_SUPPORT | |
| 106 | |
| 107 | |
| 108 TEST(ExternalReferenceEncoder) { | 101 TEST(ExternalReferenceEncoder) { |
| 109 StatsTable::SetCounterFunction(counter_function); | 102 StatsTable::SetCounterFunction(counter_function); |
| 110 Heap::Setup(false); | 103 Heap::Setup(false); |
| 111 ExternalReferenceEncoder encoder; | 104 ExternalReferenceEncoder encoder; |
| 112 CHECK_EQ(make_code(BUILTIN, Builtins::ArrayCode), | 105 CHECK_EQ(make_code(BUILTIN, Builtins::ArrayCode), |
| 113 Encode(encoder, Builtins::ArrayCode)); | 106 Encode(encoder, Builtins::ArrayCode)); |
| 114 CHECK_EQ(make_code(RUNTIME_FUNCTION, Runtime::kAbort), | 107 CHECK_EQ(make_code(RUNTIME_FUNCTION, Runtime::kAbort), |
| 115 Encode(encoder, Runtime::kAbort)); | 108 Encode(encoder, Runtime::kAbort)); |
| 116 CHECK_EQ(make_code(IC_UTILITY, IC::kLoadCallbackProperty), | 109 CHECK_EQ(make_code(IC_UTILITY, IC::kLoadCallbackProperty), |
| 117 Encode(encoder, IC_Utility(IC::kLoadCallbackProperty))); | 110 Encode(encoder, IC_Utility(IC::kLoadCallbackProperty))); |
| 118 #ifdef ENABLE_DEBUGGER_SUPPORT | |
| 119 CHECK_EQ(make_code(DEBUG_ADDRESS, register_code(3)), | |
| 120 Encode(encoder, Debug_Address(Debug::k_register_address, 3))); | |
| 121 #endif // ENABLE_DEBUGGER_SUPPORT | |
| 122 ExternalReference keyed_load_function_prototype = | 111 ExternalReference keyed_load_function_prototype = |
| 123 ExternalReference(&Counters::keyed_load_function_prototype); | 112 ExternalReference(&Counters::keyed_load_function_prototype); |
| 124 CHECK_EQ(make_code(STATS_COUNTER, Counters::k_keyed_load_function_prototype), | 113 CHECK_EQ(make_code(STATS_COUNTER, Counters::k_keyed_load_function_prototype), |
| 125 encoder.Encode(keyed_load_function_prototype.address())); | 114 encoder.Encode(keyed_load_function_prototype.address())); |
| 126 ExternalReference the_hole_value_location = | 115 ExternalReference the_hole_value_location = |
| 127 ExternalReference::the_hole_value_location(); | 116 ExternalReference::the_hole_value_location(); |
| 128 CHECK_EQ(make_code(UNCLASSIFIED, 2), | 117 CHECK_EQ(make_code(UNCLASSIFIED, 2), |
| 129 encoder.Encode(the_hole_value_location.address())); | 118 encoder.Encode(the_hole_value_location.address())); |
| 130 ExternalReference stack_limit_address = | 119 ExternalReference stack_limit_address = |
| 131 ExternalReference::address_of_stack_limit(); | 120 ExternalReference::address_of_stack_limit(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 149 TEST(ExternalReferenceDecoder) { | 138 TEST(ExternalReferenceDecoder) { |
| 150 StatsTable::SetCounterFunction(counter_function); | 139 StatsTable::SetCounterFunction(counter_function); |
| 151 Heap::Setup(false); | 140 Heap::Setup(false); |
| 152 ExternalReferenceDecoder decoder; | 141 ExternalReferenceDecoder decoder; |
| 153 CHECK_EQ(AddressOf(Builtins::ArrayCode), | 142 CHECK_EQ(AddressOf(Builtins::ArrayCode), |
| 154 decoder.Decode(make_code(BUILTIN, Builtins::ArrayCode))); | 143 decoder.Decode(make_code(BUILTIN, Builtins::ArrayCode))); |
| 155 CHECK_EQ(AddressOf(Runtime::kAbort), | 144 CHECK_EQ(AddressOf(Runtime::kAbort), |
| 156 decoder.Decode(make_code(RUNTIME_FUNCTION, Runtime::kAbort))); | 145 decoder.Decode(make_code(RUNTIME_FUNCTION, Runtime::kAbort))); |
| 157 CHECK_EQ(AddressOf(IC_Utility(IC::kLoadCallbackProperty)), | 146 CHECK_EQ(AddressOf(IC_Utility(IC::kLoadCallbackProperty)), |
| 158 decoder.Decode(make_code(IC_UTILITY, IC::kLoadCallbackProperty))); | 147 decoder.Decode(make_code(IC_UTILITY, IC::kLoadCallbackProperty))); |
| 159 #ifdef ENABLE_DEBUGGER_SUPPORT | |
| 160 CHECK_EQ(AddressOf(Debug_Address(Debug::k_register_address, 3)), | |
| 161 decoder.Decode(make_code(DEBUG_ADDRESS, register_code(3)))); | |
| 162 #endif // ENABLE_DEBUGGER_SUPPORT | |
| 163 ExternalReference keyed_load_function = | 148 ExternalReference keyed_load_function = |
| 164 ExternalReference(&Counters::keyed_load_function_prototype); | 149 ExternalReference(&Counters::keyed_load_function_prototype); |
| 165 CHECK_EQ(keyed_load_function.address(), | 150 CHECK_EQ(keyed_load_function.address(), |
| 166 decoder.Decode( | 151 decoder.Decode( |
| 167 make_code(STATS_COUNTER, | 152 make_code(STATS_COUNTER, |
| 168 Counters::k_keyed_load_function_prototype))); | 153 Counters::k_keyed_load_function_prototype))); |
| 169 CHECK_EQ(ExternalReference::the_hole_value_location().address(), | 154 CHECK_EQ(ExternalReference::the_hole_value_location().address(), |
| 170 decoder.Decode(make_code(UNCLASSIFIED, 2))); | 155 decoder.Decode(make_code(UNCLASSIFIED, 2))); |
| 171 CHECK_EQ(ExternalReference::address_of_stack_limit().address(), | 156 CHECK_EQ(ExternalReference::address_of_stack_limit().address(), |
| 172 decoder.Decode(make_code(UNCLASSIFIED, 4))); | 157 decoder.Decode(make_code(UNCLASSIFIED, 4))); |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 TEST(TestThatAlwaysFails) { | 658 TEST(TestThatAlwaysFails) { |
| 674 bool ArtificialFailure = false; | 659 bool ArtificialFailure = false; |
| 675 CHECK(ArtificialFailure); | 660 CHECK(ArtificialFailure); |
| 676 } | 661 } |
| 677 | 662 |
| 678 | 663 |
| 679 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) { | 664 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) { |
| 680 bool ArtificialFailure2 = false; | 665 bool ArtificialFailure2 = false; |
| 681 CHECK(ArtificialFailure2); | 666 CHECK(ArtificialFailure2); |
| 682 } | 667 } |
| OLD | NEW |