Index: test/cctest/compiler/test-run-intrinsics.cc |
diff --git a/test/cctest/compiler/test-run-intrinsics.cc b/test/cctest/compiler/test-run-intrinsics.cc |
index bd4038ed91997339de5e161996e4879e11a5df8f..3b8e1ded695b5f9c167d1138ceed6d671a7824f8 100644 |
--- a/test/cctest/compiler/test-run-intrinsics.cc |
+++ b/test/cctest/compiler/test-run-intrinsics.cc |
@@ -10,29 +10,72 @@ using namespace v8::internal; |
using namespace v8::internal::compiler; |
uint32_t flags = CompilationInfo::kInliningEnabled; |
-TEST(IsSmi) { |
+ |
+TEST(CallFunction) { |
FLAG_turbo_deoptimization = true; |
- FunctionTester T("(function(a) { return %_IsSmi(a); })", flags); |
+ FunctionTester T("(function(a,b) { return %_CallFunction(a, 1, 2, 3, b); })", |
+ flags); |
+ CompileRun("function f(a,b,c) { return a + b + c + this.d; }"); |
- 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)); |
+ T.CheckCall(T.Val(129), T.NewObject("({d:123})"), T.NewObject("f")); |
+ T.CheckCall(T.Val("6x"), T.NewObject("({d:'x'})"), T.NewObject("f")); |
+} |
+ |
+ |
+TEST(ClassOf) { |
+ FLAG_turbo_deoptimization = true; |
+ FunctionTester T("(function(a) { return %_ClassOf(a); })", flags); |
+ |
+ T.CheckCall(T.Val("Function"), T.NewObject("(function() {})")); |
+ T.CheckCall(T.Val("Array"), T.NewObject("([1])")); |
+ T.CheckCall(T.Val("Object"), T.NewObject("({})")); |
+ T.CheckCall(T.Val("RegExp"), T.NewObject("(/x/)")); |
+ T.CheckCall(T.null(), T.undefined()); |
+ T.CheckCall(T.null(), T.null()); |
+ T.CheckCall(T.null(), T.Val("x")); |
+ T.CheckCall(T.null(), T.Val(1)); |
+} |
+ |
+ |
+TEST(HeapObjectGetMap) { |
+ FLAG_turbo_deoptimization = true; |
+ FunctionTester T("(function(a) { return %_HeapObjectGetMap(a); })", flags); |
+ |
+ Factory* factory = T.main_isolate()->factory(); |
+ T.CheckCall(factory->null_map(), T.null()); |
+ T.CheckCall(factory->undefined_map(), T.undefined()); |
+ T.CheckCall(factory->heap_number_map(), T.Val(3.1415)); |
+ T.CheckCall(factory->symbol_map(), factory->NewSymbol()); |
+} |
+ |
+ |
+TEST(IsArray) { |
+ FLAG_turbo_deoptimization = true; |
+ FunctionTester T("(function(a) { return %_IsArray(a); })", flags); |
+ |
+ 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(IsNonNegativeSmi) { |
+TEST(IsFunction) { |
FLAG_turbo_deoptimization = true; |
- FunctionTester T("(function(a) { return %_IsNonNegativeSmi(a); })", flags); |
+ FunctionTester T("(function(a) { return %_IsFunction(a); })", flags); |
- T.CheckTrue(T.Val(1)); |
- T.CheckFalse(T.Val(1.1)); |
- T.CheckFalse(T.Val(-0.0)); |
- T.CheckFalse(T.Val(-2)); |
- T.CheckFalse(T.Val(-2.3)); |
+ T.CheckTrue(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)); |
} |
@@ -49,18 +92,16 @@ TEST(IsMinusZero) { |
} |
-TEST(IsArray) { |
+TEST(IsNonNegativeSmi) { |
FLAG_turbo_deoptimization = true; |
- FunctionTester T("(function(a) { return %_IsArray(a); })", flags); |
+ FunctionTester T("(function(a) { return %_IsNonNegativeSmi(a); })", flags); |
- T.CheckFalse(T.NewObject("(function() {})")); |
- T.CheckTrue(T.NewObject("([1])")); |
- T.CheckFalse(T.NewObject("({})")); |
- T.CheckFalse(T.NewObject("(/x/)")); |
+ T.CheckTrue(T.Val(1)); |
+ T.CheckFalse(T.Val(1.1)); |
+ T.CheckFalse(T.Val(-0.0)); |
+ T.CheckFalse(T.Val(-2)); |
+ T.CheckFalse(T.Val(-2.3)); |
T.CheckFalse(T.undefined()); |
- T.CheckFalse(T.null()); |
- T.CheckFalse(T.Val("x")); |
- T.CheckFalse(T.Val(1)); |
} |
@@ -79,14 +120,14 @@ TEST(IsObject) { |
} |
-TEST(IsFunction) { |
+TEST(IsRegExp) { |
FLAG_turbo_deoptimization = true; |
- FunctionTester T("(function(a) { return %_IsFunction(a); })", flags); |
+ FunctionTester T("(function(a) { return %_IsRegExp(a); })", flags); |
- T.CheckTrue(T.NewObject("(function() {})")); |
+ T.CheckFalse(T.NewObject("(function() {})")); |
T.CheckFalse(T.NewObject("([1])")); |
T.CheckFalse(T.NewObject("({})")); |
- T.CheckFalse(T.NewObject("(/x/)")); |
+ T.CheckTrue(T.NewObject("(/x/)")); |
T.CheckFalse(T.undefined()); |
T.CheckFalse(T.null()); |
T.CheckFalse(T.Val("x")); |
@@ -94,33 +135,30 @@ TEST(IsFunction) { |
} |
-TEST(IsRegExp) { |
+TEST(IsSmi) { |
FLAG_turbo_deoptimization = true; |
- FunctionTester T("(function(a) { return %_IsRegExp(a); })", flags); |
+ FunctionTester T("(function(a) { return %_IsSmi(a); })", flags); |
- T.CheckFalse(T.NewObject("(function() {})")); |
- T.CheckFalse(T.NewObject("([1])")); |
- T.CheckFalse(T.NewObject("({})")); |
- T.CheckTrue(T.NewObject("(/x/)")); |
+ 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)); |
T.CheckFalse(T.undefined()); |
- T.CheckFalse(T.null()); |
- T.CheckFalse(T.Val("x")); |
- T.CheckFalse(T.Val(1)); |
} |
-TEST(ClassOf) { |
+TEST(MapGetInstanceType) { |
FLAG_turbo_deoptimization = true; |
- FunctionTester T("(function(a) { return %_ClassOf(a); })", flags); |
- |
- T.CheckCall(T.Val("Function"), T.NewObject("(function() {})")); |
- T.CheckCall(T.Val("Array"), T.NewObject("([1])")); |
- T.CheckCall(T.Val("Object"), T.NewObject("({})")); |
- T.CheckCall(T.Val("RegExp"), T.NewObject("(/x/)")); |
- T.CheckCall(T.null(), T.undefined()); |
- T.CheckCall(T.null(), T.null()); |
- T.CheckCall(T.null(), T.Val("x")); |
- T.CheckCall(T.null(), T.Val(1)); |
+ FunctionTester T( |
+ "(function(a) { return %_MapGetInstanceType(%_HeapObjectGetMap(a)); })", |
+ flags); |
+ |
+ Factory* factory = T.main_isolate()->factory(); |
+ T.CheckCall(T.Val(ODDBALL_TYPE), T.null()); |
+ T.CheckCall(T.Val(ODDBALL_TYPE), T.undefined()); |
+ T.CheckCall(T.Val(HEAP_NUMBER_TYPE), T.Val(3.1415)); |
+ T.CheckCall(T.Val(SYMBOL_TYPE), factory->NewSymbol()); |
} |
@@ -138,17 +176,6 @@ TEST(ObjectEquals) { |
} |
-TEST(ValueOf) { |
- FLAG_turbo_deoptimization = true; |
- FunctionTester T("(function(a) { return %_ValueOf(a); })", flags); |
- |
- T.CheckCall(T.Val("a"), T.Val("a")); |
- T.CheckCall(T.Val("b"), T.NewObject("(new String('b'))")); |
- T.CheckCall(T.Val(123), T.Val(123)); |
- T.CheckCall(T.Val(456), T.NewObject("(new Number(456))")); |
-} |
- |
- |
TEST(SetValueOf) { |
FLAG_turbo_deoptimization = true; |
FunctionTester T("(function(a,b) { return %_SetValueOf(a,b); })", flags); |
@@ -159,13 +186,13 @@ TEST(SetValueOf) { |
} |
-TEST(StringCharFromCode) { |
+TEST(StringAdd) { |
FLAG_turbo_deoptimization = true; |
- FunctionTester T("(function(a) { return %_StringCharFromCode(a); })", flags); |
+ FunctionTester T("(function(a,b) { return %_StringAdd(a,b); })", flags); |
- T.CheckCall(T.Val("a"), T.Val(97)); |
- T.CheckCall(T.Val("\xE2\x9D\x8A"), T.Val(0x274A)); |
- T.CheckCall(T.Val(""), T.undefined()); |
+ T.CheckCall(T.Val("aaabbb"), T.Val("aaa"), T.Val("bbb")); |
+ T.CheckCall(T.Val("aaa"), T.Val("aaa"), T.Val("")); |
+ T.CheckCall(T.Val("bbb"), T.Val(""), T.Val("bbb")); |
} |
@@ -190,23 +217,13 @@ TEST(StringCharCodeAt) { |
} |
-TEST(StringAdd) { |
- FLAG_turbo_deoptimization = true; |
- FunctionTester T("(function(a,b) { return %_StringAdd(a,b); })", flags); |
- |
- T.CheckCall(T.Val("aaabbb"), T.Val("aaa"), T.Val("bbb")); |
- T.CheckCall(T.Val("aaa"), T.Val("aaa"), T.Val("")); |
- T.CheckCall(T.Val("bbb"), T.Val(""), T.Val("bbb")); |
-} |
- |
- |
-TEST(StringSubString) { |
+TEST(StringCharFromCode) { |
FLAG_turbo_deoptimization = true; |
- FunctionTester T("(function(a,b) { return %_SubString(a,b,b+3); })", flags); |
+ FunctionTester T("(function(a) { return %_StringCharFromCode(a); })", flags); |
- T.CheckCall(T.Val("aaa"), T.Val("aaabbb"), T.Val(0.0)); |
- T.CheckCall(T.Val("abb"), T.Val("aaabbb"), T.Val(2)); |
- T.CheckCall(T.Val("aaa"), T.Val("aaa"), T.Val(0.0)); |
+ T.CheckCall(T.Val("a"), T.Val(97)); |
+ T.CheckCall(T.Val("\xE2\x9D\x8A"), T.Val(0x274A)); |
+ T.CheckCall(T.Val(""), T.undefined()); |
} |
@@ -220,12 +237,22 @@ TEST(StringCompare) { |
} |
-TEST(CallFunction) { |
+TEST(SubString) { |
FLAG_turbo_deoptimization = true; |
- FunctionTester T("(function(a,b) { return %_CallFunction(a, 1, 2, 3, b); })", |
- flags); |
- CompileRun("function f(a,b,c) { return a + b + c + this.d; }"); |
+ FunctionTester T("(function(a,b) { return %_SubString(a,b,b+3); })", flags); |
- T.CheckCall(T.Val(129), T.NewObject("({d:123})"), T.NewObject("f")); |
- T.CheckCall(T.Val("6x"), T.NewObject("({d:'x'})"), T.NewObject("f")); |
+ T.CheckCall(T.Val("aaa"), T.Val("aaabbb"), T.Val(0.0)); |
+ T.CheckCall(T.Val("abb"), T.Val("aaabbb"), T.Val(2)); |
+ T.CheckCall(T.Val("aaa"), T.Val("aaa"), T.Val(0.0)); |
+} |
+ |
+ |
+TEST(ValueOf) { |
+ FLAG_turbo_deoptimization = true; |
+ FunctionTester T("(function(a) { return %_ValueOf(a); })", flags); |
+ |
+ T.CheckCall(T.Val("a"), T.Val("a")); |
+ T.CheckCall(T.Val("b"), T.NewObject("(new String('b'))")); |
+ T.CheckCall(T.Val(123), T.Val(123)); |
+ T.CheckCall(T.Val(456), T.NewObject("(new Number(456))")); |
} |