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

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

Issue 383173002: Serialize builtins by referencing canonical ones. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-compiler.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 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 TEST(TestThatAlwaysFails) { 654 TEST(TestThatAlwaysFails) {
655 bool ArtificialFailure = false; 655 bool ArtificialFailure = false;
656 CHECK(ArtificialFailure); 656 CHECK(ArtificialFailure);
657 } 657 }
658 658
659 659
660 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) { 660 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) {
661 bool ArtificialFailure2 = false; 661 bool ArtificialFailure2 = false;
662 CHECK(ArtificialFailure2); 662 CHECK(ArtificialFailure2);
663 } 663 }
664
665
666 int CountBuiltins() {
667 // Check that we have not deserialized any additional builtin.
668 HeapIterator iterator(CcTest::heap());
669 DisallowHeapAllocation no_allocation;
670 int counter = 0;
671 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) {
672 if (obj->IsCode() && Code::cast(obj)->kind() == Code::BUILTIN) counter++;
673 }
674 return counter;
675 }
676
677
678 TEST(SerializeToplevel) {
679 FLAG_serialize_toplevel = true;
680 v8::HandleScope scope(CcTest::isolate());
681 v8::Local<v8::Context> context = CcTest::NewContext(PRINT_EXTENSION);
682 v8::Context::Scope context_scope(context);
683
684 const char* source1 = "1 + 1";
685 const char* source2 = "1 + 2"; // Use alternate string to verify caching.
686
687 Isolate* isolate = CcTest::i_isolate();
688 Handle<String> source1_string = isolate->factory()
689 ->NewStringFromUtf8(CStrVector(source1))
690 .ToHandleChecked();
691
692 Handle<String> source2_string = isolate->factory()
693 ->NewStringFromUtf8(CStrVector(source2))
694 .ToHandleChecked();
695
696 ScriptData* cache = NULL;
697
698 Handle<SharedFunctionInfo> orig =
699 Compiler::CompileScript(source1_string, Handle<String>(), 0, 0, false,
700 Handle<Context>(isolate->native_context()), NULL,
701 &cache, PRODUCE_CACHED_DATA, NOT_NATIVES_CODE);
702
703 int builtins_count = CountBuiltins();
704
705 Handle<SharedFunctionInfo> info =
706 Compiler::CompileScript(source2_string, Handle<String>(), 0, 0, false,
707 Handle<Context>(isolate->native_context()), NULL,
708 &cache, CONSUME_CACHED_DATA, NOT_NATIVES_CODE);
709
710 CHECK_NE(*orig, *info);
711 Handle<JSFunction> fun =
712 isolate->factory()->NewFunctionFromSharedFunctionInfo(
713 info, isolate->native_context());
714 Handle<JSObject> global(isolate->context()->global_object());
715 Handle<Object> result =
716 Execution::Call(isolate, fun, global, 0, NULL).ToHandleChecked();
717 CHECK_EQ(2, Handle<Smi>::cast(result)->value());
718
719 CHECK_EQ(builtins_count, CountBuiltins());
720
721 delete cache;
722 }
OLDNEW
« no previous file with comments | « test/cctest/test-compiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698