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

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

Issue 387343002: Fix up internalized strings after deserializing user code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: remove TODO 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/serialize.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-serialize.cc
diff --git a/test/cctest/test-serialize.cc b/test/cctest/test-serialize.cc
index 3177fd6394c9edac6e0c349c707eac466d4ff96e..7d228cabfbcbb3105d0421687415bacffcf2702c 100644
--- a/test/cctest/test-serialize.cc
+++ b/test/cctest/test-serialize.cc
@@ -675,11 +675,10 @@ int CountBuiltins() {
}
-TEST(SerializeToplevel) {
+TEST(SerializeToplevelOnePlusOne) {
FLAG_serialize_toplevel = true;
+ LocalContext context;
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.
@@ -702,21 +701,75 @@ TEST(SerializeToplevel) {
int builtins_count = CountBuiltins();
- Handle<SharedFunctionInfo> info =
+ Handle<SharedFunctionInfo> copy =
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 =
+ CHECK_NE(*orig, *copy);
+ Handle<JSFunction> copy_fun =
isolate->factory()->NewFunctionFromSharedFunctionInfo(
- info, isolate->native_context());
+ copy, 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());
+ Handle<Object> copy_result =
+ Execution::Call(isolate, copy_fun, global, 0, NULL).ToHandleChecked();
+ CHECK_EQ(2, Handle<Smi>::cast(copy_result)->value());
CHECK_EQ(builtins_count, CountBuiltins());
delete cache;
}
+
+
+TEST(SerializeToplevelInternalizedString) {
mvstanton 2014/07/14 13:31:03 Per our discussion, it might be nice in debug mode
+ FLAG_serialize_toplevel = true;
+ LocalContext context;
+ v8::HandleScope scope(CcTest::isolate());
+
+ const char* source1 = "'string1'";
+ const char* source2 = "'string2'"; // 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();
+ Handle<JSObject> global(isolate->context()->global_object());
+ 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<JSFunction> orig_fun =
+ isolate->factory()->NewFunctionFromSharedFunctionInfo(
+ orig, isolate->native_context());
+ Handle<Object> orig_result =
+ Execution::Call(isolate, orig_fun, global, 0, NULL).ToHandleChecked();
+ CHECK(orig_result->IsInternalizedString());
+
+ int builtins_count = CountBuiltins();
+
+ Handle<SharedFunctionInfo> copy =
+ 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, *copy);
+ Handle<JSFunction> copy_fun =
+ isolate->factory()->NewFunctionFromSharedFunctionInfo(
+ copy, isolate->native_context());
+ CHECK_NE(*orig_fun, *copy_fun);
+ Handle<Object> copy_result =
+ Execution::Call(isolate, copy_fun, global, 0, NULL).ToHandleChecked();
+ CHECK(orig_result.is_identical_to(copy_result));
+ Handle<String> expected =
+ isolate->factory()->NewStringFromAsciiChecked("string1");
+
+ CHECK(Handle<String>::cast(copy_result)->Equals(*expected));
+ CHECK_EQ(builtins_count, CountBuiltins());
+
+ delete cache;
+}
« no previous file with comments | « src/serialize.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698