| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c34ae48 commit 785a9e5
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,7 +11,7 @@ | |||
| 11 | 11 | #define V8_MAJOR_VERSION 5 | |
| 12 | 12 | #define V8_MINOR_VERSION 9 | |
| 13 | 13 | #define V8_BUILD_NUMBER 211 | |
| 14 | - #define V8_PATCH_LEVEL 37 | ||
| 14 | + #define V8_PATCH_LEVEL 38 | ||
| 15 | 15 | ||
| 16 | 16 | // Use 1 for candidates and 0 otherwise. | |
| 17 | 17 | // (Boolean macro values are not supported by all preprocessors.) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,6 +13,11 @@ | |||
| 13 | 13 | namespace v8 { | |
| 14 | 14 | namespace internal { | |
| 15 | 15 | ||
| 16 | + // Decodes kind from Smi-handler. | ||
| 17 | + LoadHandler::Kind LoadHandler::GetHandlerKind(Smi* smi_handler) { | ||
| 18 | + return KindBits::decode(smi_handler->value()); | ||
| 19 | + } | ||
| 20 | + | ||
| 16 | 21 | Handle<Smi> LoadHandler::LoadNormal(Isolate* isolate) { | |
| 17 | 22 | int config = KindBits::encode(kNormal); | |
| 18 | 23 | return handle(Smi::FromInt(config), isolate); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -90,6 +90,9 @@ class LoadHandler { | |||
| 90 | 90 | static const int kHolderCellIndex = 2; | |
| 91 | 91 | static const int kFirstPrototypeIndex = 3; | |
| 92 | 92 | ||
| 93 | + // Decodes kind from Smi-handler. | ||
| 94 | + static inline Kind GetHandlerKind(Smi* smi_handler); | ||
| 95 | + | ||
| 93 | 96 | // Creates a Smi-handler for loading a property from a slow object. | |
| 94 | 97 | static inline Handle<Smi> LoadNormal(Isolate* isolate); | |
| 95 | 98 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -868,10 +868,15 @@ int GetPrototypeCheckCount(Isolate* isolate, Handle<Map> receiver_map, | |||
| 868 | 868 | Handle<FixedArray>(), 0); | |
| 869 | 869 | } | |
| 870 | 870 | ||
| 871 | + enum class HolderCellRequest { | ||
| 872 | + kGlobalPropertyCell, | ||
| 873 | + kHolder, | ||
| 874 | + }; | ||
| 875 | + | ||
| 871 | 876 | Handle<WeakCell> HolderCell(Isolate* isolate, Handle<JSObject> holder, | |
| 872 | - Handle<Name> name, Handle<Smi> smi_handler) { | ||
| 873 | - if (holder->IsJSGlobalObject() && | ||
| 874 | - *smi_handler != *LoadHandler::LoadInterceptor(isolate)) { | ||
| 877 | + Handle<Name> name, HolderCellRequest request) { | ||
| 878 | + if (request == HolderCellRequest::kGlobalPropertyCell) { | ||
| 879 | + DCHECK(holder->IsJSGlobalObject()); | ||
| 875 | 880 | Handle<JSGlobalObject> global = Handle<JSGlobalObject>::cast(holder); | |
| 876 | 881 | GlobalDictionary* dict = global->global_dictionary(); | |
| 877 | 882 | int number = dict->FindEntry(name); | |
@@ -908,8 +913,14 @@ Handle<Object> LoadIC::LoadFromPrototype(Handle<Map> receiver_map, | |||
| 908 | 913 | Map::GetOrCreatePrototypeChainValidityCell(receiver_map, isolate()); | |
| 909 | 914 | DCHECK(!validity_cell.is_null()); | |
| 910 | 915 | ||
| 911 | - Handle<WeakCell> holder_cell = | ||
| 912 | - HolderCell(isolate(), holder, name, smi_handler); | ||
| 916 | + // LoadIC dispatcher expects PropertyCell as a "holder" in case of kGlobal | ||
| 917 | + // handler kind. | ||
| 918 | + HolderCellRequest request = | ||
| 919 | + LoadHandler::GetHandlerKind(*smi_handler) == LoadHandler::kGlobal | ||
| 920 | + ? HolderCellRequest::kGlobalPropertyCell | ||
| 921 | + : HolderCellRequest::kHolder; | ||
| 922 | + | ||
| 923 | + Handle<WeakCell> holder_cell = HolderCell(isolate(), holder, name, request); | ||
| 913 | 924 | ||
| 914 | 925 | if (checks_count == 0) { | |
| 915 | 926 | return isolate()->factory()->NewTuple3(holder_cell, smi_handler, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1383,6 +1383,41 @@ THREADED_TEST(InterceptorLoadGlobalICGlobalWithInterceptor) { | |||
| 1383 | 1383 | CHECK(value->BooleanValue(context.local()).FromJust()); | |
| 1384 | 1384 | } | |
| 1385 | 1385 | ||
| 1386 | + // Test load of a non-existing global through prototype chain when a global | ||
| 1387 | + // object has an interceptor. | ||
| 1388 | + THREADED_TEST(InterceptorLoadICGlobalWithInterceptor) { | ||
| 1389 | + i::FLAG_allow_natives_syntax = true; | ||
| 1390 | + v8::Isolate* isolate = CcTest::isolate(); | ||
| 1391 | + v8::HandleScope scope(isolate); | ||
| 1392 | + v8::Local<v8::ObjectTemplate> templ_global = v8::ObjectTemplate::New(isolate); | ||
| 1393 | + templ_global->SetHandler(v8::NamedPropertyHandlerConfiguration( | ||
| 1394 | + GenericInterceptorGetter, GenericInterceptorSetter)); | ||
| 1395 | + | ||
| 1396 | + LocalContext context(nullptr, templ_global); | ||
| 1397 | + i::Handle<i::JSReceiver> global_proxy = | ||
| 1398 | + v8::Utils::OpenHandle<Object, i::JSReceiver>(context->Global()); | ||
| 1399 | + CHECK(global_proxy->IsJSGlobalProxy()); | ||
| 1400 | + i::Handle<i::JSGlobalObject> global( | ||
| 1401 | + i::JSGlobalObject::cast(global_proxy->map()->prototype())); | ||
| 1402 | + CHECK(global->map()->has_named_interceptor()); | ||
| 1403 | + | ||
| 1404 | + ExpectInt32( | ||
| 1405 | + "(function() {" | ||
| 1406 | + " var f = function(obj) { " | ||
| 1407 | + " return obj.foo;" | ||
| 1408 | + " };" | ||
| 1409 | + " var obj = { __proto__: this, _str_foo: 42 };" | ||
| 1410 | + " for (var i = 0; i < 1500; i++) obj['p' + i] = 0;" | ||
| 1411 | + " /* Ensure that |obj| is in dictionary mode. */" | ||
| 1412 | + " if (%HasFastProperties(obj)) return -1;" | ||
| 1413 | + " for (var i = 0; i < 3; i++) {" | ||
| 1414 | + " f(obj);" | ||
| 1415 | + " };" | ||
| 1416 | + " return f(obj);" | ||
| 1417 | + "})();", | ||
| 1418 | + 42); | ||
| 1419 | + } | ||
| 1420 | + | ||
| 1386 | 1421 | static void InterceptorLoadICGetter0( | |
| 1387 | 1422 | Local<Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { | |
| 1388 | 1423 | ApiTestFuzzer::Fuzz(); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments