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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 TEST(ExternalReferenceEncoder) { | 101 TEST(ExternalReferenceEncoder) { |
102 OS::Setup(); | |
103 Isolate* isolate = i::Isolate::Current(); | 102 Isolate* isolate = i::Isolate::Current(); |
104 isolate->stats_table()->SetCounterFunction(counter_function); | 103 isolate->stats_table()->SetCounterFunction(counter_function); |
105 HEAP->Setup(false); | 104 v8::V8::Initialize(); |
| 105 |
106 ExternalReferenceEncoder encoder; | 106 ExternalReferenceEncoder encoder; |
107 CHECK_EQ(make_code(BUILTIN, Builtins::kArrayCode), | 107 CHECK_EQ(make_code(BUILTIN, Builtins::kArrayCode), |
108 Encode(encoder, Builtins::kArrayCode)); | 108 Encode(encoder, Builtins::kArrayCode)); |
109 CHECK_EQ(make_code(v8::internal::RUNTIME_FUNCTION, Runtime::kAbort), | 109 CHECK_EQ(make_code(v8::internal::RUNTIME_FUNCTION, Runtime::kAbort), |
110 Encode(encoder, Runtime::kAbort)); | 110 Encode(encoder, Runtime::kAbort)); |
111 CHECK_EQ(make_code(IC_UTILITY, IC::kLoadCallbackProperty), | 111 CHECK_EQ(make_code(IC_UTILITY, IC::kLoadCallbackProperty), |
112 Encode(encoder, IC_Utility(IC::kLoadCallbackProperty))); | 112 Encode(encoder, IC_Utility(IC::kLoadCallbackProperty))); |
113 ExternalReference keyed_load_function_prototype = | 113 ExternalReference keyed_load_function_prototype = |
114 ExternalReference(isolate->counters()->keyed_load_function_prototype()); | 114 ExternalReference(isolate->counters()->keyed_load_function_prototype()); |
115 CHECK_EQ(make_code(STATS_COUNTER, Counters::k_keyed_load_function_prototype), | 115 CHECK_EQ(make_code(STATS_COUNTER, Counters::k_keyed_load_function_prototype), |
(...skipping 16 matching lines...) Expand all Loading... |
132 #endif // ENABLE_DEBUGGER_SUPPORT | 132 #endif // ENABLE_DEBUGGER_SUPPORT |
133 CHECK_EQ(make_code(UNCLASSIFIED, 10), | 133 CHECK_EQ(make_code(UNCLASSIFIED, 10), |
134 encoder.Encode( | 134 encoder.Encode( |
135 ExternalReference::new_space_start(isolate).address())); | 135 ExternalReference::new_space_start(isolate).address())); |
136 CHECK_EQ(make_code(UNCLASSIFIED, 3), | 136 CHECK_EQ(make_code(UNCLASSIFIED, 3), |
137 encoder.Encode(ExternalReference::roots_address(isolate).address())); | 137 encoder.Encode(ExternalReference::roots_address(isolate).address())); |
138 } | 138 } |
139 | 139 |
140 | 140 |
141 TEST(ExternalReferenceDecoder) { | 141 TEST(ExternalReferenceDecoder) { |
142 OS::Setup(); | |
143 Isolate* isolate = i::Isolate::Current(); | 142 Isolate* isolate = i::Isolate::Current(); |
144 isolate->stats_table()->SetCounterFunction(counter_function); | 143 isolate->stats_table()->SetCounterFunction(counter_function); |
145 HEAP->Setup(false); | 144 v8::V8::Initialize(); |
| 145 |
146 ExternalReferenceDecoder decoder; | 146 ExternalReferenceDecoder decoder; |
147 CHECK_EQ(AddressOf(Builtins::kArrayCode), | 147 CHECK_EQ(AddressOf(Builtins::kArrayCode), |
148 decoder.Decode(make_code(BUILTIN, Builtins::kArrayCode))); | 148 decoder.Decode(make_code(BUILTIN, Builtins::kArrayCode))); |
149 CHECK_EQ(AddressOf(Runtime::kAbort), | 149 CHECK_EQ(AddressOf(Runtime::kAbort), |
150 decoder.Decode(make_code(v8::internal::RUNTIME_FUNCTION, | 150 decoder.Decode(make_code(v8::internal::RUNTIME_FUNCTION, |
151 Runtime::kAbort))); | 151 Runtime::kAbort))); |
152 CHECK_EQ(AddressOf(IC_Utility(IC::kLoadCallbackProperty)), | 152 CHECK_EQ(AddressOf(IC_Utility(IC::kLoadCallbackProperty)), |
153 decoder.Decode(make_code(IC_UTILITY, IC::kLoadCallbackProperty))); | 153 decoder.Decode(make_code(IC_UTILITY, IC::kLoadCallbackProperty))); |
154 ExternalReference keyed_load_function = | 154 ExternalReference keyed_load_function = |
155 ExternalReference(isolate->counters()->keyed_load_function_prototype()); | 155 ExternalReference(isolate->counters()->keyed_load_function_prototype()); |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 TEST(TestThatAlwaysFails) { | 674 TEST(TestThatAlwaysFails) { |
675 bool ArtificialFailure = false; | 675 bool ArtificialFailure = false; |
676 CHECK(ArtificialFailure); | 676 CHECK(ArtificialFailure); |
677 } | 677 } |
678 | 678 |
679 | 679 |
680 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) { | 680 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) { |
681 bool ArtificialFailure2 = false; | 681 bool ArtificialFailure2 = false; |
682 CHECK(ArtificialFailure2); | 682 CHECK(ArtificialFailure2); |
683 } | 683 } |
OLD | NEW |