LCOV - code coverage report
Current view: top level - src/runtime - runtime-proxy.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 39 49 79.6 %
Date: 2019-01-20 Functions: 6 16 37.5 %

          Line data    Source code
       1             : // Copyright 2014 the V8 project authors. All rights reserved.
       2             : // Use of this source code is governed by a BSD-style license that can be
       3             : // found in the LICENSE file.
       4             : 
       5             : #include "src/runtime/runtime-utils.h"
       6             : 
       7             : #include "src/arguments-inl.h"
       8             : #include "src/counters.h"
       9             : #include "src/elements.h"
      10             : #include "src/heap/factory.h"
      11             : #include "src/isolate-inl.h"
      12             : #include "src/objects-inl.h"
      13             : 
      14             : namespace v8 {
      15             : namespace internal {
      16             : 
      17             : 
      18           0 : RUNTIME_FUNCTION(Runtime_IsJSProxy) {
      19             :   SealHandleScope shs(isolate);
      20             :   DCHECK_EQ(1, args.length());
      21           0 :   CONVERT_ARG_CHECKED(Object, obj, 0);
      22           0 :   return isolate->heap()->ToBoolean(obj->IsJSProxy());
      23             : }
      24             : 
      25             : 
      26           0 : RUNTIME_FUNCTION(Runtime_JSProxyGetHandler) {
      27             :   SealHandleScope shs(isolate);
      28             :   DCHECK_EQ(1, args.length());
      29           0 :   CONVERT_ARG_CHECKED(JSProxy, proxy, 0);
      30           0 :   return proxy->handler();
      31             : }
      32             : 
      33             : 
      34           0 : RUNTIME_FUNCTION(Runtime_JSProxyGetTarget) {
      35             :   SealHandleScope shs(isolate);
      36             :   DCHECK_EQ(1, args.length());
      37           0 :   CONVERT_ARG_CHECKED(JSProxy, proxy, 0);
      38           0 :   return proxy->target();
      39             : }
      40             : 
      41             : 
      42        4211 : RUNTIME_FUNCTION(Runtime_GetPropertyWithReceiver) {
      43        4211 :   HandleScope scope(isolate);
      44             : 
      45             :   DCHECK_EQ(4, args.length());
      46        8422 :   CONVERT_ARG_HANDLE_CHECKED(JSReceiver, holder, 0);
      47        4211 :   CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
      48        4211 :   CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 2);
      49        8422 :   CONVERT_ARG_HANDLE_CHECKED(Smi, on_non_existent, 3);
      50             : 
      51        4211 :   bool success = false;
      52             :   LookupIterator it = LookupIterator::PropertyOrElement(isolate, receiver, key,
      53        4211 :                                                         &success, holder);
      54        4211 :   if (!success) {
      55             :     DCHECK(isolate->has_pending_exception());
      56             :     return ReadOnlyRoots(isolate).exception();
      57             :   }
      58             : 
      59        8404 :   RETURN_RESULT_OR_FAILURE(
      60             :       isolate, Object::GetProperty(
      61        4211 :                    &it, static_cast<OnNonExistent>(on_non_existent->value())));
      62             : }
      63             : 
      64         540 : RUNTIME_FUNCTION(Runtime_SetPropertyWithReceiver) {
      65         540 :   HandleScope scope(isolate);
      66             : 
      67             :   DCHECK_EQ(5, args.length());
      68        1080 :   CONVERT_ARG_HANDLE_CHECKED(JSReceiver, holder, 0);
      69         540 :   CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
      70         540 :   CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
      71         540 :   CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 3);
      72        1080 :   CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 4);
      73             : 
      74         540 :   bool success = false;
      75             :   LookupIterator it = LookupIterator::PropertyOrElement(isolate, receiver, key,
      76         540 :                                                         &success, holder);
      77         540 :   if (!success) {
      78             :     DCHECK(isolate->has_pending_exception());
      79             :     return ReadOnlyRoots(isolate).exception();
      80             :   }
      81             :   Maybe<bool> result = Object::SetSuperProperty(&it, value, language_mode,
      82         531 :                                                 StoreOrigin::kMaybeKeyed);
      83         531 :   MAYBE_RETURN(result, ReadOnlyRoots(isolate).exception());
      84         198 :   return *isolate->factory()->ToBoolean(result.FromJust());
      85             : }
      86             : 
      87          99 : RUNTIME_FUNCTION(Runtime_CheckProxyGetSetTrapResult) {
      88          99 :   HandleScope scope(isolate);
      89             : 
      90             :   DCHECK_EQ(4, args.length());
      91         198 :   CONVERT_ARG_HANDLE_CHECKED(Name, name, 0);
      92         198 :   CONVERT_ARG_HANDLE_CHECKED(JSReceiver, target, 1);
      93          99 :   CONVERT_ARG_HANDLE_CHECKED(Object, trap_result, 2);
      94         198 :   CONVERT_NUMBER_CHECKED(int64_t, access_kind, Int64, args[3]);
      95             : 
      96         198 :   RETURN_RESULT_OR_FAILURE(isolate, JSProxy::CheckGetSetTrapResult(
      97             :                                         isolate, name, target, trap_result,
      98          99 :                                         JSProxy::AccessKind(access_kind)));
      99             : }
     100             : 
     101           9 : RUNTIME_FUNCTION(Runtime_CheckProxyHasTrap) {
     102           9 :   HandleScope scope(isolate);
     103             : 
     104             :   DCHECK_EQ(2, args.length());
     105          18 :   CONVERT_ARG_HANDLE_CHECKED(Name, name, 0);
     106          18 :   CONVERT_ARG_HANDLE_CHECKED(JSReceiver, target, 1);
     107             : 
     108           9 :   Maybe<bool> result = JSProxy::CheckHasTrap(isolate, name, target);
     109           9 :   if (!result.IsJust()) return ReadOnlyRoots(isolate).exception();
     110           0 :   return isolate->heap()->ToBoolean(result.FromJust());
     111             : }
     112             : 
     113             : }  // namespace internal
     114      183867 : }  // namespace v8

Generated by: LCOV version 1.10