OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 14793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14804 TEST(PreCompileSerialization) { | 14804 TEST(PreCompileSerialization) { |
14805 v8::V8::Initialize(); | 14805 v8::V8::Initialize(); |
14806 LocalContext env; | 14806 LocalContext env; |
14807 v8::Isolate* isolate = env->GetIsolate(); | 14807 v8::Isolate* isolate = env->GetIsolate(); |
14808 HandleScope handle_scope(isolate); | 14808 HandleScope handle_scope(isolate); |
14809 | 14809 |
14810 i::FLAG_min_preparse_length = 0; | 14810 i::FLAG_min_preparse_length = 0; |
14811 const char* script = "function foo(a) { return a+1; }"; | 14811 const char* script = "function foo(a) { return a+1; }"; |
14812 v8::ScriptCompiler::Source source(v8_str(script)); | 14812 v8::ScriptCompiler::Source source(v8_str(script)); |
14813 v8::ScriptCompiler::Compile(isolate, &source, | 14813 v8::ScriptCompiler::Compile(isolate, &source, |
14814 v8::ScriptCompiler::kProduceDataToCache); | 14814 v8::ScriptCompiler::kProduceParserCache); |
14815 // Serialize. | 14815 // Serialize. |
14816 const v8::ScriptCompiler::CachedData* cd = source.GetCachedData(); | 14816 const v8::ScriptCompiler::CachedData* cd = source.GetCachedData(); |
14817 i::byte* serialized_data = i::NewArray<i::byte>(cd->length); | 14817 i::byte* serialized_data = i::NewArray<i::byte>(cd->length); |
14818 i::MemCopy(serialized_data, cd->data, cd->length); | 14818 i::MemCopy(serialized_data, cd->data, cd->length); |
14819 | 14819 |
14820 // Deserialize. | 14820 // Deserialize. |
14821 i::ScriptData* deserialized = new i::ScriptData(serialized_data, cd->length); | 14821 i::ScriptData* deserialized = new i::ScriptData(serialized_data, cd->length); |
14822 | 14822 |
14823 // Verify that the original is the same as the deserialized. | 14823 // Verify that the original is the same as the deserialized. |
14824 CHECK_EQ(cd->length, deserialized->length()); | 14824 CHECK_EQ(cd->length, deserialized->length()); |
(...skipping 7956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
22781 desc = x->GetOwnPropertyDescriptor(v8_str("p1")); | 22781 desc = x->GetOwnPropertyDescriptor(v8_str("p1")); |
22782 Local<Function> set = | 22782 Local<Function> set = |
22783 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("set"))); | 22783 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("set"))); |
22784 Local<Function> get = | 22784 Local<Function> get = |
22785 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("get"))); | 22785 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("get"))); |
22786 CHECK_EQ(v8_num(13), get->Call(x, 0, NULL)); | 22786 CHECK_EQ(v8_num(13), get->Call(x, 0, NULL)); |
22787 Handle<Value> args[] = { v8_num(14) }; | 22787 Handle<Value> args[] = { v8_num(14) }; |
22788 set->Call(x, 1, args); | 22788 set->Call(x, 1, args); |
22789 CHECK_EQ(v8_num(14), get->Call(x, 0, NULL)); | 22789 CHECK_EQ(v8_num(14), get->Call(x, 0, NULL)); |
22790 } | 22790 } |
OLD | NEW |