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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/objects.h" 5 #include "src/objects.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <iomanip> 8 #include <iomanip>
9 #include <sstream> 9 #include <sstream>
10 10
(...skipping 970 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 if (IsHeapNumber()) { 981 if (IsHeapNumber()) {
982 double num = HeapNumber::cast(this)->value(); 982 double num = HeapNumber::cast(this)->value();
983 if (FastI2D(FastD2I(num)) == num) { 983 if (FastI2D(FastD2I(num)) == num) {
984 *value = FastD2I(num); 984 *value = FastD2I(num);
985 return true; 985 return true;
986 } 986 }
987 } 987 }
988 return false; 988 return false;
989 } 989 }
990 990
991 Handle<SharedFunctionInfo> FunctionTemplateInfo::GetOrCreateSharedFunctionInfo(
992 Isolate* isolate, Handle<FunctionTemplateInfo> info) {
993 Object* current_info = info->shared_function_info();
994 if (current_info->IsSharedFunctionInfo()) {
995 return handle(SharedFunctionInfo::cast(current_info), isolate);
996 }
997
998 Handle<Object> class_name(info->class_name(), isolate);
999 Handle<String> name = class_name->IsString()
1000 ? Handle<String>::cast(class_name)
1001 : isolate->factory()->empty_string();
1002 Handle<Code> code;
1003 if (info->call_code()->IsCallHandlerInfo() &&
1004 CallHandlerInfo::cast(info->call_code())->fast_handler()->IsCode()) {
1005 code = isolate->builtins()->HandleFastApiCall();
1006 } else {
1007 code = isolate->builtins()->HandleApiCall();
1008 }
1009 bool is_constructor = !info->remove_prototype();
1010 Handle<SharedFunctionInfo> result =
1011 isolate->factory()->NewSharedFunctionInfo(name, code, is_constructor);
1012 if (is_constructor) {
1013 result->set_construct_stub(*isolate->builtins()->JSConstructStubApi());
1014 }
1015
1016 result->set_length(info->length());
1017 if (class_name->IsString()) result->set_instance_class_name(*class_name);
1018 result->set_api_func_data(*info);
1019 result->DontAdaptArguments();
1020 DCHECK(result->IsApiFunction());
1021
1022 info->set_shared_function_info(*result);
1023 return result;
1024 }
1025
991 bool FunctionTemplateInfo::IsTemplateFor(Map* map) { 1026 bool FunctionTemplateInfo::IsTemplateFor(Map* map) {
992 // There is a constraint on the object; check. 1027 // There is a constraint on the object; check.
993 if (!map->IsJSObjectMap()) return false; 1028 if (!map->IsJSObjectMap()) return false;
994 // Fetch the constructor function of the object. 1029 // Fetch the constructor function of the object.
995 Object* cons_obj = map->GetConstructor(); 1030 Object* cons_obj = map->GetConstructor();
996 if (!cons_obj->IsJSFunction()) return false; 1031 if (!cons_obj->IsJSFunction()) return false;
997 JSFunction* fun = JSFunction::cast(cons_obj); 1032 JSFunction* fun = JSFunction::cast(cons_obj);
998 // Iterate through the chain of inheriting function templates to 1033 // Iterate through the chain of inheriting function templates to
999 // see if the required one occurs. 1034 // see if the required one occurs.
1000 for (Object* type = fun->shared()->function_data(); 1035 for (Object* type = fun->shared()->function_data();
(...skipping 17850 matching lines...) Expand 10 before | Expand all | Expand 10 after
18851 } else { 18886 } else {
18852 // Old-style generators. 18887 // Old-style generators.
18853 int offset = continuation(); 18888 int offset = continuation();
18854 CHECK(0 <= offset && offset < function()->code()->instruction_size()); 18889 CHECK(0 <= offset && offset < function()->code()->instruction_size());
18855 return function()->code()->SourcePosition(offset); 18890 return function()->code()->SourcePosition(offset);
18856 } 18891 }
18857 } 18892 }
18858 18893
18859 } // namespace internal 18894 } // namespace internal
18860 } // namespace v8 18895 } // namespace v8
OLDNEW
« 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