| 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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 byte* snapshot = ReadBytes(file_name, &snapshot_size); | 452 byte* snapshot = ReadBytes(file_name, &snapshot_size); |
| 453 | 453 |
| 454 Object* root; | 454 Object* root; |
| 455 { | 455 { |
| 456 SnapshotByteSource source(snapshot, snapshot_size); | 456 SnapshotByteSource source(snapshot, snapshot_size); |
| 457 Deserializer deserializer(&source); | 457 Deserializer deserializer(&source); |
| 458 deserializer.DeserializePartial(&root); | 458 deserializer.DeserializePartial(&root); |
| 459 CHECK(root->IsString()); | 459 CHECK(root->IsString()); |
| 460 } | 460 } |
| 461 v8::HandleScope handle_scope; | 461 v8::HandleScope handle_scope; |
| 462 Handle<Object>root_handle(root); | 462 Handle<Object> root_handle(root); |
| 463 |
| 464 ReserveSpaceForPartialSnapshot(file_name); |
| 463 | 465 |
| 464 Object* root2; | 466 Object* root2; |
| 465 { | 467 { |
| 466 SnapshotByteSource source(snapshot, snapshot_size); | 468 SnapshotByteSource source(snapshot, snapshot_size); |
| 467 Deserializer deserializer(&source); | 469 Deserializer deserializer(&source); |
| 468 deserializer.DeserializePartial(&root2); | 470 deserializer.DeserializePartial(&root2); |
| 469 CHECK(root2->IsString()); | 471 CHECK(root2->IsString()); |
| 470 CHECK(*root_handle == root2); | 472 CHECK(*root_handle == root2); |
| 471 } | 473 } |
| 472 } | 474 } |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 byte* snapshot = ReadBytes(file_name, &snapshot_size); | 537 byte* snapshot = ReadBytes(file_name, &snapshot_size); |
| 536 | 538 |
| 537 Object* root; | 539 Object* root; |
| 538 { | 540 { |
| 539 SnapshotByteSource source(snapshot, snapshot_size); | 541 SnapshotByteSource source(snapshot, snapshot_size); |
| 540 Deserializer deserializer(&source); | 542 Deserializer deserializer(&source); |
| 541 deserializer.DeserializePartial(&root); | 543 deserializer.DeserializePartial(&root); |
| 542 CHECK(root->IsContext()); | 544 CHECK(root->IsContext()); |
| 543 } | 545 } |
| 544 v8::HandleScope handle_scope; | 546 v8::HandleScope handle_scope; |
| 545 Handle<Object>root_handle(root); | 547 Handle<Object> root_handle(root); |
| 548 |
| 549 ReserveSpaceForPartialSnapshot(file_name); |
| 546 | 550 |
| 547 Object* root2; | 551 Object* root2; |
| 548 { | 552 { |
| 549 SnapshotByteSource source(snapshot, snapshot_size); | 553 SnapshotByteSource source(snapshot, snapshot_size); |
| 550 Deserializer deserializer(&source); | 554 Deserializer deserializer(&source); |
| 551 deserializer.DeserializePartial(&root2); | 555 deserializer.DeserializePartial(&root2); |
| 552 CHECK(root2->IsContext()); | 556 CHECK(root2->IsContext()); |
| 553 CHECK(*root_handle != root2); | 557 CHECK(*root_handle != root2); |
| 554 } | 558 } |
| 555 } | 559 } |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 TEST(TestThatAlwaysFails) { | 679 TEST(TestThatAlwaysFails) { |
| 676 bool ArtificialFailure = false; | 680 bool ArtificialFailure = false; |
| 677 CHECK(ArtificialFailure); | 681 CHECK(ArtificialFailure); |
| 678 } | 682 } |
| 679 | 683 |
| 680 | 684 |
| 681 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) { | 685 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) { |
| 682 bool ArtificialFailure2 = false; | 686 bool ArtificialFailure2 = false; |
| 683 CHECK(ArtificialFailure2); | 687 CHECK(ArtificialFailure2); |
| 684 } | 688 } |
| OLD | NEW |