| Index: src/compiler.cc
|
| diff --git a/src/compiler.cc b/src/compiler.cc
|
| index f01f532f137ce83150b8cf90a163bfc259af68af..7fbbfb17ff5daf7b809e94144a3b35a3f45ba633 100644
|
| --- a/src/compiler.cc
|
| +++ b/src/compiler.cc
|
| @@ -1651,6 +1651,37 @@ Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfo(
|
| return existing;
|
| }
|
|
|
| +Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForNative(
|
| + v8::Extension* extension, Handle<String> name) {
|
| + Isolate* isolate = name->GetIsolate();
|
| + v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
|
| +
|
| + // Compute the function template for the native function.
|
| + v8::Local<v8::FunctionTemplate> fun_template =
|
| + extension->GetNativeFunctionTemplate(v8_isolate,
|
| + v8::Utils::ToLocal(name));
|
| + DCHECK(!fun_template.IsEmpty());
|
| +
|
| + // Instantiate the function and create a shared function info from it.
|
| + Handle<JSFunction> fun = Handle<JSFunction>::cast(Utils::OpenHandle(
|
| + *fun_template->GetFunction(v8_isolate->GetCurrentContext())
|
| + .ToLocalChecked()));
|
| + const int literals = fun->NumberOfLiterals();
|
| + Handle<Code> code = Handle<Code>(fun->shared()->code());
|
| + Handle<Code> construct_stub = Handle<Code>(fun->shared()->construct_stub());
|
| + Handle<SharedFunctionInfo> shared = isolate->factory()->NewSharedFunctionInfo(
|
| + name, literals, FunctionKind::kNormalFunction, code,
|
| + Handle<ScopeInfo>(fun->shared()->scope_info()),
|
| + Handle<TypeFeedbackVector>(fun->shared()->feedback_vector()));
|
| + shared->set_construct_stub(*construct_stub);
|
| +
|
| + // Copy the function data to the shared function info.
|
| + shared->set_function_data(fun->shared()->function_data());
|
| + int parameters = fun->shared()->internal_formal_parameter_count();
|
| + shared->set_internal_formal_parameter_count(parameters);
|
| +
|
| + return shared;
|
| +}
|
|
|
| MaybeHandle<Code> Compiler::GetOptimizedCode(Handle<JSFunction> function,
|
| ConcurrencyMode mode,
|
|
|