Chromium Code Reviews| Index: test/cctest/test-compiler.cc |
| diff --git a/test/cctest/test-compiler.cc b/test/cctest/test-compiler.cc |
| index 5384dcc13139d1fe5721d637cfe69aa45a071a92..9b716f5173192e324f776aacc13fae243b68a95c 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,42 @@ 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* source = "1 + 1"; |
|
vogelheim
2014/07/07 15:20:01
It might be useful - maybe as a separate test - to
Yang
2014/07/08 09:01:05
Done.
|
| + |
| + Isolate* isolate = CcTest::i_isolate(); |
| + Handle<String> source_code = isolate->factory() |
| + ->NewStringFromUtf8(CStrVector(source)) |
| + .ToHandleChecked(); |
| + |
| + ScriptData* cache = NULL; |
| + |
| + Handle<SharedFunctionInfo> orig = |
| + Compiler::CompileScript(source_code, Handle<String>(), 0, 0, false, |
| + Handle<Context>(isolate->native_context()), NULL, |
| + &cache, PRODUCE_CACHED_DATA, NOT_NATIVES_CODE); |
| + |
| + Handle<SharedFunctionInfo> info = |
| + Compiler::CompileScript(source_code, 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) { |