Verified Commit 0b2e0686 authored by Iain Ireland's avatar Iain Ireland Committed by ma1
Browse files

Bug 2074164: Resolve primitive object constructors in WarpOracle a=dsmith

parent 6ee4b74b
Loading
Loading
Loading
Loading
+14 −1
Changes for js/src/jit/WarpOracle.cpp: 14 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -347,7 +347,8 @@ AbortReasonOr<WarpScriptSnapshot*> WarpScriptOracle::createScriptSnapshot() {
      }

      case JSOp::FunctionThis:
        if (!script_->strict() && script_->hasNonSyntacticScope()) {
        if (!script_->strict()) {
          if (script_->hasNonSyntacticScope()) {
            // Abort because MBoxNonStrictThis doesn't support non-syntactic
            // scopes (a deprecated SpiderMonkey mechanism). If this becomes an
            // issue we could support it by refactoring GetFunctionThis to not
@@ -355,6 +356,18 @@ AbortReasonOr<WarpScriptSnapshot*> WarpScriptOracle::createScriptSnapshot() {
            return abort(AbortReason::Disable,
                         "JSOp::FunctionThis with non-syntactic scope");
          }

          // Ensure that all constructors called by PrimitiveToObject are
          // already resolved.
          Handle<GlobalObject*> global = cx_->global();
          if (!GlobalObject::ensureConstructor(cx_, global, JSProto_Number) ||
              !GlobalObject::ensureConstructor(cx_, global, JSProto_Boolean) ||
              !GlobalObject::ensureConstructor(cx_, global, JSProto_String) ||
              !GlobalObject::ensureConstructor(cx_, global, JSProto_Symbol) ||
              !GlobalObject::ensureConstructor(cx_, global, JSProto_BigInt)) {
            return abort(AbortReason::Error);
          }
        }
        break;

      case JSOp::GlobalThis:
+3 −0
Changes for js/src/vm/JSObject.cpp: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -2533,6 +2533,9 @@ bool js::IsPrototypeOf(JSContext* cx, HandleObject protoObj, JSObject* obj,
JSObject* js::PrimitiveToObject(JSContext* cx, const Value& v) {
  MOZ_ASSERT(v.isPrimitive());

  // Note: if a new primitive type is added here, its constructor
  // should also be resolved in the JSOp::FunctionThis case in
  // WarpScriptOracle::createScriptSnapshot.
  switch (v.type()) {
    case ValueType::String: {
      Rooted<JSString*> str(cx, v.toString());