From cefee262b7059d035667b148d56ebc7af5120d37 Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Sat, 8 Jun 2019 17:19:11 -0400 Subject: 1333143 - Self-host Object.prototype.valueOf. --- js/src/wasm/AsmJS.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'js/src/wasm/AsmJS.cpp') diff --git a/js/src/wasm/AsmJS.cpp b/js/src/wasm/AsmJS.cpp index f906d4bf1..81795b47d 100644 --- a/js/src/wasm/AsmJS.cpp +++ b/js/src/wasm/AsmJS.cpp @@ -34,6 +34,7 @@ #include "frontend/Parser.h" #include "gc/Policy.h" #include "js/MemoryMetrics.h" +#include "vm/SelfHosting.h" #include "vm/StringBuffer.h" #include "vm/Time.h" #include "vm/TypedArrayObject.h" @@ -7464,6 +7465,20 @@ GetDataProperty(JSContext* cx, HandleValue objVal, ImmutablePropertyNamePtr fiel return GetDataProperty(cx, objVal, fieldHandle, v); } +static bool +HasObjectValueOfMethodPure(JSObject* obj, JSContext* cx) +{ + Value v; + if (!GetPropertyPure(cx, obj, NameToId(cx->names().valueOf), &v)) + return false; + + JSFunction* fun; + if (!IsFunctionObject(v, &fun)) + return false; + + return IsSelfHostedFunctionWithName(fun, cx->names().Object_valueOf); +} + static bool HasPureCoercion(JSContext* cx, HandleValue v) { @@ -7480,7 +7495,7 @@ HasPureCoercion(JSContext* cx, HandleValue v) // most apps have been built with newer Emscripten. if (v.toObject().is() && HasNoToPrimitiveMethodPure(&v.toObject(), cx) && - HasNativeMethodPure(&v.toObject(), cx->names().valueOf, obj_valueOf, cx) && + HasObjectValueOfMethodPure(&v.toObject(), cx) && HasNativeMethodPure(&v.toObject(), cx->names().toString, fun_toString, cx)) { return true; -- cgit v1.2.3