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

Side by Side Diff: src/api.cc

Issue 389573006: Change ScriptCompiler::CompileOptions and add d8 --cache. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 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
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 1681 matching lines...) Expand 10 before | Expand all | Expand 10 after
1692 i::Handle<i::Object> obj = Utils::OpenHandle(this); 1692 i::Handle<i::Object> obj = Utils::OpenHandle(this);
1693 return ToApiHandle<UnboundScript>( 1693 return ToApiHandle<UnboundScript>(
1694 i::Handle<i::SharedFunctionInfo>(i::JSFunction::cast(*obj)->shared())); 1694 i::Handle<i::SharedFunctionInfo>(i::JSFunction::cast(*obj)->shared()));
1695 } 1695 }
1696 1696
1697 1697
1698 Local<UnboundScript> ScriptCompiler::CompileUnbound( 1698 Local<UnboundScript> ScriptCompiler::CompileUnbound(
1699 Isolate* v8_isolate, 1699 Isolate* v8_isolate,
1700 Source* source, 1700 Source* source,
1701 CompileOptions options) { 1701 CompileOptions options) {
1702 i::ScriptData* script_data = NULL;
1703 i::CachedDataMode cached_data_mode = i::NO_CACHED_DATA;
1704 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); 1702 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
1705 ON_BAILOUT(isolate, "v8::ScriptCompiler::CompileUnbound()", 1703 ON_BAILOUT(isolate, "v8::ScriptCompiler::CompileUnbound()",
1706 return Local<UnboundScript>()); 1704 return Local<UnboundScript>());
1707 if (options & kProduceDataToCache) { 1705
1708 cached_data_mode = i::PRODUCE_CACHED_DATA; 1706 i::ScriptData* script_data = NULL;
1709 CHECK(source->cached_data == NULL); 1707 if (options == kConsumeParserCache || options == kConsumeCodeCache) {
1710 } else if (source->cached_data) { 1708 ASSERT(source->cached_data);
1711 cached_data_mode = i::CONSUME_CACHED_DATA;
1712 // ScriptData takes care of pointer-aligning the data. 1709 // ScriptData takes care of pointer-aligning the data.
1713 script_data = new i::ScriptData(source->cached_data->data, 1710 script_data = new i::ScriptData(source->cached_data->data,
1714 source->cached_data->length); 1711 source->cached_data->length);
1715 } 1712 }
1716 1713
1717 i::Handle<i::String> str = Utils::OpenHandle(*(source->source_string)); 1714 i::Handle<i::String> str = Utils::OpenHandle(*(source->source_string));
1718 LOG_API(isolate, "ScriptCompiler::CompileUnbound"); 1715 LOG_API(isolate, "ScriptCompiler::CompileUnbound");
1719 ENTER_V8(isolate); 1716 ENTER_V8(isolate);
1720 i::SharedFunctionInfo* raw_result = NULL; 1717 i::SharedFunctionInfo* raw_result = NULL;
1721 { i::HandleScope scope(isolate); 1718 { i::HandleScope scope(isolate);
(...skipping 12 matching lines...) Expand all
1734 static_cast<int>(source->resource_column_offset->Value()); 1731 static_cast<int>(source->resource_column_offset->Value());
1735 } 1732 }
1736 if (!source->resource_is_shared_cross_origin.IsEmpty()) { 1733 if (!source->resource_is_shared_cross_origin.IsEmpty()) {
1737 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate); 1734 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
1738 is_shared_cross_origin = 1735 is_shared_cross_origin =
1739 source->resource_is_shared_cross_origin == v8::True(v8_isolate); 1736 source->resource_is_shared_cross_origin == v8::True(v8_isolate);
1740 } 1737 }
1741 EXCEPTION_PREAMBLE(isolate); 1738 EXCEPTION_PREAMBLE(isolate);
1742 i::Handle<i::SharedFunctionInfo> result = i::Compiler::CompileScript( 1739 i::Handle<i::SharedFunctionInfo> result = i::Compiler::CompileScript(
1743 str, name_obj, line_offset, column_offset, is_shared_cross_origin, 1740 str, name_obj, line_offset, column_offset, is_shared_cross_origin,
1744 isolate->global_context(), NULL, &script_data, cached_data_mode, 1741 isolate->global_context(), NULL, &script_data, options,
1745 i::NOT_NATIVES_CODE); 1742 i::NOT_NATIVES_CODE);
1746 has_pending_exception = result.is_null(); 1743 has_pending_exception = result.is_null();
1747 if (has_pending_exception && cached_data_mode == i::CONSUME_CACHED_DATA) { 1744 if (has_pending_exception && script_data != NULL) {
1748 // This case won't happen during normal operation; we have compiled 1745 // This case won't happen during normal operation; we have compiled
1749 // successfully and produced cached data, and but the second compilation 1746 // successfully and produced cached data, and but the second compilation
1750 // of the same source code fails. 1747 // of the same source code fails.
1751 delete script_data; 1748 delete script_data;
1752 script_data = NULL; 1749 script_data = NULL;
1753 } 1750 }
1754 EXCEPTION_BAILOUT_CHECK(isolate, Local<UnboundScript>()); 1751 EXCEPTION_BAILOUT_CHECK(isolate, Local<UnboundScript>());
1755 raw_result = *result; 1752 raw_result = *result;
1756 if ((options & kProduceDataToCache) && script_data != NULL) { 1753
1757 // script_data_impl now contains the data that was generated. source will 1754 if ((options == kProduceParserCache || options == kProduceCodeCache) &&
1755 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
1756 // script_data now contains the data that was generated. source will
1758 // take the ownership. 1757 // take the ownership.
1759 source->cached_data = new CachedData( 1758 source->cached_data = new CachedData(
1760 script_data->data(), script_data->length(), CachedData::BufferOwned); 1759 script_data->data(), script_data->length(), CachedData::BufferOwned);
1761 script_data->ReleaseDataOwnership(); 1760 script_data->ReleaseDataOwnership();
1762 } 1761 }
1763 delete script_data; 1762 delete script_data;
1764 } 1763 }
1765 i::Handle<i::SharedFunctionInfo> result(raw_result, isolate); 1764 i::Handle<i::SharedFunctionInfo> result(raw_result, isolate);
1766 return ToApiHandle<UnboundScript>(result); 1765 return ToApiHandle<UnboundScript>(result);
1767 } 1766 }
(...skipping 5861 matching lines...) Expand 10 before | Expand all | Expand 10 after
7629 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7628 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7630 Address callback_address = 7629 Address callback_address =
7631 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7630 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7632 VMState<EXTERNAL> state(isolate); 7631 VMState<EXTERNAL> state(isolate);
7633 ExternalCallbackScope call_scope(isolate, callback_address); 7632 ExternalCallbackScope call_scope(isolate, callback_address);
7634 callback(info); 7633 callback(info);
7635 } 7634 }
7636 7635
7637 7636
7638 } } // namespace v8::internal 7637 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/bootstrapper.cc » ('j') | test/cctest/test-compiler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698