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

Side by Side Diff: src/api.cc

Issue 906463002: add support for all can read interceptors (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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/ic/ic.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 1189 matching lines...) Expand 10 before | Expand all | Expand 10 after
1200 AccessControl settings, 1200 AccessControl settings,
1201 PropertyAttribute attribute, 1201 PropertyAttribute attribute,
1202 v8::Handle<AccessorSignature> signature) { 1202 v8::Handle<AccessorSignature> signature) {
1203 TemplateSetAccessor( 1203 TemplateSetAccessor(
1204 this, name, getter, setter, data, settings, attribute, signature); 1204 this, name, getter, setter, data, settings, attribute, signature);
1205 } 1205 }
1206 1206
1207 1207
1208 template <typename Getter, typename Setter, typename Query, typename Deleter, 1208 template <typename Getter, typename Setter, typename Query, typename Deleter,
1209 typename Enumerator> 1209 typename Enumerator>
1210 static void ObjectTemplateSetNamedPropertyHandler(ObjectTemplate* templ, 1210 static void ObjectTemplateSetNamedPropertyHandler(
1211 Getter getter, Setter setter, 1211 ObjectTemplate* templ, Getter getter, Setter setter, Query query,
1212 Query query, Deleter remover, 1212 Deleter remover, Enumerator enumerator, Handle<Value> data,
1213 Enumerator enumerator, 1213 bool can_intercept_symbols, PropertyHandlerFlags flags) {
1214 Handle<Value> data,
1215 bool can_intercept_symbols) {
1216 i::Isolate* isolate = Utils::OpenHandle(templ)->GetIsolate(); 1214 i::Isolate* isolate = Utils::OpenHandle(templ)->GetIsolate();
1217 ENTER_V8(isolate); 1215 ENTER_V8(isolate);
1218 i::HandleScope scope(isolate); 1216 i::HandleScope scope(isolate);
1219 auto cons = EnsureConstructor(isolate, templ); 1217 auto cons = EnsureConstructor(isolate, templ);
1220 EnsureNotInstantiated(cons, "ObjectTemplateSetNamedPropertyHandler"); 1218 EnsureNotInstantiated(cons, "ObjectTemplateSetNamedPropertyHandler");
1221 i::Handle<i::Struct> struct_obj = 1219 auto obj = i::Handle<i::InterceptorInfo>::cast(
1222 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE); 1220 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE));
1223 i::Handle<i::InterceptorInfo> obj =
1224 i::Handle<i::InterceptorInfo>::cast(struct_obj);
1225 1221
1226 if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter); 1222 if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter);
1227 if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter); 1223 if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter);
1228 if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query); 1224 if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query);
1229 if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover); 1225 if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover);
1230 if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator); 1226 if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator);
1231 obj->set_flags(0); 1227 obj->set_flags(0);
1232 obj->set_can_intercept_symbols(can_intercept_symbols); 1228 obj->set_can_intercept_symbols(can_intercept_symbols);
1229 obj->set_all_can_read(static_cast<int>(flags) &
1230 static_cast<int>(PropertyHandlerFlags::kAllCanRead));
1233 1231
1234 if (data.IsEmpty()) { 1232 if (data.IsEmpty()) {
1235 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); 1233 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate));
1236 } 1234 }
1237 obj->set_data(*Utils::OpenHandle(*data)); 1235 obj->set_data(*Utils::OpenHandle(*data));
1238 cons->set_named_property_handler(*obj); 1236 cons->set_named_property_handler(*obj);
1239 } 1237 }
1240 1238
1241 1239
1242 void ObjectTemplate::SetNamedPropertyHandler( 1240 void ObjectTemplate::SetNamedPropertyHandler(
1243 NamedPropertyGetterCallback getter, NamedPropertySetterCallback setter, 1241 NamedPropertyGetterCallback getter, NamedPropertySetterCallback setter,
1244 NamedPropertyQueryCallback query, NamedPropertyDeleterCallback remover, 1242 NamedPropertyQueryCallback query, NamedPropertyDeleterCallback remover,
1245 NamedPropertyEnumeratorCallback enumerator, Handle<Value> data) { 1243 NamedPropertyEnumeratorCallback enumerator, Handle<Value> data) {
1246 ObjectTemplateSetNamedPropertyHandler(this, getter, setter, query, remover, 1244 ObjectTemplateSetNamedPropertyHandler(this, getter, setter, query, remover,
1247 enumerator, data, false); 1245 enumerator, data, false,
1246 PropertyHandlerFlags::kNone);
1248 } 1247 }
1249 1248
1250 1249
1251 void ObjectTemplate::SetHandler( 1250 void ObjectTemplate::SetHandler(
1252 const NamedPropertyHandlerConfiguration& config) { 1251 const NamedPropertyHandlerConfiguration& config) {
1253 ObjectTemplateSetNamedPropertyHandler(this, config.getter, config.setter, 1252 ObjectTemplateSetNamedPropertyHandler(
1254 config.query, config.deleter, 1253 this, config.getter, config.setter, config.query, config.deleter,
1255 config.enumerator, config.data, true); 1254 config.enumerator, config.data, true, config.flags);
1256 } 1255 }
1257 1256
1258 1257
1259 void ObjectTemplate::MarkAsUndetectable() { 1258 void ObjectTemplate::MarkAsUndetectable() {
1260 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1259 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1261 ENTER_V8(isolate); 1260 ENTER_V8(isolate);
1262 i::HandleScope scope(isolate); 1261 i::HandleScope scope(isolate);
1263 auto cons = EnsureConstructor(isolate, this); 1262 auto cons = EnsureConstructor(isolate, this);
1264 EnsureNotInstantiated(cons, "v8::ObjectTemplate::MarkAsUndetectable"); 1263 EnsureNotInstantiated(cons, "v8::ObjectTemplate::MarkAsUndetectable");
1265 cons->set_undetectable(true); 1264 cons->set_undetectable(true);
(...skipping 29 matching lines...) Expand all
1295 } 1294 }
1296 1295
1297 1296
1298 void ObjectTemplate::SetHandler( 1297 void ObjectTemplate::SetHandler(
1299 const IndexedPropertyHandlerConfiguration& config) { 1298 const IndexedPropertyHandlerConfiguration& config) {
1300 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1299 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1301 ENTER_V8(isolate); 1300 ENTER_V8(isolate);
1302 i::HandleScope scope(isolate); 1301 i::HandleScope scope(isolate);
1303 auto cons = EnsureConstructor(isolate, this); 1302 auto cons = EnsureConstructor(isolate, this);
1304 EnsureNotInstantiated(cons, "v8::ObjectTemplate::SetHandler"); 1303 EnsureNotInstantiated(cons, "v8::ObjectTemplate::SetHandler");
1305 i::Handle<i::Struct> struct_obj = 1304 auto obj = i::Handle<i::InterceptorInfo>::cast(
1306 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE); 1305 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE));
1307 i::Handle<i::InterceptorInfo> obj =
1308 i::Handle<i::InterceptorInfo>::cast(struct_obj);
1309 1306
1310 if (config.getter != 0) SET_FIELD_WRAPPED(obj, set_getter, config.getter); 1307 if (config.getter != 0) SET_FIELD_WRAPPED(obj, set_getter, config.getter);
1311 if (config.setter != 0) SET_FIELD_WRAPPED(obj, set_setter, config.setter); 1308 if (config.setter != 0) SET_FIELD_WRAPPED(obj, set_setter, config.setter);
1312 if (config.query != 0) SET_FIELD_WRAPPED(obj, set_query, config.query); 1309 if (config.query != 0) SET_FIELD_WRAPPED(obj, set_query, config.query);
1313 if (config.deleter != 0) SET_FIELD_WRAPPED(obj, set_deleter, config.deleter); 1310 if (config.deleter != 0) SET_FIELD_WRAPPED(obj, set_deleter, config.deleter);
1314 if (config.enumerator != 0) { 1311 if (config.enumerator != 0) {
1315 SET_FIELD_WRAPPED(obj, set_enumerator, config.enumerator); 1312 SET_FIELD_WRAPPED(obj, set_enumerator, config.enumerator);
1316 } 1313 }
1317 obj->set_flags(0); 1314 obj->set_flags(0);
1315 obj->set_all_can_read(static_cast<int>(config.flags) &
1316 static_cast<int>(PropertyHandlerFlags::kAllCanRead));
1318 1317
1319 v8::Local<v8::Value> data = config.data; 1318 v8::Local<v8::Value> data = config.data;
1320 if (data.IsEmpty()) { 1319 if (data.IsEmpty()) {
1321 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); 1320 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate));
1322 } 1321 }
1323 obj->set_data(*Utils::OpenHandle(*data)); 1322 obj->set_data(*Utils::OpenHandle(*data));
1324 cons->set_indexed_property_handler(*obj); 1323 cons->set_indexed_property_handler(*obj);
1325 } 1324 }
1326 1325
1327 1326
(...skipping 6386 matching lines...) Expand 10 before | Expand all | Expand 10 after
7714 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7713 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7715 Address callback_address = 7714 Address callback_address =
7716 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7715 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7717 VMState<EXTERNAL> state(isolate); 7716 VMState<EXTERNAL> state(isolate);
7718 ExternalCallbackScope call_scope(isolate, callback_address); 7717 ExternalCallbackScope call_scope(isolate, callback_address);
7719 callback(info); 7718 callback(info);
7720 } 7719 }
7721 7720
7722 7721
7723 } } // namespace v8::internal 7722 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/ic/ic.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698