sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1 | // Copyright 2007-2010 the V8 project authors. All rights reserved. |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 2 | // Redistribution and use in source and binary forms, with or without |
| 3 | // modification, are permitted provided that the following conditions are |
| 4 | // met: |
| 5 | // |
| 6 | // * Redistributions of source code must retain the above copyright |
| 7 | // notice, this list of conditions and the following disclaimer. |
| 8 | // * Redistributions in binary form must reproduce the above |
| 9 | // copyright notice, this list of conditions and the following |
| 10 | // disclaimer in the documentation and/or other materials provided |
| 11 | // with the distribution. |
| 12 | // * Neither the name of Google Inc. nor the names of its |
| 13 | // contributors may be used to endorse or promote products derived |
| 14 | // from this software without specific prior written permission. |
| 15 | // |
| 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | |
| 28 | #include <signal.h> |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 29 | |
| 30 | #include "sys/stat.h" |
| 31 | #include "v8.h" |
| 32 | |
| 33 | #include "debug.h" |
| 34 | #include "ic-inl.h" |
| 35 | #include "runtime.h" |
| 36 | #include "serialize.h" |
| 37 | #include "scopeinfo.h" |
| 38 | #include "snapshot.h" |
| 39 | #include "cctest.h" |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 40 | #include "spaces.h" |
| 41 | #include "objects.h" |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 42 | #include "natives.h" |
| 43 | #include "bootstrapper.h" |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 44 | |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 45 | using namespace v8::internal; |
| 46 | |
ager@chromium.org | 5ec4892 | 2009-05-05 07:25:34 +0000 | [diff] [blame] | 47 | static const unsigned kCounters = 256; |
| 48 | static int local_counters[kCounters]; |
| 49 | static const char* local_counter_names[kCounters]; |
| 50 | |
| 51 | |
| 52 | static unsigned CounterHash(const char* s) { |
| 53 | unsigned hash = 0; |
| 54 | while (*++s) { |
| 55 | hash |= hash << 5; |
| 56 | hash += *s; |
| 57 | } |
| 58 | return hash; |
| 59 | } |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 60 | |
| 61 | |
| 62 | // Callback receiver to track counters in test. |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 63 | static int* counter_function(const char* name) { |
ager@chromium.org | 5ec4892 | 2009-05-05 07:25:34 +0000 | [diff] [blame] | 64 | unsigned hash = CounterHash(name) % kCounters; |
| 65 | unsigned original_hash = hash; |
| 66 | USE(original_hash); |
| 67 | while (true) { |
| 68 | if (local_counter_names[hash] == name) { |
| 69 | return &local_counters[hash]; |
| 70 | } |
| 71 | if (local_counter_names[hash] == 0) { |
| 72 | local_counter_names[hash] = name; |
| 73 | return &local_counters[hash]; |
| 74 | } |
| 75 | if (strcmp(local_counter_names[hash], name) == 0) { |
| 76 | return &local_counters[hash]; |
| 77 | } |
| 78 | hash = (hash + 1) % kCounters; |
| 79 | ASSERT(hash != original_hash); // Hash table has been filled up. |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 80 | } |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | |
| 84 | template <class T> |
| 85 | static Address AddressOf(T id) { |
| 86 | return ExternalReference(id).address(); |
| 87 | } |
| 88 | |
| 89 | |
| 90 | template <class T> |
| 91 | static uint32_t Encode(const ExternalReferenceEncoder& encoder, T id) { |
| 92 | return encoder.Encode(AddressOf(id)); |
| 93 | } |
| 94 | |
| 95 | |
| 96 | static int make_code(TypeCode type, int id) { |
| 97 | return static_cast<uint32_t>(type) << kReferenceTypeShift | id; |
| 98 | } |
| 99 | |
| 100 | |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 101 | TEST(ExternalReferenceEncoder) { |
| 102 | StatsTable::SetCounterFunction(counter_function); |
| 103 | Heap::Setup(false); |
| 104 | ExternalReferenceEncoder encoder; |
| 105 | CHECK_EQ(make_code(BUILTIN, Builtins::ArrayCode), |
| 106 | Encode(encoder, Builtins::ArrayCode)); |
| 107 | CHECK_EQ(make_code(RUNTIME_FUNCTION, Runtime::kAbort), |
| 108 | Encode(encoder, Runtime::kAbort)); |
| 109 | CHECK_EQ(make_code(IC_UTILITY, IC::kLoadCallbackProperty), |
| 110 | Encode(encoder, IC_Utility(IC::kLoadCallbackProperty))); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 111 | ExternalReference keyed_load_function_prototype = |
| 112 | ExternalReference(&Counters::keyed_load_function_prototype); |
| 113 | CHECK_EQ(make_code(STATS_COUNTER, Counters::k_keyed_load_function_prototype), |
| 114 | encoder.Encode(keyed_load_function_prototype.address())); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 115 | ExternalReference the_hole_value_location = |
| 116 | ExternalReference::the_hole_value_location(); |
| 117 | CHECK_EQ(make_code(UNCLASSIFIED, 2), |
| 118 | encoder.Encode(the_hole_value_location.address())); |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 119 | ExternalReference stack_limit_address = |
| 120 | ExternalReference::address_of_stack_limit(); |
ager@chromium.org | ab99eea | 2009-08-25 07:05:41 +0000 | [diff] [blame] | 121 | CHECK_EQ(make_code(UNCLASSIFIED, 4), |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 122 | encoder.Encode(stack_limit_address.address())); |
| 123 | ExternalReference real_stack_limit_address = |
| 124 | ExternalReference::address_of_real_stack_limit(); |
| 125 | CHECK_EQ(make_code(UNCLASSIFIED, 5), |
| 126 | encoder.Encode(real_stack_limit_address.address())); |
ricow@chromium.org | 5ad5ace | 2010-06-23 09:06:43 +0000 | [diff] [blame] | 127 | #ifdef ENABLE_DEBUGGER_SUPPORT |
whesse@chromium.org | 2c186ca | 2010-06-16 11:32:39 +0000 | [diff] [blame] | 128 | CHECK_EQ(make_code(UNCLASSIFIED, 15), |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 129 | encoder.Encode(ExternalReference::debug_break().address())); |
ricow@chromium.org | 5ad5ace | 2010-06-23 09:06:43 +0000 | [diff] [blame] | 130 | #endif // ENABLE_DEBUGGER_SUPPORT |
whesse@chromium.org | 2c186ca | 2010-06-16 11:32:39 +0000 | [diff] [blame] | 131 | CHECK_EQ(make_code(UNCLASSIFIED, 10), |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 132 | encoder.Encode(ExternalReference::new_space_start().address())); |
ager@chromium.org | ab99eea | 2009-08-25 07:05:41 +0000 | [diff] [blame] | 133 | CHECK_EQ(make_code(UNCLASSIFIED, 3), |
| 134 | encoder.Encode(ExternalReference::roots_address().address())); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | |
| 138 | TEST(ExternalReferenceDecoder) { |
| 139 | StatsTable::SetCounterFunction(counter_function); |
| 140 | Heap::Setup(false); |
| 141 | ExternalReferenceDecoder decoder; |
| 142 | CHECK_EQ(AddressOf(Builtins::ArrayCode), |
| 143 | decoder.Decode(make_code(BUILTIN, Builtins::ArrayCode))); |
| 144 | CHECK_EQ(AddressOf(Runtime::kAbort), |
| 145 | decoder.Decode(make_code(RUNTIME_FUNCTION, Runtime::kAbort))); |
| 146 | CHECK_EQ(AddressOf(IC_Utility(IC::kLoadCallbackProperty)), |
| 147 | decoder.Decode(make_code(IC_UTILITY, IC::kLoadCallbackProperty))); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 148 | ExternalReference keyed_load_function = |
| 149 | ExternalReference(&Counters::keyed_load_function_prototype); |
| 150 | CHECK_EQ(keyed_load_function.address(), |
| 151 | decoder.Decode( |
| 152 | make_code(STATS_COUNTER, |
| 153 | Counters::k_keyed_load_function_prototype))); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 154 | CHECK_EQ(ExternalReference::the_hole_value_location().address(), |
| 155 | decoder.Decode(make_code(UNCLASSIFIED, 2))); |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 156 | CHECK_EQ(ExternalReference::address_of_stack_limit().address(), |
ager@chromium.org | ab99eea | 2009-08-25 07:05:41 +0000 | [diff] [blame] | 157 | decoder.Decode(make_code(UNCLASSIFIED, 4))); |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 158 | CHECK_EQ(ExternalReference::address_of_real_stack_limit().address(), |
| 159 | decoder.Decode(make_code(UNCLASSIFIED, 5))); |
ricow@chromium.org | 5ad5ace | 2010-06-23 09:06:43 +0000 | [diff] [blame] | 160 | #ifdef ENABLE_DEBUGGER_SUPPORT |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 161 | CHECK_EQ(ExternalReference::debug_break().address(), |
whesse@chromium.org | 2c186ca | 2010-06-16 11:32:39 +0000 | [diff] [blame] | 162 | decoder.Decode(make_code(UNCLASSIFIED, 15))); |
ricow@chromium.org | 5ad5ace | 2010-06-23 09:06:43 +0000 | [diff] [blame] | 163 | #endif // ENABLE_DEBUGGER_SUPPORT |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 164 | CHECK_EQ(ExternalReference::new_space_start().address(), |
whesse@chromium.org | 2c186ca | 2010-06-16 11:32:39 +0000 | [diff] [blame] | 165 | decoder.Decode(make_code(UNCLASSIFIED, 10))); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 169 | class FileByteSink : public SnapshotByteSink { |
| 170 | public: |
| 171 | explicit FileByteSink(const char* snapshot_file) { |
| 172 | fp_ = OS::FOpen(snapshot_file, "wb"); |
| 173 | file_name_ = snapshot_file; |
| 174 | if (fp_ == NULL) { |
| 175 | PrintF("Unable to write to snapshot file \"%s\"\n", snapshot_file); |
| 176 | exit(1); |
| 177 | } |
| 178 | } |
| 179 | virtual ~FileByteSink() { |
| 180 | if (fp_ != NULL) { |
| 181 | fclose(fp_); |
| 182 | } |
| 183 | } |
| 184 | virtual void Put(int byte, const char* description) { |
| 185 | if (fp_ != NULL) { |
| 186 | fputc(byte, fp_); |
| 187 | } |
| 188 | } |
| 189 | virtual int Position() { |
| 190 | return ftell(fp_); |
| 191 | } |
| 192 | void WriteSpaceUsed( |
| 193 | int new_space_used, |
| 194 | int pointer_space_used, |
| 195 | int data_space_used, |
| 196 | int code_space_used, |
| 197 | int map_space_used, |
| 198 | int cell_space_used, |
| 199 | int large_space_used); |
| 200 | |
| 201 | private: |
| 202 | FILE* fp_; |
| 203 | const char* file_name_; |
| 204 | }; |
| 205 | |
| 206 | |
| 207 | void FileByteSink::WriteSpaceUsed( |
| 208 | int new_space_used, |
| 209 | int pointer_space_used, |
| 210 | int data_space_used, |
| 211 | int code_space_used, |
| 212 | int map_space_used, |
| 213 | int cell_space_used, |
| 214 | int large_space_used) { |
| 215 | int file_name_length = StrLength(file_name_) + 10; |
| 216 | Vector<char> name = Vector<char>::New(file_name_length + 1); |
| 217 | OS::SNPrintF(name, "%s.size", file_name_); |
| 218 | FILE* fp = OS::FOpen(name.start(), "w"); |
fschneider@chromium.org | e03fb64 | 2010-11-01 12:34:09 +0000 | [diff] [blame] | 219 | name.Dispose(); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 220 | fprintf(fp, "new %d\n", new_space_used); |
| 221 | fprintf(fp, "pointer %d\n", pointer_space_used); |
| 222 | fprintf(fp, "data %d\n", data_space_used); |
| 223 | fprintf(fp, "code %d\n", code_space_used); |
| 224 | fprintf(fp, "map %d\n", map_space_used); |
| 225 | fprintf(fp, "cell %d\n", cell_space_used); |
| 226 | fprintf(fp, "large %d\n", large_space_used); |
| 227 | fclose(fp); |
| 228 | } |
| 229 | |
| 230 | |
| 231 | static bool WriteToFile(const char* snapshot_file) { |
| 232 | FileByteSink file(snapshot_file); |
| 233 | StartupSerializer ser(&file); |
| 234 | ser.Serialize(); |
| 235 | return true; |
| 236 | } |
| 237 | |
| 238 | |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 239 | static void Serialize() { |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 240 | // We have to create one context. One reason for this is so that the builtins |
| 241 | // can be loaded from v8natives.js and their addresses can be processed. This |
| 242 | // will clear the pending fixups array, which would otherwise contain GC roots |
| 243 | // that would confuse the serialization/deserialization process. |
| 244 | v8::Persistent<v8::Context> env = v8::Context::New(); |
| 245 | env.Dispose(); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 246 | WriteToFile(FLAG_testing_serialization_file); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 247 | } |
| 248 | |
| 249 | |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 250 | // Test that the whole heap can be serialized. |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 251 | TEST(Serialize) { |
kasperl@chromium.org | 061ef74 | 2009-02-27 12:16:20 +0000 | [diff] [blame] | 252 | Serializer::Enable(); |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 253 | v8::V8::Initialize(); |
| 254 | Serialize(); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 255 | } |
| 256 | |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 257 | |
sgjesse@chromium.org | ac6aa17 | 2009-12-04 12:29:05 +0000 | [diff] [blame] | 258 | // Test that heap serialization is non-destructive. |
| 259 | TEST(SerializeTwice) { |
| 260 | Serializer::Enable(); |
| 261 | v8::V8::Initialize(); |
| 262 | Serialize(); |
| 263 | Serialize(); |
| 264 | } |
| 265 | |
| 266 | |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 267 | //---------------------------------------------------------------------------- |
| 268 | // Tests that the heap can be deserialized. |
| 269 | |
| 270 | static void Deserialize() { |
kasperl@chromium.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 271 | CHECK(Snapshot::Initialize(FLAG_testing_serialization_file)); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | |
| 275 | static void SanityCheck() { |
| 276 | v8::HandleScope scope; |
| 277 | #ifdef DEBUG |
| 278 | Heap::Verify(); |
| 279 | #endif |
| 280 | CHECK(Top::global()->IsJSObject()); |
| 281 | CHECK(Top::global_context()->IsContext()); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 282 | CHECK(Heap::symbol_table()->IsSymbolTable()); |
| 283 | CHECK(!Factory::LookupAsciiSymbol("Empty")->IsFailure()); |
| 284 | } |
| 285 | |
| 286 | |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 287 | DEPENDENT_TEST(Deserialize, Serialize) { |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 288 | // The serialize-deserialize tests only work if the VM is built without |
| 289 | // serialization. That doesn't matter. We don't need to be able to |
| 290 | // serialize a snapshot in a VM that is booted from a snapshot. |
| 291 | if (!Snapshot::IsEnabled()) { |
| 292 | v8::HandleScope scope; |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 293 | |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 294 | Deserialize(); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 295 | |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 296 | v8::Persistent<v8::Context> env = v8::Context::New(); |
| 297 | env->Enter(); |
sgjesse@chromium.org | ac6aa17 | 2009-12-04 12:29:05 +0000 | [diff] [blame] | 298 | |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 299 | SanityCheck(); |
| 300 | } |
sgjesse@chromium.org | ac6aa17 | 2009-12-04 12:29:05 +0000 | [diff] [blame] | 301 | } |
| 302 | |
| 303 | |
| 304 | DEPENDENT_TEST(DeserializeFromSecondSerialization, SerializeTwice) { |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 305 | if (!Snapshot::IsEnabled()) { |
| 306 | v8::HandleScope scope; |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 307 | |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 308 | Deserialize(); |
sgjesse@chromium.org | ac6aa17 | 2009-12-04 12:29:05 +0000 | [diff] [blame] | 309 | |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 310 | v8::Persistent<v8::Context> env = v8::Context::New(); |
| 311 | env->Enter(); |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 312 | |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 313 | SanityCheck(); |
| 314 | } |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 315 | } |
| 316 | |
| 317 | |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 318 | DEPENDENT_TEST(DeserializeAndRunScript2, Serialize) { |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 319 | if (!Snapshot::IsEnabled()) { |
| 320 | v8::HandleScope scope; |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 321 | |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 322 | Deserialize(); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 323 | |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 324 | v8::Persistent<v8::Context> env = v8::Context::New(); |
| 325 | env->Enter(); |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 326 | |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 327 | const char* c_source = "\"1234\".length"; |
| 328 | v8::Local<v8::String> source = v8::String::New(c_source); |
| 329 | v8::Local<v8::Script> script = v8::Script::Compile(source); |
| 330 | CHECK_EQ(4, script->Run()->Int32Value()); |
| 331 | } |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 332 | } |
| 333 | |
| 334 | |
sgjesse@chromium.org | ac6aa17 | 2009-12-04 12:29:05 +0000 | [diff] [blame] | 335 | DEPENDENT_TEST(DeserializeFromSecondSerializationAndRunScript2, |
| 336 | SerializeTwice) { |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 337 | if (!Snapshot::IsEnabled()) { |
| 338 | v8::HandleScope scope; |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 339 | |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 340 | Deserialize(); |
sgjesse@chromium.org | ac6aa17 | 2009-12-04 12:29:05 +0000 | [diff] [blame] | 341 | |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 342 | v8::Persistent<v8::Context> env = v8::Context::New(); |
| 343 | env->Enter(); |
sgjesse@chromium.org | ac6aa17 | 2009-12-04 12:29:05 +0000 | [diff] [blame] | 344 | |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 345 | const char* c_source = "\"1234\".length"; |
| 346 | v8::Local<v8::String> source = v8::String::New(c_source); |
| 347 | v8::Local<v8::Script> script = v8::Script::Compile(source); |
| 348 | CHECK_EQ(4, script->Run()->Int32Value()); |
| 349 | } |
sgjesse@chromium.org | ac6aa17 | 2009-12-04 12:29:05 +0000 | [diff] [blame] | 350 | } |
| 351 | |
| 352 | |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 353 | TEST(PartialSerialization) { |
| 354 | Serializer::Enable(); |
| 355 | v8::V8::Initialize(); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 356 | |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 357 | v8::Persistent<v8::Context> env = v8::Context::New(); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 358 | ASSERT(!env.IsEmpty()); |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 359 | env->Enter(); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 360 | // Make sure all builtin scripts are cached. |
| 361 | { HandleScope scope; |
| 362 | for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { |
| 363 | Bootstrapper::NativesSourceLookup(i); |
| 364 | } |
| 365 | } |
| 366 | Heap::CollectAllGarbage(true); |
| 367 | Heap::CollectAllGarbage(true); |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 368 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 369 | Object* raw_foo; |
| 370 | { |
| 371 | v8::HandleScope handle_scope; |
| 372 | v8::Local<v8::String> foo = v8::String::New("foo"); |
| 373 | ASSERT(!foo.IsEmpty()); |
| 374 | raw_foo = *(v8::Utils::OpenHandle(*foo)); |
| 375 | } |
| 376 | |
| 377 | int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; |
| 378 | Vector<char> startup_name = Vector<char>::New(file_name_length + 1); |
| 379 | OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); |
| 380 | |
| 381 | env->Exit(); |
| 382 | env.Dispose(); |
| 383 | |
| 384 | FileByteSink startup_sink(startup_name.start()); |
fschneider@chromium.org | e03fb64 | 2010-11-01 12:34:09 +0000 | [diff] [blame] | 385 | startup_name.Dispose(); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 386 | StartupSerializer startup_serializer(&startup_sink); |
| 387 | startup_serializer.SerializeStrongReferences(); |
| 388 | |
| 389 | FileByteSink partial_sink(FLAG_testing_serialization_file); |
| 390 | PartialSerializer p_ser(&startup_serializer, &partial_sink); |
| 391 | p_ser.Serialize(&raw_foo); |
| 392 | startup_serializer.SerializeWeakReferences(); |
| 393 | partial_sink.WriteSpaceUsed(p_ser.CurrentAllocationAddress(NEW_SPACE), |
| 394 | p_ser.CurrentAllocationAddress(OLD_POINTER_SPACE), |
| 395 | p_ser.CurrentAllocationAddress(OLD_DATA_SPACE), |
| 396 | p_ser.CurrentAllocationAddress(CODE_SPACE), |
| 397 | p_ser.CurrentAllocationAddress(MAP_SPACE), |
| 398 | p_ser.CurrentAllocationAddress(CELL_SPACE), |
| 399 | p_ser.CurrentAllocationAddress(LO_SPACE)); |
| 400 | } |
| 401 | |
| 402 | |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 403 | static void ReserveSpaceForPartialSnapshot(const char* file_name) { |
| 404 | int file_name_length = StrLength(file_name) + 10; |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 405 | Vector<char> name = Vector<char>::New(file_name_length + 1); |
| 406 | OS::SNPrintF(name, "%s.size", file_name); |
| 407 | FILE* fp = OS::FOpen(name.start(), "r"); |
fschneider@chromium.org | e03fb64 | 2010-11-01 12:34:09 +0000 | [diff] [blame] | 408 | name.Dispose(); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 409 | int new_size, pointer_size, data_size, code_size, map_size, cell_size; |
| 410 | int large_size; |
| 411 | #ifdef _MSC_VER |
| 412 | // Avoid warning about unsafe fscanf from MSVC. |
| 413 | // Please note that this is only fine if %c and %s are not being used. |
| 414 | #define fscanf fscanf_s |
| 415 | #endif |
| 416 | CHECK_EQ(1, fscanf(fp, "new %d\n", &new_size)); |
| 417 | CHECK_EQ(1, fscanf(fp, "pointer %d\n", &pointer_size)); |
| 418 | CHECK_EQ(1, fscanf(fp, "data %d\n", &data_size)); |
| 419 | CHECK_EQ(1, fscanf(fp, "code %d\n", &code_size)); |
| 420 | CHECK_EQ(1, fscanf(fp, "map %d\n", &map_size)); |
| 421 | CHECK_EQ(1, fscanf(fp, "cell %d\n", &cell_size)); |
| 422 | CHECK_EQ(1, fscanf(fp, "large %d\n", &large_size)); |
| 423 | #ifdef _MSC_VER |
| 424 | #undef fscanf |
| 425 | #endif |
| 426 | fclose(fp); |
| 427 | Heap::ReserveSpace(new_size, |
| 428 | pointer_size, |
| 429 | data_size, |
| 430 | code_size, |
| 431 | map_size, |
| 432 | cell_size, |
| 433 | large_size); |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 434 | } |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 435 | |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 436 | |
| 437 | DEPENDENT_TEST(PartialDeserialization, PartialSerialization) { |
| 438 | if (!Snapshot::IsEnabled()) { |
| 439 | int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; |
| 440 | Vector<char> startup_name = Vector<char>::New(file_name_length + 1); |
| 441 | OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); |
| 442 | |
| 443 | CHECK(Snapshot::Initialize(startup_name.start())); |
fschneider@chromium.org | e03fb64 | 2010-11-01 12:34:09 +0000 | [diff] [blame] | 444 | startup_name.Dispose(); |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 445 | |
| 446 | const char* file_name = FLAG_testing_serialization_file; |
| 447 | ReserveSpaceForPartialSnapshot(file_name); |
| 448 | |
| 449 | int snapshot_size = 0; |
| 450 | byte* snapshot = ReadBytes(file_name, &snapshot_size); |
| 451 | |
| 452 | Object* root; |
| 453 | { |
| 454 | SnapshotByteSource source(snapshot, snapshot_size); |
| 455 | Deserializer deserializer(&source); |
| 456 | deserializer.DeserializePartial(&root); |
| 457 | CHECK(root->IsString()); |
| 458 | } |
| 459 | v8::HandleScope handle_scope; |
| 460 | Handle<Object>root_handle(root); |
| 461 | |
| 462 | Object* root2; |
| 463 | { |
| 464 | SnapshotByteSource source(snapshot, snapshot_size); |
| 465 | Deserializer deserializer(&source); |
| 466 | deserializer.DeserializePartial(&root2); |
| 467 | CHECK(root2->IsString()); |
| 468 | CHECK(*root_handle == root2); |
| 469 | } |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 470 | } |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 471 | } |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 472 | |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 473 | |
| 474 | TEST(ContextSerialization) { |
| 475 | Serializer::Enable(); |
| 476 | v8::V8::Initialize(); |
| 477 | |
| 478 | v8::Persistent<v8::Context> env = v8::Context::New(); |
| 479 | ASSERT(!env.IsEmpty()); |
| 480 | env->Enter(); |
| 481 | // Make sure all builtin scripts are cached. |
| 482 | { HandleScope scope; |
| 483 | for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { |
| 484 | Bootstrapper::NativesSourceLookup(i); |
| 485 | } |
| 486 | } |
| 487 | // If we don't do this then we end up with a stray root pointing at the |
| 488 | // context even after we have disposed of env. |
| 489 | Heap::CollectAllGarbage(true); |
| 490 | |
| 491 | int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; |
| 492 | Vector<char> startup_name = Vector<char>::New(file_name_length + 1); |
| 493 | OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); |
| 494 | |
| 495 | env->Exit(); |
| 496 | |
| 497 | Object* raw_context = *(v8::Utils::OpenHandle(*env)); |
| 498 | |
| 499 | env.Dispose(); |
| 500 | |
| 501 | FileByteSink startup_sink(startup_name.start()); |
fschneider@chromium.org | e03fb64 | 2010-11-01 12:34:09 +0000 | [diff] [blame] | 502 | startup_name.Dispose(); |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 503 | StartupSerializer startup_serializer(&startup_sink); |
| 504 | startup_serializer.SerializeStrongReferences(); |
| 505 | |
| 506 | FileByteSink partial_sink(FLAG_testing_serialization_file); |
| 507 | PartialSerializer p_ser(&startup_serializer, &partial_sink); |
| 508 | p_ser.Serialize(&raw_context); |
| 509 | startup_serializer.SerializeWeakReferences(); |
| 510 | partial_sink.WriteSpaceUsed(p_ser.CurrentAllocationAddress(NEW_SPACE), |
| 511 | p_ser.CurrentAllocationAddress(OLD_POINTER_SPACE), |
| 512 | p_ser.CurrentAllocationAddress(OLD_DATA_SPACE), |
| 513 | p_ser.CurrentAllocationAddress(CODE_SPACE), |
| 514 | p_ser.CurrentAllocationAddress(MAP_SPACE), |
| 515 | p_ser.CurrentAllocationAddress(CELL_SPACE), |
| 516 | p_ser.CurrentAllocationAddress(LO_SPACE)); |
| 517 | } |
| 518 | |
| 519 | |
| 520 | DEPENDENT_TEST(ContextDeserialization, ContextSerialization) { |
| 521 | if (!Snapshot::IsEnabled()) { |
| 522 | int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; |
| 523 | Vector<char> startup_name = Vector<char>::New(file_name_length + 1); |
| 524 | OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); |
| 525 | |
| 526 | CHECK(Snapshot::Initialize(startup_name.start())); |
fschneider@chromium.org | e03fb64 | 2010-11-01 12:34:09 +0000 | [diff] [blame] | 527 | startup_name.Dispose(); |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 528 | |
| 529 | const char* file_name = FLAG_testing_serialization_file; |
| 530 | ReserveSpaceForPartialSnapshot(file_name); |
| 531 | |
| 532 | int snapshot_size = 0; |
| 533 | byte* snapshot = ReadBytes(file_name, &snapshot_size); |
| 534 | |
| 535 | Object* root; |
| 536 | { |
| 537 | SnapshotByteSource source(snapshot, snapshot_size); |
| 538 | Deserializer deserializer(&source); |
| 539 | deserializer.DeserializePartial(&root); |
| 540 | CHECK(root->IsContext()); |
| 541 | } |
| 542 | v8::HandleScope handle_scope; |
| 543 | Handle<Object>root_handle(root); |
| 544 | |
| 545 | Object* root2; |
| 546 | { |
| 547 | SnapshotByteSource source(snapshot, snapshot_size); |
| 548 | Deserializer deserializer(&source); |
| 549 | deserializer.DeserializePartial(&root2); |
| 550 | CHECK(root2->IsContext()); |
| 551 | CHECK(*root_handle != root2); |
| 552 | } |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 553 | } |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 554 | } |
| 555 | |
| 556 | |
| 557 | TEST(LinearAllocation) { |
| 558 | v8::V8::Initialize(); |
| 559 | int new_space_max = 512 * KB; |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 560 | |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 561 | for (int size = 1000; size < 5 * MB; size += size >> 1) { |
| 562 | int new_space_size = (size < new_space_max) ? size : new_space_max; |
| 563 | Heap::ReserveSpace( |
| 564 | new_space_size, |
| 565 | size, // Old pointer space. |
| 566 | size, // Old data space. |
| 567 | size, // Code space. |
| 568 | size, // Map space. |
| 569 | size, // Cell space. |
| 570 | size); // Large object space. |
| 571 | LinearAllocationScope linear_allocation_scope; |
| 572 | const int kSmallFixedArrayLength = 4; |
| 573 | const int kSmallFixedArraySize = |
| 574 | FixedArray::kHeaderSize + kSmallFixedArrayLength * kPointerSize; |
| 575 | const int kSmallStringLength = 16; |
| 576 | const int kSmallStringSize = |
ager@chromium.org | ac091b7 | 2010-05-05 07:34:42 +0000 | [diff] [blame] | 577 | (SeqAsciiString::kHeaderSize + kSmallStringLength + |
| 578 | kObjectAlignmentMask) & ~kObjectAlignmentMask; |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 579 | const int kMapSize = Map::kSize; |
| 580 | |
| 581 | Object* new_last = NULL; |
| 582 | for (int i = 0; |
| 583 | i + kSmallFixedArraySize <= new_space_size; |
| 584 | i += kSmallFixedArraySize) { |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 585 | Object* obj = |
| 586 | Heap::AllocateFixedArray(kSmallFixedArrayLength)->ToObjectChecked(); |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 587 | if (new_last != NULL) { |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 588 | CHECK(reinterpret_cast<char*>(obj) == |
| 589 | reinterpret_cast<char*>(new_last) + kSmallFixedArraySize); |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 590 | } |
| 591 | new_last = obj; |
| 592 | } |
| 593 | |
| 594 | Object* pointer_last = NULL; |
| 595 | for (int i = 0; |
| 596 | i + kSmallFixedArraySize <= size; |
| 597 | i += kSmallFixedArraySize) { |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 598 | Object* obj = Heap::AllocateFixedArray(kSmallFixedArrayLength, |
| 599 | TENURED)->ToObjectChecked(); |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 600 | int old_page_fullness = i % Page::kPageSize; |
| 601 | int page_fullness = (i + kSmallFixedArraySize) % Page::kPageSize; |
| 602 | if (page_fullness < old_page_fullness || |
| 603 | page_fullness > Page::kObjectAreaSize) { |
| 604 | i = RoundUp(i, Page::kPageSize); |
| 605 | pointer_last = NULL; |
| 606 | } |
| 607 | if (pointer_last != NULL) { |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 608 | CHECK(reinterpret_cast<char*>(obj) == |
| 609 | reinterpret_cast<char*>(pointer_last) + kSmallFixedArraySize); |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 610 | } |
| 611 | pointer_last = obj; |
| 612 | } |
| 613 | |
| 614 | Object* data_last = NULL; |
| 615 | for (int i = 0; i + kSmallStringSize <= size; i += kSmallStringSize) { |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 616 | Object* obj = Heap::AllocateRawAsciiString(kSmallStringLength, |
| 617 | TENURED)->ToObjectChecked(); |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 618 | int old_page_fullness = i % Page::kPageSize; |
| 619 | int page_fullness = (i + kSmallStringSize) % Page::kPageSize; |
| 620 | if (page_fullness < old_page_fullness || |
| 621 | page_fullness > Page::kObjectAreaSize) { |
| 622 | i = RoundUp(i, Page::kPageSize); |
| 623 | data_last = NULL; |
| 624 | } |
| 625 | if (data_last != NULL) { |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 626 | CHECK(reinterpret_cast<char*>(obj) == |
| 627 | reinterpret_cast<char*>(data_last) + kSmallStringSize); |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 628 | } |
| 629 | data_last = obj; |
| 630 | } |
| 631 | |
| 632 | Object* map_last = NULL; |
| 633 | for (int i = 0; i + kMapSize <= size; i += kMapSize) { |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 634 | Object* obj = Heap::AllocateMap(JS_OBJECT_TYPE, |
| 635 | 42 * kPointerSize)->ToObjectChecked(); |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 636 | int old_page_fullness = i % Page::kPageSize; |
| 637 | int page_fullness = (i + kMapSize) % Page::kPageSize; |
| 638 | if (page_fullness < old_page_fullness || |
| 639 | page_fullness > Page::kObjectAreaSize) { |
| 640 | i = RoundUp(i, Page::kPageSize); |
| 641 | map_last = NULL; |
| 642 | } |
| 643 | if (map_last != NULL) { |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 644 | CHECK(reinterpret_cast<char*>(obj) == |
| 645 | reinterpret_cast<char*>(map_last) + kMapSize); |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 646 | } |
| 647 | map_last = obj; |
| 648 | } |
| 649 | |
| 650 | if (size > Page::kObjectAreaSize) { |
| 651 | // Support for reserving space in large object space is not there yet, |
| 652 | // but using an always-allocate scope is fine for now. |
| 653 | AlwaysAllocateScope always; |
| 654 | int large_object_array_length = |
| 655 | (size - FixedArray::kHeaderSize) / kPointerSize; |
| 656 | Object* obj = Heap::AllocateFixedArray(large_object_array_length, |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 657 | TENURED)->ToObjectChecked(); |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 658 | CHECK(!obj->IsFailure()); |
| 659 | } |
| 660 | } |
| 661 | } |
| 662 | |
| 663 | |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 664 | TEST(TestThatAlwaysSucceeds) { |
| 665 | } |
| 666 | |
| 667 | |
| 668 | TEST(TestThatAlwaysFails) { |
| 669 | bool ArtificialFailure = false; |
| 670 | CHECK(ArtificialFailure); |
| 671 | } |
| 672 | |
| 673 | |
| 674 | DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) { |
| 675 | bool ArtificialFailure2 = false; |
| 676 | CHECK(ArtificialFailure2); |
| 677 | } |