diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc index 76c282a5b6..3c00a5e098 100644 --- a/src/bootstrapper.cc +++ b/src/bootstrapper.cc @@ -1214,6 +1214,9 @@ void Genesis::InitializeGlobal(Handle global_object, SimpleInstallFunction(isolate->initial_object_prototype(), "__lookupSetter__", Builtins::kObjectLookupSetter, 1, true); + SimpleInstallFunction( + isolate->initial_object_prototype(), "propertyIsEnumerable", + Builtins::kObjectPrototypePropertyIsEnumerable, 1, false); } Handle global(native_context()->global_object()); diff --git a/src/builtins.cc b/src/builtins.cc index 13bea63102..d386ae9cf6 100644 --- a/src/builtins.cc +++ b/src/builtins.cc @@ -4994,7 +4994,26 @@ BUILTIN(AsyncFunctionConstructor) { return *func; } -// ES6 19.1.3.6 Object.prototype.toString +// ----------------------------------------------------------------------------- +// ES6 section 19.1 Object Objects + +// ES6 section 19.1.3.4 Object.prototype.propertyIsEnumerable ( V ) +BUILTIN(ObjectPrototypePropertyIsEnumerable) { + HandleScope scope(isolate); + Handle object; + Handle name; + ASSIGN_RETURN_FAILURE_ON_EXCEPTION( + isolate, name, Object::ToName(isolate, args.atOrUndefined(isolate, 1))); + ASSIGN_RETURN_FAILURE_ON_EXCEPTION( + isolate, object, JSReceiver::ToObject(isolate, args.receiver())); + Maybe maybe = + JSReceiver::GetOwnPropertyAttributes(object, name); + if (!maybe.IsJust()) return isolate->heap()->exception(); + if (maybe.FromJust() == ABSENT) return isolate->heap()->false_value(); + return isolate->heap()->ToBoolean((maybe.FromJust() & DONT_ENUM) == 0); +} + +// ES6 section 19.1.3.6 Object.prototype.toString BUILTIN(ObjectProtoToString) { HandleScope scope(isolate); Handle object = args.at(0); diff --git a/src/builtins.h b/src/builtins.h index 4e2e45f05a..76e0df3ed9 100644 --- a/src/builtins.h +++ b/src/builtins.h @@ -145,6 +145,7 @@ class CodeStubAssembler; V(ObjectLookupGetter, BUILTIN_EXIT) \ V(ObjectLookupSetter, BUILTIN_EXIT) \ V(ObjectPreventExtensions, BUILTIN_EXIT) \ + V(ObjectPrototypePropertyIsEnumerable, BUILTIN_EXIT) \ V(ObjectProtoToString, BUILTIN_EXIT) \ V(ObjectSeal, BUILTIN_EXIT) \ V(ObjectValues, BUILTIN_EXIT) \ diff --git a/src/compiler/js-intrinsic-lowering.cc b/src/compiler/js-intrinsic-lowering.cc index 1d939e1ee0..080c530ab6 100644 --- a/src/compiler/js-intrinsic-lowering.cc +++ b/src/compiler/js-intrinsic-lowering.cc @@ -68,14 +68,10 @@ Reduction JSIntrinsicLowering::Reduce(Node* node) { return ReduceToInteger(node); case Runtime::kInlineToLength: return ReduceToLength(node); - case Runtime::kInlineToName: - return ReduceToName(node); case Runtime::kInlineToNumber: return ReduceToNumber(node); case Runtime::kInlineToObject: return ReduceToObject(node); - case Runtime::kInlineToPrimitive: - return ReduceToPrimitive(node); case Runtime::kInlineToString: return ReduceToString(node); case Runtime::kInlineCall: @@ -280,12 +276,6 @@ Reduction JSIntrinsicLowering::ReduceToInteger(Node* node) { } -Reduction JSIntrinsicLowering::ReduceToName(Node* node) { - NodeProperties::ChangeOp(node, javascript()->ToName()); - return Changed(node); -} - - Reduction JSIntrinsicLowering::ReduceToNumber(Node* node) { NodeProperties::ChangeOp(node, javascript()->ToNumber()); return Changed(node); @@ -304,17 +294,6 @@ Reduction JSIntrinsicLowering::ReduceToObject(Node* node) { } -Reduction JSIntrinsicLowering::ReduceToPrimitive(Node* node) { - Node* value = NodeProperties::GetValueInput(node, 0); - Type* value_type = NodeProperties::GetType(value); - if (value_type->Is(Type::Primitive())) { - ReplaceWithValue(node, value); - return Replace(value); - } - return NoChange(); -} - - Reduction JSIntrinsicLowering::ReduceToString(Node* node) { NodeProperties::ChangeOp(node, javascript()->ToString()); return Changed(node); diff --git a/src/compiler/js-intrinsic-lowering.h b/src/compiler/js-intrinsic-lowering.h index 9728eaf679..87ea5d1c50 100644 --- a/src/compiler/js-intrinsic-lowering.h +++ b/src/compiler/js-intrinsic-lowering.h @@ -54,10 +54,8 @@ class JSIntrinsicLowering final : public AdvancedReducer { Reduction ReduceSubString(Node* node); Reduction ReduceToInteger(Node* node); Reduction ReduceToLength(Node* node); - Reduction ReduceToName(Node* node); Reduction ReduceToNumber(Node* node); Reduction ReduceToObject(Node* node); - Reduction ReduceToPrimitive(Node* node); Reduction ReduceToString(Node* node); Reduction ReduceCall(Node* node); Reduction ReduceNewObject(Node* node); diff --git a/src/compiler/linkage.cc b/src/compiler/linkage.cc index 1fe62f2ccf..1c392eb893 100644 --- a/src/compiler/linkage.cc +++ b/src/compiler/linkage.cc @@ -188,12 +188,8 @@ bool Linkage::NeedsFrameStateInput(Runtime::FunctionId function) { case Runtime::kInlineThrowNotDateError: case Runtime::kInlineToInteger: case Runtime::kInlineToLength: - case Runtime::kInlineToName: case Runtime::kInlineToNumber: case Runtime::kInlineToObject: - case Runtime::kInlineToPrimitive: - case Runtime::kInlineToPrimitive_Number: - case Runtime::kInlineToPrimitive_String: case Runtime::kInlineToString: return true; default: diff --git a/src/compiler/typer.cc b/src/compiler/typer.cc index ce8a563623..df6a7c2890 100644 --- a/src/compiler/typer.cc +++ b/src/compiler/typer.cc @@ -1481,16 +1481,10 @@ Type* Typer::Visitor::TypeJSCallRuntime(Node* node) { return TypeUnaryOp(node, ToInteger); case Runtime::kInlineToLength: return TypeUnaryOp(node, ToLength); - case Runtime::kInlineToName: - return TypeUnaryOp(node, ToName); case Runtime::kInlineToNumber: return TypeUnaryOp(node, ToNumber); case Runtime::kInlineToObject: return TypeUnaryOp(node, ToObject); - case Runtime::kInlineToPrimitive: - case Runtime::kInlineToPrimitive_Number: - case Runtime::kInlineToPrimitive_String: - return TypeUnaryOp(node, ToPrimitive); case Runtime::kInlineToString: return TypeUnaryOp(node, ToString); case Runtime::kHasInPrototypeChain: diff --git a/src/crankshaft/hydrogen.cc b/src/crankshaft/hydrogen.cc index 697f97dda5..742c1497e2 100644 --- a/src/crankshaft/hydrogen.cc +++ b/src/crankshaft/hydrogen.cc @@ -12312,29 +12312,6 @@ void HOptimizedGraphBuilder::GenerateToInteger(CallRuntime* call) { } -void HOptimizedGraphBuilder::GenerateToName(CallRuntime* call) { - DCHECK_EQ(1, call->arguments()->length()); - CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); - HValue* input = Pop(); - if (input->type().IsSmi()) { - HValue* result = BuildNumberToString(input, Type::SignedSmall()); - return ast_context()->ReturnValue(result); - } else if (input->type().IsTaggedNumber()) { - HValue* result = BuildNumberToString(input, Type::Number()); - return ast_context()->ReturnValue(result); - } else if (input->type().IsString()) { - return ast_context()->ReturnValue(input); - } else { - Callable callable = CodeFactory::ToName(isolate()); - HValue* stub = Add(callable.code()); - HValue* values[] = {context(), input}; - HInstruction* result = New( - stub, 0, callable.descriptor(), ArrayVector(values)); - return ast_context()->ReturnInstruction(result, call->id()); - } -} - - void HOptimizedGraphBuilder::GenerateToObject(CallRuntime* call) { DCHECK_EQ(1, call->arguments()->length()); CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); diff --git a/src/crankshaft/hydrogen.h b/src/crankshaft/hydrogen.h index 1a83ba0c90..8d9e33b98d 100644 --- a/src/crankshaft/hydrogen.h +++ b/src/crankshaft/hydrogen.h @@ -2217,7 +2217,6 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor { F(NewObject) \ F(StringCharFromCode) \ F(ToInteger) \ - F(ToName) \ F(ToObject) \ F(ToString) \ F(ToLength) \ diff --git a/src/debug/mirrors.js b/src/debug/mirrors.js index c888f8603b..1ccb001711 100644 --- a/src/debug/mirrors.js +++ b/src/debug/mirrors.js @@ -785,7 +785,7 @@ ObjectMirror.prototype.internalProperties = function() { ObjectMirror.prototype.property = function(name) { - var details = %DebugGetPropertyDetails(this.value_, TO_NAME(name)); + var details = %DebugGetPropertyDetails(this.value_, name); if (details) { return new PropertyMirror(this, name, details); } diff --git a/src/full-codegen/full-codegen.cc b/src/full-codegen/full-codegen.cc index a6d14f72e2..14113dd189 100644 --- a/src/full-codegen/full-codegen.cc +++ b/src/full-codegen/full-codegen.cc @@ -561,11 +561,6 @@ void FullCodeGenerator::EmitToString(CallRuntime* expr) { } -void FullCodeGenerator::EmitToName(CallRuntime* expr) { - EmitIntrinsicAsStubCall(expr, CodeFactory::ToName(isolate())); -} - - void FullCodeGenerator::EmitToLength(CallRuntime* expr) { EmitIntrinsicAsStubCall(expr, CodeFactory::ToLength(isolate())); } diff --git a/src/full-codegen/full-codegen.h b/src/full-codegen/full-codegen.h index e1551e7e47..22f1731008 100644 --- a/src/full-codegen/full-codegen.h +++ b/src/full-codegen/full-codegen.h @@ -527,7 +527,6 @@ class FullCodeGenerator: public AstVisitor { F(ToString) \ F(ToLength) \ F(ToNumber) \ - F(ToName) \ F(ToObject) \ F(DebugIsActive) \ F(CreateIterResultObject) diff --git a/src/interpreter/interpreter-intrinsics.cc b/src/interpreter/interpreter-intrinsics.cc index ae8e83a826..600b9c086f 100644 --- a/src/interpreter/interpreter-intrinsics.cc +++ b/src/interpreter/interpreter-intrinsics.cc @@ -269,10 +269,6 @@ Node* IntrinsicsHelper::ToString(Node* input, Node* arg_count, Node* context) { return IntrinsicAsStubCall(input, context, CodeFactory::ToString(isolate())); } -Node* IntrinsicsHelper::ToName(Node* input, Node* arg_count, Node* context) { - return IntrinsicAsStubCall(input, context, CodeFactory::ToName(isolate())); -} - Node* IntrinsicsHelper::ToLength(Node* input, Node* arg_count, Node* context) { return IntrinsicAsStubCall(input, context, CodeFactory::ToLength(isolate())); } diff --git a/src/interpreter/interpreter-intrinsics.h b/src/interpreter/interpreter-intrinsics.h index e6a085dcb3..14c29134f6 100644 --- a/src/interpreter/interpreter-intrinsics.h +++ b/src/interpreter/interpreter-intrinsics.h @@ -40,7 +40,6 @@ namespace interpreter { V(RegExpExec, reg_exp_exec, 4) \ V(SubString, sub_string, 3) \ V(ToString, to_string, 1) \ - V(ToName, to_name, 1) \ V(ToLength, to_length, 1) \ V(ToInteger, to_integer, 1) \ V(ToNumber, to_number, 1) \ diff --git a/src/js/macros.py b/src/js/macros.py index 2d6b6b924f..cf762f78e8 100644 --- a/src/js/macros.py +++ b/src/js/macros.py @@ -32,12 +32,6 @@ define NONE = 0; define READ_ONLY = 1; define DONT_ENUM = 2; define DONT_DELETE = 4; -define NEW_ONE_BYTE_STRING = true; -define NEW_TWO_BYTE_STRING = false; - -# Constants used for getter and setter operations. -define GETTER = 0; -define SETTER = 1; # 2^53 - 1 define kMaxSafeInteger = 9007199254740991; @@ -45,10 +39,6 @@ define kMaxSafeInteger = 9007199254740991; # 2^32 - 1 define kMaxUint32 = 4294967295; -# Strict mode flags for passing to %SetProperty -define kSloppyMode = 0; -define kStrictMode = 1; - # Native cache ids. define STRING_TO_REGEXP_CACHE_ID = 0; @@ -108,11 +98,6 @@ macro TO_LENGTH(arg) = (%_ToLength(arg)); macro TO_STRING(arg) = (%_ToString(arg)); macro TO_NUMBER(arg) = (%_ToNumber(arg)); macro TO_OBJECT(arg) = (%_ToObject(arg)); -macro TO_PRIMITIVE(arg) = (%_ToPrimitive(arg)); -macro TO_PRIMITIVE_NUMBER(arg) = (%_ToPrimitive_Number(arg)); -macro TO_PRIMITIVE_STRING(arg) = (%_ToPrimitive_String(arg)); -macro TO_NAME(arg) = (%_ToName(arg)); -macro JSON_NUMBER_TO_STRING(arg) = ((%_IsSmi(%IS_VAR(arg)) || arg - arg == 0) ? %_NumberToString(arg) : "null"); macro HAS_OWN_PROPERTY(obj, key) = (%_Call(ObjectHasOwnProperty, obj, key)); # Private names. @@ -222,10 +207,6 @@ define NOT_FOUND = -1; # Check whether debug is active. define DEBUG_IS_ACTIVE = (%_DebugIsActive() != 0); -# SharedFlag equivalents -define kNotShared = false; -define kShared = true; - # UseCounters from include/v8.h define kUseAsm = 0; define kBreakIterator = 1; diff --git a/src/js/v8natives.js b/src/js/v8natives.js index 9026cfe684..4e7d536645 100644 --- a/src/js/v8natives.js +++ b/src/js/v8natives.js @@ -131,12 +131,6 @@ function ObjectIsPrototypeOf(V) { } -// ES6 19.1.3.4 -function ObjectPropertyIsEnumerable(V) { - var P = TO_NAME(V); - return %PropertyIsEnumerable(TO_OBJECT(this), P); -} - // ES6 7.3.9 function GetMethod(obj, p) { var func = obj[p]; @@ -201,7 +195,7 @@ utils.InstallFunctions(GlobalObject.prototype, DONT_ENUM, [ "toLocaleString", ObjectToLocaleString, "valueOf", ObjectValueOf, "isPrototypeOf", ObjectIsPrototypeOf, - "propertyIsEnumerable", ObjectPropertyIsEnumerable, + // propertyIsEnumerable is added in bootstrapper.cc. // __defineGetter__ is added in bootstrapper.cc. // __lookupGetter__ is added in bootstrapper.cc. // __defineSetter__ is added in bootstrapper.cc. diff --git a/src/runtime/runtime-debug.cc b/src/runtime/runtime-debug.cc index 9db7b7f0f1..877421cf5a 100644 --- a/src/runtime/runtime-debug.cc +++ b/src/runtime/runtime-debug.cc @@ -330,11 +330,14 @@ RUNTIME_FUNCTION(Runtime_DebugGetInternalProperties) { // Items 2-4 are only filled if the property has either a getter or a setter. RUNTIME_FUNCTION(Runtime_DebugGetPropertyDetails) { HandleScope scope(isolate); - - DCHECK(args.length() == 2); - + DCHECK_EQ(2, args.length()); CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); - CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); + CONVERT_ARG_HANDLE_CHECKED(Object, name_obj, 1); + + // Convert the {name_obj} to a Name. + Handle name; + ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name, + Object::ToName(isolate, name_obj)); // Make sure to set the current context to the context before the debugger was // entered (if the debugger is entered). The reason for switching context here diff --git a/src/runtime/runtime-object.cc b/src/runtime/runtime-object.cc index 60d054d3e4..88c3490f87 100644 --- a/src/runtime/runtime-object.cc +++ b/src/runtime/runtime-object.cc @@ -564,21 +564,6 @@ RUNTIME_FUNCTION(Runtime_HasProperty) { } -RUNTIME_FUNCTION(Runtime_PropertyIsEnumerable) { - HandleScope scope(isolate); - DCHECK(args.length() == 2); - - CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); - CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); - - Maybe maybe = - JSReceiver::GetOwnPropertyAttributes(object, key); - if (!maybe.IsJust()) return isolate->heap()->exception(); - if (maybe.FromJust() == ABSENT) return isolate->heap()->false_value(); - return isolate->heap()->ToBoolean((maybe.FromJust() & DONT_ENUM) == 0); -} - - RUNTIME_FUNCTION(Runtime_GetOwnPropertyKeys) { HandleScope scope(isolate); DCHECK(args.length() == 2); @@ -868,15 +853,6 @@ RUNTIME_FUNCTION(Runtime_ToPrimitive_Number) { } -RUNTIME_FUNCTION(Runtime_ToPrimitive_String) { - HandleScope scope(isolate); - DCHECK_EQ(1, args.length()); - CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); - RETURN_RESULT_OR_FAILURE( - isolate, Object::ToPrimitive(input, ToPrimitiveHint::kString)); -} - - RUNTIME_FUNCTION(Runtime_ToNumber) { HandleScope scope(isolate); DCHECK_EQ(1, args.length()); diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h index fee79531c8..563849c667 100644 --- a/src/runtime/runtime.h +++ b/src/runtime/runtime.h @@ -388,7 +388,6 @@ namespace internal { F(DeleteProperty_Sloppy, 2, 1) \ F(DeleteProperty_Strict, 2, 1) \ F(HasProperty, 2, 1) \ - F(PropertyIsEnumerable, 2, 1) \ F(GetOwnPropertyKeys, 2, 1) \ F(GetInterceptorInfo, 1, 1) \ F(ToFastProperties, 1, 1) \ @@ -411,7 +410,6 @@ namespace internal { F(ToObject, 1, 1) \ F(ToPrimitive, 1, 1) \ F(ToPrimitive_Number, 1, 1) \ - F(ToPrimitive_String, 1, 1) \ F(ToNumber, 1, 1) \ F(ToInteger, 1, 1) \ F(ToLength, 1, 1) \ diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index 9762ae25ab..4560767062 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -22393,7 +22393,7 @@ TEST(AccessCheckThrows) { CheckCorrectThrow("%DeleteProperty_Strict(other, '1')"); CheckCorrectThrow("Object.prototype.hasOwnProperty.call(other, 'x')"); CheckCorrectThrow("%HasProperty('x', other)"); - CheckCorrectThrow("%PropertyIsEnumerable(other, 'x')"); + CheckCorrectThrow("Object.prototype.propertyIsEnumerable(other, 'x')"); // PROPERTY_ATTRIBUTES_NONE = 0 CheckCorrectThrow("%DefineAccessorPropertyUnchecked(" "other, 'x', null, null, 1)"); diff --git a/test/mjsunit/harmony/to-name.js b/test/mjsunit/harmony/to-name.js index 6d5d64e5e4..0a2c043a2f 100644 --- a/test/mjsunit/harmony/to-name.js +++ b/test/mjsunit/harmony/to-name.js @@ -5,50 +5,37 @@ // Flags: --allow-natives-syntax assertEquals("1", %ToName(1)); -assertEquals("1", %_ToName(1)); assertEquals("0.5", %ToName(.5)); -assertEquals("0.5", %_ToName(.5)); assertEquals("null", %ToName(null)); -assertEquals("null", %_ToName(null)); assertEquals("true", %ToName(true)); -assertEquals("true", %_ToName(true)); assertEquals("false", %ToName(false)); -assertEquals("false", %_ToName(false)); assertEquals("undefined", %ToName(undefined)); -assertEquals("undefined", %_ToName(undefined)); assertEquals("random text", %ToName("random text")); -assertEquals("random text", %_ToName("random text")); assertEquals(Symbol.toPrimitive, %ToName(Symbol.toPrimitive)); -assertEquals(Symbol.toPrimitive, %_ToName(Symbol.toPrimitive)); var a = { toString: function() { return "xyz" }}; assertEquals("xyz", %ToName(a)); -assertEquals("xyz", %_ToName(a)); var b = { valueOf: function() { return 42 }}; assertEquals("[object Object]", %ToName(b)); -assertEquals("[object Object]", %_ToName(b)); var c = { toString: function() { return "x"}, valueOf: function() { return 123 } }; assertEquals("x", %ToName(c)); -assertEquals("x", %_ToName(c)); var d = { [Symbol.toPrimitive]: function(hint) { return hint } }; assertEquals("string", %ToName(d)); -assertEquals("string", %_ToName(d)); var e = new Date(0); assertEquals(e.toString(), %ToName(e)); -assertEquals(e.toString(), %_ToName(e)); diff --git a/test/mjsunit/harmony/to-primitive.js b/test/mjsunit/harmony/to-primitive.js index 09280bf1ee..8decb04657 100644 --- a/test/mjsunit/harmony/to-primitive.js +++ b/test/mjsunit/harmony/to-primitive.js @@ -6,75 +6,35 @@ assertEquals(1, %ToPrimitive(1)); assertEquals(1, %ToPrimitive_Number(1)); -assertEquals(1, %ToPrimitive_String(1)); -assertEquals(1, %_ToPrimitive(1)); -assertEquals(1, %_ToPrimitive_Number(1)); -assertEquals(1, %_ToPrimitive_String(1)); assertEquals(.5, %ToPrimitive(.5)); assertEquals(.5, %ToPrimitive_Number(.5)); -assertEquals(.5, %ToPrimitive_String(.5)); -assertEquals(.5, %_ToPrimitive(.5)); -assertEquals(.5, %_ToPrimitive_Number(.5)); -assertEquals(.5, %_ToPrimitive_String(.5)); assertEquals(null, %ToPrimitive(null)); assertEquals(null, %ToPrimitive_Number(null)); -assertEquals(null, %ToPrimitive_String(null)); -assertEquals(null, %_ToPrimitive(null)); -assertEquals(null, %_ToPrimitive_Number(null)); -assertEquals(null, %_ToPrimitive_String(null)); assertEquals(true, %ToPrimitive(true)); assertEquals(true, %ToPrimitive_Number(true)); -assertEquals(true, %ToPrimitive_String(true)); -assertEquals(true, %_ToPrimitive(true)); -assertEquals(true, %_ToPrimitive_Number(true)); -assertEquals(true, %_ToPrimitive_String(true)); assertEquals(false, %ToPrimitive(false)); assertEquals(false, %ToPrimitive_Number(false)); -assertEquals(false, %ToPrimitive_String(false)); -assertEquals(false, %_ToPrimitive(false)); -assertEquals(false, %_ToPrimitive_Number(false)); -assertEquals(false, %_ToPrimitive_String(false)); assertEquals(undefined, %ToPrimitive(undefined)); assertEquals(undefined, %ToPrimitive_Number(undefined)); -assertEquals(undefined, %ToPrimitive_String(undefined)); -assertEquals(undefined, %_ToPrimitive(undefined)); -assertEquals(undefined, %_ToPrimitive_Number(undefined)); -assertEquals(undefined, %_ToPrimitive_String(undefined)); assertEquals("random text", %ToPrimitive("random text")); assertEquals("random text", %ToPrimitive_Number("random text")); -assertEquals("random text", %ToPrimitive_String("random text")); -assertEquals("random text", %_ToPrimitive("random text")); -assertEquals("random text", %_ToPrimitive_Number("random text")); -assertEquals("random text", %_ToPrimitive_String("random text")); assertEquals(Symbol.toPrimitive, %ToPrimitive(Symbol.toPrimitive)); assertEquals(Symbol.toPrimitive, %ToPrimitive_Number(Symbol.toPrimitive)); -assertEquals(Symbol.toPrimitive, %ToPrimitive_String(Symbol.toPrimitive)); -assertEquals(Symbol.toPrimitive, %_ToPrimitive(Symbol.toPrimitive)); -assertEquals(Symbol.toPrimitive, %_ToPrimitive_Number(Symbol.toPrimitive)); -assertEquals(Symbol.toPrimitive, %_ToPrimitive_String(Symbol.toPrimitive)); var a = { toString: function() { return "xyz" }}; assertEquals("xyz", %ToPrimitive(a)); assertEquals("xyz", %ToPrimitive_Number(a)); -assertEquals("xyz", %ToPrimitive_String(a)); -assertEquals("xyz", %_ToPrimitive(a)); -assertEquals("xyz", %_ToPrimitive_Number(a)); -assertEquals("xyz", %_ToPrimitive_String(a)); var b = { valueOf: function() { return 42 }}; assertEquals(42, %ToPrimitive(b)); assertEquals(42, %ToPrimitive_Number(b)); -assertEquals("[object Object]", %ToPrimitive_String(b)); -assertEquals(42, %_ToPrimitive(b)); -assertEquals(42, %_ToPrimitive_Number(b)); -assertEquals("[object Object]", %_ToPrimitive_String(b)); var c = { toString: function() { return "x"}, @@ -82,25 +42,13 @@ var c = { }; assertEquals(123, %ToPrimitive(c)); assertEquals(123, %ToPrimitive_Number(c)); -assertEquals("x", %ToPrimitive_String(c)); -assertEquals(123, %_ToPrimitive(c)); -assertEquals(123, %_ToPrimitive_Number(c)); -assertEquals("x", %_ToPrimitive_String(c)); var d = { [Symbol.toPrimitive]: function(hint) { return hint } }; assertEquals("default", %ToPrimitive(d)); assertEquals("number", %ToPrimitive_Number(d)); -assertEquals("string", %ToPrimitive_String(d)); -assertEquals("default", %_ToPrimitive(d)); -assertEquals("number", %_ToPrimitive_Number(d)); -assertEquals("string", %_ToPrimitive_String(d)); var e = new Date(0); assertEquals(e.toString(), %ToPrimitive(e)); assertEquals(0, %ToPrimitive_Number(e)); -assertEquals(e.toString(), %ToPrimitive_String(e)); -assertEquals(e.toString(), %_ToPrimitive(e)); -assertEquals(0, %_ToPrimitive_Number(e)); -assertEquals(e.toString(), %_ToPrimitive_String(e)); diff --git a/test/mjsunit/harmony/to-string.js b/test/mjsunit/harmony/to-string.js index 103ba89d1d..dfe36c2dd9 100644 --- a/test/mjsunit/harmony/to-string.js +++ b/test/mjsunit/harmony/to-string.js @@ -50,5 +50,5 @@ assertEquals("string", %ToString(d)); assertEquals("string", %_ToString(d)); var e = new Date(0); -assertEquals(e.toString(), %ToName(e)); -assertEquals(e.toString(), %_ToName(e)); +assertEquals(e.toString(), %ToString(e)); +assertEquals(e.toString(), %_ToString(e));