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

Side by Side Diff: src/compiler.cc

Issue 2163933002: Move CompileString to Compiler (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 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
« src/compiler.h ('K') | « src/compiler.h ('k') | no next file » | 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/compiler.h" 5 #include "src/compiler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "src/asmjs/asm-js.h" 9 #include "src/asmjs/asm-js.h"
10 #include "src/asmjs/asm-typer.h" 10 #include "src/asmjs/asm-typer.h"
(...skipping 1742 matching lines...) Expand 10 before | Expand all | Expand 10 after
1753 shared->set_feedback_metadata(fun->shared()->feedback_metadata()); 1753 shared->set_feedback_metadata(fun->shared()->feedback_metadata());
1754 1754
1755 // Copy the function data to the shared function info. 1755 // Copy the function data to the shared function info.
1756 shared->set_function_data(fun->shared()->function_data()); 1756 shared->set_function_data(fun->shared()->function_data());
1757 int parameters = fun->shared()->internal_formal_parameter_count(); 1757 int parameters = fun->shared()->internal_formal_parameter_count();
1758 shared->set_internal_formal_parameter_count(parameters); 1758 shared->set_internal_formal_parameter_count(parameters);
1759 1759
1760 return shared; 1760 return shared;
1761 } 1761 }
1762 1762
1763 namespace {
1764
1765 bool CodeGenerationFromStringsAllowed(Isolate* isolate,
1766 Handle<Context> context) {
1767 DCHECK(context->allow_code_gen_from_strings()->IsFalse(isolate));
1768 // Check with callback if set.
1769 AllowCodeGenerationFromStringsCallback callback =
1770 isolate->allow_code_gen_callback();
1771 if (callback == NULL) {
1772 // No callback set and code generation disallowed.
1773 return false;
1774 } else {
1775 // Callback set. Let it decide if code generation is allowed.
1776 VMState<EXTERNAL> state(isolate);
1777 return callback(v8::Utils::ToLocal(context));
1778 }
1779 }
1780
1781 } // namespace
1782
1783 MaybeHandle<JSFunction> Compiler::CompileString(Handle<Context> context,
Michael Starzinger 2016/07/20 12:03:35 Likewise, please move this to after GetFunctionFro
jgruber 2016/07/20 12:42:11 Done.
1784 Handle<String> source,
1785 ParseRestriction restriction) {
1786 Isolate* const isolate = context->GetIsolate();
1787 Handle<Context> native_context(context->native_context(), isolate);
1788
1789 // Check if native context allows code generation from
1790 // strings. Throw an exception if it doesn't.
1791 if (native_context->allow_code_gen_from_strings()->IsFalse(isolate) &&
1792 !CodeGenerationFromStringsAllowed(isolate, native_context)) {
1793 Handle<Object> error_message =
1794 native_context->ErrorMessageForCodeGenerationFromStrings();
1795 THROW_NEW_ERROR(isolate, NewEvalError(MessageTemplate::kCodeGenFromStrings,
1796 error_message),
1797 JSFunction);
1798 }
1799
1800 // Compile source string in the native context.
1801 int eval_scope_position = 0;
1802 int eval_position = kNoSourcePosition;
1803 Handle<SharedFunctionInfo> outer_info(native_context->closure()->shared());
1804 return Compiler::GetFunctionFromEval(source, outer_info, native_context,
1805 SLOPPY, restriction, eval_scope_position,
1806 eval_position);
1807 }
1808
1763 MaybeHandle<Code> Compiler::GetOptimizedCodeForOSR(Handle<JSFunction> function, 1809 MaybeHandle<Code> Compiler::GetOptimizedCodeForOSR(Handle<JSFunction> function,
1764 BailoutId osr_ast_id, 1810 BailoutId osr_ast_id,
1765 JavaScriptFrame* osr_frame) { 1811 JavaScriptFrame* osr_frame) {
1766 DCHECK(!osr_ast_id.IsNone()); 1812 DCHECK(!osr_ast_id.IsNone());
1767 DCHECK_NOT_NULL(osr_frame); 1813 DCHECK_NOT_NULL(osr_frame);
1768 return GetOptimizedCode(function, NOT_CONCURRENT, osr_ast_id, osr_frame); 1814 return GetOptimizedCode(function, NOT_CONCURRENT, osr_ast_id, osr_frame);
1769 } 1815 }
1770 1816
1771 void Compiler::FinalizeCompilationJob(CompilationJob* raw_job) { 1817 void Compiler::FinalizeCompilationJob(CompilationJob* raw_job) {
1772 // Take ownership of compilation job. Deleting job also tears down the zone. 1818 // Take ownership of compilation job. Deleting job also tears down the zone.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1843 DCHECK(shared->is_compiled()); 1889 DCHECK(shared->is_compiled());
1844 function->set_literals(cached.literals); 1890 function->set_literals(cached.literals);
1845 } else if (shared->is_compiled()) { 1891 } else if (shared->is_compiled()) {
1846 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. 1892 // TODO(mvstanton): pass pretenure flag to EnsureLiterals.
1847 JSFunction::EnsureLiterals(function); 1893 JSFunction::EnsureLiterals(function);
1848 } 1894 }
1849 } 1895 }
1850 1896
1851 } // namespace internal 1897 } // namespace internal
1852 } // namespace v8 1898 } // namespace v8
OLDNEW
« src/compiler.h ('K') | « src/compiler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698