Commit 863a2d6c authored by Toon Verwaest's avatar Toon Verwaest Committed by V8 LUCI CQ

[interpreter] Remove unused interpreter intrinsics

This also removes intrinsics that were just used in tests. It keeps
InlineIncBlockCounter for now because it's a less straightforward.

Change-Id: I77e55d7a746294892d0fd7ab577ebf8eb42f1f08
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2953195
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75217}
parent 11f7e438
......@@ -1274,56 +1274,6 @@ void BaselineCompiler::VisitInvokeIntrinsic() {
}
}
void BaselineCompiler::VisitIntrinsicIsJSReceiver(
interpreter::RegisterList args) {
SelectBooleanConstant(
kInterpreterAccumulatorRegister,
[&](Label* is_true, Label::Distance distance) {
BaselineAssembler::ScratchRegisterScope scratch_scope(&basm_);
__ LoadRegister(kInterpreterAccumulatorRegister, args[0]);
Label is_smi;
__ JumpIfSmi(kInterpreterAccumulatorRegister, &is_smi, Label::kNear);
// If we ever added more instance types after LAST_JS_RECEIVER_TYPE,
// this would have to become a range check.
STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE);
__ JumpIfObjectType(Condition::kGreaterThanEqual,
kInterpreterAccumulatorRegister,
FIRST_JS_RECEIVER_TYPE,
scratch_scope.AcquireScratch(), is_true, distance);
__ Bind(&is_smi);
});
}
void BaselineCompiler::VisitIntrinsicIsArray(interpreter::RegisterList args) {
SelectBooleanConstant(
kInterpreterAccumulatorRegister,
[&](Label* is_true, Label::Distance distance) {
BaselineAssembler::ScratchRegisterScope scratch_scope(&basm_);
__ LoadRegister(kInterpreterAccumulatorRegister, args[0]);
Label is_smi;
__ JumpIfSmi(kInterpreterAccumulatorRegister, &is_smi, Label::kNear);
__ JumpIfObjectType(Condition::kEqual, kInterpreterAccumulatorRegister,
JS_ARRAY_TYPE, scratch_scope.AcquireScratch(),
is_true, distance);
__ Bind(&is_smi);
});
}
void BaselineCompiler::VisitIntrinsicIsSmi(interpreter::RegisterList args) {
SelectBooleanConstant(
kInterpreterAccumulatorRegister,
[&](Label* is_true, Label::Distance distance) {
__ LoadRegister(kInterpreterAccumulatorRegister, args[0]);
__ JumpIfSmi(kInterpreterAccumulatorRegister, is_true, distance);
});
}
void BaselineCompiler::VisitIntrinsicCopyDataProperties(
interpreter::RegisterList args) {
CallBuiltin<Builtin::kCopyDataProperties>(args);
......@@ -1334,19 +1284,6 @@ void BaselineCompiler::VisitIntrinsicCreateIterResultObject(
CallBuiltin<Builtin::kCreateIterResultObject>(args);
}
void BaselineCompiler::VisitIntrinsicHasProperty(
interpreter::RegisterList args) {
CallBuiltin<Builtin::kHasProperty>(args);
}
void BaselineCompiler::VisitIntrinsicToLength(interpreter::RegisterList args) {
CallBuiltin<Builtin::kToLength>(args);
}
void BaselineCompiler::VisitIntrinsicToObject(interpreter::RegisterList args) {
CallBuiltin<Builtin::kToObject>(args);
}
void BaselineCompiler::VisitIntrinsicCall(interpreter::RegisterList args) {
// First argument register contains the function target.
__ LoadRegister(kJavaScriptCallTargetRegister, args.first_register());
......
......@@ -74,16 +74,6 @@ Reduction JSIntrinsicLowering::Reduce(Node* node) {
return ReduceAsyncGeneratorYield(node);
case Runtime::kInlineGeneratorGetResumeMode:
return ReduceGeneratorGetResumeMode(node);
case Runtime::kInlineIsArray:
return ReduceIsInstanceType(node, JS_ARRAY_TYPE);
case Runtime::kInlineIsJSReceiver:
return ReduceIsJSReceiver(node);
case Runtime::kInlineIsSmi:
return ReduceIsSmi(node);
case Runtime::kInlineToLength:
return ReduceToLength(node);
case Runtime::kInlineToObject:
return ReduceToObject(node);
case Runtime::kInlineCall:
return ReduceCall(node);
case Runtime::kInlineIncBlockCounter:
......@@ -272,10 +262,6 @@ Reduction JSIntrinsicLowering::ReduceIsJSReceiver(Node* node) {
}
Reduction JSIntrinsicLowering::ReduceIsSmi(Node* node) {
return Change(node, simplified()->ObjectIsSmi());
}
Reduction JSIntrinsicLowering::ReduceTurbofanStaticAssert(Node* node) {
if (FLAG_always_opt) {
// Ignore static asserts, as we most likely won't have enough information
......
......@@ -57,7 +57,6 @@ class V8_EXPORT_PRIVATE JSIntrinsicLowering final
Reduction ReduceGeneratorGetResumeMode(Node* node);
Reduction ReduceIsInstanceType(Node* node, InstanceType instance_type);
Reduction ReduceIsJSReceiver(Node* node);
Reduction ReduceIsSmi(Node* node);
Reduction ReduceIsBeingInterpreted(Node* node);
Reduction ReduceTurbofanStaticAssert(Node* node);
Reduction ReduceVerifyType(Node* node);
......
......@@ -260,10 +260,6 @@ bool Linkage::NeedsFrameStateInput(Runtime::FunctionId function) {
case Runtime::kInlineGeneratorClose:
case Runtime::kInlineGeneratorGetResumeMode:
case Runtime::kInlineCreateJSGeneratorObject:
case Runtime::kInlineIsArray:
case Runtime::kInlineIsJSReceiver:
case Runtime::kInlineIsRegExp:
case Runtime::kInlineIsSmi:
return false;
default:
......
......@@ -1825,21 +1825,8 @@ Type Typer::Visitor::TypeJSCallWithSpread(Node* node) {
Type Typer::Visitor::TypeJSCallRuntime(Node* node) {
switch (CallRuntimeParametersOf(node->op()).id()) {
case Runtime::kInlineIsJSReceiver:
return TypeUnaryOp(node, ObjectIsReceiver);
case Runtime::kInlineIsSmi:
return TypeUnaryOp(node, ObjectIsSmi);
case Runtime::kInlineIsArray:
case Runtime::kInlineIsRegExp:
return Type::Boolean();
case Runtime::kInlineCreateIterResultObject:
return Type::OtherObject();
case Runtime::kInlineToLength:
return TypeUnaryOp(node, ToLength);
case Runtime::kInlineToNumber:
return TypeUnaryOp(node, ToNumber);
case Runtime::kInlineToObject:
return TypeUnaryOp(node, ToObject);
case Runtime::kHasInPrototypeChain:
return Type::Boolean();
default:
......
......@@ -396,7 +396,6 @@ bool IntrinsicHasNoSideEffect(Runtime::FunctionId id) {
// Intrinsics with inline versions have to be allowlisted here a second time.
#define INLINE_INTRINSIC_ALLOWLIST(V) \
V(Call) \
V(IsJSReceiver) \
V(AsyncFunctionEnter) \
V(AsyncFunctionReject) \
V(AsyncFunctionResolve)
......
......@@ -166,32 +166,6 @@ TNode<Object> IntrinsicsGenerator::IntrinsicAsBuiltinCall(
}
}
TNode<Object> IntrinsicsGenerator::IsJSReceiver(
const InterpreterAssembler::RegListNodePair& args, TNode<Context> context,
int arg_count) {
TNode<Object> input = __ LoadRegisterFromRegisterList(args, 0);
TNode<Oddball> result = __ Select<Oddball>(
__ TaggedIsSmi(input), [=] { return __ FalseConstant(); },
[=] {
return __ SelectBooleanConstant(__ IsJSReceiver(__ CAST(input)));
});
return result;
}
TNode<Object> IntrinsicsGenerator::IsArray(
const InterpreterAssembler::RegListNodePair& args, TNode<Context> context,
int arg_count) {
TNode<Object> input = __ LoadRegisterFromRegisterList(args, 0);
return IsInstanceType(input, JS_ARRAY_TYPE);
}
TNode<Object> IntrinsicsGenerator::IsSmi(
const InterpreterAssembler::RegListNodePair& args, TNode<Context> context,
int arg_count) {
TNode<Object> input = __ LoadRegisterFromRegisterList(args, 0);
return __ SelectBooleanConstant(__ TaggedIsSmi(input));
}
TNode<Object> IntrinsicsGenerator::CopyDataProperties(
const InterpreterAssembler::RegListNodePair& args, TNode<Context> context,
int arg_count) {
......@@ -206,25 +180,6 @@ TNode<Object> IntrinsicsGenerator::CreateIterResultObject(
arg_count);
}
TNode<Object> IntrinsicsGenerator::HasProperty(
const InterpreterAssembler::RegListNodePair& args, TNode<Context> context,
int arg_count) {
return IntrinsicAsBuiltinCall(args, context, Builtin::kHasProperty,
arg_count);
}
TNode<Object> IntrinsicsGenerator::ToLength(
const InterpreterAssembler::RegListNodePair& args, TNode<Context> context,
int arg_count) {
return IntrinsicAsBuiltinCall(args, context, Builtin::kToLength, arg_count);
}
TNode<Object> IntrinsicsGenerator::ToObject(
const InterpreterAssembler::RegListNodePair& args, TNode<Context> context,
int arg_count) {
return IntrinsicAsBuiltinCall(args, context, Builtin::kToObject, arg_count);
}
TNode<Object> IntrinsicsGenerator::Call(
const InterpreterAssembler::RegListNodePair& args, TNode<Context> context,
int arg_count) {
......
......@@ -13,31 +13,25 @@ namespace interpreter {
// List of supported intrisics, with upper case name, lower case name and
// expected number of arguments (-1 denoting argument count is variable).
#define INTRINSICS_LIST(V) \
V(AsyncFunctionAwaitCaught, async_function_await_caught, 2) \
V(AsyncFunctionAwaitUncaught, async_function_await_uncaught, 2) \
V(AsyncFunctionEnter, async_function_enter, 2) \
V(AsyncFunctionReject, async_function_reject, 3) \
V(AsyncFunctionResolve, async_function_resolve, 3) \
V(AsyncGeneratorAwaitCaught, async_generator_await_caught, 2) \
V(AsyncGeneratorAwaitUncaught, async_generator_await_uncaught, 2) \
V(AsyncGeneratorReject, async_generator_reject, 2) \
V(AsyncGeneratorResolve, async_generator_resolve, 3) \
V(AsyncGeneratorYield, async_generator_yield, 3) \
V(CreateJSGeneratorObject, create_js_generator_object, 2) \
V(GeneratorGetResumeMode, generator_get_resume_mode, 1) \
V(GeneratorClose, generator_close, 1) \
V(GetImportMetaObject, get_import_meta_object, 0) \
V(Call, call, -1) \
V(CopyDataProperties, copy_data_properties, 2) \
V(CreateIterResultObject, create_iter_result_object, 2) \
V(CreateAsyncFromSyncIterator, create_async_from_sync_iterator, 1) \
V(HasProperty, has_property, 2) \
V(IsArray, is_array, 1) \
V(IsJSReceiver, is_js_receiver, 1) \
V(IsSmi, is_smi, 1) \
V(ToLength, to_length, 1) \
V(ToObject, to_object, 1)
#define INTRINSICS_LIST(V) \
V(AsyncFunctionAwaitCaught, async_function_await_caught, 2) \
V(AsyncFunctionAwaitUncaught, async_function_await_uncaught, 2) \
V(AsyncFunctionEnter, async_function_enter, 2) \
V(AsyncFunctionReject, async_function_reject, 3) \
V(AsyncFunctionResolve, async_function_resolve, 3) \
V(AsyncGeneratorAwaitCaught, async_generator_await_caught, 2) \
V(AsyncGeneratorAwaitUncaught, async_generator_await_uncaught, 2) \
V(AsyncGeneratorReject, async_generator_reject, 2) \
V(AsyncGeneratorResolve, async_generator_resolve, 3) \
V(AsyncGeneratorYield, async_generator_yield, 3) \
V(CreateJSGeneratorObject, create_js_generator_object, 2) \
V(GeneratorGetResumeMode, generator_get_resume_mode, 1) \
V(GeneratorClose, generator_close, 1) \
V(GetImportMetaObject, get_import_meta_object, 0) \
V(Call, call, -1) \
V(CopyDataProperties, copy_data_properties, 2) \
V(CreateIterResultObject, create_iter_result_object, 2) \
V(CreateAsyncFromSyncIterator, create_async_from_sync_iterator, 1)
class IntrinsicsHelper {
public:
......
......@@ -46,7 +46,7 @@ namespace internal {
F(ArrayIsArray, 1, 1) \
F(ArraySpeciesConstructor, 1, 1) \
F(GrowArrayElements, 2, 1) \
I(IsArray, 1, 1) \
F(IsArray, 1, 1) \
F(NewArray, -1 /* >= 3 */, 1) \
F(NormalizeElements, 1, 1) \
F(TransitionElementsKind, 2, 1) \
......@@ -276,7 +276,7 @@ namespace internal {
F(ArrayBufferMaxByteLength, 0, 1) \
F(GetHoleNaNLower, 0, 1) \
F(GetHoleNaNUpper, 0, 1) \
I(IsSmi, 1, 1) \
F(IsSmi, 1, 1) \
F(MaxSmi, 0, 1) \
F(NumberToStringSlow, 1, 1) \
F(StringParseFloat, 1, 1) \
......@@ -308,9 +308,9 @@ namespace internal {
F(GetProperty, -1 /* [2, 3] */, 1) \
F(HasFastPackedElements, 1, 1) \
F(HasInPrototypeChain, 2, 1) \
I(HasProperty, 2, 1) \
F(HasProperty, 2, 1) \
F(InternalSetPrototype, 2, 1) \
I(IsJSReceiver, 1, 1) \
F(IsJSReceiver, 1, 1) \
F(JSReceiverPreventExtensionsDontThrow, 1, 1) \
F(JSReceiverPreventExtensionsThrow, 1, 1) \
F(JSReceiverGetPrototypeOf, 1, 1) \
......@@ -338,11 +338,11 @@ namespace internal {
F(ShrinkNameDictionary, 1, 1) \
F(ShrinkSwissNameDictionary, 1, 1) \
F(ToFastProperties, 1, 1) \
I(ToLength, 1, 1) \
F(ToLength, 1, 1) \
F(ToName, 1, 1) \
I(ToNumber, 1, 1) \
F(ToNumber, 1, 1) \
F(ToNumeric, 1, 1) \
I(ToObject, 1, 1) \
F(ToObject, 1, 1) \
F(ToString, 1, 1) \
F(TryMigrateInstance, 1, 1) \
F(SwissTableAdd, 4, 1) \
......@@ -397,7 +397,7 @@ namespace internal {
F(SetPropertyWithReceiver, 4, 1)
#define FOR_EACH_INTRINSIC_REGEXP(F, I) \
I(IsRegExp, 1, 1) \
F(IsRegExp, 1, 1) \
F(RegExpBuildIndices, 3, 1) \
F(RegExpExec, 4, 1) \
F(RegExpExecTreatMatchAtEndAsFailure, 4, 1) \
......
......@@ -633,27 +633,6 @@ TEST(BytecodeGraphBuilderCallRuntime) {
}
}
TEST(BytecodeGraphBuilderInvokeIntrinsic) {
HandleAndZoneScope scope;
Isolate* isolate = scope.main_isolate();
Factory* factory = isolate->factory();
ExpectedSnippet<1> snippets[] = {
{"function f(arg0) { return %_IsJSReceiver(arg0); }\nf()",
{factory->false_value(), factory->NewNumberFromInt(1)}},
{"function f(arg0) { return %_IsArray(arg0) }\nf(undefined)",
{factory->true_value(), BytecodeGraphTester::NewObject("[1, 2, 3]")}},
};
for (size_t i = 0; i < arraysize(snippets); i++) {
BytecodeGraphTester tester(isolate, snippets[i].code_snippet);
auto callable = tester.GetCallable<Handle<Object>>();
Handle<Object> return_value =
callable(snippets[i].parameter(0)).ToHandleChecked();
CHECK(return_value->SameValue(*snippets[i].return_value()));
}
}
void TestBytecodeGraphBuilderGlobals(size_t shard) {
HandleAndZoneScope scope;
Isolate* isolate = scope.main_isolate();
......
......@@ -20,37 +20,6 @@ TEST(Call) {
T.CheckCall(T.Val("6x"), T.NewObject("({d:'x'})"), T.NewObject("f"));
}
TEST(IsArray) {
FunctionTester T("(function(a) { return %_IsArray(a); })", flags);
T.CheckFalse(T.NewObject("new Date()"));
T.CheckFalse(T.NewObject("(function() {})"));
T.CheckTrue(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(IsSmi) {
FunctionTester T("(function(a) { return %_IsSmi(a); })", flags);
T.CheckFalse(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.CheckTrue(T.Val(1));
T.CheckFalse(T.Val(1.1));
T.CheckFalse(T.Val(-0.0));
T.CheckTrue(T.Val(-2));
T.CheckFalse(T.Val(-2.3));
}
} // namespace compiler
} // namespace internal
} // namespace v8
......@@ -148,21 +148,6 @@ TEST(RuntimeCall) {
}
TEST(RuntimeCallInline) {
FLAG_allow_natives_syntax = true;
FunctionTester T("(function(a) { return %_IsJSReceiver(a); })");
T.CheckCall(T.false_value(), T.Val(23), T.undefined());
T.CheckCall(T.false_value(), T.Val(4.2), T.undefined());
T.CheckCall(T.false_value(), T.Val("str"), T.undefined());
T.CheckCall(T.false_value(), T.true_value(), T.undefined());
T.CheckCall(T.false_value(), T.false_value(), T.undefined());
T.CheckCall(T.false_value(), T.undefined(), T.undefined());
T.CheckCall(T.true_value(), T.NewObject("({})"), T.undefined());
T.CheckCall(T.true_value(), T.NewObject("([])"), T.undefined());
}
TEST(EvalCall) {
FunctionTester T("(function(a,b) { return eval(a); })");
Handle<JSObject> g(T.function->context().global_object().global_proxy(),
......
......@@ -60,72 +60,6 @@ class InvokeIntrinsicHelper {
} // namespace
TEST(IsJSReceiver) {
HandleAndZoneScope handles;
InvokeIntrinsicHelper helper(handles.main_isolate(), handles.main_zone(),
Runtime::kInlineIsJSReceiver);
Factory* factory = handles.main_isolate()->factory();
CHECK_EQ(*factory->true_value(),
*helper.Invoke(helper.NewObject("new Date()")));
CHECK_EQ(*factory->true_value(),
*helper.Invoke(helper.NewObject("(function() {})")));
CHECK_EQ(*factory->true_value(), *helper.Invoke(helper.NewObject("([1])")));
CHECK_EQ(*factory->true_value(), *helper.Invoke(helper.NewObject("({})")));
CHECK_EQ(*factory->true_value(), *helper.Invoke(helper.NewObject("(/x/)")));
CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.Undefined()));
CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.Null()));
CHECK_EQ(*factory->false_value(),
*helper.Invoke(helper.NewObject("'string'")));
CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.NewObject("42")));
}
TEST(IsArray) {
HandleAndZoneScope handles;
InvokeIntrinsicHelper helper(handles.main_isolate(), handles.main_zone(),
Runtime::kInlineIsArray);
Factory* factory = handles.main_isolate()->factory();
CHECK_EQ(*factory->false_value(),
*helper.Invoke(helper.NewObject("new Date()")));
CHECK_EQ(*factory->false_value(),
*helper.Invoke(helper.NewObject("(function() {})")));
CHECK_EQ(*factory->true_value(), *helper.Invoke(helper.NewObject("([1])")));
CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.NewObject("({})")));
CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.NewObject("(/x/)")));
CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.Undefined()));
CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.Null()));
CHECK_EQ(*factory->false_value(),
*helper.Invoke(helper.NewObject("'string'")));
CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.NewObject("42")));
}
TEST(IsSmi) {
HandleAndZoneScope handles;
InvokeIntrinsicHelper helper(handles.main_isolate(), handles.main_zone(),
Runtime::kInlineIsSmi);
Factory* factory = handles.main_isolate()->factory();
CHECK_EQ(*factory->false_value(),
*helper.Invoke(helper.NewObject("new Date()")));
CHECK_EQ(*factory->false_value(),
*helper.Invoke(helper.NewObject("(function() {})")));
CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.NewObject("([1])")));
CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.NewObject("({})")));
CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.NewObject("(/x/)")));
CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.Undefined()));
CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.Null()));
CHECK_EQ(*factory->false_value(),
*helper.Invoke(helper.NewObject("'string'")));
CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.NewObject("42.2")));
CHECK_EQ(*factory->false_value(),
*helper.Invoke(helper.NewObject("4294967297")));
CHECK_EQ(*factory->true_value(), *helper.Invoke(helper.NewObject("42")));
}
TEST(Call) {
HandleAndZoneScope handles;
Isolate* isolate = handles.main_isolate();
......@@ -148,23 +82,6 @@ TEST(Call) {
handle(Smi::FromInt(7), isolate), handle(Smi::FromInt(3), isolate)));
}
TEST(IntrinsicAsStubCall) {
HandleAndZoneScope handles;
Isolate* isolate = handles.main_isolate();
Factory* factory = isolate->factory();
InvokeIntrinsicHelper has_property_helper(isolate, handles.main_zone(),
Runtime::kInlineHasProperty);
CHECK_EQ(
*factory->true_value(),
*has_property_helper.Invoke(has_property_helper.NewObject("({ x: 20 })"),
has_property_helper.NewObject("'x'")));
CHECK_EQ(
*factory->false_value(),
*has_property_helper.Invoke(has_property_helper.NewObject("({ x: 20 })"),
has_property_helper.NewObject("'y'")));
}
} // namespace interpreter
} // namespace internal
} // namespace v8
......@@ -2452,27 +2452,6 @@ TEST(InterpreterCallRuntime) {
CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(55));
}
TEST(InterpreterInvokeIntrinsic) {
HandleAndZoneScope handles;
Isolate* isolate = handles.main_isolate();
Zone* zone = handles.main_zone();
BytecodeArrayBuilder builder(zone, 1, 2);
builder.LoadLiteral(Smi::FromInt(15))
.StoreAccumulatorInRegister(Register(0))
.CallRuntime(Runtime::kInlineIsArray, Register(0))
.Return();
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
InterpreterTester tester(isolate, bytecode_array);
auto callable = tester.GetCallable<>();
Handle<Object> return_val = callable().ToHandleChecked();
CHECK(return_val->IsBoolean());
CHECK_EQ(return_val->BooleanValue(isolate), false);
}
TEST(InterpreterFunctionLiteral) {
HandleAndZoneScope handles;
Isolate* isolate = handles.main_isolate();
......
......@@ -194,9 +194,6 @@ assertEquals(run(()=>{return new Array(1, 2, 39);}).reduce((a,x)=>a+x), 42);
assertMatches(run(() => { return %NewRegExpWithBacktrackLimit("ax", "", 50); }), "ax");
run(() => { %CompileBaseline(()=>{}); });
// Call Intrinsics
assertEquals(run(()=>{return %_IsSmi(42)}), true);
// CallRuntimeForPair
assertEquals(run(()=>{with (f0) return f0();}), 42);
......
......@@ -4,7 +4,7 @@
// Flags: --allow-natives-syntax
function foo() { %_ToLength(42n) }
function foo() { %ToLength(42n) }
%PrepareFunctionForOptimization(foo);
assertThrows(foo, TypeError);
%OptimizeFunctionOnNextCall(foo);
......
......@@ -14,15 +14,15 @@ function test() {
assertEquals("object", typeof {});
assertEquals("object", typeof /regex/);
assertTrue(%_IsSmi(1));
assertFalse(%_IsSmi(1.1));
assertFalse(%_IsSmi({}));
assertTrue(%IsSmi(1));
assertFalse(%IsSmi(1.1));
assertFalse(%IsSmi({}));
assertTrue(%_IsArray([1]));
assertFalse(%_IsArray(function() {}));
assertTrue(%IsArray([1]));
assertFalse(%IsArray(function() {}));
assertTrue(%_IsJSReceiver(new Date()));
assertFalse(%_IsJSReceiver(1));
assertTrue(%IsJSReceiver(new Date()));
assertFalse(%IsJSReceiver(1));
}
%PrepareFunctionForOptimization(test);
......
......@@ -5,62 +5,44 @@
// Flags: --allow-natives-syntax
assertEquals(0, %ToLength(NaN));
assertEquals(0, %_ToLength(NaN));
assertEquals(0, %ToLength(-Infinity));
assertEquals(0, %_ToLength(-Infinity));
assertEquals(0, %ToLength(0));
assertEquals(0, %_ToLength(0));
assertEquals(0, %ToLength(.5));
assertEquals(0, %_ToLength(.5));
assertEquals(42, %ToLength(42.99999));
assertEquals(42, %_ToLength(42.99999));
assertEquals(9007199254740991, %ToLength(9007199254740991));
assertEquals(9007199254740991, %_ToLength(9007199254740991));
assertEquals(9007199254740991, %ToLength(Infinity));
assertEquals(9007199254740991, %_ToLength(Infinity));
assertEquals(0, %ToLength(null));
assertEquals(0, %_ToLength(null));
assertEquals(1, %ToLength(true));
assertEquals(1, %_ToLength(true));
assertEquals(0, %ToLength(false));
assertEquals(0, %_ToLength(false));
assertEquals(0, %ToLength(undefined));
assertEquals(0, %_ToLength(undefined));
assertEquals(0, %ToLength("-1"));
assertEquals(0, %_ToLength("-1"));
assertEquals(123, %ToLength("123"));
assertEquals(123, %_ToLength("123"));
assertEquals(0, %ToLength("random text"));
assertEquals(0, %_ToLength("random text"));
assertThrows(function() { %ToLength(Symbol.toPrimitive) }, TypeError);
assertThrows(function() { %_ToLength(Symbol.toPrimitive) }, TypeError);
var a = { toString: function() { return 54321 }};
assertEquals(54321, %ToLength(a));
assertEquals(54321, %_ToLength(a));
var b = { valueOf: function() { return 42 }};
assertEquals(42, %ToLength(b));
assertEquals(42, %_ToLength(b));
var c = {
toString: function() { return "x"},
valueOf: function() { return 123 }
};
assertEquals(123, %ToLength(c));
assertEquals(123, %_ToLength(c));
var d = {
[Symbol.toPrimitive]: function(hint) {
......@@ -69,8 +51,6 @@ var d = {
}
};
assertEquals(987654321, %ToLength(d));
assertEquals(987654321, %_ToLength(d));
var e = new Date(0);
assertEquals(0, %ToLength(e));
assertEquals(0, %_ToLength(e));
......@@ -55,11 +55,11 @@ var ZERO = (function() {
assertEquals(0, ZERO);
assertEquals(Infinity, 1/ZERO);
assertEquals(-Infinity, 1/-ZERO);
// Here we would like to have assertFalse(%_IsSmi(ZERO)); This is, however,
// Here we would like to have assertFalse(%IsSmi(ZERO)); This is, however,
// unreliable, since a new space exhaustion at a critical moment could send
// us into the runtime system, which would quite legitimately put a Smi zero
// here.
assertFalse(%_IsSmi(-ZERO));
assertFalse(%IsSmi(-ZERO));
var o = {};
o.valueOf = function() { return 1; };
......
......@@ -33,8 +33,8 @@
// HHasInstance.
function f(value) {
if (%_IsJSReceiver(value)) {
if ((%_IsArray(value))) assertTrue(false);
if (%IsJSReceiver(value)) {
if ((%IsArray(value))) assertTrue(false);
}
}
f(new String("bar"));
......
......@@ -4,7 +4,7 @@
// Flags: --allow-natives-syntax
function foo(o) { return %_ToLength(o.length); }
function foo(o) { return %ToLength(o.length); }
%PrepareFunctionForOptimization(foo);
foo(new Array(4));
......
......@@ -47,70 +47,6 @@ class JSIntrinsicLoweringTest : public GraphTest {
};
// -----------------------------------------------------------------------------
// %_IsSmi
TEST_F(JSIntrinsicLoweringTest, InlineIsSmi) {
Node* const input = Parameter(0);
Node* const context = Parameter(1);
Node* const effect = graph()->start();
Node* const control = graph()->start();
Reduction const r = Reduce(
graph()->NewNode(javascript()->CallRuntime(Runtime::kInlineIsSmi, 1),
input, context, effect, control));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsObjectIsSmi(input));
}
// -----------------------------------------------------------------------------
// %_IsArray
TEST_F(JSIntrinsicLoweringTest, InlineIsArray) {
Node* const input = Parameter(0);
Node* const context = Parameter(1);
Node* const effect = graph()->start();
Node* const control = graph()->start();
Reduction const r = Reduce(
graph()->NewNode(javascript()->CallRuntime(Runtime::kInlineIsArray, 1),
input, context, effect, control));
ASSERT_TRUE(r.Changed());
Node* phi = r.replacement();
Capture<Node*> branch, if_false;
EXPECT_THAT(
phi,
IsPhi(
MachineRepresentation::kTagged, IsFalseConstant(),
IsNumberEqual(IsLoadField(AccessBuilder::ForMapInstanceType(),
IsLoadField(AccessBuilder::ForMap(), input,
effect, CaptureEq(&if_false)),
_, _),
IsNumberConstant(JS_ARRAY_TYPE)),
IsMerge(IsIfTrue(AllOf(CaptureEq(&branch),
IsBranch(IsObjectIsSmi(input), control))),
AllOf(CaptureEq(&if_false), IsIfFalse(CaptureEq(&branch))))));
}
// -----------------------------------------------------------------------------
// %_IsJSReceiver
TEST_F(JSIntrinsicLoweringTest, InlineIsJSReceiver) {
Node* const input = Parameter(0);
Node* const context = Parameter(1);
Node* const effect = graph()->start();
Node* const control = graph()->start();
Reduction const r = Reduce(graph()->NewNode(
javascript()->CallRuntime(Runtime::kInlineIsJSReceiver, 1), input,
context, effect, control));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsObjectIsReceiver(input));
}
// -----------------------------------------------------------------------------
// %_CreateJSGeneratorObject
......
......@@ -418,7 +418,7 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) {
builder.SwitchOnGeneratorState(reg, gen_jump_table).Bind(gen_jump_table, 0);
// Intrinsics handled by the interpreter.
builder.CallRuntime(Runtime::kInlineIsArray, reg_list);
builder.CallRuntime(Runtime::kInlineCall, reg_list);
// Emit debugger bytecode.
builder.Debugger();
......
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