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

Side by Side Diff: src/api.cc

Issue 2531653002: [api] Support sharing prototypes between FunctionTemplates (Closed)
Patch Set: fixing test Created 4 years 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/api-natives.cc » ('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 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1167 i_isolate); 1167 i_isolate);
1168 if (result->IsUndefined(i_isolate)) { 1168 if (result->IsUndefined(i_isolate)) {
1169 // Do not cache prototype objects. 1169 // Do not cache prototype objects.
1170 result = Utils::OpenHandle( 1170 result = Utils::OpenHandle(
1171 *ObjectTemplateNew(i_isolate, Local<FunctionTemplate>(), true)); 1171 *ObjectTemplateNew(i_isolate, Local<FunctionTemplate>(), true));
1172 Utils::OpenHandle(this)->set_prototype_template(*result); 1172 Utils::OpenHandle(this)->set_prototype_template(*result);
1173 } 1173 }
1174 return ToApiHandle<ObjectTemplate>(result); 1174 return ToApiHandle<ObjectTemplate>(result);
1175 } 1175 }
1176 1176
1177 void FunctionTemplate::SetPrototypeProviderTemplate(
1178 Local<FunctionTemplate> prototype_provider) {
1179 i::Isolate* i_isolate = Utils::OpenHandle(this)->GetIsolate();
1180 ENTER_V8(i_isolate);
1181 i::Handle<i::Object> result = Utils::OpenHandle(*prototype_provider);
1182 auto info = Utils::OpenHandle(this);
1183 CHECK(info->prototype_template()->IsUndefined(i_isolate));
1184 CHECK(info->parent_template()->IsUndefined(i_isolate));
1185 info->set_prototype_provider_template(*result);
1186 }
1177 1187
1178 static void EnsureNotInstantiated(i::Handle<i::FunctionTemplateInfo> info, 1188 static void EnsureNotInstantiated(i::Handle<i::FunctionTemplateInfo> info,
1179 const char* func) { 1189 const char* func) {
1180 Utils::ApiCheck(!info->instantiated(), func, 1190 Utils::ApiCheck(!info->instantiated(), func,
1181 "FunctionTemplate already instantiated"); 1191 "FunctionTemplate already instantiated");
1182 } 1192 }
1183 1193
1184 1194
1185 void FunctionTemplate::Inherit(v8::Local<FunctionTemplate> value) { 1195 void FunctionTemplate::Inherit(v8::Local<FunctionTemplate> value) {
1186 auto info = Utils::OpenHandle(this); 1196 auto info = Utils::OpenHandle(this);
1187 EnsureNotInstantiated(info, "v8::FunctionTemplate::Inherit"); 1197 EnsureNotInstantiated(info, "v8::FunctionTemplate::Inherit");
1188 i::Isolate* isolate = info->GetIsolate(); 1198 i::Isolate* i_isolate = info->GetIsolate();
1189 ENTER_V8(isolate); 1199 ENTER_V8(i_isolate);
1200 CHECK(info->prototype_provider_template()->IsUndefined(i_isolate));
1190 info->set_parent_template(*Utils::OpenHandle(*value)); 1201 info->set_parent_template(*Utils::OpenHandle(*value));
1191 } 1202 }
1192 1203
1193 static Local<FunctionTemplate> FunctionTemplateNew( 1204 static Local<FunctionTemplate> FunctionTemplateNew(
1194 i::Isolate* isolate, FunctionCallback callback, 1205 i::Isolate* isolate, FunctionCallback callback,
1195 experimental::FastAccessorBuilder* fast_handler, v8::Local<Value> data, 1206 experimental::FastAccessorBuilder* fast_handler, v8::Local<Value> data,
1196 v8::Local<Signature> signature, int length, bool do_not_cache, 1207 v8::Local<Signature> signature, int length, bool do_not_cache,
1197 v8::Local<Private> cached_property_name = v8::Local<Private>()) { 1208 v8::Local<Private> cached_property_name = v8::Local<Private>()) {
1198 i::Handle<i::Struct> struct_obj = 1209 i::Handle<i::Struct> struct_obj =
1199 isolate->factory()->NewStruct(i::FUNCTION_TEMPLATE_INFO_TYPE); 1210 isolate->factory()->NewStruct(i::FUNCTION_TEMPLATE_INFO_TYPE);
(...skipping 8654 matching lines...) Expand 10 before | Expand all | Expand 10 after
9854 Address callback_address = 9865 Address callback_address =
9855 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 9866 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
9856 VMState<EXTERNAL> state(isolate); 9867 VMState<EXTERNAL> state(isolate);
9857 ExternalCallbackScope call_scope(isolate, callback_address); 9868 ExternalCallbackScope call_scope(isolate, callback_address);
9858 callback(info); 9869 callback(info);
9859 } 9870 }
9860 9871
9861 9872
9862 } // namespace internal 9873 } // namespace internal
9863 } // namespace v8 9874 } // namespace v8
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/api-natives.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698