Chromium Code Reviews| Index: src/api.cc |
| diff --git a/src/api.cc b/src/api.cc |
| index 106c1fd916a90137bb268bcf7b51f83c44d07efa..127043db894fa5c0d0b2f4a15ded769f80c0dcf5 100644 |
| --- a/src/api.cc |
| +++ b/src/api.cc |
| @@ -1699,16 +1699,13 @@ Local<UnboundScript> ScriptCompiler::CompileUnbound( |
| Isolate* v8_isolate, |
| Source* source, |
| CompileOptions options) { |
| - i::ScriptData* script_data = NULL; |
| - i::CachedDataMode cached_data_mode = i::NO_CACHED_DATA; |
| i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
| ON_BAILOUT(isolate, "v8::ScriptCompiler::CompileUnbound()", |
| return Local<UnboundScript>()); |
| - if (options & kProduceDataToCache) { |
| - cached_data_mode = i::PRODUCE_CACHED_DATA; |
| - CHECK(source->cached_data == NULL); |
| - } else if (source->cached_data) { |
| - cached_data_mode = i::CONSUME_CACHED_DATA; |
| + |
| + i::ScriptData* script_data = NULL; |
| + if (options == kConsumeParserCache || options == kConsumeCodeCache) { |
| + ASSERT(source->cached_data); |
| // ScriptData takes care of pointer-aligning the data. |
| script_data = new i::ScriptData(source->cached_data->data, |
| source->cached_data->length); |
| @@ -1741,10 +1738,10 @@ Local<UnboundScript> ScriptCompiler::CompileUnbound( |
| EXCEPTION_PREAMBLE(isolate); |
| i::Handle<i::SharedFunctionInfo> result = i::Compiler::CompileScript( |
| str, name_obj, line_offset, column_offset, is_shared_cross_origin, |
| - isolate->global_context(), NULL, &script_data, cached_data_mode, |
| + isolate->global_context(), NULL, &script_data, options, |
| i::NOT_NATIVES_CODE); |
| has_pending_exception = result.is_null(); |
| - if (has_pending_exception && cached_data_mode == i::CONSUME_CACHED_DATA) { |
| + if (has_pending_exception && script_data != NULL) { |
| // This case won't happen during normal operation; we have compiled |
| // successfully and produced cached data, and but the second compilation |
| // of the same source code fails. |
| @@ -1753,8 +1750,10 @@ Local<UnboundScript> ScriptCompiler::CompileUnbound( |
| } |
| EXCEPTION_BAILOUT_CHECK(isolate, Local<UnboundScript>()); |
| raw_result = *result; |
| - if ((options & kProduceDataToCache) && script_data != NULL) { |
| - // script_data_impl now contains the data that was generated. source will |
| + |
| + if ((options == kProduceParserCache || options == kProduceCodeCache) && |
| + script_data != NULL) { |
|
marja
2014/07/14 07:45:46
I don't think it's possible that (options == kProd
vogelheim
2014/07/14 10:40:04
Well... if any kProduce*Cache is set and Compiler:
marja
2014/07/14 10:41:12
Ahh, I missed the if above which actually does nul
|
| + // script_data now contains the data that was generated. source will |
| // take the ownership. |
| source->cached_data = new CachedData( |
| script_data->data(), script_data->length(), CachedData::BufferOwned); |