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

Unified Diff: src/compiler.cc

Issue 1635553002: [Interpreter] Add native function literal support. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add back some skips for Arm64 Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler.h ('k') | src/full-codegen/full-codegen.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
« no previous file with comments | « src/compiler.h ('k') | src/full-codegen/full-codegen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698