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 1634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 Loading... |
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 |
OLD | NEW |