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

Side by Side Diff: src/api.cc

Issue 2369933005: Speedup global_proxy.* attributes/accessors (specialize GlobalProxy access). (Closed)
Patch Set: Merge cached accessors + global proxy specialization Created 4 years, 2 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 | « include/v8.h ('k') | src/crankshaft/hydrogen.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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/api.h" 5 #include "src/api.h"
6 6
7 #include <string.h> // For memcpy, strlen. 7 #include <string.h> // For memcpy, strlen.
8 #ifdef V8_USE_ADDRESS_SANITIZER 8 #ifdef V8_USE_ADDRESS_SANITIZER
9 #include <sanitizer/asan_interface.h> 9 #include <sanitizer/asan_interface.h>
10 #endif // V8_USE_ADDRESS_SANITIZER 10 #endif // V8_USE_ADDRESS_SANITIZER
(...skipping 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after
1069 templ->set_serial_number(i::Smi::FromInt(0)); 1069 templ->set_serial_number(i::Smi::FromInt(0));
1070 if (templ->IsFunctionTemplateInfo()) { 1070 if (templ->IsFunctionTemplateInfo()) {
1071 i::Handle<i::FunctionTemplateInfo>::cast(templ)->set_do_not_cache(true); 1071 i::Handle<i::FunctionTemplateInfo>::cast(templ)->set_do_not_cache(true);
1072 } 1072 }
1073 } 1073 }
1074 i::ApiNatives::AddDataProperty(isolate, templ, Utils::OpenHandle(*name), 1074 i::ApiNatives::AddDataProperty(isolate, templ, Utils::OpenHandle(*name),
1075 value_obj, 1075 value_obj,
1076 static_cast<i::PropertyAttributes>(attribute)); 1076 static_cast<i::PropertyAttributes>(attribute));
1077 } 1077 }
1078 1078
1079 void Template::SetPrivate(v8::Local<Private> name, v8::Local<Data> value,
1080 v8::PropertyAttribute attribute) {
1081 Set(Utils::ToLocal(Utils::OpenHandle(reinterpret_cast<Name*>(*name))), value,
1082 attribute);
1083 }
1079 1084
1080 void Template::SetAccessorProperty( 1085 void Template::SetAccessorProperty(
1081 v8::Local<v8::Name> name, 1086 v8::Local<v8::Name> name,
1082 v8::Local<FunctionTemplate> getter, 1087 v8::Local<FunctionTemplate> getter,
1083 v8::Local<FunctionTemplate> setter, 1088 v8::Local<FunctionTemplate> setter,
1084 v8::PropertyAttribute attribute, 1089 v8::PropertyAttribute attribute,
1085 v8::AccessControl access_control) { 1090 v8::AccessControl access_control) {
1086 // TODO(verwaest): Remove |access_control|. 1091 // TODO(verwaest): Remove |access_control|.
1087 DCHECK_EQ(v8::DEFAULT, access_control); 1092 DCHECK_EQ(v8::DEFAULT, access_control);
1088 auto templ = Utils::OpenHandle(this); 1093 auto templ = Utils::OpenHandle(this);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 1137
1133 1138
1134 void FunctionTemplate::Inherit(v8::Local<FunctionTemplate> value) { 1139 void FunctionTemplate::Inherit(v8::Local<FunctionTemplate> value) {
1135 auto info = Utils::OpenHandle(this); 1140 auto info = Utils::OpenHandle(this);
1136 EnsureNotInstantiated(info, "v8::FunctionTemplate::Inherit"); 1141 EnsureNotInstantiated(info, "v8::FunctionTemplate::Inherit");
1137 i::Isolate* isolate = info->GetIsolate(); 1142 i::Isolate* isolate = info->GetIsolate();
1138 ENTER_V8(isolate); 1143 ENTER_V8(isolate);
1139 info->set_parent_template(*Utils::OpenHandle(*value)); 1144 info->set_parent_template(*Utils::OpenHandle(*value));
1140 } 1145 }
1141 1146
1142
1143 static Local<FunctionTemplate> FunctionTemplateNew( 1147 static Local<FunctionTemplate> FunctionTemplateNew(
1144 i::Isolate* isolate, FunctionCallback callback, 1148 i::Isolate* isolate, FunctionCallback callback,
1145 experimental::FastAccessorBuilder* fast_handler, v8::Local<Value> data, 1149 experimental::FastAccessorBuilder* fast_handler, v8::Local<Value> data,
1146 v8::Local<Signature> signature, int length, bool do_not_cache) { 1150 v8::Local<Signature> signature, int length, bool do_not_cache,
1151 v8::Local<Private> cache_property = v8::Local<Private>()) {
1147 i::Handle<i::Struct> struct_obj = 1152 i::Handle<i::Struct> struct_obj =
1148 isolate->factory()->NewStruct(i::FUNCTION_TEMPLATE_INFO_TYPE); 1153 isolate->factory()->NewStruct(i::FUNCTION_TEMPLATE_INFO_TYPE);
1149 i::Handle<i::FunctionTemplateInfo> obj = 1154 i::Handle<i::FunctionTemplateInfo> obj =
1150 i::Handle<i::FunctionTemplateInfo>::cast(struct_obj); 1155 i::Handle<i::FunctionTemplateInfo>::cast(struct_obj);
1151 InitializeFunctionTemplate(obj); 1156 InitializeFunctionTemplate(obj);
1152 obj->set_do_not_cache(do_not_cache); 1157 obj->set_do_not_cache(do_not_cache);
1153 int next_serial_number = 0; 1158 int next_serial_number = 0;
1154 if (!do_not_cache) { 1159 if (!do_not_cache) {
1155 next_serial_number = isolate->heap()->GetNextTemplateSerialNumber(); 1160 next_serial_number = isolate->heap()->GetNextTemplateSerialNumber();
1156 } 1161 }
1157 obj->set_serial_number(i::Smi::FromInt(next_serial_number)); 1162 obj->set_serial_number(i::Smi::FromInt(next_serial_number));
1158 if (callback != 0) { 1163 if (callback != 0) {
1159 if (data.IsEmpty()) { 1164 if (data.IsEmpty()) {
1160 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); 1165 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate));
1161 } 1166 }
1162 Utils::ToLocal(obj)->SetCallHandler(callback, data, fast_handler); 1167 Utils::ToLocal(obj)->SetCallHandler(callback, data, fast_handler);
1163 } 1168 }
1164 obj->set_length(length); 1169 obj->set_length(length);
1165 obj->set_undetectable(false); 1170 obj->set_undetectable(false);
1166 obj->set_needs_access_check(false); 1171 obj->set_needs_access_check(false);
1167 obj->set_accept_any_receiver(true); 1172 obj->set_accept_any_receiver(true);
1168 if (!signature.IsEmpty()) 1173 if (!signature.IsEmpty())
1169 obj->set_signature(*Utils::OpenHandle(*signature)); 1174 obj->set_signature(*Utils::OpenHandle(*signature));
1175
1176 if (!cache_property.IsEmpty()) {
1177 obj->set_cache_property(*Utils::OpenHandle(*cache_property));
1178 } else {
1179 obj->set_cache_property(isolate->heap()->the_hole_value());
1180 }
1181
1170 return Utils::ToLocal(obj); 1182 return Utils::ToLocal(obj);
1171 } 1183 }
1172 1184
1173 Local<FunctionTemplate> FunctionTemplate::New( 1185 Local<FunctionTemplate> FunctionTemplate::New(
1174 Isolate* isolate, FunctionCallback callback, v8::Local<Value> data, 1186 Isolate* isolate, FunctionCallback callback, v8::Local<Value> data,
1175 v8::Local<Signature> signature, int length, ConstructorBehavior behavior) { 1187 v8::Local<Signature> signature, int length, ConstructorBehavior behavior) {
1176 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 1188 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
1177 // Changes to the environment cannot be captured in the snapshot. Expect no 1189 // Changes to the environment cannot be captured in the snapshot. Expect no
1178 // function templates when the isolate is created for serialization. 1190 // function templates when the isolate is created for serialization.
1179 LOG_API(i_isolate, FunctionTemplate, New); 1191 LOG_API(i_isolate, FunctionTemplate, New);
(...skipping 24 matching lines...) Expand all
1204 experimental::FastAccessorBuilder* fast_handler, v8::Local<Value> data, 1216 experimental::FastAccessorBuilder* fast_handler, v8::Local<Value> data,
1205 v8::Local<Signature> signature, int length) { 1217 v8::Local<Signature> signature, int length) {
1206 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 1218 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
1207 DCHECK(!i_isolate->serializer_enabled()); 1219 DCHECK(!i_isolate->serializer_enabled());
1208 LOG_API(i_isolate, FunctionTemplate, NewWithFastHandler); 1220 LOG_API(i_isolate, FunctionTemplate, NewWithFastHandler);
1209 ENTER_V8(i_isolate); 1221 ENTER_V8(i_isolate);
1210 return FunctionTemplateNew(i_isolate, callback, fast_handler, data, signature, 1222 return FunctionTemplateNew(i_isolate, callback, fast_handler, data, signature,
1211 length, false); 1223 length, false);
1212 } 1224 }
1213 1225
1226 Local<FunctionTemplate> FunctionTemplate::NewWithCache(
1227 Isolate* isolate, FunctionCallback callback, Local<Private> cache_property,
1228 Local<Value> data, Local<Signature> signature, int length) {
1229 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
1230 DCHECK(!i_isolate->serializer_enabled());
1231 LOG_API(i_isolate, FunctionTemplate, NewWithFastHandler);
1232 ENTER_V8(i_isolate);
1233 return FunctionTemplateNew(i_isolate, callback, nullptr, data, signature,
1234 length, false, cache_property);
1235 }
1214 1236
1215 Local<Signature> Signature::New(Isolate* isolate, 1237 Local<Signature> Signature::New(Isolate* isolate,
1216 Local<FunctionTemplate> receiver) { 1238 Local<FunctionTemplate> receiver) {
1217 return Utils::SignatureToLocal(Utils::OpenHandle(*receiver)); 1239 return Utils::SignatureToLocal(Utils::OpenHandle(*receiver));
1218 } 1240 }
1219 1241
1220 1242
1221 Local<AccessorSignature> AccessorSignature::New( 1243 Local<AccessorSignature> AccessorSignature::New(
1222 Isolate* isolate, Local<FunctionTemplate> receiver) { 1244 Isolate* isolate, Local<FunctionTemplate> receiver) {
1223 return Utils::AccessorSignatureToLocal(Utils::OpenHandle(*receiver)); 1245 return Utils::AccessorSignatureToLocal(Utils::OpenHandle(*receiver));
(...skipping 8166 matching lines...) Expand 10 before | Expand all | Expand 10 after
9390 Address callback_address = 9412 Address callback_address =
9391 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 9413 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
9392 VMState<EXTERNAL> state(isolate); 9414 VMState<EXTERNAL> state(isolate);
9393 ExternalCallbackScope call_scope(isolate, callback_address); 9415 ExternalCallbackScope call_scope(isolate, callback_address);
9394 callback(info); 9416 callback(info);
9395 } 9417 }
9396 9418
9397 9419
9398 } // namespace internal 9420 } // namespace internal
9399 } // namespace v8 9421 } // namespace v8
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/crankshaft/hydrogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698