OLD | NEW |
1 // Copyright 2007-2010 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2010 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 1224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1235 | 1235 |
1236 CompileRun(source1); | 1236 CompileRun(source1); |
1237 CompileRun(source2); | 1237 CompileRun(source2); |
1238 | 1238 |
1239 v8::Local<v8::String> source_str = v8_str(source3); | 1239 v8::Local<v8::String> source_str = v8_str(source3); |
1240 v8::ScriptOrigin origin(v8_str("test")); | 1240 v8::ScriptOrigin origin(v8_str("test")); |
1241 v8::ScriptCompiler::Source source(source_str, origin); | 1241 v8::ScriptCompiler::Source source(source_str, origin); |
1242 v8::Local<v8::UnboundScript> script = v8::ScriptCompiler::CompileUnbound( | 1242 v8::Local<v8::UnboundScript> script = v8::ScriptCompiler::CompileUnbound( |
1243 isolate1, &source, v8::ScriptCompiler::kProduceCodeCache); | 1243 isolate1, &source, v8::ScriptCompiler::kProduceCodeCache); |
1244 const v8::ScriptCompiler::CachedData* data = source.GetCachedData(); | 1244 const v8::ScriptCompiler::CachedData* data = source.GetCachedData(); |
| 1245 CHECK(data); |
1245 // Persist cached data. | 1246 // Persist cached data. |
1246 uint8_t* buffer = NewArray<uint8_t>(data->length); | 1247 uint8_t* buffer = NewArray<uint8_t>(data->length); |
1247 MemCopy(buffer, data->data, data->length); | 1248 MemCopy(buffer, data->data, data->length); |
1248 cache = new v8::ScriptCompiler::CachedData( | 1249 cache = new v8::ScriptCompiler::CachedData( |
1249 buffer, data->length, v8::ScriptCompiler::CachedData::BufferOwned); | 1250 buffer, data->length, v8::ScriptCompiler::CachedData::BufferOwned); |
1250 | 1251 |
1251 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run(); | 1252 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run(); |
1252 CHECK(result->ToString()->Equals(v8_str("XY"))); | 1253 CHECK(result->ToString()->Equals(v8_str("XY"))); |
1253 } | 1254 } |
1254 isolate1->Dispose(); | 1255 isolate1->Dispose(); |
(...skipping 16 matching lines...) Expand all Loading... |
1271 { | 1272 { |
1272 DisallowCompilation no_compile(reinterpret_cast<Isolate*>(isolate2)); | 1273 DisallowCompilation no_compile(reinterpret_cast<Isolate*>(isolate2)); |
1273 script = v8::ScriptCompiler::CompileUnbound( | 1274 script = v8::ScriptCompiler::CompileUnbound( |
1274 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache); | 1275 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache); |
1275 } | 1276 } |
1276 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run(); | 1277 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run(); |
1277 CHECK(result->ToString()->Equals(v8_str("XY"))); | 1278 CHECK(result->ToString()->Equals(v8_str("XY"))); |
1278 } | 1279 } |
1279 isolate2->Dispose(); | 1280 isolate2->Dispose(); |
1280 } | 1281 } |
OLD | NEW |