function settleWithX (p, x) {
      // 2.3.1
      if (x === p && x) {
          settlePromise(p, $rejected, genTypeError($promiseCircularChain));
          return p;
      }

      // 2.3.2
      // 2.3.3
      if (x !== $null && (isFunction(x) || isObject(x))) {
          // 2.3.2.1
          var xthen = genTryCatcher(getThen)(x);

          if (xthen === $tryErr) {
              // 2.3.3.2
              settlePromise(p, $rejected, xthen.e);
              return p;
          }

          if (isFunction(xthen)) {
              if (isLongStackTrace && isYaku(x))
                  p._next = x;

              // Fix https://bugs.chromium.org/p/v8/issues/detail?id=4162
              if (isYaku(x))
                  settleXthen(p, x, xthen);
              else
                  Yaku.nextTick(function () {
                      settleXthen(p, x, xthen);
                  });
          } else
              // 2.3.3.4
              settlePromise(p, $resolved, x);
      } else
          // 2.3.4
          settlePromise(p, $resolved, x);

      return p;
  }
Resolve or reject promise with value x. The x can also be a thenable.
@private
@param {Yaku} p
@param {Any | Thenable} x A normal value or a thenable.