Chromium Code Reviews| Index: test/cctest/test-serialize.cc |
| diff --git a/test/cctest/test-serialize.cc b/test/cctest/test-serialize.cc |
| index f025d8f26c152d7952e2043b24a1ea590a13ec32..a68d1be98967aa3fcda6c7f809671cc33a66188b 100644 |
| --- a/test/cctest/test-serialize.cc |
| +++ b/test/cctest/test-serialize.cc |
| @@ -32,6 +32,7 @@ |
| #include "src/v8.h" |
| #include "src/bootstrapper.h" |
| +#include "src/compilation-cache.h" |
| #include "src/debug.h" |
| #include "src/ic-inl.h" |
| #include "src/natives.h" |
| @@ -680,34 +681,36 @@ TEST(SerializeToplevelOnePlusOne) { |
| LocalContext context; |
| v8::HandleScope scope(CcTest::isolate()); |
| - const char* source1 = "1 + 1"; |
| - const char* source2 = "1 + 2"; // Use alternate string to verify caching. |
| + const char* source = "1 + 1"; |
| Isolate* isolate = CcTest::i_isolate(); |
| - Handle<String> source1_string = isolate->factory() |
| - ->NewStringFromUtf8(CStrVector(source1)) |
| - .ToHandleChecked(); |
| + isolate->compilation_cache()->Disable(); |
| - Handle<String> source2_string = isolate->factory() |
| - ->NewStringFromUtf8(CStrVector(source2)) |
| - .ToHandleChecked(); |
| + Handle<String> orig_source = isolate->factory() |
| + ->NewStringFromUtf8(CStrVector(source)) |
| + .ToHandleChecked(); |
| + Handle<String> copy_source = isolate->factory() |
| + ->NewStringFromUtf8(CStrVector(source)) |
| + .ToHandleChecked(); |
| + CHECK(!orig_source.is_identical_to(copy_source)); |
| + CHECK(orig_source->Equals(*copy_source)); |
| ScriptData* cache = NULL; |
| Handle<SharedFunctionInfo> orig = |
| - Compiler::CompileScript(source1_string, Handle<String>(), 0, 0, false, |
| + Compiler::CompileScript(orig_source, Handle<String>(), 0, 0, false, |
| Handle<Context>(isolate->native_context()), NULL, |
| &cache, PRODUCE_CACHED_DATA, NOT_NATIVES_CODE); |
| int builtins_count = CountBuiltins(); |
| Handle<SharedFunctionInfo> copy = |
| - Compiler::CompileScript(source2_string, Handle<String>(), 0, 0, false, |
| + Compiler::CompileScript(copy_source, Handle<String>(), 0, 0, false, |
| Handle<Context>(isolate->native_context()), NULL, |
| &cache, CONSUME_CACHED_DATA, NOT_NATIVES_CODE); |
|
vogelheim
2014/07/15 13:42:31
Just for my understanding: Previously, this would
Yang
2014/07/15 13:47:31
You are right. Currently, if CompileScript was to
|
| CHECK_NE(*orig, *copy); |
| - CHECK(Script::cast(copy->script())->source() == *source2_string); |
| + CHECK(Script::cast(copy->script())->source() == *copy_source); |
| Handle<JSFunction> copy_fun = |
| isolate->factory()->NewFunctionFromSharedFunctionInfo( |
| @@ -728,22 +731,25 @@ TEST(SerializeToplevelInternalizedString) { |
| LocalContext context; |
| v8::HandleScope scope(CcTest::isolate()); |
| - const char* source1 = "'string1'"; |
| - const char* source2 = "'string2'"; // Use alternate string to verify caching. |
| + const char* source = "'string1'"; |
| Isolate* isolate = CcTest::i_isolate(); |
| - Handle<String> source1_string = isolate->factory() |
| - ->NewStringFromUtf8(CStrVector(source1)) |
| - .ToHandleChecked(); |
| + isolate->compilation_cache()->Disable(); |
| + |
| + Handle<String> orig_source = isolate->factory() |
| + ->NewStringFromUtf8(CStrVector(source)) |
| + .ToHandleChecked(); |
| + Handle<String> copy_source = isolate->factory() |
| + ->NewStringFromUtf8(CStrVector(source)) |
| + .ToHandleChecked(); |
| + CHECK(!orig_source.is_identical_to(copy_source)); |
| + CHECK(orig_source->Equals(*copy_source)); |
| - 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, |
| + Compiler::CompileScript(orig_source, Handle<String>(), 0, 0, false, |
| Handle<Context>(isolate->native_context()), NULL, |
| &cache, PRODUCE_CACHED_DATA, NOT_NATIVES_CODE); |
| Handle<JSFunction> orig_fun = |
| @@ -756,11 +762,11 @@ TEST(SerializeToplevelInternalizedString) { |
| int builtins_count = CountBuiltins(); |
| Handle<SharedFunctionInfo> copy = |
| - Compiler::CompileScript(source2_string, Handle<String>(), 0, 0, false, |
| + Compiler::CompileScript(copy_source, Handle<String>(), 0, 0, false, |
| Handle<Context>(isolate->native_context()), NULL, |
| &cache, CONSUME_CACHED_DATA, NOT_NATIVES_CODE); |
| CHECK_NE(*orig, *copy); |
| - CHECK(Script::cast(copy->script())->source() == *source2_string); |
| + CHECK(Script::cast(copy->script())->source() == *copy_source); |
| Handle<JSFunction> copy_fun = |
| isolate->factory()->NewFunctionFromSharedFunctionInfo( |