Commit 74adec5b authored by Benedikt Meurer's avatar Benedikt Meurer Committed by Commit Bot

[cleanup] Remove obsolete runtime functions.

Remove %ToPrimitive, %ToPrimitive_Number, %SameValue and %SameValueZero,
as these runtime functions were only used from tests. For the %SameValue
we use Object.is() to test the internal algorithm (the actual one even),
and for %SameValueZero we use Set#has() - this was already the case for
most uses anyways.

Also drop %IsDate and %ValueOf, which didn't have uses at all.

Bug: v8:8015
Change-Id: Ice26d25e68aed4d5d8adac0547c56aedf9826b13
Reviewed-on: https://chromium-review.googlesource.com/1237677
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56127}
parent 3978bb02
......@@ -1719,7 +1719,6 @@ Type Typer::Visitor::TypeJSCallRuntime(Node* node) {
case Runtime::kInlineIsSmi:
return TypeUnaryOp(node, ObjectIsSmi);
case Runtime::kInlineIsArray:
case Runtime::kInlineIsDate:
case Runtime::kInlineIsTypedArray:
case Runtime::kInlineIsRegExp:
return Type::Boolean();
......
......@@ -252,7 +252,6 @@ bool IntrinsicHasNoSideEffect(Runtime::FunctionId id) {
V(ToString) \
/* Type checks */ \
V(IsArray) \
V(IsDate) \
V(IsFunction) \
V(IsJSProxy) \
V(IsJSReceiver) \
......
......@@ -14,13 +14,6 @@
namespace v8 {
namespace internal {
RUNTIME_FUNCTION(Runtime_IsDate) {
SealHandleScope shs(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_CHECKED(Object, obj, 0);
return isolate->heap()->ToBoolean(obj->IsJSDate());
}
RUNTIME_FUNCTION(Runtime_DateCurrentTime) {
HandleScope scope(isolate);
DCHECK_EQ(0, args.length());
......
......@@ -917,15 +917,6 @@ RUNTIME_FUNCTION(Runtime_HasFastPackedElements) {
}
RUNTIME_FUNCTION(Runtime_ValueOf) {
SealHandleScope shs(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_CHECKED(Object, obj, 0);
if (!obj->IsJSValue()) return obj;
return JSValue::cast(obj)->value();
}
RUNTIME_FUNCTION(Runtime_IsJSReceiver) {
SealHandleScope shs(isolate);
DCHECK_EQ(1, args.length());
......@@ -1126,22 +1117,6 @@ RUNTIME_FUNCTION(Runtime_ToObject) {
UNREACHABLE();
}
RUNTIME_FUNCTION(Runtime_ToPrimitive) {
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(Object, input, 0);
RETURN_RESULT_OR_FAILURE(isolate, Object::ToPrimitive(input));
}
RUNTIME_FUNCTION(Runtime_ToPrimitive_Number) {
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(Object, input, 0);
RETURN_RESULT_OR_FAILURE(
isolate, Object::ToPrimitive(input, ToPrimitiveHint::kNumber));
}
RUNTIME_FUNCTION(Runtime_ToNumber) {
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
......@@ -1180,24 +1155,6 @@ RUNTIME_FUNCTION(Runtime_ToName) {
RETURN_RESULT_OR_FAILURE(isolate, Object::ToName(isolate, input));
}
RUNTIME_FUNCTION(Runtime_SameValue) {
SealHandleScope scope(isolate);
DCHECK_EQ(2, args.length());
CONVERT_ARG_CHECKED(Object, x, 0);
CONVERT_ARG_CHECKED(Object, y, 1);
return isolate->heap()->ToBoolean(x->SameValue(y));
}
RUNTIME_FUNCTION(Runtime_SameValueZero) {
SealHandleScope scope(isolate);
DCHECK_EQ(2, args.length());
CONVERT_ARG_CHECKED(Object, x, 0);
CONVERT_ARG_CHECKED(Object, y, 1);
return isolate->heap()->ToBoolean(x->SameValueZero(y));
}
RUNTIME_FUNCTION(Runtime_HasInPrototypeChain) {
HandleScope scope(isolate);
DCHECK_EQ(2, args.length());
......
......@@ -118,9 +118,7 @@ namespace internal {
F(NotifyDeoptimized, 0, 1) \
F(ResolvePossiblyDirectEval, 6, 1)
#define FOR_EACH_INTRINSIC_DATE(F) \
F(DateCurrentTime, 0, 1) \
F(IsDate, 1, 1)
#define FOR_EACH_INTRINSIC_DATE(F) F(DateCurrentTime, 0, 1)
#define FOR_EACH_INTRINSIC_DEBUG(F) \
F(ClearStepping, 0, 1) \
......@@ -324,8 +322,6 @@ namespace internal {
F(ObjectValuesSkipFastPath, 1, 1) \
F(OptimizeObjectForAddingMultipleProperties, 2, 1) \
F(PerformSideEffectCheckForObject, 1, 1) \
F(SameValue, 2, 1) \
F(SameValueZero, 2, 1) \
F(SetDataProperties, 2, 1) \
F(SetKeyedProperty, 4, 1) \
F(SetNamedProperty, 4, 1) \
......@@ -337,11 +333,8 @@ namespace internal {
F(ToNumber, 1, 1) \
F(ToNumeric, 1, 1) \
F(ToObject, 1, 1) \
F(ToPrimitive, 1, 1) \
F(ToPrimitive_Number, 1, 1) \
F(ToString, 1, 1) \
F(TryMigrateInstance, 1, 1) \
F(ValueOf, 1, 1)
F(TryMigrateInstance, 1, 1)
#define FOR_EACH_INTRINSIC_OPERATORS(F) \
F(Add, 2, 1) \
......
......@@ -50,21 +50,6 @@ TEST(IsArray) {
}
TEST(IsDate) {
FunctionTester T("(function(a) { return %_IsDate(a); })", flags);
T.CheckTrue(T.NewObject("new Date()"));
T.CheckFalse(T.NewObject("(function() {})"));
T.CheckFalse(T.NewObject("([1])"));
T.CheckFalse(T.NewObject("({})"));
T.CheckFalse(T.NewObject("(/x/)"));
T.CheckFalse(T.undefined());
T.CheckFalse(T.null());
T.CheckFalse(T.Val("x"));
T.CheckFalse(T.Val(1));
}
TEST(IsFunction) {
FunctionTester T("(function(a) { return %_IsFunction(a); })", flags);
......
......@@ -297,18 +297,6 @@ const six = BigInt(6);
assertTrue(Reflect.defineProperty(obj, 'foo', {value: zero}));
assertTrue(Reflect.defineProperty(obj, 'foo', {value: another_zero}));
assertFalse(Reflect.defineProperty(obj, 'foo', {value: one}));
}{
assertTrue(%SameValue(zero, zero));
assertTrue(%SameValue(zero, another_zero));
assertFalse(%SameValue(zero, +0));
assertFalse(%SameValue(zero, -0));
assertFalse(%SameValue(+0, zero));
assertFalse(%SameValue(-0, zero));
assertTrue(%SameValue(one, one));
assertTrue(%SameValue(one, another_one));
}
// SameValueZero
......@@ -351,18 +339,6 @@ const six = BigInt(6);
assertTrue(new Map([[one, 42]]).has(one));
assertTrue(new Map([[one, 42]]).has(another_one));
}{
assertTrue(%SameValueZero(zero, zero));
assertTrue(%SameValueZero(zero, another_zero));
assertFalse(%SameValueZero(zero, +0));
assertFalse(%SameValueZero(zero, -0));
assertFalse(%SameValueZero(+0, zero));
assertFalse(%SameValueZero(-0, zero));
assertTrue(%SameValueZero(one, one));
assertTrue(%SameValueZero(one, another_one));
}
// Abstract comparison
......
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax
assertEquals(1, %ToPrimitive(1));
assertEquals(1, %ToPrimitive_Number(1));
assertEquals(.5, %ToPrimitive(.5));
assertEquals(.5, %ToPrimitive_Number(.5));
assertEquals(null, %ToPrimitive(null));
assertEquals(null, %ToPrimitive_Number(null));
assertEquals(true, %ToPrimitive(true));
assertEquals(true, %ToPrimitive_Number(true));
assertEquals(false, %ToPrimitive(false));
assertEquals(false, %ToPrimitive_Number(false));
assertEquals(undefined, %ToPrimitive(undefined));
assertEquals(undefined, %ToPrimitive_Number(undefined));
assertEquals("random text", %ToPrimitive("random text"));
assertEquals("random text", %ToPrimitive_Number("random text"));
assertEquals(Symbol.toPrimitive, %ToPrimitive(Symbol.toPrimitive));
assertEquals(Symbol.toPrimitive, %ToPrimitive_Number(Symbol.toPrimitive));
var a = { toString: function() { return "xyz" }};
assertEquals("xyz", %ToPrimitive(a));
assertEquals("xyz", %ToPrimitive_Number(a));
var b = { valueOf: function() { return 42 }};
assertEquals(42, %ToPrimitive(b));
assertEquals(42, %ToPrimitive_Number(b));
var c = {
toString: function() { return "x"},
valueOf: function() { return 123 }
};
assertEquals(123, %ToPrimitive(c));
assertEquals(123, %ToPrimitive_Number(c));
var d = {
[Symbol.toPrimitive]: function(hint) { return hint }
};
assertEquals("default", %ToPrimitive(d));
assertEquals("number", %ToPrimitive_Number(d));
var e = new Date(0);
assertEquals(e.toString(), %ToPrimitive(e));
assertEquals(0, %ToPrimitive_Number(e));
......@@ -32,8 +32,11 @@
var obj1 = {x: 10, y: 11, z: "test"};
var obj2 = {x: 10, y: 11, z: "test"};
// Object.is() uses the SameValue algorithm.
var sameValue = Object.is;
var sameValueZero = function(x, y) { return %SameValueZero(x, y); }
// Set#has() uses the SameValueZero algorithm.
var sameValueZero = (x, y) => new Set([x]).has(y);
// Calls SameValue and SameValueZero and checks that their results match.
function sameValueBoth(a, b) {
......
......@@ -49,10 +49,10 @@ TEST(BytecodeDecoder, DecodeBytecodeAndOperands) {
3,
0,
" ForInPrepare r10-r12, [11]"},
{{B(CallRuntime), U16(Runtime::FunctionId::kIsDate), R8(0), U8(0)},
{{B(CallRuntime), U16(Runtime::FunctionId::kIsSmi), R8(0), U8(0)},
5,
0,
" CallRuntime [IsDate], r0-r0"},
" CallRuntime [IsSmi], r0-r0"},
{{B(Ldar),
static_cast<uint8_t>(Register::FromParameterIndex(2, 3).ToOperand())},
2,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment