Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(835)

Side by Side Diff: src/api.cc

Issue 234953002: Fail the compilation if the cached data is invalid. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/messages.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1676 matching lines...) Expand 10 before | Expand all | Expand 10 after
1687 i::Handle<i::SharedFunctionInfo>(i::JSFunction::cast(*obj)->shared())); 1687 i::Handle<i::SharedFunctionInfo>(i::JSFunction::cast(*obj)->shared()));
1688 } 1688 }
1689 1689
1690 1690
1691 Local<UnboundScript> ScriptCompiler::CompileUnbound( 1691 Local<UnboundScript> ScriptCompiler::CompileUnbound(
1692 Isolate* v8_isolate, 1692 Isolate* v8_isolate,
1693 Source* source, 1693 Source* source,
1694 CompileOptions options) { 1694 CompileOptions options) {
1695 i::ScriptData* script_data_impl = NULL; 1695 i::ScriptData* script_data_impl = NULL;
1696 i::CachedDataMode cached_data_mode = i::NO_CACHED_DATA; 1696 i::CachedDataMode cached_data_mode = i::NO_CACHED_DATA;
1697 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
1698 ON_BAILOUT(isolate, "v8::ScriptCompiler::CompileUnbound()",
1699 return Local<UnboundScript>());
1697 if (options & kProduceDataToCache) { 1700 if (options & kProduceDataToCache) {
1698 cached_data_mode = i::PRODUCE_CACHED_DATA; 1701 cached_data_mode = i::PRODUCE_CACHED_DATA;
1699 ASSERT(source->cached_data == NULL); 1702 ASSERT(source->cached_data == NULL);
1700 if (source->cached_data) { 1703 if (source->cached_data) {
1701 // Asked to produce cached data even though there is some already -> not 1704 // Asked to produce cached data even though there is some already -> not
1702 // good. In release mode, try to do the right thing: Just regenerate the 1705 // good. Fail the compilation.
1703 // data. 1706 EXCEPTION_PREAMBLE(isolate);
1704 delete source->cached_data; 1707 i::Handle<i::Object> result = isolate->factory()->NewSyntaxError(
1705 source->cached_data = NULL; 1708 "invalid_cached_data", isolate->factory()->NewJSArray(0));
1709 isolate->Throw(*result);
1710 isolate->ReportPendingMessages();
1711 has_pending_exception = true;
1712 EXCEPTION_BAILOUT_CHECK(isolate, Local<UnboundScript>());
1706 } 1713 }
1707 } else if (source->cached_data) { 1714 } else if (source->cached_data) {
1715 cached_data_mode = i::CONSUME_CACHED_DATA;
1708 // ScriptData takes care of aligning, in case the data is not aligned 1716 // ScriptData takes care of aligning, in case the data is not aligned
1709 // correctly. 1717 // correctly.
1710 script_data_impl = i::ScriptData::New( 1718 script_data_impl = i::ScriptData::New(
1711 reinterpret_cast<const char*>(source->cached_data->data), 1719 reinterpret_cast<const char*>(source->cached_data->data),
1712 source->cached_data->length); 1720 source->cached_data->length);
1713 // We assert that the pre-data is sane, even though we can actually 1721 // If the cached data is not valid, fail the compilation.
1714 // handle it if it turns out not to be in release mode. 1722 if (script_data_impl == NULL || !script_data_impl->SanityCheck()) {
1715 ASSERT(script_data_impl->SanityCheck()); 1723 EXCEPTION_PREAMBLE(isolate);
1716 if (script_data_impl->SanityCheck()) { 1724 i::Handle<i::Object> result = isolate->factory()->NewSyntaxError(
1717 cached_data_mode = i::CONSUME_CACHED_DATA; 1725 "invalid_cached_data", isolate->factory()->NewJSArray(0));
1718 } else { 1726 isolate->Throw(*result);
1719 // If the pre-data isn't sane we simply ignore it. 1727 isolate->ReportPendingMessages();
1720 delete script_data_impl; 1728 delete script_data_impl;
1721 script_data_impl = NULL; 1729 has_pending_exception = true;
1722 delete source->cached_data; 1730 EXCEPTION_BAILOUT_CHECK(isolate, Local<UnboundScript>());
1723 source->cached_data = NULL;
1724 } 1731 }
1725 } 1732 }
1726 1733
1727 i::Handle<i::String> str = Utils::OpenHandle(*(source->source_string)); 1734 i::Handle<i::String> str = Utils::OpenHandle(*(source->source_string));
1728 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
1729 ON_BAILOUT(isolate, "v8::ScriptCompiler::CompileUnbound()",
1730 return Local<UnboundScript>());
1731 LOG_API(isolate, "ScriptCompiler::CompileUnbound"); 1735 LOG_API(isolate, "ScriptCompiler::CompileUnbound");
1732 ENTER_V8(isolate); 1736 ENTER_V8(isolate);
1733 i::SharedFunctionInfo* raw_result = NULL; 1737 i::SharedFunctionInfo* raw_result = NULL;
1734 { i::HandleScope scope(isolate); 1738 { i::HandleScope scope(isolate);
1735 i::Handle<i::Object> name_obj; 1739 i::Handle<i::Object> name_obj;
1736 int line_offset = 0; 1740 int line_offset = 0;
1737 int column_offset = 0; 1741 int column_offset = 0;
1738 bool is_shared_cross_origin = false; 1742 bool is_shared_cross_origin = false;
1739 if (!source->resource_name.IsEmpty()) { 1743 if (!source->resource_name.IsEmpty()) {
1740 name_obj = Utils::OpenHandle(*(source->resource_name)); 1744 name_obj = Utils::OpenHandle(*(source->resource_name));
(...skipping 5907 matching lines...) Expand 10 before | Expand all | Expand 10 after
7648 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7652 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7649 Address callback_address = 7653 Address callback_address =
7650 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7654 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7651 VMState<EXTERNAL> state(isolate); 7655 VMState<EXTERNAL> state(isolate);
7652 ExternalCallbackScope call_scope(isolate, callback_address); 7656 ExternalCallbackScope call_scope(isolate, callback_address);
7653 callback(info); 7657 callback(info);
7654 } 7658 }
7655 7659
7656 7660
7657 } } // namespace v8::internal 7661 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/messages.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698