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

Side by Side Diff: src/api.cc

Issue 724023002: Soft fail for invalid cache data. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: use flag to indicate rejection Created 6 years, 1 month 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/api.h" 5 #include "src/api.h"
6 6
7 #include <string.h> // For memcpy, strlen. 7 #include <string.h> // For memcpy, strlen.
8 #ifdef V8_USE_ADDRESS_SANITIZER 8 #ifdef V8_USE_ADDRESS_SANITIZER
9 #include <sanitizer/asan_interface.h> 9 #include <sanitizer/asan_interface.h>
10 #endif // V8_USE_ADDRESS_SANITIZER 10 #endif // V8_USE_ADDRESS_SANITIZER
(...skipping 1518 matching lines...) Expand 10 before | Expand all | Expand 10 after
1529 1529
1530 1530
1531 // --- S c r i p t s --- 1531 // --- S c r i p t s ---
1532 1532
1533 1533
1534 // Internally, UnboundScript is a SharedFunctionInfo, and Script is a 1534 // Internally, UnboundScript is a SharedFunctionInfo, and Script is a
1535 // JSFunction. 1535 // JSFunction.
1536 1536
1537 ScriptCompiler::CachedData::CachedData(const uint8_t* data_, int length_, 1537 ScriptCompiler::CachedData::CachedData(const uint8_t* data_, int length_,
1538 BufferPolicy buffer_policy_) 1538 BufferPolicy buffer_policy_)
1539 : data(data_), length(length_), buffer_policy(buffer_policy_) {} 1539 : data(data_),
1540 length(length_),
1541 rejected(false),
1542 buffer_policy(buffer_policy_) {}
1540 1543
1541 1544
1542 ScriptCompiler::CachedData::~CachedData() { 1545 ScriptCompiler::CachedData::~CachedData() {
1543 if (buffer_policy == BufferOwned) { 1546 if (buffer_policy == BufferOwned) {
1544 delete[] data; 1547 delete[] data;
1545 } 1548 }
1546 } 1549 }
1547 1550
1548 1551
1549 ScriptCompiler::StreamedSource::StreamedSource(ExternalSourceStream* stream, 1552 ScriptCompiler::StreamedSource::StreamedSource(ExternalSourceStream* stream,
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1745 EXCEPTION_BAILOUT_CHECK(isolate, Local<UnboundScript>()); 1748 EXCEPTION_BAILOUT_CHECK(isolate, Local<UnboundScript>());
1746 raw_result = *result; 1749 raw_result = *result;
1747 1750
1748 if ((options == kProduceParserCache || options == kProduceCodeCache) && 1751 if ((options == kProduceParserCache || options == kProduceCodeCache) &&
1749 script_data != NULL) { 1752 script_data != NULL) {
1750 // script_data now contains the data that was generated. source will 1753 // script_data now contains the data that was generated. source will
1751 // take the ownership. 1754 // take the ownership.
1752 source->cached_data = new CachedData( 1755 source->cached_data = new CachedData(
1753 script_data->data(), script_data->length(), CachedData::BufferOwned); 1756 script_data->data(), script_data->length(), CachedData::BufferOwned);
1754 script_data->ReleaseDataOwnership(); 1757 script_data->ReleaseDataOwnership();
1758 } else if (options == kConsumeParserCache || options == kConsumeCodeCache) {
1759 source->cached_data->rejected = script_data->rejected();
1755 } 1760 }
1756 delete script_data; 1761 delete script_data;
1757 } 1762 }
1758 i::Handle<i::SharedFunctionInfo> result(raw_result, isolate); 1763 i::Handle<i::SharedFunctionInfo> result(raw_result, isolate);
1759 return ToApiHandle<UnboundScript>(result); 1764 return ToApiHandle<UnboundScript>(result);
1760 } 1765 }
1761 1766
1762 1767
1763 Local<Script> ScriptCompiler::Compile( 1768 Local<Script> ScriptCompiler::Compile(
1764 Isolate* v8_isolate, 1769 Isolate* v8_isolate,
(...skipping 6005 matching lines...) Expand 10 before | Expand all | Expand 10 after
7770 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7775 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7771 Address callback_address = 7776 Address callback_address =
7772 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7777 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7773 VMState<EXTERNAL> state(isolate); 7778 VMState<EXTERNAL> state(isolate);
7774 ExternalCallbackScope call_scope(isolate, callback_address); 7779 ExternalCallbackScope call_scope(isolate, callback_address);
7775 callback(info); 7780 callback(info);
7776 } 7781 }
7777 7782
7778 7783
7779 } } // namespace v8::internal 7784 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/compiler.h » ('j') | test/cctest/test-api.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698