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

Side by Side Diff: src/api.cc

Issue 962613002: add interceptors which do not mask existing properties (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 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/handler-compiler.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 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after
1299 AccessControl settings, 1299 AccessControl settings,
1300 PropertyAttribute attribute, 1300 PropertyAttribute attribute,
1301 v8::Handle<AccessorSignature> signature) { 1301 v8::Handle<AccessorSignature> signature) {
1302 TemplateSetAccessor( 1302 TemplateSetAccessor(
1303 this, name, getter, setter, data, settings, attribute, signature); 1303 this, name, getter, setter, data, settings, attribute, signature);
1304 } 1304 }
1305 1305
1306 1306
1307 template <typename Getter, typename Setter, typename Query, typename Deleter, 1307 template <typename Getter, typename Setter, typename Query, typename Deleter,
1308 typename Enumerator> 1308 typename Enumerator>
1309 static void ObjectTemplateSetNamedPropertyHandler( 1309 static void ObjectTemplateSetNamedPropertyHandler(ObjectTemplate* templ,
1310 ObjectTemplate* templ, Getter getter, Setter setter, Query query, 1310 Getter getter, Setter setter,
1311 Deleter remover, Enumerator enumerator, Handle<Value> data, 1311 Query query, Deleter remover,
1312 bool can_intercept_symbols, PropertyHandlerFlags flags) { 1312 Enumerator enumerator,
1313 Handle<Value> data,
1314 PropertyHandlerFlags flags) {
1313 i::Isolate* isolate = Utils::OpenHandle(templ)->GetIsolate(); 1315 i::Isolate* isolate = Utils::OpenHandle(templ)->GetIsolate();
1314 ENTER_V8(isolate); 1316 ENTER_V8(isolate);
1315 i::HandleScope scope(isolate); 1317 i::HandleScope scope(isolate);
1316 auto cons = EnsureConstructor(isolate, templ); 1318 auto cons = EnsureConstructor(isolate, templ);
1317 EnsureNotInstantiated(cons, "ObjectTemplateSetNamedPropertyHandler"); 1319 EnsureNotInstantiated(cons, "ObjectTemplateSetNamedPropertyHandler");
1318 auto obj = i::Handle<i::InterceptorInfo>::cast( 1320 auto obj = i::Handle<i::InterceptorInfo>::cast(
1319 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE)); 1321 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE));
1320 1322
1321 if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter); 1323 if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter);
1322 if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter); 1324 if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter);
1323 if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query); 1325 if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query);
1324 if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover); 1326 if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover);
1325 if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator); 1327 if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator);
1326 obj->set_flags(0); 1328 obj->set_flags(0);
1327 obj->set_can_intercept_symbols(can_intercept_symbols); 1329 obj->set_can_intercept_symbols(
1330 !(static_cast<int>(flags) &
1331 static_cast<int>(PropertyHandlerFlags::kOnlyInterceptStrings)));
1328 obj->set_all_can_read(static_cast<int>(flags) & 1332 obj->set_all_can_read(static_cast<int>(flags) &
1329 static_cast<int>(PropertyHandlerFlags::kAllCanRead)); 1333 static_cast<int>(PropertyHandlerFlags::kAllCanRead));
1334 obj->set_non_masking(static_cast<int>(flags) &
1335 static_cast<int>(PropertyHandlerFlags::kNonMasking));
1330 1336
1331 if (data.IsEmpty()) { 1337 if (data.IsEmpty()) {
1332 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); 1338 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate));
1333 } 1339 }
1334 obj->set_data(*Utils::OpenHandle(*data)); 1340 obj->set_data(*Utils::OpenHandle(*data));
1335 cons->set_named_property_handler(*obj); 1341 cons->set_named_property_handler(*obj);
1336 } 1342 }
1337 1343
1338 1344
1339 void ObjectTemplate::SetNamedPropertyHandler( 1345 void ObjectTemplate::SetNamedPropertyHandler(
1340 NamedPropertyGetterCallback getter, NamedPropertySetterCallback setter, 1346 NamedPropertyGetterCallback getter, NamedPropertySetterCallback setter,
1341 NamedPropertyQueryCallback query, NamedPropertyDeleterCallback remover, 1347 NamedPropertyQueryCallback query, NamedPropertyDeleterCallback remover,
1342 NamedPropertyEnumeratorCallback enumerator, Handle<Value> data) { 1348 NamedPropertyEnumeratorCallback enumerator, Handle<Value> data) {
1343 ObjectTemplateSetNamedPropertyHandler(this, getter, setter, query, remover, 1349 ObjectTemplateSetNamedPropertyHandler(
1344 enumerator, data, false, 1350 this, getter, setter, query, remover, enumerator, data,
1345 PropertyHandlerFlags::kNone); 1351 PropertyHandlerFlags::kOnlyInterceptStrings);
1346 } 1352 }
1347 1353
1348 1354
1349 void ObjectTemplate::SetHandler( 1355 void ObjectTemplate::SetHandler(
1350 const NamedPropertyHandlerConfiguration& config) { 1356 const NamedPropertyHandlerConfiguration& config) {
1351 ObjectTemplateSetNamedPropertyHandler( 1357 ObjectTemplateSetNamedPropertyHandler(
1352 this, config.getter, config.setter, config.query, config.deleter, 1358 this, config.getter, config.setter, config.query, config.deleter,
1353 config.enumerator, config.data, true, config.flags); 1359 config.enumerator, config.data, config.flags);
1354 } 1360 }
1355 1361
1356 1362
1357 void ObjectTemplate::MarkAsUndetectable() { 1363 void ObjectTemplate::MarkAsUndetectable() {
1358 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1364 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1359 ENTER_V8(isolate); 1365 ENTER_V8(isolate);
1360 i::HandleScope scope(isolate); 1366 i::HandleScope scope(isolate);
1361 auto cons = EnsureConstructor(isolate, this); 1367 auto cons = EnsureConstructor(isolate, this);
1362 EnsureNotInstantiated(cons, "v8::ObjectTemplate::MarkAsUndetectable"); 1368 EnsureNotInstantiated(cons, "v8::ObjectTemplate::MarkAsUndetectable");
1363 cons->set_undetectable(true); 1369 cons->set_undetectable(true);
(...skipping 6653 matching lines...) Expand 10 before | Expand all | Expand 10 after
8017 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 8023 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
8018 Address callback_address = 8024 Address callback_address =
8019 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 8025 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
8020 VMState<EXTERNAL> state(isolate); 8026 VMState<EXTERNAL> state(isolate);
8021 ExternalCallbackScope call_scope(isolate, callback_address); 8027 ExternalCallbackScope call_scope(isolate, callback_address);
8022 callback(info); 8028 callback(info);
8023 } 8029 }
8024 8030
8025 8031
8026 } } // namespace v8::internal 8032 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/ic/handler-compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698