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

Unified Diff: src/objects.cc

Issue 2095673002: Share SharedFunctionInfo between all functions created for a FunctionTemplateInfo (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 1653247d9b653a2c839b883608ac4b6c8bb56eed..90aaac3efd04a00dde919044cc5f91e138c00369 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -988,6 +988,41 @@ bool Object::ToInt32(int32_t* value) {
return false;
}
+Handle<SharedFunctionInfo> FunctionTemplateInfo::GetOrCreateSharedFunctionInfo(
+ Isolate* isolate, Handle<FunctionTemplateInfo> info) {
+ Object* current_info = info->shared_function_info();
+ if (current_info->IsSharedFunctionInfo()) {
+ return handle(SharedFunctionInfo::cast(current_info), isolate);
+ }
+
+ Handle<Object> class_name(info->class_name(), isolate);
+ Handle<String> name = class_name->IsString()
+ ? Handle<String>::cast(class_name)
+ : isolate->factory()->empty_string();
+ Handle<Code> code;
+ if (info->call_code()->IsCallHandlerInfo() &&
+ CallHandlerInfo::cast(info->call_code())->fast_handler()->IsCode()) {
+ code = isolate->builtins()->HandleFastApiCall();
+ } else {
+ code = isolate->builtins()->HandleApiCall();
+ }
+ bool is_constructor = !info->remove_prototype();
+ Handle<SharedFunctionInfo> result =
+ isolate->factory()->NewSharedFunctionInfo(name, code, is_constructor);
+ if (is_constructor) {
+ result->set_construct_stub(*isolate->builtins()->JSConstructStubApi());
+ }
+
+ result->set_length(info->length());
+ if (class_name->IsString()) result->set_instance_class_name(*class_name);
+ result->set_api_func_data(*info);
+ result->DontAdaptArguments();
+ DCHECK(result->IsApiFunction());
+
+ info->set_shared_function_info(*result);
+ return result;
+}
+
bool FunctionTemplateInfo::IsTemplateFor(Map* map) {
// There is a constraint on the object; check.
if (!map->IsJSObjectMap()) return false;
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698