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

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

Issue 1210503002: Version 4.3.61.32 (cherry-pick) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@4.3
Patch Set: fix test Created 5 years, 6 months 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
« no previous file with comments | « src/snapshot/serialize.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 679 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 v8::Local<v8::Context> context = v8::Context::New(isolate2); 690 v8::Local<v8::Context> context = v8::Context::New(isolate2);
691 delete[] data2.data; // We can dispose of the snapshot blob now. 691 delete[] data2.data; // We can dispose of the snapshot blob now.
692 v8::Context::Scope c_scope(context); 692 v8::Context::Scope c_scope(context);
693 CHECK_EQ(86, CompileRun("f()")->ToInt32(isolate2)->Int32Value()); 693 CHECK_EQ(86, CompileRun("f()")->ToInt32(isolate2)->Int32Value());
694 CHECK_EQ(43, CompileRun("g()")->ToInt32(isolate2)->Int32Value()); 694 CHECK_EQ(43, CompileRun("g()")->ToInt32(isolate2)->Int32Value());
695 } 695 }
696 isolate2->Dispose(); 696 isolate2->Dispose();
697 } 697 }
698 698
699 699
700 static void SerializationFunctionTemplate(
701 const v8::FunctionCallbackInfo<v8::Value>& args) {
702 args.GetReturnValue().Set(args[0]);
703 }
704
705
706 TEST(PerIsolateSnapshotBlobsOutdatedContextWithOverflow) {
707 DisableTurbofan();
708
709 const char* source1 =
710 "var o = {};"
711 "(function() {"
712 " function f1(x) { return f2(x) instanceof Array; }"
713 " function f2(x) { return foo.bar(x); }"
714 " o.a = f2.bind(null);"
715 " o.b = 1;"
716 " o.c = 2;"
717 " o.d = 3;"
718 " o.e = 4;"
719 "})();\n";
720
721 const char* source2 = "o.a(42)";
722
723 v8::StartupData data = v8::V8::CreateSnapshotDataBlob(source1);
724
725 v8::Isolate::CreateParams params;
726 params.snapshot_blob = &data;
727
728 v8::Isolate* isolate = v8::Isolate::New(params);
729 {
730 v8::Isolate::Scope i_scope(isolate);
731 v8::HandleScope h_scope(isolate);
732
733 v8::Local<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate);
734 v8::Local<v8::ObjectTemplate> property = v8::ObjectTemplate::New(isolate);
735 v8::Local<v8::FunctionTemplate> function =
736 v8::FunctionTemplate::New(isolate, SerializationFunctionTemplate);
737 property->Set(isolate, "bar", function);
738 global->Set(isolate, "foo", property);
739
740 v8::Local<v8::Context> context = v8::Context::New(isolate, NULL, global);
741 delete[] data.data; // We can dispose of the snapshot blob now.
742 v8::Context::Scope c_scope(context);
743 v8::Local<v8::Value> result = CompileRun(source2);
744 CHECK(v8_str("42")->Equals(result));
745 }
746 isolate->Dispose();
747 }
748
749
700 TEST(PerIsolateSnapshotBlobsWithLocker) { 750 TEST(PerIsolateSnapshotBlobsWithLocker) {
701 DisableTurbofan(); 751 DisableTurbofan();
702 v8::Isolate* isolate0 = v8::Isolate::New(); 752 v8::Isolate* isolate0 = v8::Isolate::New();
703 { 753 {
704 v8::Locker locker(isolate0); 754 v8::Locker locker(isolate0);
705 v8::Isolate::Scope i_scope(isolate0); 755 v8::Isolate::Scope i_scope(isolate0);
706 v8::HandleScope h_scope(isolate0); 756 v8::HandleScope h_scope(isolate0);
707 v8::Local<v8::Context> context = v8::Context::New(isolate0); 757 v8::Local<v8::Context> context = v8::Context::New(isolate0);
708 v8::Context::Scope c_scope(context); 758 v8::Context::Scope c_scope(context);
709 CHECK_EQ(1, CompileRun("Math.cos(0)")->ToInt32(isolate0)->Int32Value()); 759 CHECK_EQ(1, CompileRun("Math.cos(0)")->ToInt32(isolate0)->Int32Value());
(...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after
1579 CHECK_EQ(11, CompileRun("foo(0)")->ToInt32(isolate)->Int32Value()); 1629 CHECK_EQ(11, CompileRun("foo(0)")->ToInt32(isolate)->Int32Value());
1580 CHECK_EQ(11, CompileRun("foo(1)")->ToInt32(isolate)->Int32Value()); 1630 CHECK_EQ(11, CompileRun("foo(1)")->ToInt32(isolate)->Int32Value());
1581 CHECK_EQ(12, CompileRun("foo(2)")->ToInt32(isolate)->Int32Value()); 1631 CHECK_EQ(12, CompileRun("foo(2)")->ToInt32(isolate)->Int32Value());
1582 CHECK_EQ(12, CompileRun("foo(3)")->ToInt32(isolate)->Int32Value()); 1632 CHECK_EQ(12, CompileRun("foo(3)")->ToInt32(isolate)->Int32Value());
1583 CHECK_EQ(23, CompileRun("foo(4)")->ToInt32(isolate)->Int32Value()); 1633 CHECK_EQ(23, CompileRun("foo(4)")->ToInt32(isolate)->Int32Value());
1584 CHECK_EQ(23, CompileRun("foo(5)")->ToInt32(isolate)->Int32Value()); 1634 CHECK_EQ(23, CompileRun("foo(5)")->ToInt32(isolate)->Int32Value());
1585 CHECK_EQ(10, CompileRun("foo(6)")->ToInt32(isolate)->Int32Value()); 1635 CHECK_EQ(10, CompileRun("foo(6)")->ToInt32(isolate)->Int32Value());
1586 } 1636 }
1587 isolate->Dispose(); 1637 isolate->Dispose();
1588 } 1638 }
OLDNEW
« no previous file with comments | « src/snapshot/serialize.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698