| OLD | NEW |
| 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 Loading... |
| 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_), | 1539 : data(data_), length(length_), buffer_policy(buffer_policy_) {} |
| 1540 length(length_), | |
| 1541 rejected(false), | |
| 1542 buffer_policy(buffer_policy_) {} | |
| 1543 | 1540 |
| 1544 | 1541 |
| 1545 ScriptCompiler::CachedData::~CachedData() { | 1542 ScriptCompiler::CachedData::~CachedData() { |
| 1546 if (buffer_policy == BufferOwned) { | 1543 if (buffer_policy == BufferOwned) { |
| 1547 delete[] data; | 1544 delete[] data; |
| 1548 } | 1545 } |
| 1549 } | 1546 } |
| 1550 | 1547 |
| 1551 | 1548 |
| 1552 ScriptCompiler::StreamedSource::StreamedSource(ExternalSourceStream* stream, | 1549 ScriptCompiler::StreamedSource::StreamedSource(ExternalSourceStream* stream, |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1748 EXCEPTION_BAILOUT_CHECK(isolate, Local<UnboundScript>()); | 1745 EXCEPTION_BAILOUT_CHECK(isolate, Local<UnboundScript>()); |
| 1749 raw_result = *result; | 1746 raw_result = *result; |
| 1750 | 1747 |
| 1751 if ((options == kProduceParserCache || options == kProduceCodeCache) && | 1748 if ((options == kProduceParserCache || options == kProduceCodeCache) && |
| 1752 script_data != NULL) { | 1749 script_data != NULL) { |
| 1753 // script_data now contains the data that was generated. source will | 1750 // script_data now contains the data that was generated. source will |
| 1754 // take the ownership. | 1751 // take the ownership. |
| 1755 source->cached_data = new CachedData( | 1752 source->cached_data = new CachedData( |
| 1756 script_data->data(), script_data->length(), CachedData::BufferOwned); | 1753 script_data->data(), script_data->length(), CachedData::BufferOwned); |
| 1757 script_data->ReleaseDataOwnership(); | 1754 script_data->ReleaseDataOwnership(); |
| 1758 } else if (options == kConsumeParserCache || options == kConsumeCodeCache) { | |
| 1759 source->cached_data->rejected = script_data->rejected(); | |
| 1760 } | 1755 } |
| 1761 delete script_data; | 1756 delete script_data; |
| 1762 } | 1757 } |
| 1763 i::Handle<i::SharedFunctionInfo> result(raw_result, isolate); | 1758 i::Handle<i::SharedFunctionInfo> result(raw_result, isolate); |
| 1764 return ToApiHandle<UnboundScript>(result); | 1759 return ToApiHandle<UnboundScript>(result); |
| 1765 } | 1760 } |
| 1766 | 1761 |
| 1767 | 1762 |
| 1768 Local<Script> ScriptCompiler::Compile( | 1763 Local<Script> ScriptCompiler::Compile( |
| 1769 Isolate* v8_isolate, | 1764 Isolate* v8_isolate, |
| (...skipping 6005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7775 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7770 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
| 7776 Address callback_address = | 7771 Address callback_address = |
| 7777 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7772 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 7778 VMState<EXTERNAL> state(isolate); | 7773 VMState<EXTERNAL> state(isolate); |
| 7779 ExternalCallbackScope call_scope(isolate, callback_address); | 7774 ExternalCallbackScope call_scope(isolate, callback_address); |
| 7780 callback(info); | 7775 callback(info); |
| 7781 } | 7776 } |
| 7782 | 7777 |
| 7783 | 7778 |
| 7784 } } // namespace v8::internal | 7779 } } // namespace v8::internal |
| OLD | NEW |