} else {
// If the function isn't compiled yet, the length is not computed
// correctly yet. Compile it now and return the right length.
- if (Compiler::EnsureCompiled(function, KEEP_EXCEPTION)) {
+ if (Compiler::Compile(function, KEEP_EXCEPTION)) {
length = function->shared()->length();
}
if (isolate->has_pending_exception()) {
// Just to make sure nobody calls this...
inner->set_code(isolate()->builtins()->builtin(Builtins::kIllegal));
- Zone zone;
- // Build a "hybrid" CompilationInfo for a JSFunction/CodeStub pair.
- ParseInfo parse_info(&zone, inner);
- CompilationInfo info(&parse_info);
- info.SetFunctionType(GetCallInterfaceDescriptor().GetFunctionType());
- info.MarkAsContextSpecializing();
- info.MarkAsDeoptimizationEnabled();
- info.SetStub(this);
- return info.GenerateCodeStub();
+ return Compiler::GetStubCode(inner, this).ToHandleChecked();
}
}
-Handle<Code> CompilationInfo::GenerateCodeStub() {
- // Run a "mini pipeline", extracted from compiler.cc.
- CHECK(Parser::ParseStatic(parse_info()));
- CHECK(Compiler::Analyze(parse_info()));
- return compiler::Pipeline(this).GenerateCode();
-}
-
-
class HOptimizedGraphBuilderWithPositions: public HOptimizedGraphBuilder {
public:
explicit HOptimizedGraphBuilderWithPositions(CompilationInfo* info)
}
-bool Compiler::EnsureCompiled(Handle<JSFunction> function,
- ClearExceptionFlag flag) {
+MaybeHandle<Code> Compiler::GetStubCode(Handle<JSFunction> function,
+ CodeStub* stub) {
+ // Build a "hybrid" CompilationInfo for a JSFunction/CodeStub pair.
+ Zone zone;
+ ParseInfo parse_info(&zone, function);
+ CompilationInfo info(&parse_info);
+ info.SetFunctionType(stub->GetCallInterfaceDescriptor().GetFunctionType());
+ info.MarkAsContextSpecializing();
+ info.MarkAsDeoptimizationEnabled();
+ info.SetStub(stub);
+
+ // Run a "mini pipeline", extracted from compiler.cc.
+ if (!ParseAndAnalyze(&parse_info)) return MaybeHandle<Code>();
+ return compiler::Pipeline(&info).GenerateCode();
+}
+
+
+bool Compiler::Compile(Handle<JSFunction> function, ClearExceptionFlag flag) {
if (function->is_compiled()) return true;
MaybeHandle<Code> maybe_code = Compiler::GetLazyCode(function);
Handle<Code> code;
bool has_simple_parameters();
- Handle<Code> GenerateCodeStub();
-
typedef std::vector<Handle<SharedFunctionInfo>> InlinedFunctionList;
InlinedFunctionList const& inlined_functions() const {
return inlined_functions_;
Handle<JSFunction> function);
MUST_USE_RESULT static MaybeHandle<Code> GetLazyCode(
Handle<JSFunction> function);
+ MUST_USE_RESULT static MaybeHandle<Code> GetStubCode(
+ Handle<JSFunction> function, CodeStub* stub);
+ static bool Compile(Handle<JSFunction> function, ClearExceptionFlag flag);
static bool CompileDebugCode(Handle<JSFunction> function);
static bool CompileDebugCode(Handle<SharedFunctionInfo> shared);
+ static void CompileForLiveEdit(Handle<Script> script);
// Parser::Parse, then Compiler::Analyze.
static bool ParseAndAnalyze(ParseInfo* info);
// Adds deoptimization support, requires ParseAndAnalyze.
static bool EnsureDeoptimizationSupport(CompilationInfo* info);
- static bool EnsureCompiled(Handle<JSFunction> function,
- ClearExceptionFlag flag);
-
- static void CompileForLiveEdit(Handle<Script> script);
-
// Compile a String source within a context for eval.
MUST_USE_RESULT static MaybeHandle<JSFunction> GetFunctionFromEval(
Handle<String> source, Handle<SharedFunctionInfo> outer_info,
if (function.is_null()) {
DCHECK(shared->HasDebugCode());
- } else if (!Compiler::EnsureCompiled(function, CLEAR_EXCEPTION)) {
+ } else if (!Compiler::Compile(function, CLEAR_EXCEPTION)) {
return false;
}
Handle<SharedFunctionInfo> source_shared(source->shared());
RUNTIME_ASSERT(!source_shared->bound());
- if (!Compiler::EnsureCompiled(source, KEEP_EXCEPTION)) {
+ if (!Compiler::Compile(source, KEEP_EXCEPTION)) {
return isolate->heap()->exception();
}
// The function should be compiled for the optimization hints to be
// available.
- Compiler::EnsureCompiled(function, CLEAR_EXCEPTION);
+ Compiler::Compile(function, CLEAR_EXCEPTION);
Handle<JSObject> result;
if (site.is_null()) {
DCHECK(args.length() == 1);
// Get the function and make sure it is compiled.
CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0);
- if (!Compiler::EnsureCompiled(func, KEEP_EXCEPTION)) {
+ if (!Compiler::Compile(func, KEEP_EXCEPTION)) {
return isolate->heap()->exception();
}
OFStream os(stdout);