Merge from v8 at revision 3723
diff --git a/src/runtime.js b/src/runtime.js
index ce2f197..c4c855e 100644
--- a/src/runtime.js
+++ b/src/runtime.js
@@ -541,7 +541,9 @@
   if (IS_STRING(x)) return new $String(x);
   if (IS_NUMBER(x)) return new $Number(x);
   if (IS_BOOLEAN(x)) return new $Boolean(x);
-  if (x == null) throw %MakeTypeError('null_to_object', []);
+  if (IS_NULL_OR_UNDEFINED(x) && !IS_UNDETECTABLE(x)) {
+    throw %MakeTypeError('null_to_object', []);
+  }
   return x;
 }