Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: test/cctest/test-serialize.cc

Issue 2470143004: [test] Speed up some slow tests. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 .ToLocalChecked() 602 .ToLocalChecked()
603 ->Int32Value(v8_isolate->GetCurrentContext()) 603 ->Int32Value(v8_isolate->GetCurrentContext())
604 .FromJust(); 604 .FromJust();
605 CHECK_EQ(100002, b); 605 CHECK_EQ(100002, b);
606 } 606 }
607 partial_blob.Dispose(); 607 partial_blob.Dispose();
608 } 608 }
609 v8_isolate->Dispose(); 609 v8_isolate->Dispose();
610 } 610 }
611 611
612 TEST(CustomSnapshotDataBlob) { 612 TEST(CustomSnapshotDataBlob1) {
613 DisableTurbofan(); 613 DisableTurbofan();
Jakob Kummerow 2016/11/03 13:28:40 As discussed offline, it seems scary that these te
Yang 2016/11/04 08:39:41 Will address this in a follow-up.
614 const char* source1 = "function f() { return 42; }"; 614 const char* source1 = "function f() { return 42; }";
615 const char* source2 =
616 "function f() { return g() * 2; }"
617 "function g() { return 43; }"
618 "/./.test('a')";
619 615
620 v8::StartupData data1 = v8::V8::CreateSnapshotDataBlob(source1); 616 v8::StartupData data1 = v8::V8::CreateSnapshotDataBlob(source1);
621 v8::StartupData data2 = v8::V8::CreateSnapshotDataBlob(source2);
622 617
623 v8::Isolate::CreateParams params1; 618 v8::Isolate::CreateParams params1;
624 params1.snapshot_blob = &data1; 619 params1.snapshot_blob = &data1;
625 params1.array_buffer_allocator = CcTest::array_buffer_allocator(); 620 params1.array_buffer_allocator = CcTest::array_buffer_allocator();
626 621
627 v8::Isolate* isolate1 = v8::Isolate::New(params1); 622 v8::Isolate* isolate1 = v8::Isolate::New(params1);
628 { 623 {
629 v8::Isolate::Scope i_scope(isolate1); 624 v8::Isolate::Scope i_scope(isolate1);
630 v8::HandleScope h_scope(isolate1); 625 v8::HandleScope h_scope(isolate1);
631 v8::Local<v8::Context> context = v8::Context::New(isolate1); 626 v8::Local<v8::Context> context = v8::Context::New(isolate1);
632 delete[] data1.data; // We can dispose of the snapshot blob now. 627 delete[] data1.data; // We can dispose of the snapshot blob now.
633 v8::Context::Scope c_scope(context); 628 v8::Context::Scope c_scope(context);
634 v8::Maybe<int32_t> result = 629 v8::Maybe<int32_t> result =
635 CompileRun("f()")->Int32Value(isolate1->GetCurrentContext()); 630 CompileRun("f()")->Int32Value(isolate1->GetCurrentContext());
636 CHECK_EQ(42, result.FromJust()); 631 CHECK_EQ(42, result.FromJust());
637 CHECK(CompileRun("this.g")->IsUndefined()); 632 CHECK(CompileRun("this.g")->IsUndefined());
638 } 633 }
639 isolate1->Dispose(); 634 isolate1->Dispose();
635 }
636
637 TEST(CustomSnapshotDataBlob2) {
638 DisableTurbofan();
639 const char* source2 =
640 "function f() { return g() * 2; }"
641 "function g() { return 43; }"
642 "/./.test('a')";
643
644 v8::StartupData data2 = v8::V8::CreateSnapshotDataBlob(source2);
640 645
641 v8::Isolate::CreateParams params2; 646 v8::Isolate::CreateParams params2;
642 params2.snapshot_blob = &data2; 647 params2.snapshot_blob = &data2;
643 params2.array_buffer_allocator = CcTest::array_buffer_allocator(); 648 params2.array_buffer_allocator = CcTest::array_buffer_allocator();
644 v8::Isolate* isolate2 = v8::Isolate::New(params2); 649 v8::Isolate* isolate2 = v8::Isolate::New(params2);
645 { 650 {
646 v8::Isolate::Scope i_scope(isolate2); 651 v8::Isolate::Scope i_scope(isolate2);
647 v8::HandleScope h_scope(isolate2); 652 v8::HandleScope h_scope(isolate2);
648 v8::Local<v8::Context> context = v8::Context::New(isolate2); 653 v8::Local<v8::Context> context = v8::Context::New(isolate2);
649 delete[] data2.data; // We can dispose of the snapshot blob now. 654 delete[] data2.data; // We can dispose of the snapshot blob now.
650 v8::Context::Scope c_scope(context); 655 v8::Context::Scope c_scope(context);
651 v8::Maybe<int32_t> result = 656 v8::Maybe<int32_t> result =
652 CompileRun("f()")->Int32Value(isolate2->GetCurrentContext()); 657 CompileRun("f()")->Int32Value(isolate2->GetCurrentContext());
653 CHECK_EQ(86, result.FromJust()); 658 CHECK_EQ(86, result.FromJust());
654 result = CompileRun("g()")->Int32Value(isolate2->GetCurrentContext()); 659 result = CompileRun("g()")->Int32Value(isolate2->GetCurrentContext());
655 CHECK_EQ(43, result.FromJust()); 660 CHECK_EQ(43, result.FromJust());
656 } 661 }
657 isolate2->Dispose(); 662 isolate2->Dispose();
658 } 663 }
659 664
660
661 static void SerializationFunctionTemplate( 665 static void SerializationFunctionTemplate(
662 const v8::FunctionCallbackInfo<v8::Value>& args) { 666 const v8::FunctionCallbackInfo<v8::Value>& args) {
663 args.GetReturnValue().Set(args[0]); 667 args.GetReturnValue().Set(args[0]);
664 } 668 }
665 669
666 TEST(CustomSnapshotDataBlobOutdatedContextWithOverflow) { 670 TEST(CustomSnapshotDataBlobOutdatedContextWithOverflow) {
667 DisableTurbofan(); 671 DisableTurbofan();
668 672
669 const char* source1 = 673 const char* source1 =
670 "var o = {};" 674 "var o = {};"
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 Isolate* isolate = CcTest::i_isolate(); 1067 Isolate* isolate = CcTest::i_isolate();
1064 isolate->compilation_cache()->Disable(); // Disable same-isolate code cache. 1068 isolate->compilation_cache()->Disable(); // Disable same-isolate code cache.
1065 1069
1066 v8::HandleScope scope(CcTest::isolate()); 1070 v8::HandleScope scope(CcTest::isolate());
1067 1071
1068 // The serializer only tests the shared code, which is always the unoptimized 1072 // The serializer only tests the shared code, which is always the unoptimized
1069 // code. Don't even bother generating optimized code to avoid timeouts. 1073 // code. Don't even bother generating optimized code to avoid timeouts.
1070 FLAG_always_opt = false; 1074 FLAG_always_opt = false;
1071 1075
1072 Vector<const uint8_t> source = 1076 Vector<const uint8_t> source =
1073 ConstructSource(STATIC_CHAR_VECTOR("var j=1; if (!j) {"), 1077 ConstructSource(STATIC_CHAR_VECTOR("var j=1; if (j == 0) {"),
1074 STATIC_CHAR_VECTOR("for (let i of Object.prototype);"), 1078 STATIC_CHAR_VECTOR("for (let i of Object.prototype);"),
1075 STATIC_CHAR_VECTOR("} j=7; j"), 2000); 1079 STATIC_CHAR_VECTOR("} j=7; j"), 1000);
1076 Handle<String> source_str = 1080 Handle<String> source_str =
1077 isolate->factory()->NewStringFromOneByte(source).ToHandleChecked(); 1081 isolate->factory()->NewStringFromOneByte(source).ToHandleChecked();
1078 1082
1079 Handle<JSObject> global(isolate->context()->global_object()); 1083 Handle<JSObject> global(isolate->context()->global_object());
1080 ScriptData* cache = NULL; 1084 ScriptData* cache = NULL;
1081 1085
1082 Handle<SharedFunctionInfo> orig = 1086 Handle<SharedFunctionInfo> orig =
1083 CompileScript(isolate, source_str, Handle<String>(), &cache, 1087 CompileScript(isolate, source_str, Handle<String>(), &cache,
1084 v8::ScriptCompiler::kProduceCodeCache); 1088 v8::ScriptCompiler::kProduceCodeCache);
1085 1089
(...skipping 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after
2283 } 2287 }
2284 delete[] blob.data; 2288 delete[] blob.data;
2285 } 2289 }
2286 2290
2287 TEST(SerializationMemoryStats) { 2291 TEST(SerializationMemoryStats) {
2288 FLAG_profile_deserialization = true; 2292 FLAG_profile_deserialization = true;
2289 FLAG_always_opt = false; 2293 FLAG_always_opt = false;
2290 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); 2294 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob();
2291 delete[] blob.data; 2295 delete[] blob.data;
2292 } 2296 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698