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

Side by Side Diff: src/api.cc

Issue 910683002: Introduce a compile method that takes context extensions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 5 years, 10 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
« no previous file with comments | « include/v8.h ('k') | test/cctest/test-compiler.cc » ('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 // 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 1634 matching lines...) Expand 10 before | Expand all | Expand 10 after
1645 return Local<Script>()); 1645 return Local<Script>());
1646 LOG_API(isolate, "ScriptCompiler::CompileModule()"); 1646 LOG_API(isolate, "ScriptCompiler::CompileModule()");
1647 ENTER_V8(isolate); 1647 ENTER_V8(isolate);
1648 Local<UnboundScript> generic = 1648 Local<UnboundScript> generic =
1649 CompileUnboundInternal(v8_isolate, source, options, true); 1649 CompileUnboundInternal(v8_isolate, source, options, true);
1650 if (generic.IsEmpty()) return Local<Script>(); 1650 if (generic.IsEmpty()) return Local<Script>();
1651 return generic->BindToCurrentContext(); 1651 return generic->BindToCurrentContext();
1652 } 1652 }
1653 1653
1654 1654
1655 Local<Function> ScriptCompiler::CompileFunctionInContext(
1656 Isolate* v8_isolate, Source* source, Local<Context> v8_context,
1657 size_t context_extension_count, Local<Object> context_extensions[]) {
1658 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
1659 ON_BAILOUT(isolate, "v8::ScriptCompiler::CompileFunctionInContext()",
1660 return Local<Function>());
1661 LOG_API(isolate, "ScriptCompiler::CompileFunctionInContext()");
1662 ENTER_V8(isolate);
1663 i::Handle<i::Context> context = Utils::OpenHandle(*v8_context);
1664 i::Handle<i::SharedFunctionInfo> outer_info(context->closure()->shared(),
1665 isolate);
1666 for (size_t i = 0; i < context_extension_count; ++i) {
1667 i::Handle<i::JSObject> extension =
1668 Utils::OpenHandle(*context_extensions[i]);
1669 i::Handle<i::JSFunction> closure(context->closure(), isolate);
1670 context = isolate->factory()->NewWithContext(closure, context, extension);
1671 }
1672 EXCEPTION_PREAMBLE(isolate);
1673 i::MaybeHandle<i::JSFunction> result = i::Compiler::GetFunctionFromEval(
1674 Utils::OpenHandle(*source->source_string), outer_info, context, i::SLOPPY,
1675 i::NO_PARSE_RESTRICTION, 0 /* scope_position */);
1676 has_pending_exception = result.is_null();
1677 EXCEPTION_BAILOUT_CHECK(isolate, Local<Function>());
1678 return Utils::ToLocal(result.ToHandleChecked());
1679 }
1680
1681
1655 ScriptCompiler::ScriptStreamingTask* ScriptCompiler::StartStreamingScript( 1682 ScriptCompiler::ScriptStreamingTask* ScriptCompiler::StartStreamingScript(
1656 Isolate* v8_isolate, StreamedSource* source, CompileOptions options) { 1683 Isolate* v8_isolate, StreamedSource* source, CompileOptions options) {
1657 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); 1684 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
1658 return new i::BackgroundParsingTask(source->impl(), options, 1685 return new i::BackgroundParsingTask(source->impl(), options,
1659 i::FLAG_stack_size, isolate); 1686 i::FLAG_stack_size, isolate);
1660 } 1687 }
1661 1688
1662 1689
1663 Local<Script> ScriptCompiler::Compile(Isolate* v8_isolate, 1690 Local<Script> ScriptCompiler::Compile(Isolate* v8_isolate,
1664 StreamedSource* v8_source, 1691 StreamedSource* v8_source,
(...skipping 6049 matching lines...) Expand 10 before | Expand all | Expand 10 after
7714 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7741 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7715 Address callback_address = 7742 Address callback_address =
7716 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7743 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7717 VMState<EXTERNAL> state(isolate); 7744 VMState<EXTERNAL> state(isolate);
7718 ExternalCallbackScope call_scope(isolate, callback_address); 7745 ExternalCallbackScope call_scope(isolate, callback_address);
7719 callback(info); 7746 callback(info);
7720 } 7747 }
7721 7748
7722 7749
7723 } } // namespace v8::internal 7750 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | test/cctest/test-compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698