ItsTotallyRSX

7 FUCKING MILLISECOND STUBS VS 3 MS OBJECTS

Oct 23rd, 2022
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.10 KB | None | 0 0
  1. RUNTIME_ENTRY_WITH_RCS(Address, Object, BUILTIN_CONVERT_RESULT,
  2.                        Runtime_StorePropertyWithInterceptor)
  3.  Address Runtime_StorePropertyWithInterceptor(int args_length,
  4.                                               Address* args_object,
  5.                                               Isolate* isolate) {
  6.    DCHECK_EQ(3, args_length);
  7.    HandleScope scope(isolate);
  8.  
  9. #define RT_STPWI_VALUE_ADDRESS                                         \
  10.   (reinterpret_cast<Address*>(reinterpret_cast<Address>(args_object) - \
  11.                               (0 * kSystemPointerSize)))
  12.  
  13. #define RT_STPWI_NAME_ADDRESS                                          \
  14.   (reinterpret_cast<Address*>(reinterpret_cast<Address>(args_object) - \
  15.                               (2 * kSystemPointerSize)))
  16.  
  17. #define RT_STPWI_RECV_ADDRESS                                          \
  18.   (reinterpret_cast<Address*>(reinterpret_cast<Address>(args_object) - \
  19.                               (1 * kSystemPointerSize)))
  20.    Handle<JSObject> receiver = Handle<JSObject>(RT_STPWI_RECV_ADDRESS);
  21.    Handle<Name> name = Handle<Name>(RT_STPWI_NAME_ADDRESS);
  22.    Handle<Object> value = Handle<Object>(RT_STPWI_VALUE_ADDRESS);
  23.  
  24.    {
  25.      bool bCont{};
  26.      InterceptorInfo interceptorInfo;
  27.      auto handler = receiver->map().cached_property_handler();
  28.  
  29.      if (!handler.is_null()) {
  30.        interceptorInfo = InterceptorInfo::cast(handler);
  31.      } else {
  32.        if (receiver->HasNamedInterceptor()) {
  33.          Handle<JSObject> interceptor_holder = receiver;
  34.  
  35.          if (receiver->IsJSGlobalProxy() &&
  36.              (!receiver->HasNamedInterceptor() ||
  37.               receiver->GetNamedInterceptor().non_masking())) {
  38.            interceptor_holder =
  39.                handle(JSObject::cast(receiver->map().prototype()), isolate);
  40.          }
  41.          DCHECK(interceptor_holder->HasNamedInterceptor());
  42.  
  43.          interceptorInfo = interceptor_holder->GetNamedInterceptor();
  44.          receiver->map().set_cached_property_handler(interceptorInfo);
  45.        } else {
  46.          // intentional fallthrough to LookupIterator it [...] without goto
  47.          bCont = true;
  48.        }
  49.      }
  50.  
  51.      if (!bCont) {
  52.        DCHECK(!interceptorInfo.non_masking());
  53.  
  54.        if (interceptorInfo.use_fastpath()) {
  55.          bool bStatus =
  56.              reinterpret_cast<GenericNamedPropertySetterFastCallback>(
  57.                  v8::internal::Foreign::cast(interceptorInfo.setter())
  58.                      .foreign_address())(
  59.                  (v8::Isolate*)(isolate), v8::Utils::ToLocal(receiver),
  60.                  v8::Utils::ToLocal(name),
  61.                  v8::Utils::ToLocal(
  62.                      value));
  63.          if (isolate->has_scheduled_exception()) {
  64.            return isolate->PromoteScheduledException().ptr();
  65.          }
  66.          if (bStatus) {
  67.            return *RT_STPWI_VALUE_ADDRESS;  // 1:
  68.          }
  69.        } else {
  70.          PropertyCallbackArguments arguments(isolate, interceptorInfo.data(),
  71.                                              *receiver, *receiver,
  72.                                              Just(kDontThrow));
  73.  
  74.          if (isolate->has_scheduled_exception()) {
  75.            arguments.AcceptSideEffects();
  76.            return isolate->PromoteScheduledException().ptr();
  77.          }
  78.  
  79.          if (!arguments
  80.                   .CallNamedSetter(
  81.                       Handle<InterceptorInfo>(interceptorInfo, isolate), name,
  82.                       value)
  83.                   .is_null()) {
  84.            return *RT_STPWI_VALUE_ADDRESS;  // 1:
  85.          }
  86.        }
  87.  
  88.        // 1: If the interceptor didn't handle the request, then there must be no
  89.        // side effects.
  90.      }
  91.    }
  92.  
  93.    LookupIterator it(isolate, receiver, name, receiver);
  94.    // Skip past any access check on the receiver.
  95.    if (it.state() == LookupIterator::ACCESS_CHECK) {
  96.      DCHECK(it.HasAccess());
  97.      it.Next();
  98.    }
  99.    // Skip past the interceptor on the receiver.
  100.    DCHECK_EQ(LookupIterator::INTERCEPTOR, it.state());
  101.    it.Next();
  102.  
  103.    Object::SetProperty(&it, value, StoreOrigin::kNamed),
  104.    ReadOnlyRoots(isolate).exception();
  105.    return *RT_STPWI_VALUE_ADDRESS;
  106.  }
  107.  
Add Comment
Please, Sign In to add comment