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

Unified Diff: test/cctest/test-compiler.cc

Issue 373713006: Introduce code serializer/deserializer. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments and rebased 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/version.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-compiler.cc
diff --git a/test/cctest/test-compiler.cc b/test/cctest/test-compiler.cc
index 5384dcc13139d1fe5721d637cfe69aa45a071a92..c77b4b2dd3924936b4a758a1e776802d77f7fae5 100644
--- a/test/cctest/test-compiler.cc
+++ b/test/cctest/test-compiler.cc
@@ -32,6 +32,7 @@
#include "src/compiler.h"
#include "src/disasm.h"
+#include "src/parser.h"
#include "test/cctest/cctest.h"
using namespace v8::internal;
@@ -398,6 +399,46 @@ TEST(OptimizedCodeSharing) {
}
+TEST(SerializeToplevel) {
+ FLAG_serialize_toplevel = true;
+ v8::HandleScope scope(CcTest::isolate());
+ v8::Local<v8::Context> context = CcTest::NewContext(PRINT_EXTENSION);
+ v8::Context::Scope context_scope(context);
+
+ const char* source1 = "1 + 1";
+ const char* source2 = "1 + 2"; // Use alternate string to verify caching.
+
+ Isolate* isolate = CcTest::i_isolate();
+ Handle<String> source1_string = isolate->factory()
+ ->NewStringFromUtf8(CStrVector(source1))
+ .ToHandleChecked();
+ Handle<String> source2_string = isolate->factory()
+ ->NewStringFromUtf8(CStrVector(source2))
+ .ToHandleChecked();
+
+ ScriptData* cache = NULL;
+
+ Handle<SharedFunctionInfo> orig =
+ Compiler::CompileScript(source1_string, Handle<String>(), 0, 0, false,
+ Handle<Context>(isolate->native_context()), NULL,
+ &cache, PRODUCE_CACHED_DATA, NOT_NATIVES_CODE);
+
+ Handle<SharedFunctionInfo> info =
+ Compiler::CompileScript(source2_string, Handle<String>(), 0, 0, false,
+ Handle<Context>(isolate->native_context()), NULL,
+ &cache, CONSUME_CACHED_DATA, NOT_NATIVES_CODE);
+
+ CHECK_NE(*orig, *info);
+ Handle<JSFunction> fun =
+ isolate->factory()->NewFunctionFromSharedFunctionInfo(
+ info, isolate->native_context());
+ Handle<JSObject> global(isolate->context()->global_object());
+ Handle<Object> result =
+ Execution::Call(isolate, fun, global, 0, NULL).ToHandleChecked();
+ CHECK_EQ(2, Handle<Smi>::cast(result)->value());
+}
+
+
#ifdef ENABLE_DISASSEMBLER
static Handle<JSFunction> GetJSFunction(v8::Handle<v8::Object> obj,
const char* property_name) {
« no previous file with comments | « src/version.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698