Upgrade V8 to 5.1.281.57 DO NOT MERGE
FPIIM-449
Change-Id: Id981b686b4d587ac31697662eb98bb34be42ad90
(cherry picked from commit 3b9bc31999c9787eb726ecdbfd5796bfdec32a18)
diff --git a/test/cctest/compiler/call-tester.h b/test/cctest/compiler/call-tester.h
index 8ee6b99..c75bde1 100644
--- a/test/cctest/compiler/call-tester.h
+++ b/test/cctest/compiler/call-tester.h
@@ -220,7 +220,8 @@
Simulator::CallArgument(p5), Simulator::CallArgument::End()};
return CastReturnValue<R>(CallSimulator(FUNCTION_ADDR(f), args));
}
-#elif USE_SIMULATOR && (V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64)
+#elif USE_SIMULATOR && \
+ (V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64 || V8_TARGET_ARCH_S390X)
uintptr_t CallSimulator(byte* f, int64_t p1 = 0, int64_t p2 = 0,
int64_t p3 = 0, int64_t p4 = 0, int64_t p5 = 0) {
Simulator* simulator = Simulator::current(isolate_);
@@ -264,8 +265,8 @@
ParameterTraits<P2>::Cast(p2), ParameterTraits<P3>::Cast(p3),
ParameterTraits<P4>::Cast(p4), ParameterTraits<P5>::Cast(p5)));
}
-#elif USE_SIMULATOR && \
- (V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_PPC)
+#elif USE_SIMULATOR && (V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS || \
+ V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390)
uintptr_t CallSimulator(byte* f, int32_t p1 = 0, int32_t p2 = 0,
int32_t p3 = 0, int32_t p4 = 0, int32_t p5 = 0) {
Simulator* simulator = Simulator::current(isolate_);
diff --git a/test/cctest/compiler/codegen-tester.cc b/test/cctest/compiler/codegen-tester.cc
index fc0956f..9b5a9d9 100644
--- a/test/cctest/compiler/codegen-tester.cc
+++ b/test/cctest/compiler/codegen-tester.cc
@@ -563,7 +563,7 @@
Float64BinopTester bt(&m);
bt.AddReturn(bt.param0);
- FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(*i, bt.call(*i, 9.0)); }
+ FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(*i, bt.call(*i, 9.0)); }
}
{
@@ -571,7 +571,7 @@
Float64BinopTester bt(&m);
bt.AddReturn(bt.param1);
- FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(*i, bt.call(-11.25, *i)); }
+ FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(*i, bt.call(-11.25, *i)); }
}
}
@@ -587,7 +587,7 @@
{
BufferedRawMachineAssemblerTester<double> m(MachineType::Float64());
m.Return(m.Parameter(0));
- FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(*i, m.Call(*i)); }
+ FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(*i, m.Call(*i)); }
}
{
BufferedRawMachineAssemblerTester<int64_t> m(MachineType::Int64(),
@@ -647,7 +647,7 @@
m.Return(m.Int32Constant(0));
FOR_FLOAT64_INPUTS(i) {
m.Call(*i);
- CheckDoubleEq(*i, result);
+ CHECK_DOUBLE_EQ(*i, result);
}
}
{
diff --git a/test/cctest/compiler/function-tester.h b/test/cctest/compiler/function-tester.h
index c6093ce..631bdde 100644
--- a/test/cctest/compiler/function-tester.h
+++ b/test/cctest/compiler/function-tester.h
@@ -175,7 +175,7 @@
uint32_t flags_;
Handle<JSFunction> Compile(Handle<JSFunction> function) {
- Zone zone;
+ Zone zone(function->GetIsolate()->allocator());
ParseInfo parse_info(&zone, function);
CompilationInfo info(&parse_info);
info.MarkAsDeoptimizationEnabled();
@@ -224,7 +224,7 @@
// Compile the given machine graph instead of the source of the function
// and replace the JSFunction's code with the result.
Handle<JSFunction> CompileGraph(Graph* graph) {
- Zone zone;
+ Zone zone(function->GetIsolate()->allocator());
ParseInfo parse_info(&zone, function);
CompilationInfo info(&parse_info);
diff --git a/test/cctest/compiler/test-changes-lowering.cc b/test/cctest/compiler/test-changes-lowering.cc
index e850da7..ddeabe4 100644
--- a/test/cctest/compiler/test-changes-lowering.cc
+++ b/test/cctest/compiler/test-changes-lowering.cc
@@ -237,13 +237,13 @@
{
Handle<Object> number = t.factory()->NewNumber(input);
t.Call(*number);
- CheckDoubleEq(input, result);
+ CHECK_DOUBLE_EQ(input, result);
}
{
Handle<HeapNumber> number = t.factory()->NewHeapNumber(input);
t.Call(*number);
- CheckDoubleEq(input, result);
+ CHECK_DOUBLE_EQ(input, result);
}
}
}
diff --git a/test/cctest/compiler/test-code-stub-assembler.cc b/test/cctest/compiler/test-code-stub-assembler.cc
index 0306561..ff02cc9 100644
--- a/test/cctest/compiler/test-code-stub-assembler.cc
+++ b/test/cctest/compiler/test-code-stub-assembler.cc
@@ -13,12 +13,19 @@
class CodeStubAssemblerTester : public CodeStubAssembler {
public:
+ // Test generating code for a stub.
CodeStubAssemblerTester(Isolate* isolate,
const CallInterfaceDescriptor& descriptor)
: CodeStubAssembler(isolate, isolate->runtime_zone(), descriptor,
Code::ComputeFlags(Code::STUB), "test"),
scope_(isolate) {}
+ // Test generating code for a JS function (e.g. builtins).
+ CodeStubAssemblerTester(Isolate* isolate, int parameter_count)
+ : CodeStubAssembler(isolate, isolate->runtime_zone(), parameter_count,
+ Code::ComputeFlags(Code::FUNCTION), "test"),
+ scope_(isolate) {}
+
private:
HandleScope scope_;
LocalContext context_;
@@ -68,12 +75,12 @@
VoidDescriptor descriptor(isolate);
CodeStubAssemblerTester m(isolate, descriptor);
Node* context = m.HeapConstant(Handle<Context>(isolate->native_context()));
- Node* b = m.SmiTag(m.Int32Constant(256));
- m.Return(m.CallRuntime(Runtime::kMathSqrt, context, b));
+ Node* b = m.SmiTag(m.Int32Constant(0));
+ m.Return(m.CallRuntime(Runtime::kNumberToSmi, context, b));
Handle<Code> code = m.GenerateCode();
FunctionTester ft(descriptor, code);
MaybeHandle<Object> result = ft.Call();
- CHECK_EQ(16, Handle<Smi>::cast(result.ToHandleChecked())->value());
+ CHECK_EQ(0, Handle<Smi>::cast(result.ToHandleChecked())->value());
}
@@ -82,12 +89,12 @@
VoidDescriptor descriptor(isolate);
CodeStubAssemblerTester m(isolate, descriptor);
Node* context = m.HeapConstant(Handle<Context>(isolate->native_context()));
- Node* b = m.SmiTag(m.Int32Constant(256));
- m.TailCallRuntime(Runtime::kMathSqrt, context, b);
+ Node* b = m.SmiTag(m.Int32Constant(0));
+ m.TailCallRuntime(Runtime::kNumberToSmi, context, b);
Handle<Code> code = m.GenerateCode();
FunctionTester ft(descriptor, code);
MaybeHandle<Object> result = ft.Call();
- CHECK_EQ(16, Handle<Smi>::cast(result.ToHandleChecked())->value());
+ CHECK_EQ(0, Handle<Smi>::cast(result.ToHandleChecked())->value());
}
@@ -247,6 +254,113 @@
CHECK_EQ(733, Handle<Smi>::cast(result.ToHandleChecked())->value());
}
+TEST(LoadHeapNumberValue) {
+ Isolate* isolate(CcTest::InitIsolateOnce());
+ VoidDescriptor descriptor(isolate);
+ CodeStubAssemblerTester m(isolate, descriptor);
+ Handle<HeapNumber> number = isolate->factory()->NewHeapNumber(1234);
+ m.Return(m.SmiTag(
+ m.ChangeFloat64ToUint32(m.LoadHeapNumberValue(m.HeapConstant(number)))));
+ Handle<Code> code = m.GenerateCode();
+ FunctionTester ft(descriptor, code);
+ MaybeHandle<Object> result = ft.Call();
+ CHECK_EQ(1234, Handle<Smi>::cast(result.ToHandleChecked())->value());
+}
+
+TEST(LoadInstanceType) {
+ Isolate* isolate(CcTest::InitIsolateOnce());
+ VoidDescriptor descriptor(isolate);
+ CodeStubAssemblerTester m(isolate, descriptor);
+ Handle<HeapObject> undefined = isolate->factory()->undefined_value();
+ m.Return(m.SmiTag(m.LoadInstanceType(m.HeapConstant(undefined))));
+ Handle<Code> code = m.GenerateCode();
+ FunctionTester ft(descriptor, code);
+ MaybeHandle<Object> result = ft.Call();
+ CHECK_EQ(InstanceType::ODDBALL_TYPE,
+ Handle<Smi>::cast(result.ToHandleChecked())->value());
+}
+
+namespace {
+
+class TestBitField : public BitField<unsigned, 3, 3> {};
+
+} // namespace
+
+TEST(BitFieldDecode) {
+ Isolate* isolate(CcTest::InitIsolateOnce());
+ VoidDescriptor descriptor(isolate);
+ CodeStubAssemblerTester m(isolate, descriptor);
+ m.Return(m.SmiTag(m.BitFieldDecode<TestBitField>(m.Int32Constant(0x2f))));
+ Handle<Code> code = m.GenerateCode();
+ FunctionTester ft(descriptor, code);
+ MaybeHandle<Object> result = ft.Call();
+ // value = 00101111
+ // mask = 00111000
+ // result = 101
+ CHECK_EQ(5, Handle<Smi>::cast(result.ToHandleChecked())->value());
+}
+
+namespace {
+
+Handle<JSFunction> CreateFunctionFromCode(int parameter_count_with_receiver,
+ Handle<Code> code) {
+ Isolate* isolate = code->GetIsolate();
+ Handle<String> name = isolate->factory()->InternalizeUtf8String("test");
+ Handle<JSFunction> function =
+ isolate->factory()->NewFunctionWithoutPrototype(name, code);
+ function->shared()->set_internal_formal_parameter_count(
+ parameter_count_with_receiver - 1); // Implicit undefined receiver.
+ return function;
+}
+
+} // namespace
+
+TEST(JSFunction) {
+ const int kNumParams = 3; // Receiver, left, right.
+ Isolate* isolate(CcTest::InitIsolateOnce());
+ CodeStubAssemblerTester m(isolate, kNumParams);
+ m.Return(m.SmiTag(m.Int32Add(m.SmiToWord32(m.Parameter(1)),
+ m.SmiToWord32(m.Parameter(2)))));
+ Handle<Code> code = m.GenerateCode();
+ Handle<JSFunction> function = CreateFunctionFromCode(kNumParams, code);
+ Handle<Object> args[] = {Handle<Smi>(Smi::FromInt(23), isolate),
+ Handle<Smi>(Smi::FromInt(34), isolate)};
+ MaybeHandle<Object> result =
+ Execution::Call(isolate, function, isolate->factory()->undefined_value(),
+ arraysize(args), args);
+ CHECK_EQ(57, Handle<Smi>::cast(result.ToHandleChecked())->value());
+}
+
+TEST(SplitEdgeBranchMerge) {
+ Isolate* isolate(CcTest::InitIsolateOnce());
+ VoidDescriptor descriptor(isolate);
+ CodeStubAssemblerTester m(isolate, descriptor);
+ CodeStubAssembler::Label l1(&m), merge(&m);
+ m.Branch(m.Int32Constant(1), &l1, &merge);
+ m.Bind(&l1);
+ m.Goto(&merge);
+ m.Bind(&merge);
+ USE(m.GenerateCode());
+}
+
+TEST(SplitEdgeSwitchMerge) {
+ Isolate* isolate(CcTest::InitIsolateOnce());
+ VoidDescriptor descriptor(isolate);
+ CodeStubAssemblerTester m(isolate, descriptor);
+ CodeStubAssembler::Label l1(&m), l2(&m), l3(&m), default_label(&m);
+ CodeStubAssembler::Label* labels[] = {&l1, &l2};
+ int32_t values[] = {1, 2};
+ m.Branch(m.Int32Constant(1), &l3, &l1);
+ m.Bind(&l3);
+ m.Switch(m.Int32Constant(2), &default_label, values, labels, 2);
+ m.Bind(&l1);
+ m.Goto(&l2);
+ m.Bind(&l2);
+ m.Goto(&default_label);
+ m.Bind(&default_label);
+ USE(m.GenerateCode());
+}
+
} // namespace compiler
} // namespace internal
} // namespace v8
diff --git a/test/cctest/compiler/test-instruction.cc b/test/cctest/compiler/test-instruction.cc
index 4de3373..4cf72a5 100644
--- a/test/cctest/compiler/test-instruction.cc
+++ b/test/cctest/compiler/test-instruction.cc
@@ -268,7 +268,8 @@
TEST(InstructionOperands) {
- Zone zone;
+ base::AccountingAllocator allocator;
+ Zone zone(&allocator);
{
TestInstr* i = TestInstr::New(&zone, 101);
diff --git a/test/cctest/compiler/test-js-typed-lowering.cc b/test/cctest/compiler/test-js-typed-lowering.cc
index 24db6a5..0075de5 100644
--- a/test/cctest/compiler/test-js-typed-lowering.cc
+++ b/test/cctest/compiler/test-js-typed-lowering.cc
@@ -975,7 +975,7 @@
BinopEffectsTester B(ops[j], Type::Symbol(), Type::String());
CHECK_EQ(ops[j + 1]->opcode(), B.result->op()->opcode());
- Node* i0 = B.CheckConvertedInput(IrOpcode::kJSToNumber, 0, true);
+ Node* i0 = B.CheckConvertedInput(IrOpcode::kStringToNumber, 0, false);
Node* i1 = B.CheckConvertedInput(IrOpcode::kJSToNumber, 1, true);
// Inputs should be commuted.
diff --git a/test/cctest/compiler/test-jump-threading.cc b/test/cctest/compiler/test-jump-threading.cc
index 71f774f..ed3d79e 100644
--- a/test/cctest/compiler/test-jump-threading.cc
+++ b/test/cctest/compiler/test-jump-threading.cc
@@ -106,7 +106,8 @@
void VerifyForwarding(TestCode& code, int count, int* expected) {
- Zone local_zone;
+ base::AccountingAllocator allocator;
+ Zone local_zone(&allocator);
ZoneVector<RpoNumber> result(&local_zone);
JumpThreading::ComputeForwarding(&local_zone, result, &code.sequence_, true);
diff --git a/test/cctest/compiler/test-linkage.cc b/test/cctest/compiler/test-linkage.cc
index 6722f59..0cbdb4c 100644
--- a/test/cctest/compiler/test-linkage.cc
+++ b/test/cctest/compiler/test-linkage.cc
@@ -30,12 +30,12 @@
Handle<String> source_code = isolate->factory()
->NewStringFromUtf8(CStrVector(source))
.ToHandleChecked();
- Handle<SharedFunctionInfo> shared_function = Compiler::CompileScript(
+ Handle<SharedFunctionInfo> shared = Compiler::GetSharedFunctionInfoForScript(
source_code, Handle<String>(), 0, 0, v8::ScriptOriginOptions(),
Handle<Object>(), Handle<Context>(isolate->native_context()), NULL, NULL,
v8::ScriptCompiler::kNoCompileOptions, NOT_NATIVES_CODE, false);
return isolate->factory()->NewFunctionFromSharedFunctionInfo(
- shared_function, isolate->native_context());
+ shared, isolate->native_context());
}
@@ -96,7 +96,7 @@
TEST(TestLinkageStubCall) {
Isolate* isolate = CcTest::InitIsolateOnce();
- Zone zone;
+ Zone zone(isolate->allocator());
ToNumberStub stub(isolate);
CompilationInfo info("test", isolate, &zone, Code::ComputeFlags(Code::STUB));
CallInterfaceDescriptor interface_descriptor =
diff --git a/test/cctest/compiler/test-loop-analysis.cc b/test/cctest/compiler/test-loop-analysis.cc
index 68bfc28..fb61e20 100644
--- a/test/cctest/compiler/test-loop-analysis.cc
+++ b/test/cctest/compiler/test-loop-analysis.cc
@@ -127,7 +127,7 @@
OFStream os(stdout);
os << AsRPO(graph);
}
- Zone zone;
+ Zone zone(main_isolate()->allocator());
loop_tree = LoopFinder::BuildLoopTree(&graph, &zone);
}
return loop_tree;
diff --git a/test/cctest/compiler/test-multiple-return.cc b/test/cctest/compiler/test-multiple-return.cc
index 7c08238..2108ab1 100644
--- a/test/cctest/compiler/test-multiple-return.cc
+++ b/test/cctest/compiler/test-multiple-return.cc
@@ -69,7 +69,8 @@
TEST(ReturnThreeValues) {
- Zone zone;
+ base::AccountingAllocator allocator;
+ Zone zone(&allocator);
CallDescriptor* desc = GetCallDescriptor(&zone, 3, 2);
HandleAndZoneScope handles;
RawMachineAssembler m(handles.main_isolate(),
diff --git a/test/cctest/compiler/test-node.cc b/test/cctest/compiler/test-node.cc
index de1c2c0..d317c38 100644
--- a/test/cctest/compiler/test-node.cc
+++ b/test/cctest/compiler/test-node.cc
@@ -141,7 +141,8 @@
TEST(NodeUseIteratorReplaceUses) {
- Zone zone;
+ base::AccountingAllocator allocator;
+ Zone zone(&allocator);
Graph graph(&zone);
Node* n0 = graph.NewNode(&dummy_operator0);
Node* n1 = graph.NewNode(&dummy_operator1, n0);
@@ -166,7 +167,8 @@
TEST(NodeUseIteratorReplaceUsesSelf) {
- Zone zone;
+ base::AccountingAllocator allocator;
+ Zone zone(&allocator);
Graph graph(&zone);
Node* n0 = graph.NewNode(&dummy_operator0);
Node* n1 = graph.NewNode(&dummy_operator1, n0);
@@ -190,7 +192,8 @@
TEST(ReplaceInput) {
- Zone zone;
+ base::AccountingAllocator allocator;
+ Zone zone(&allocator);
Graph graph(&zone);
Node* n0 = graph.NewNode(&dummy_operator0);
Node* n1 = graph.NewNode(&dummy_operator0);
@@ -216,7 +219,8 @@
TEST(OwnedBy) {
- Zone zone;
+ base::AccountingAllocator allocator;
+ Zone zone(&allocator);
Graph graph(&zone);
{
@@ -266,7 +270,8 @@
TEST(Uses) {
- Zone zone;
+ base::AccountingAllocator allocator;
+ Zone zone(&allocator);
Graph graph(&zone);
Node* n0 = graph.NewNode(&dummy_operator0);
@@ -288,7 +293,8 @@
TEST(Inputs) {
- Zone zone;
+ base::AccountingAllocator allocator;
+ Zone zone(&allocator);
Graph graph(&zone);
Node* n0 = graph.NewNode(&dummy_operator0);
@@ -316,7 +322,8 @@
TEST(RemoveInput) {
- Zone zone;
+ base::AccountingAllocator allocator;
+ Zone zone(&allocator);
Graph graph(&zone);
Node* n0 = graph.NewNode(&dummy_operator0);
@@ -346,7 +353,8 @@
TEST(AppendInputsAndIterator) {
- Zone zone;
+ base::AccountingAllocator allocator;
+ Zone zone(&allocator);
Graph graph(&zone);
Node* n0 = graph.NewNode(&dummy_operator0);
@@ -368,7 +376,8 @@
TEST(NullInputsSimple) {
- Zone zone;
+ base::AccountingAllocator allocator;
+ Zone zone(&allocator);
Graph graph(&zone);
Node* n0 = graph.NewNode(&dummy_operator0);
@@ -395,7 +404,8 @@
TEST(NullInputsAppended) {
- Zone zone;
+ base::AccountingAllocator allocator;
+ Zone zone(&allocator);
Graph graph(&zone);
Node* n0 = graph.NewNode(&dummy_operator0);
@@ -418,7 +428,8 @@
TEST(ReplaceUsesFromAppendedInputs) {
- Zone zone;
+ base::AccountingAllocator allocator;
+ Zone zone(&allocator);
Graph graph(&zone);
Node* n0 = graph.NewNode(&dummy_operator0);
@@ -446,7 +457,8 @@
TEST(ReplaceInputMultipleUses) {
- Zone zone;
+ base::AccountingAllocator allocator;
+ Zone zone(&allocator);
Graph graph(&zone);
Node* n0 = graph.NewNode(&dummy_operator0);
@@ -464,7 +476,8 @@
TEST(TrimInputCountInline) {
- Zone zone;
+ base::AccountingAllocator allocator;
+ Zone zone(&allocator);
Graph graph(&zone);
{
@@ -532,7 +545,8 @@
TEST(TrimInputCountOutOfLine1) {
- Zone zone;
+ base::AccountingAllocator allocator;
+ Zone zone(&allocator);
Graph graph(&zone);
{
@@ -626,7 +640,8 @@
TEST(TrimInputCountOutOfLine2) {
- Zone zone;
+ base::AccountingAllocator allocator;
+ Zone zone(&allocator);
Graph graph(&zone);
{
@@ -695,7 +710,8 @@
TEST(NullAllInputs) {
- Zone zone;
+ base::AccountingAllocator allocator;
+ Zone zone(&allocator);
Graph graph(&zone);
for (int i = 0; i < 2; i++) {
@@ -747,7 +763,8 @@
TEST(AppendAndTrim) {
- Zone zone;
+ base::AccountingAllocator allocator;
+ Zone zone(&allocator);
Graph graph(&zone);
Node* nodes[] = {
diff --git a/test/cctest/compiler/test-representation-change.cc b/test/cctest/compiler/test-representation-change.cc
index 7353e16..7e75bf8 100644
--- a/test/cctest/compiler/test-representation-change.cc
+++ b/test/cctest/compiler/test-representation-change.cc
@@ -55,13 +55,13 @@
void CheckFloat64Constant(Node* n, double expected) {
Float64Matcher m(n);
CHECK(m.HasValue());
- CheckDoubleEq(expected, m.Value());
+ CHECK_DOUBLE_EQ(expected, m.Value());
}
void CheckFloat32Constant(Node* n, float expected) {
CHECK_EQ(IrOpcode::kFloat32Constant, n->opcode());
float fval = OpParameter<float>(n->op());
- CheckDoubleEq(expected, fval);
+ CHECK_FLOAT_EQ(expected, fval);
}
void CheckHeapConstant(Node* n, HeapObject* expected) {
@@ -74,7 +74,7 @@
NumberMatcher m(n);
CHECK_EQ(IrOpcode::kNumberConstant, n->opcode());
CHECK(m.HasValue());
- CheckDoubleEq(expected, m.Value());
+ CHECK_DOUBLE_EQ(expected, m.Value());
}
Node* Parameter(int index = 0) {
diff --git a/test/cctest/compiler/test-run-bytecode-graph-builder.cc b/test/cctest/compiler/test-run-bytecode-graph-builder.cc
index 9a03822..c32f923 100644
--- a/test/cctest/compiler/test-run-bytecode-graph-builder.cc
+++ b/test/cctest/compiler/test-run-bytecode-graph-builder.cc
@@ -79,12 +79,6 @@
i::FLAG_always_opt = false;
i::FLAG_allow_natives_syntax = true;
i::FLAG_loop_assignment_analysis = false;
- // Set ignition filter flag via SetFlagsFromString to avoid double-free
- // (or potential leak with StrDup() based on ownership confusion).
- ScopedVector<char> ignition_filter(64);
- SNPrintF(ignition_filter, "--ignition-filter=%s", filter);
- FlagList::SetFlagsFromString(ignition_filter.start(),
- ignition_filter.length());
// Ensure handler table is generated.
isolate->interpreter()->Initialize();
}
@@ -659,6 +653,28 @@
}
}
+TEST(BytecodeGraphBuilderInvokeIntrinsic) {
+ HandleAndZoneScope scope;
+ Isolate* isolate = scope.main_isolate();
+ Zone* zone = scope.main_zone();
+ 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, zone, 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();
@@ -2835,29 +2851,6 @@
Handle<Object> return_value = callable().ToHandleChecked();
CHECK(return_value->SameValue(*const_decl[i].return_value()));
}
-
- // Tests for Legacy constant.
- bool old_flag_legacy_const = FLAG_legacy_const;
- FLAG_legacy_const = true;
-
- ExpectedSnippet<0> legacy_const_decl[] = {
- {"return outerConst = 23;", {handle(Smi::FromInt(23), isolate)}},
- {"outerConst = 30; return outerConst;",
- {handle(Smi::FromInt(10), isolate)}},
- };
-
- for (size_t i = 0; i < arraysize(legacy_const_decl); i++) {
- ScopedVector<char> script(1024);
- SNPrintF(script, "%s %s %s", prologue, legacy_const_decl[i].code_snippet,
- epilogue);
-
- BytecodeGraphTester tester(isolate, zone, script.start(), "*");
- auto callable = tester.GetCallable<>();
- Handle<Object> return_value = callable().ToHandleChecked();
- CHECK(return_value->SameValue(*legacy_const_decl[i].return_value()));
- }
-
- FLAG_legacy_const = old_flag_legacy_const;
}
TEST(BytecodeGraphBuilderIllegalConstDeclaration) {
@@ -2911,43 +2904,6 @@
}
}
-TEST(BytecodeGraphBuilderLegacyConstDeclaration) {
- bool old_flag_legacy_const = FLAG_legacy_const;
- FLAG_legacy_const = true;
-
- HandleAndZoneScope scope;
- Isolate* isolate = scope.main_isolate();
- Zone* zone = scope.main_zone();
-
- ExpectedSnippet<0> snippets[] = {
- {"const x = (x = 10) + 3; return x;",
- {handle(Smi::FromInt(13), isolate)}},
- {"const x = 10; x = 20; return x;", {handle(Smi::FromInt(10), isolate)}},
- {"var a = 10;\n"
- "for (var i = 0; i < 10; ++i) {\n"
- " const x = i;\n" // Legacy constants are not block scoped.
- " a = a + x;\n"
- "}\n"
- "return a;\n",
- {handle(Smi::FromInt(10), isolate)}},
- {"const x = 20; eval('x = 10;'); return x;",
- {handle(Smi::FromInt(20), isolate)}},
- };
-
- for (size_t i = 0; i < arraysize(snippets); i++) {
- ScopedVector<char> script(1024);
- SNPrintF(script, "function %s() { %s }\n%s();", kFunctionName,
- snippets[i].code_snippet, kFunctionName);
-
- BytecodeGraphTester tester(isolate, zone, script.start());
- auto callable = tester.GetCallable<>();
- Handle<Object> return_value = callable().ToHandleChecked();
- CHECK(return_value->SameValue(*snippets[i].return_value()));
- }
-
- FLAG_legacy_const = old_flag_legacy_const;
-}
-
TEST(BytecodeGraphBuilderDebuggerStatement) {
FLAG_expose_debug_as = "debug";
HandleAndZoneScope scope;
diff --git a/test/cctest/compiler/test-run-calls-to-external-references.cc b/test/cctest/compiler/test-run-calls-to-external-references.cc
new file mode 100644
index 0000000..3b79cd8
--- /dev/null
+++ b/test/cctest/compiler/test-run-calls-to-external-references.cc
@@ -0,0 +1,531 @@
+// Copyright 2014 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.
+
+#include "test/cctest/cctest.h"
+#include "test/cctest/compiler/codegen-tester.h"
+#include "test/cctest/compiler/value-helper.h"
+
+namespace v8 {
+namespace internal {
+namespace compiler {
+
+template <typename T>
+void TestExternalReferenceRoundingFunction(
+ BufferedRawMachineAssemblerTester<int32_t>* m, ExternalReference ref,
+ T (*comparison)(T)) {
+ T parameter;
+
+ Node* function = m->ExternalConstant(ref);
+ m->CallCFunction1(MachineType::Pointer(), MachineType::Pointer(), function,
+ m->PointerConstant(¶meter));
+ m->Return(m->Int32Constant(4356));
+ FOR_FLOAT64_INPUTS(i) {
+ parameter = *i;
+ m->Call();
+ CHECK_DOUBLE_EQ(comparison(*i), parameter);
+ }
+}
+
+TEST(RunCallF32Trunc) {
+ BufferedRawMachineAssemblerTester<int32_t> m;
+ ExternalReference ref = ExternalReference::wasm_f32_trunc(m.isolate());
+ TestExternalReferenceRoundingFunction<float>(&m, ref, truncf);
+}
+
+TEST(RunCallF32Floor) {
+ BufferedRawMachineAssemblerTester<int32_t> m;
+ ExternalReference ref = ExternalReference::wasm_f32_floor(m.isolate());
+ TestExternalReferenceRoundingFunction<float>(&m, ref, floorf);
+}
+
+TEST(RunCallF32Ceil) {
+ BufferedRawMachineAssemblerTester<int32_t> m;
+ ExternalReference ref = ExternalReference::wasm_f32_ceil(m.isolate());
+ TestExternalReferenceRoundingFunction<float>(&m, ref, ceilf);
+}
+
+TEST(RunCallF32RoundTiesEven) {
+ BufferedRawMachineAssemblerTester<int32_t> m;
+ ExternalReference ref = ExternalReference::wasm_f32_nearest_int(m.isolate());
+ TestExternalReferenceRoundingFunction<float>(&m, ref, nearbyintf);
+}
+
+TEST(RunCallF64Trunc) {
+ BufferedRawMachineAssemblerTester<int32_t> m;
+ ExternalReference ref = ExternalReference::wasm_f64_trunc(m.isolate());
+ TestExternalReferenceRoundingFunction<double>(&m, ref, trunc);
+}
+
+TEST(RunCallF64Floor) {
+ BufferedRawMachineAssemblerTester<int32_t> m;
+ ExternalReference ref = ExternalReference::wasm_f64_floor(m.isolate());
+ TestExternalReferenceRoundingFunction<double>(&m, ref, floor);
+}
+
+TEST(RunCallF64Ceil) {
+ BufferedRawMachineAssemblerTester<int32_t> m;
+ ExternalReference ref = ExternalReference::wasm_f64_ceil(m.isolate());
+ TestExternalReferenceRoundingFunction<double>(&m, ref, ceil);
+}
+
+TEST(RunCallF64RoundTiesEven) {
+ BufferedRawMachineAssemblerTester<int32_t> m;
+ ExternalReference ref = ExternalReference::wasm_f64_nearest_int(m.isolate());
+ TestExternalReferenceRoundingFunction<double>(&m, ref, nearbyint);
+}
+
+TEST(RunCallInt64ToFloat32) {
+ BufferedRawMachineAssemblerTester<int32_t> m;
+ ExternalReference ref = ExternalReference::wasm_int64_to_float32(m.isolate());
+
+ int64_t input;
+ float output;
+
+ Node* function = m.ExternalConstant(ref);
+ m.CallCFunction2(MachineType::Pointer(), MachineType::Pointer(),
+ MachineType::Pointer(), function, m.PointerConstant(&input),
+ m.PointerConstant(&output));
+ m.Return(m.Int32Constant(4356));
+ FOR_INT64_INPUTS(i) {
+ input = *i;
+ m.Call();
+ CHECK_FLOAT_EQ(static_cast<float>(*i), output);
+ }
+}
+
+TEST(RunCallUint64ToFloat32) {
+ struct {
+ uint64_t input;
+ uint32_t expected;
+ } values[] = {{0x0, 0x0},
+ {0x1, 0x3f800000},
+ {0xffffffff, 0x4f800000},
+ {0x1b09788b, 0x4dd84bc4},
+ {0x4c5fce8, 0x4c98bf9d},
+ {0xcc0de5bf, 0x4f4c0de6},
+ {0x2, 0x40000000},
+ {0x3, 0x40400000},
+ {0x4, 0x40800000},
+ {0x5, 0x40a00000},
+ {0x8, 0x41000000},
+ {0x9, 0x41100000},
+ {0xffffffffffffffff, 0x5f800000},
+ {0xfffffffffffffffe, 0x5f800000},
+ {0xfffffffffffffffd, 0x5f800000},
+ {0x0, 0x0},
+ {0x100000000, 0x4f800000},
+ {0xffffffff00000000, 0x5f800000},
+ {0x1b09788b00000000, 0x5dd84bc4},
+ {0x4c5fce800000000, 0x5c98bf9d},
+ {0xcc0de5bf00000000, 0x5f4c0de6},
+ {0x200000000, 0x50000000},
+ {0x300000000, 0x50400000},
+ {0x400000000, 0x50800000},
+ {0x500000000, 0x50a00000},
+ {0x800000000, 0x51000000},
+ {0x900000000, 0x51100000},
+ {0x273a798e187937a3, 0x5e1ce9e6},
+ {0xece3af835495a16b, 0x5f6ce3b0},
+ {0xb668ecc11223344, 0x5d3668ed},
+ {0x9e, 0x431e0000},
+ {0x43, 0x42860000},
+ {0xaf73, 0x472f7300},
+ {0x116b, 0x458b5800},
+ {0x658ecc, 0x4acb1d98},
+ {0x2b3b4c, 0x4a2ced30},
+ {0x88776655, 0x4f087766},
+ {0x70000000, 0x4ee00000},
+ {0x7200000, 0x4ce40000},
+ {0x7fffffff, 0x4f000000},
+ {0x56123761, 0x4eac246f},
+ {0x7fffff00, 0x4efffffe},
+ {0x761c4761eeeeeeee, 0x5eec388f},
+ {0x80000000eeeeeeee, 0x5f000000},
+ {0x88888888dddddddd, 0x5f088889},
+ {0xa0000000dddddddd, 0x5f200000},
+ {0xddddddddaaaaaaaa, 0x5f5dddde},
+ {0xe0000000aaaaaaaa, 0x5f600000},
+ {0xeeeeeeeeeeeeeeee, 0x5f6eeeef},
+ {0xfffffffdeeeeeeee, 0x5f800000},
+ {0xf0000000dddddddd, 0x5f700000},
+ {0x7fffffdddddddd, 0x5b000000},
+ {0x3fffffaaaaaaaa, 0x5a7fffff},
+ {0x1fffffaaaaaaaa, 0x59fffffd},
+ {0xfffff, 0x497ffff0},
+ {0x7ffff, 0x48ffffe0},
+ {0x3ffff, 0x487fffc0},
+ {0x1ffff, 0x47ffff80},
+ {0xffff, 0x477fff00},
+ {0x7fff, 0x46fffe00},
+ {0x3fff, 0x467ffc00},
+ {0x1fff, 0x45fff800},
+ {0xfff, 0x457ff000},
+ {0x7ff, 0x44ffe000},
+ {0x3ff, 0x447fc000},
+ {0x1ff, 0x43ff8000},
+ {0x3fffffffffff, 0x56800000},
+ {0x1fffffffffff, 0x56000000},
+ {0xfffffffffff, 0x55800000},
+ {0x7ffffffffff, 0x55000000},
+ {0x3ffffffffff, 0x54800000},
+ {0x1ffffffffff, 0x54000000},
+ {0x8000008000000000, 0x5f000000},
+ {0x8000008000000001, 0x5f000001},
+ {0x8000008000000002, 0x5f000001},
+ {0x8000008000000004, 0x5f000001},
+ {0x8000008000000008, 0x5f000001},
+ {0x8000008000000010, 0x5f000001},
+ {0x8000008000000020, 0x5f000001},
+ {0x8000009000000000, 0x5f000001},
+ {0x800000a000000000, 0x5f000001},
+ {0x8000008000100000, 0x5f000001},
+ {0x8000000000000400, 0x5f000000},
+ {0x8000000000000401, 0x5f000000}};
+
+ BufferedRawMachineAssemblerTester<int32_t> m;
+ ExternalReference ref =
+ ExternalReference::wasm_uint64_to_float32(m.isolate());
+
+ uint64_t input;
+ float output;
+
+ Node* function = m.ExternalConstant(ref);
+ m.CallCFunction2(MachineType::Pointer(), MachineType::Pointer(),
+ MachineType::Pointer(), function, m.PointerConstant(&input),
+ m.PointerConstant(&output));
+ m.Return(m.Int32Constant(4356));
+
+ for (size_t i = 0; i < arraysize(values); i++) {
+ input = values[i].input;
+ m.Call();
+ CHECK_EQ(values[i].expected, bit_cast<uint32_t>(output));
+ }
+}
+
+TEST(RunCallInt64ToFloat64) {
+ BufferedRawMachineAssemblerTester<int32_t> m;
+ ExternalReference ref = ExternalReference::wasm_int64_to_float64(m.isolate());
+
+ int64_t input;
+ double output;
+
+ Node* function = m.ExternalConstant(ref);
+ m.CallCFunction2(MachineType::Pointer(), MachineType::Pointer(),
+ MachineType::Pointer(), function, m.PointerConstant(&input),
+ m.PointerConstant(&output));
+ m.Return(m.Int32Constant(4356));
+ FOR_INT64_INPUTS(i) {
+ input = *i;
+ m.Call();
+ CHECK_DOUBLE_EQ(static_cast<double>(*i), output);
+ }
+}
+
+TEST(RunCallUint64ToFloat64) {
+ struct {
+ uint64_t input;
+ uint64_t expected;
+ } values[] = {{0x0, 0x0},
+ {0x1, 0x3ff0000000000000},
+ {0xffffffff, 0x41efffffffe00000},
+ {0x1b09788b, 0x41bb09788b000000},
+ {0x4c5fce8, 0x419317f3a0000000},
+ {0xcc0de5bf, 0x41e981bcb7e00000},
+ {0x2, 0x4000000000000000},
+ {0x3, 0x4008000000000000},
+ {0x4, 0x4010000000000000},
+ {0x5, 0x4014000000000000},
+ {0x8, 0x4020000000000000},
+ {0x9, 0x4022000000000000},
+ {0xffffffffffffffff, 0x43f0000000000000},
+ {0xfffffffffffffffe, 0x43f0000000000000},
+ {0xfffffffffffffffd, 0x43f0000000000000},
+ {0x100000000, 0x41f0000000000000},
+ {0xffffffff00000000, 0x43efffffffe00000},
+ {0x1b09788b00000000, 0x43bb09788b000000},
+ {0x4c5fce800000000, 0x439317f3a0000000},
+ {0xcc0de5bf00000000, 0x43e981bcb7e00000},
+ {0x200000000, 0x4200000000000000},
+ {0x300000000, 0x4208000000000000},
+ {0x400000000, 0x4210000000000000},
+ {0x500000000, 0x4214000000000000},
+ {0x800000000, 0x4220000000000000},
+ {0x900000000, 0x4222000000000000},
+ {0x273a798e187937a3, 0x43c39d3cc70c3c9c},
+ {0xece3af835495a16b, 0x43ed9c75f06a92b4},
+ {0xb668ecc11223344, 0x43a6cd1d98224467},
+ {0x9e, 0x4063c00000000000},
+ {0x43, 0x4050c00000000000},
+ {0xaf73, 0x40e5ee6000000000},
+ {0x116b, 0x40b16b0000000000},
+ {0x658ecc, 0x415963b300000000},
+ {0x2b3b4c, 0x41459da600000000},
+ {0x88776655, 0x41e10eeccaa00000},
+ {0x70000000, 0x41dc000000000000},
+ {0x7200000, 0x419c800000000000},
+ {0x7fffffff, 0x41dfffffffc00000},
+ {0x56123761, 0x41d5848dd8400000},
+ {0x7fffff00, 0x41dfffffc0000000},
+ {0x761c4761eeeeeeee, 0x43dd8711d87bbbbc},
+ {0x80000000eeeeeeee, 0x43e00000001dddde},
+ {0x88888888dddddddd, 0x43e11111111bbbbc},
+ {0xa0000000dddddddd, 0x43e40000001bbbbc},
+ {0xddddddddaaaaaaaa, 0x43ebbbbbbbb55555},
+ {0xe0000000aaaaaaaa, 0x43ec000000155555},
+ {0xeeeeeeeeeeeeeeee, 0x43edddddddddddde},
+ {0xfffffffdeeeeeeee, 0x43efffffffbdddde},
+ {0xf0000000dddddddd, 0x43ee0000001bbbbc},
+ {0x7fffffdddddddd, 0x435ffffff7777777},
+ {0x3fffffaaaaaaaa, 0x434fffffd5555555},
+ {0x1fffffaaaaaaaa, 0x433fffffaaaaaaaa},
+ {0xfffff, 0x412ffffe00000000},
+ {0x7ffff, 0x411ffffc00000000},
+ {0x3ffff, 0x410ffff800000000},
+ {0x1ffff, 0x40fffff000000000},
+ {0xffff, 0x40efffe000000000},
+ {0x7fff, 0x40dfffc000000000},
+ {0x3fff, 0x40cfff8000000000},
+ {0x1fff, 0x40bfff0000000000},
+ {0xfff, 0x40affe0000000000},
+ {0x7ff, 0x409ffc0000000000},
+ {0x3ff, 0x408ff80000000000},
+ {0x1ff, 0x407ff00000000000},
+ {0x3fffffffffff, 0x42cfffffffffff80},
+ {0x1fffffffffff, 0x42bfffffffffff00},
+ {0xfffffffffff, 0x42affffffffffe00},
+ {0x7ffffffffff, 0x429ffffffffffc00},
+ {0x3ffffffffff, 0x428ffffffffff800},
+ {0x1ffffffffff, 0x427ffffffffff000},
+ {0x8000008000000000, 0x43e0000010000000},
+ {0x8000008000000001, 0x43e0000010000000},
+ {0x8000000000000400, 0x43e0000000000000},
+ {0x8000000000000401, 0x43e0000000000001},
+ {0x8000000000000402, 0x43e0000000000001},
+ {0x8000000000000404, 0x43e0000000000001},
+ {0x8000000000000408, 0x43e0000000000001},
+ {0x8000000000000410, 0x43e0000000000001},
+ {0x8000000000000420, 0x43e0000000000001},
+ {0x8000000000000440, 0x43e0000000000001},
+ {0x8000000000000480, 0x43e0000000000001},
+ {0x8000000000000500, 0x43e0000000000001},
+ {0x8000000000000600, 0x43e0000000000001}};
+
+ BufferedRawMachineAssemblerTester<int32_t> m;
+ ExternalReference ref =
+ ExternalReference::wasm_uint64_to_float64(m.isolate());
+
+ uint64_t input;
+ double output;
+
+ Node* function = m.ExternalConstant(ref);
+ m.CallCFunction2(MachineType::Pointer(), MachineType::Pointer(),
+ MachineType::Pointer(), function, m.PointerConstant(&input),
+ m.PointerConstant(&output));
+ m.Return(m.Int32Constant(4356));
+
+ for (size_t i = 0; i < arraysize(values); i++) {
+ input = values[i].input;
+ m.Call();
+ CHECK_EQ(values[i].expected, bit_cast<uint64_t>(output));
+ }
+}
+
+TEST(RunCallFloat32ToInt64) {
+ BufferedRawMachineAssemblerTester<int32_t> m;
+ ExternalReference ref = ExternalReference::wasm_float32_to_int64(m.isolate());
+
+ float input;
+ int64_t output;
+
+ Node* function = m.ExternalConstant(ref);
+ m.Return(m.CallCFunction2(
+ MachineType::Int32(), MachineType::Pointer(), MachineType::Pointer(),
+ function, m.PointerConstant(&input), m.PointerConstant(&output)));
+ FOR_FLOAT32_INPUTS(i) {
+ input = *i;
+ if (*i >= static_cast<float>(std::numeric_limits<int64_t>::min()) &&
+ *i < static_cast<float>(std::numeric_limits<int64_t>::max())) {
+ CHECK_EQ(1, m.Call());
+ CHECK_EQ(static_cast<int64_t>(*i), output);
+ } else {
+ CHECK_EQ(0, m.Call());
+ }
+ }
+}
+
+TEST(RunCallFloat32ToUint64) {
+ BufferedRawMachineAssemblerTester<int32_t> m;
+ ExternalReference ref =
+ ExternalReference::wasm_float32_to_uint64(m.isolate());
+
+ float input;
+ uint64_t output;
+
+ Node* function = m.ExternalConstant(ref);
+ m.Return(m.CallCFunction2(
+ MachineType::Int32(), MachineType::Pointer(), MachineType::Pointer(),
+ function, m.PointerConstant(&input), m.PointerConstant(&output)));
+ FOR_FLOAT32_INPUTS(i) {
+ input = *i;
+ if (*i > -1.0 &&
+ *i < static_cast<float>(std::numeric_limits<uint64_t>::max())) {
+ CHECK_EQ(1, m.Call());
+ CHECK_EQ(static_cast<uint64_t>(*i), output);
+ } else {
+ CHECK_EQ(0, m.Call());
+ }
+ }
+}
+
+TEST(RunCallFloat64ToInt64) {
+ BufferedRawMachineAssemblerTester<int32_t> m;
+ ExternalReference ref = ExternalReference::wasm_float64_to_int64(m.isolate());
+
+ double input;
+ int64_t output;
+
+ Node* function = m.ExternalConstant(ref);
+ m.Return(m.CallCFunction2(
+ MachineType::Int32(), MachineType::Pointer(), MachineType::Pointer(),
+ function, m.PointerConstant(&input), m.PointerConstant(&output)));
+ FOR_FLOAT64_INPUTS(i) {
+ input = *i;
+ if (*i >= static_cast<double>(std::numeric_limits<int64_t>::min()) &&
+ *i < static_cast<double>(std::numeric_limits<int64_t>::max())) {
+ CHECK_EQ(1, m.Call());
+ CHECK_EQ(static_cast<int64_t>(*i), output);
+ } else {
+ CHECK_EQ(0, m.Call());
+ }
+ }
+}
+
+TEST(RunCallFloat64ToUint64) {
+ BufferedRawMachineAssemblerTester<int32_t> m;
+ ExternalReference ref =
+ ExternalReference::wasm_float64_to_uint64(m.isolate());
+
+ double input;
+ uint64_t output;
+
+ Node* function = m.ExternalConstant(ref);
+ m.Return(m.CallCFunction2(
+ MachineType::Int32(), MachineType::Pointer(), MachineType::Pointer(),
+ function, m.PointerConstant(&input), m.PointerConstant(&output)));
+ FOR_FLOAT64_INPUTS(i) {
+ input = *i;
+ if (*i > -1.0 &&
+ *i < static_cast<double>(std::numeric_limits<uint64_t>::max())) {
+ CHECK_EQ(1, m.Call());
+ CHECK_EQ(static_cast<uint64_t>(*i), output);
+ } else {
+ CHECK_EQ(0, m.Call());
+ }
+ }
+}
+
+TEST(RunCallInt64Div) {
+ BufferedRawMachineAssemblerTester<int32_t> m;
+ ExternalReference ref = ExternalReference::wasm_int64_div(m.isolate());
+
+ int64_t dst;
+ int64_t src;
+
+ Node* function = m.ExternalConstant(ref);
+ m.Return(m.CallCFunction2(MachineType::Int32(), MachineType::Pointer(),
+ MachineType::Pointer(), function,
+ m.PointerConstant(&dst), m.PointerConstant(&src)));
+ FOR_INT64_INPUTS(i) {
+ FOR_INT64_INPUTS(j) {
+ dst = *i;
+ src = *j;
+ if (src == 0) {
+ CHECK_EQ(0, m.Call());
+ } else if (src == -1 && dst == std::numeric_limits<int64_t>::min()) {
+ CHECK_EQ(-1, m.Call());
+ } else {
+ CHECK_EQ(1, m.Call());
+ CHECK_EQ(*i / *j, dst);
+ }
+ }
+ }
+}
+
+TEST(RunCallInt64Mod) {
+ BufferedRawMachineAssemblerTester<int32_t> m;
+ ExternalReference ref = ExternalReference::wasm_int64_mod(m.isolate());
+
+ int64_t dst;
+ int64_t src;
+
+ Node* function = m.ExternalConstant(ref);
+ m.Return(m.CallCFunction2(MachineType::Int32(), MachineType::Pointer(),
+ MachineType::Pointer(), function,
+ m.PointerConstant(&dst), m.PointerConstant(&src)));
+ FOR_INT64_INPUTS(i) {
+ FOR_INT64_INPUTS(j) {
+ dst = *i;
+ src = *j;
+ if (src == 0) {
+ CHECK_EQ(0, m.Call());
+ } else {
+ CHECK_EQ(1, m.Call());
+ CHECK_EQ(*i % *j, dst);
+ }
+ }
+ }
+}
+
+TEST(RunCallUint64Div) {
+ BufferedRawMachineAssemblerTester<int32_t> m;
+ ExternalReference ref = ExternalReference::wasm_uint64_div(m.isolate());
+
+ uint64_t dst;
+ uint64_t src;
+
+ Node* function = m.ExternalConstant(ref);
+ m.Return(m.CallCFunction2(MachineType::Int32(), MachineType::Pointer(),
+ MachineType::Pointer(), function,
+ m.PointerConstant(&dst), m.PointerConstant(&src)));
+ FOR_UINT64_INPUTS(i) {
+ FOR_UINT64_INPUTS(j) {
+ dst = *i;
+ src = *j;
+ if (src == 0) {
+ CHECK_EQ(0, m.Call());
+ } else {
+ CHECK_EQ(1, m.Call());
+ CHECK_EQ(*i / *j, dst);
+ }
+ }
+ }
+}
+
+TEST(RunCallUint64Mod) {
+ BufferedRawMachineAssemblerTester<int32_t> m;
+ ExternalReference ref = ExternalReference::wasm_uint64_mod(m.isolate());
+
+ uint64_t dst;
+ uint64_t src;
+
+ Node* function = m.ExternalConstant(ref);
+ m.Return(m.CallCFunction2(MachineType::Int32(), MachineType::Pointer(),
+ MachineType::Pointer(), function,
+ m.PointerConstant(&dst), m.PointerConstant(&src)));
+ FOR_UINT64_INPUTS(i) {
+ FOR_UINT64_INPUTS(j) {
+ dst = *i;
+ src = *j;
+ if (src == 0) {
+ CHECK_EQ(0, m.Call());
+ } else {
+ CHECK_EQ(1, m.Call());
+ CHECK_EQ(*i % *j, dst);
+ }
+ }
+ }
+}
+} // namespace compiler
+} // namespace internal
+} // namespace v8
diff --git a/test/cctest/compiler/test-run-inlining.cc b/test/cctest/compiler/test-run-inlining.cc
index f332d74..234060c 100644
--- a/test/cctest/compiler/test-run-inlining.cc
+++ b/test/cctest/compiler/test-run-inlining.cc
@@ -268,7 +268,8 @@
"(function () {"
" var x = 42;"
" function bar(s) { AssertInlineCount(2); return x + s; };"
- " return (function (s,t) { return bar(s) + bar(t); });"
+ " function foo(s, t) { return bar(s) + bar(t); };"
+ " return foo;"
"})();",
kInlineFlags);
@@ -542,33 +543,6 @@
}
-TEST(StrongModeArity) {
- FLAG_strong_mode = true;
- FunctionTester T(
- "(function () {"
- " function foo(x, y) { 'use strong'; return x; }"
- " function bar(x, y) { return foo(x); }"
- " return bar;"
- "})();",
- kInlineFlags);
- T.CheckThrows(T.undefined(), T.undefined());
-}
-
-
-TEST(StrongModeArityOuter) {
- FLAG_strong_mode = true;
- FunctionTester T(
- "(function () {"
- " 'use strong';"
- " function foo(x, y) { return x; }"
- " function bar(x, y) { return foo(x); }"
- " return bar;"
- "})();",
- kInlineFlags);
- T.CheckThrows(T.undefined(), T.undefined());
-}
-
-
TEST(InlineSelfRecursive) {
FunctionTester T(
"(function () {"
diff --git a/test/cctest/compiler/test-run-intrinsics.cc b/test/cctest/compiler/test-run-intrinsics.cc
index 6e9ebf2..6aa5f39 100644
--- a/test/cctest/compiler/test-run-intrinsics.cc
+++ b/test/cctest/compiler/test-run-intrinsics.cc
@@ -34,31 +34,6 @@
}
-#define COUNTER_NAME "hurz"
-
-static int* LookupCounter(const char* name) {
- static int counter = 1234;
- return strcmp(name, COUNTER_NAME) == 0 ? &counter : nullptr;
-}
-
-
-TEST(IncrementStatsCounter) {
- FLAG_native_code_counters = true;
- reinterpret_cast<v8::Isolate*>(CcTest::InitIsolateOnce())
- ->SetCounterFunction(LookupCounter);
- FunctionTester T(
- "(function() { %_IncrementStatsCounter('" COUNTER_NAME "'); })", flags);
- StatsCounter counter(T.main_isolate(), COUNTER_NAME);
- if (!counter.Enabled()) return;
-
- int old_value = *counter.GetInternalPointer();
- T.CheckCall(T.undefined());
- CHECK_EQ(old_value + 1, *counter.GetInternalPointer());
-}
-
-#undef COUNTER_NAME
-
-
TEST(IsArray) {
FunctionTester T("(function(a) { return %_IsArray(a); })", flags);
diff --git a/test/cctest/compiler/test-run-jscalls.cc b/test/cctest/compiler/test-run-jscalls.cc
index c282958..12566c2 100644
--- a/test/cctest/compiler/test-run-jscalls.cc
+++ b/test/cctest/compiler/test-run-jscalls.cc
@@ -129,12 +129,18 @@
}
-TEST(RuntimeCallCPP2) {
+TEST(RuntimeCall) {
FLAG_allow_natives_syntax = true;
- FunctionTester T("(function(a,b) { return %NumberImul(a, b); })");
+ FunctionTester T("(function(a) { return %IsJSReceiver(a); })");
- T.CheckCall(T.Val(2730), T.Val(42), T.Val(65));
- T.CheckCall(T.Val(798), T.Val(42), T.Val(19));
+ 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());
}
diff --git a/test/cctest/compiler/test-run-jsobjects.cc b/test/cctest/compiler/test-run-jsobjects.cc
index 4bf10ca..80a9181 100644
--- a/test/cctest/compiler/test-run-jsobjects.cc
+++ b/test/cctest/compiler/test-run-jsobjects.cc
@@ -16,7 +16,7 @@
CHECK(arguments->IsJSObject() && !arguments->IsJSArray());
CHECK(JSObject::cast(*arguments)->HasSloppyArgumentsElements());
Handle<String> l = T.isolate->factory()->length_string();
- Handle<Object> length = JSObject::GetProperty(arguments, l).ToHandleChecked();
+ Handle<Object> length = Object::GetProperty(arguments, l).ToHandleChecked();
CHECK_EQ(4, length->Number());
}
@@ -29,7 +29,7 @@
CHECK(arguments->IsJSObject() && !arguments->IsJSArray());
CHECK(!JSObject::cast(*arguments)->HasSloppyArgumentsElements());
Handle<String> l = T.isolate->factory()->length_string();
- Handle<Object> length = JSObject::GetProperty(arguments, l).ToHandleChecked();
+ Handle<Object> length = Object::GetProperty(arguments, l).ToHandleChecked();
CHECK_EQ(4, length->Number());
}
@@ -42,7 +42,7 @@
CHECK(arguments->IsJSObject() && arguments->IsJSArray());
CHECK(!JSObject::cast(*arguments)->HasSloppyArgumentsElements());
Handle<String> l = T.isolate->factory()->length_string();
- Handle<Object> length = JSObject::GetProperty(arguments, l).ToHandleChecked();
+ Handle<Object> length = Object::GetProperty(arguments, l).ToHandleChecked();
CHECK_EQ(3, length->Number());
}
diff --git a/test/cctest/compiler/test-run-jsops.cc b/test/cctest/compiler/test-run-jsops.cc
index 9a2c467..b68fc1c 100644
--- a/test/cctest/compiler/test-run-jsops.cc
+++ b/test/cctest/compiler/test-run-jsops.cc
@@ -394,17 +394,6 @@
}
-TEST(GlobalStoreSloppy) {
- FLAG_legacy_const = true;
- FunctionTester T("(function(a,b) { g = a + b; return g; })");
-
- T.CheckCall(T.Val(33), T.Val(22), T.Val(11));
- CompileRun("delete g");
- CompileRun("const g = 23");
- T.CheckCall(T.Val(23), T.Val(55), T.Val(44));
-}
-
-
TEST(GlobalStoreStrict) {
FunctionTester T("(function(a,b) { 'use strict'; g = a + b; return g; })");
diff --git a/test/cctest/compiler/test-run-machops.cc b/test/cctest/compiler/test-run-machops.cc
index fba9e0e..2bfe124 100644
--- a/test/cctest/compiler/test-run-machops.cc
+++ b/test/cctest/compiler/test-run-machops.cc
@@ -1197,7 +1197,7 @@
p1 = *j;
p2 = *j - 5;
CHECK_EQ(magic, m.Call());
- CheckDoubleEq(p1, p2);
+ CHECK_DOUBLE_EQ(p1, p2);
}
}
}
@@ -1224,7 +1224,7 @@
p1 = *j;
p2 = *j - 5;
CHECK_EQ(magic, m.Call());
- CheckDoubleEq(p1, p2);
+ CHECK_DOUBLE_EQ(p1, p2);
}
}
}
@@ -3658,10 +3658,7 @@
m.Return(m.Float32Add(m.Parameter(0), m.Parameter(1)));
FOR_FLOAT32_INPUTS(i) {
- FOR_FLOAT32_INPUTS(j) {
- volatile float expected = *i + *j;
- CheckFloatEq(expected, m.Call(*i, *j));
- }
+ FOR_FLOAT32_INPUTS(j) { CHECK_FLOAT_EQ(*i + *j, m.Call(*i, *j)); }
}
}
@@ -3672,10 +3669,7 @@
m.Return(m.Float32Sub(m.Parameter(0), m.Parameter(1)));
FOR_FLOAT32_INPUTS(i) {
- FOR_FLOAT32_INPUTS(j) {
- volatile float expected = *i - *j;
- CheckFloatEq(expected, m.Call(*i, *j));
- }
+ FOR_FLOAT32_INPUTS(j) { CHECK_FLOAT_EQ(*i - *j, m.Call(*i, *j)); }
}
}
@@ -3686,10 +3680,7 @@
m.Return(m.Float32Mul(m.Parameter(0), m.Parameter(1)));
FOR_FLOAT32_INPUTS(i) {
- FOR_FLOAT32_INPUTS(j) {
- volatile float expected = *i * *j;
- CheckFloatEq(expected, m.Call(*i, *j));
- }
+ FOR_FLOAT32_INPUTS(j) { CHECK_FLOAT_EQ(*i * *j, m.Call(*i, *j)); }
}
}
@@ -3700,10 +3691,7 @@
m.Return(m.Float32Div(m.Parameter(0), m.Parameter(1)));
FOR_FLOAT32_INPUTS(i) {
- FOR_FLOAT32_INPUTS(j) {
- volatile float expected = *i / *j;
- CheckFloatEq(expected, m.Call(*i, *j));
- }
+ FOR_FLOAT32_INPUTS(j) { CHECK_FLOAT_EQ(*i / *j, m.Call(*i, *j)); }
}
}
@@ -3714,10 +3702,7 @@
m.Return(m.Float64Add(m.Parameter(0), m.Parameter(1)));
FOR_FLOAT64_INPUTS(i) {
- FOR_FLOAT64_INPUTS(j) {
- volatile double expected = *i + *j;
- CheckDoubleEq(expected, m.Call(*i, *j));
- }
+ FOR_FLOAT64_INPUTS(j) { CHECK_DOUBLE_EQ(*i + *j, m.Call(*i, *j)); }
}
}
@@ -3728,10 +3713,7 @@
m.Return(m.Float64Sub(m.Parameter(0), m.Parameter(1)));
FOR_FLOAT64_INPUTS(i) {
- FOR_FLOAT64_INPUTS(j) {
- volatile double expected = *i - *j;
- CheckDoubleEq(expected, m.Call(*i, *j));
- }
+ FOR_FLOAT64_INPUTS(j) { CHECK_DOUBLE_EQ(*i - *j, m.Call(*i, *j)); }
}
}
@@ -3742,10 +3724,7 @@
m.Return(m.Float64Mul(m.Parameter(0), m.Parameter(1)));
FOR_FLOAT64_INPUTS(i) {
- FOR_FLOAT64_INPUTS(j) {
- volatile double expected = *i * *j;
- CheckDoubleEq(expected, m.Call(*i, *j));
- }
+ FOR_FLOAT64_INPUTS(j) { CHECK_DOUBLE_EQ(*i * *j, m.Call(*i, *j)); }
}
}
@@ -3756,10 +3735,7 @@
m.Return(m.Float64Div(m.Parameter(0), m.Parameter(1)));
FOR_FLOAT64_INPUTS(i) {
- FOR_FLOAT64_INPUTS(j) {
- volatile double expected = *i / *j;
- CheckDoubleEq(expected, m.Call(*i, *j));
- }
+ FOR_FLOAT64_INPUTS(j) { CHECK_DOUBLE_EQ(*i / *j, m.Call(*i, *j)); }
}
}
@@ -3770,7 +3746,7 @@
m.Return(m.Float64Mod(m.Parameter(0), m.Parameter(1)));
FOR_FLOAT64_INPUTS(i) {
- FOR_FLOAT64_INPUTS(j) { CheckDoubleEq(modulo(*i, *j), m.Call(*i, *j)); }
+ FOR_FLOAT64_INPUTS(j) { CHECK_DOUBLE_EQ(modulo(*i, *j), m.Call(*i, *j)); }
}
}
@@ -3816,10 +3792,7 @@
bt.AddReturn(m.Float32Add(bt.param0, bt.param1));
FOR_FLOAT32_INPUTS(pl) {
- FOR_FLOAT32_INPUTS(pr) {
- float expected = *pl + *pr;
- CheckFloatEq(expected, bt.call(*pl, *pr));
- }
+ FOR_FLOAT32_INPUTS(pr) { CHECK_FLOAT_EQ(*pl + *pr, bt.call(*pl, *pr)); }
}
}
@@ -3831,10 +3804,7 @@
bt.AddReturn(m.Float64Add(bt.param0, bt.param1));
FOR_FLOAT64_INPUTS(pl) {
- FOR_FLOAT64_INPUTS(pr) {
- double expected = *pl + *pr;
- CheckDoubleEq(expected, bt.call(*pl, *pr));
- }
+ FOR_FLOAT64_INPUTS(pr) { CHECK_DOUBLE_EQ(*pl + *pr, bt.call(*pl, *pr)); }
}
}
@@ -3848,8 +3818,7 @@
FOR_FLOAT32_INPUTS(pl) {
FOR_FLOAT32_INPUTS(pr) {
- double expected = *pl > *pr ? *pl : *pr;
- CheckDoubleEq(expected, bt.call(*pl, *pr));
+ CHECK_DOUBLE_EQ(*pl > *pr ? *pl : *pr, bt.call(*pl, *pr));
}
}
}
@@ -3864,8 +3833,7 @@
FOR_FLOAT64_INPUTS(pl) {
FOR_FLOAT64_INPUTS(pr) {
- double expected = *pl > *pr ? *pl : *pr;
- CheckDoubleEq(expected, bt.call(*pl, *pr));
+ CHECK_DOUBLE_EQ(*pl > *pr ? *pl : *pr, bt.call(*pl, *pr));
}
}
}
@@ -3880,8 +3848,7 @@
FOR_FLOAT32_INPUTS(pl) {
FOR_FLOAT32_INPUTS(pr) {
- double expected = *pl < *pr ? *pl : *pr;
- CheckDoubleEq(expected, bt.call(*pl, *pr));
+ CHECK_DOUBLE_EQ(*pl < *pr ? *pl : *pr, bt.call(*pl, *pr));
}
}
}
@@ -3896,8 +3863,7 @@
FOR_FLOAT64_INPUTS(pl) {
FOR_FLOAT64_INPUTS(pr) {
- double expected = *pl < *pr ? *pl : *pr;
- CheckDoubleEq(expected, bt.call(*pl, *pr));
+ CHECK_DOUBLE_EQ(*pl < *pr ? *pl : *pr, bt.call(*pl, *pr));
}
}
}
@@ -3910,10 +3876,7 @@
bt.AddReturn(m.Float32Sub(bt.param0, bt.param1));
FOR_FLOAT32_INPUTS(pl) {
- FOR_FLOAT32_INPUTS(pr) {
- float expected = *pl - *pr;
- CheckFloatEq(expected, bt.call(*pl, *pr));
- }
+ FOR_FLOAT32_INPUTS(pr) { CHECK_FLOAT_EQ(*pl - *pr, bt.call(*pl, *pr)); }
}
}
@@ -3923,10 +3886,7 @@
BufferedRawMachineAssemblerTester<float> m(MachineType::Float32());
m.Return(m.Float32Sub(m.Float32Constant(*i), m.Parameter(0)));
- FOR_FLOAT32_INPUTS(j) {
- volatile float expected = *i - *j;
- CheckFloatEq(expected, m.Call(*j));
- }
+ FOR_FLOAT32_INPUTS(j) { CHECK_FLOAT_EQ(*i - *j, m.Call(*j)); }
}
}
@@ -3936,10 +3896,7 @@
BufferedRawMachineAssemblerTester<float> m(MachineType::Float32());
m.Return(m.Float32Sub(m.Parameter(0), m.Float32Constant(*i)));
- FOR_FLOAT32_INPUTS(j) {
- volatile float expected = *j - *i;
- CheckFloatEq(expected, m.Call(*j));
- }
+ FOR_FLOAT32_INPUTS(j) { CHECK_FLOAT_EQ(*j - *i, m.Call(*j)); }
}
}
@@ -3949,7 +3906,7 @@
BufferedRawMachineAssemblerTester<double> m(MachineType::Float64());
m.Return(m.Float64Sub(m.Float64Constant(*i), m.Parameter(0)));
- FOR_FLOAT64_INPUTS(j) { CheckFloatEq(*i - *j, m.Call(*j)); }
+ FOR_FLOAT64_INPUTS(j) { CHECK_FLOAT_EQ(*i - *j, m.Call(*j)); }
}
}
@@ -3959,7 +3916,7 @@
BufferedRawMachineAssemblerTester<double> m(MachineType::Float64());
m.Return(m.Float64Sub(m.Parameter(0), m.Float64Constant(*i)));
- FOR_FLOAT64_INPUTS(j) { CheckFloatEq(*j - *i, m.Call(*j)); }
+ FOR_FLOAT64_INPUTS(j) { CHECK_FLOAT_EQ(*j - *i, m.Call(*j)); }
}
}
@@ -3973,7 +3930,7 @@
FOR_FLOAT64_INPUTS(pl) {
FOR_FLOAT64_INPUTS(pr) {
double expected = *pl - *pr;
- CheckDoubleEq(expected, bt.call(*pl, *pr));
+ CHECK_DOUBLE_EQ(expected, bt.call(*pl, *pr));
}
}
}
@@ -3986,10 +3943,7 @@
bt.AddReturn(m.Float32Mul(bt.param0, bt.param1));
FOR_FLOAT32_INPUTS(pl) {
- FOR_FLOAT32_INPUTS(pr) {
- float expected = *pl * *pr;
- CheckFloatEq(expected, bt.call(*pl, *pr));
- }
+ FOR_FLOAT32_INPUTS(pr) { CHECK_FLOAT_EQ(*pl * *pr, bt.call(*pl, *pr)); }
}
}
@@ -4003,7 +3957,7 @@
FOR_FLOAT64_INPUTS(pl) {
FOR_FLOAT64_INPUTS(pr) {
double expected = *pl * *pr;
- CheckDoubleEq(expected, bt.call(*pl, *pr));
+ CHECK_DOUBLE_EQ(expected, bt.call(*pl, *pr));
}
}
}
@@ -4018,7 +3972,7 @@
FOR_FLOAT64_INPUTS(i) {
FOR_FLOAT64_INPUTS(j) {
FOR_FLOAT64_INPUTS(k) {
- CheckDoubleEq((*i * *j) + *k, m.Call(*i, *j, *k));
+ CHECK_DOUBLE_EQ((*i * *j) + *k, m.Call(*i, *j, *k));
}
}
}
@@ -4034,7 +3988,7 @@
FOR_FLOAT64_INPUTS(i) {
FOR_FLOAT64_INPUTS(j) {
FOR_FLOAT64_INPUTS(k) {
- CheckDoubleEq(*i + (*j * *k), m.Call(*i, *j, *k));
+ CHECK_DOUBLE_EQ(*i + (*j * *k), m.Call(*i, *j, *k));
}
}
}
@@ -4050,7 +4004,7 @@
FOR_FLOAT64_INPUTS(i) {
FOR_FLOAT64_INPUTS(j) {
FOR_FLOAT64_INPUTS(k) {
- CheckDoubleEq((*i * *j) - *k, m.Call(*i, *j, *k));
+ CHECK_DOUBLE_EQ((*i * *j) - *k, m.Call(*i, *j, *k));
}
}
}
@@ -4066,7 +4020,7 @@
FOR_FLOAT64_INPUTS(i) {
FOR_FLOAT64_INPUTS(j) {
FOR_FLOAT64_INPUTS(k) {
- CheckDoubleEq(*i - (*j * *k), m.Call(*i, *j, *k));
+ CHECK_DOUBLE_EQ(*i - (*j * *k), m.Call(*i, *j, *k));
}
}
}
@@ -4078,7 +4032,7 @@
BufferedRawMachineAssemblerTester<double> m(MachineType::Float64());
m.Return(m.Float64Mul(m.Float64Constant(*i), m.Parameter(0)));
- FOR_FLOAT64_INPUTS(j) { CheckFloatEq(*i * *j, m.Call(*j)); }
+ FOR_FLOAT64_INPUTS(j) { CHECK_FLOAT_EQ(*i * *j, m.Call(*j)); }
}
}
@@ -4088,7 +4042,7 @@
BufferedRawMachineAssemblerTester<double> m(MachineType::Float64());
m.Return(m.Float64Mul(m.Parameter(0), m.Float64Constant(*i)));
- FOR_FLOAT64_INPUTS(j) { CheckFloatEq(*j * *i, m.Call(*j)); }
+ FOR_FLOAT64_INPUTS(j) { CHECK_FLOAT_EQ(*j * *i, m.Call(*j)); }
}
}
@@ -4100,10 +4054,7 @@
bt.AddReturn(m.Float32Div(bt.param0, bt.param1));
FOR_FLOAT32_INPUTS(pl) {
- FOR_FLOAT32_INPUTS(pr) {
- float expected = *pl / *pr;
- CheckFloatEq(expected, bt.call(*pl, *pr));
- }
+ FOR_FLOAT32_INPUTS(pr) { CHECK_FLOAT_EQ(*pl / *pr, bt.call(*pl, *pr)); }
}
}
@@ -4115,10 +4066,7 @@
bt.AddReturn(m.Float64Div(bt.param0, bt.param1));
FOR_FLOAT64_INPUTS(pl) {
- FOR_FLOAT64_INPUTS(pr) {
- double expected = *pl / *pr;
- CheckDoubleEq(expected, bt.call(*pl, *pr));
- }
+ FOR_FLOAT64_INPUTS(pr) { CHECK_DOUBLE_EQ(*pl / *pr, bt.call(*pl, *pr)); }
}
}
@@ -4130,11 +4078,7 @@
bt.AddReturn(m.Float64Mod(bt.param0, bt.param1));
FOR_FLOAT64_INPUTS(i) {
- FOR_FLOAT64_INPUTS(j) {
- double expected = modulo(*i, *j);
- double found = bt.call(*i, *j);
- CheckDoubleEq(expected, found);
- }
+ FOR_FLOAT64_INPUTS(j) { CHECK_DOUBLE_EQ(modulo(*i, *j), bt.call(*i, *j)); }
}
}
@@ -4143,7 +4087,7 @@
int32_t magic = 0x986234;
BufferedRawMachineAssemblerTester<double> m;
m.Return(m.ChangeInt32ToFloat64(m.Int32Constant(magic)));
- CheckDoubleEq(static_cast<double>(magic), m.Call());
+ CHECK_DOUBLE_EQ(static_cast<double>(magic), m.Call());
}
@@ -4151,7 +4095,7 @@
BufferedRawMachineAssemblerTester<double> m(MachineType::Int32());
m.Return(m.ChangeInt32ToFloat64(m.Parameter(0)));
- FOR_INT32_INPUTS(i) { CheckDoubleEq(static_cast<double>(*i), m.Call(*i)); }
+ FOR_INT32_INPUTS(i) { CHECK_DOUBLE_EQ(static_cast<double>(*i), m.Call(*i)); }
}
@@ -4159,7 +4103,7 @@
BufferedRawMachineAssemblerTester<double> m(MachineType::Uint32());
m.Return(m.ChangeUint32ToFloat64(m.Parameter(0)));
- FOR_UINT32_INPUTS(i) { CheckDoubleEq(static_cast<double>(*i), m.Call(*i)); }
+ FOR_UINT32_INPUTS(i) { CHECK_DOUBLE_EQ(static_cast<double>(*i), m.Call(*i)); }
}
@@ -4169,7 +4113,7 @@
FOR_FLOAT32_INPUTS(i) {
if (*i <= static_cast<float>(std::numeric_limits<int32_t>::max()) &&
*i >= static_cast<float>(std::numeric_limits<int32_t>::min())) {
- CheckFloatEq(static_cast<int32_t>(*i), m.Call(*i));
+ CHECK_FLOAT_EQ(static_cast<int32_t>(*i), m.Call(*i));
}
}
}
@@ -4193,7 +4137,7 @@
FOR_FLOAT32_INPUTS(i) {
if (*i <= static_cast<float>(std::numeric_limits<uint32_t>::max()) &&
*i >= static_cast<float>(std::numeric_limits<uint32_t>::min())) {
- CheckFloatEq(static_cast<uint32_t>(*i), m.Call(*i));
+ CHECK_FLOAT_EQ(static_cast<uint32_t>(*i), m.Call(*i));
}
}
}
@@ -4250,9 +4194,262 @@
m.Return(m.TruncateFloat64ToFloat32(m.Parameter(0)));
- FOR_FLOAT64_INPUTS(i) { CheckFloatEq(DoubleToFloat32(*i), m.Call(*i)); }
+ FOR_FLOAT64_INPUTS(i) { CHECK_FLOAT_EQ(DoubleToFloat32(*i), m.Call(*i)); }
}
+uint64_t ToInt64(uint32_t low, uint32_t high) {
+ return (static_cast<uint64_t>(high) << 32) | static_cast<uint64_t>(low);
+}
+
+#if V8_TARGET_ARCH_32_BIT && !V8_TARGET_ARCH_MIPS && !V8_TARGET_ARCH_X87
+TEST(RunInt32PairAdd) {
+ BufferedRawMachineAssemblerTester<int32_t> m(
+ MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32(),
+ MachineType::Uint32());
+
+ uint32_t high;
+ uint32_t low;
+
+ Node* PairAdd = m.Int32PairAdd(m.Parameter(0), m.Parameter(1), m.Parameter(2),
+ m.Parameter(3));
+
+ m.StoreToPointer(&low, MachineRepresentation::kWord32,
+ m.Projection(0, PairAdd));
+ m.StoreToPointer(&high, MachineRepresentation::kWord32,
+ m.Projection(1, PairAdd));
+ m.Return(m.Int32Constant(74));
+
+ FOR_UINT64_INPUTS(i) {
+ FOR_UINT64_INPUTS(j) {
+ m.Call(static_cast<uint32_t>(*i & 0xffffffff),
+ static_cast<uint32_t>(*i >> 32),
+ static_cast<uint32_t>(*j & 0xffffffff),
+ static_cast<uint32_t>(*j >> 32));
+ CHECK_EQ(*i + *j, ToInt64(low, high));
+ }
+ }
+}
+
+void TestInt32PairAddWithSharedInput(int a, int b, int c, int d) {
+ BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Uint32(),
+ MachineType::Uint32());
+
+ uint32_t high;
+ uint32_t low;
+
+ Node* PairAdd = m.Int32PairAdd(m.Parameter(a), m.Parameter(b), m.Parameter(c),
+ m.Parameter(d));
+
+ m.StoreToPointer(&low, MachineRepresentation::kWord32,
+ m.Projection(0, PairAdd));
+ m.StoreToPointer(&high, MachineRepresentation::kWord32,
+ m.Projection(1, PairAdd));
+ m.Return(m.Int32Constant(74));
+
+ FOR_UINT32_INPUTS(i) {
+ FOR_UINT32_INPUTS(j) {
+ m.Call(*i, *j);
+ uint32_t inputs[] = {*i, *j};
+ CHECK_EQ(ToInt64(inputs[a], inputs[b]) + ToInt64(inputs[c], inputs[d]),
+ ToInt64(low, high));
+ }
+ }
+}
+
+TEST(RunInt32PairAddWithSharedInput) {
+ TestInt32PairAddWithSharedInput(0, 0, 0, 0);
+ TestInt32PairAddWithSharedInput(1, 0, 0, 0);
+ TestInt32PairAddWithSharedInput(0, 1, 0, 0);
+ TestInt32PairAddWithSharedInput(0, 0, 1, 0);
+ TestInt32PairAddWithSharedInput(0, 0, 0, 1);
+ TestInt32PairAddWithSharedInput(1, 1, 0, 0);
+}
+
+TEST(RunInt32PairSub) {
+ BufferedRawMachineAssemblerTester<int32_t> m(
+ MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32(),
+ MachineType::Uint32());
+
+ uint32_t high;
+ uint32_t low;
+
+ Node* PairSub = m.Int32PairSub(m.Parameter(0), m.Parameter(1), m.Parameter(2),
+ m.Parameter(3));
+
+ m.StoreToPointer(&low, MachineRepresentation::kWord32,
+ m.Projection(0, PairSub));
+ m.StoreToPointer(&high, MachineRepresentation::kWord32,
+ m.Projection(1, PairSub));
+ m.Return(m.Int32Constant(74));
+
+ FOR_UINT64_INPUTS(i) {
+ FOR_UINT64_INPUTS(j) {
+ m.Call(static_cast<uint32_t>(*i & 0xffffffff),
+ static_cast<uint32_t>(*i >> 32),
+ static_cast<uint32_t>(*j & 0xffffffff),
+ static_cast<uint32_t>(*j >> 32));
+ CHECK_EQ(*i - *j, ToInt64(low, high));
+ }
+ }
+}
+
+void TestInt32PairSubWithSharedInput(int a, int b, int c, int d) {
+ BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Uint32(),
+ MachineType::Uint32());
+
+ uint32_t high;
+ uint32_t low;
+
+ Node* PairSub = m.Int32PairSub(m.Parameter(a), m.Parameter(b), m.Parameter(c),
+ m.Parameter(d));
+
+ m.StoreToPointer(&low, MachineRepresentation::kWord32,
+ m.Projection(0, PairSub));
+ m.StoreToPointer(&high, MachineRepresentation::kWord32,
+ m.Projection(1, PairSub));
+ m.Return(m.Int32Constant(74));
+
+ FOR_UINT32_INPUTS(i) {
+ FOR_UINT32_INPUTS(j) {
+ m.Call(*i, *j);
+ uint32_t inputs[] = {*i, *j};
+ CHECK_EQ(ToInt64(inputs[a], inputs[b]) - ToInt64(inputs[c], inputs[d]),
+ ToInt64(low, high));
+ }
+ }
+}
+
+TEST(RunInt32PairSubWithSharedInput) {
+ TestInt32PairSubWithSharedInput(0, 0, 0, 0);
+ TestInt32PairSubWithSharedInput(1, 0, 0, 0);
+ TestInt32PairSubWithSharedInput(0, 1, 0, 0);
+ TestInt32PairSubWithSharedInput(0, 0, 1, 0);
+ TestInt32PairSubWithSharedInput(0, 0, 0, 1);
+ TestInt32PairSubWithSharedInput(1, 1, 0, 0);
+}
+
+TEST(RunInt32PairMul) {
+ BufferedRawMachineAssemblerTester<int32_t> m(
+ MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32(),
+ MachineType::Uint32());
+
+ uint32_t high;
+ uint32_t low;
+
+ Node* PairMul = m.Int32PairMul(m.Parameter(0), m.Parameter(1), m.Parameter(2),
+ m.Parameter(3));
+
+ m.StoreToPointer(&low, MachineRepresentation::kWord32,
+ m.Projection(0, PairMul));
+ m.StoreToPointer(&high, MachineRepresentation::kWord32,
+ m.Projection(1, PairMul));
+ m.Return(m.Int32Constant(74));
+
+ FOR_UINT64_INPUTS(i) {
+ FOR_UINT64_INPUTS(j) {
+ m.Call(static_cast<uint32_t>(*i & 0xffffffff),
+ static_cast<uint32_t>(*i >> 32),
+ static_cast<uint32_t>(*j & 0xffffffff),
+ static_cast<uint32_t>(*j >> 32));
+ CHECK_EQ(*i * *j, ToInt64(low, high));
+ }
+ }
+}
+
+void TestInt32PairMulWithSharedInput(int a, int b, int c, int d) {
+ BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Uint32(),
+ MachineType::Uint32());
+
+ uint32_t high;
+ uint32_t low;
+
+ Node* PairMul = m.Int32PairMul(m.Parameter(a), m.Parameter(b), m.Parameter(c),
+ m.Parameter(d));
+
+ m.StoreToPointer(&low, MachineRepresentation::kWord32,
+ m.Projection(0, PairMul));
+ m.StoreToPointer(&high, MachineRepresentation::kWord32,
+ m.Projection(1, PairMul));
+ m.Return(m.Int32Constant(74));
+
+ FOR_UINT32_INPUTS(i) {
+ FOR_UINT32_INPUTS(j) {
+ m.Call(*i, *j);
+ uint32_t inputs[] = {*i, *j};
+ CHECK_EQ(ToInt64(inputs[a], inputs[b]) * ToInt64(inputs[c], inputs[d]),
+ ToInt64(low, high));
+ }
+ }
+}
+
+TEST(RunInt32PairMulWithSharedInput) {
+ TestInt32PairMulWithSharedInput(0, 0, 0, 0);
+ TestInt32PairMulWithSharedInput(1, 0, 0, 0);
+ TestInt32PairMulWithSharedInput(0, 1, 0, 0);
+ TestInt32PairMulWithSharedInput(0, 0, 1, 0);
+ TestInt32PairMulWithSharedInput(0, 0, 0, 1);
+ TestInt32PairMulWithSharedInput(1, 1, 0, 0);
+ TestInt32PairMulWithSharedInput(0, 1, 1, 0);
+}
+
+TEST(RunWord32PairShl) {
+ BufferedRawMachineAssemblerTester<int32_t> m(
+ MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32());
+
+ uint32_t high;
+ uint32_t low;
+
+ Node* PairAdd =
+ m.Word32PairShl(m.Parameter(0), m.Parameter(1), m.Parameter(2));
+
+ m.StoreToPointer(&low, MachineRepresentation::kWord32,
+ m.Projection(0, PairAdd));
+ m.StoreToPointer(&high, MachineRepresentation::kWord32,
+ m.Projection(1, PairAdd));
+ m.Return(m.Int32Constant(74));
+
+ FOR_UINT64_INPUTS(i) {
+ for (uint32_t j = 0; j < 64; j++) {
+ m.Call(static_cast<uint32_t>(*i & 0xffffffff),
+ static_cast<uint32_t>(*i >> 32), j);
+ CHECK_EQ(*i << j, ToInt64(low, high));
+ }
+ }
+}
+
+void TestWord32PairShlWithSharedInput(int a, int b) {
+ BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Uint32(),
+ MachineType::Uint32());
+
+ uint32_t high;
+ uint32_t low;
+
+ Node* PairAdd =
+ m.Word32PairShl(m.Parameter(a), m.Parameter(b), m.Parameter(1));
+
+ m.StoreToPointer(&low, MachineRepresentation::kWord32,
+ m.Projection(0, PairAdd));
+ m.StoreToPointer(&high, MachineRepresentation::kWord32,
+ m.Projection(1, PairAdd));
+ m.Return(m.Int32Constant(74));
+
+ FOR_UINT32_INPUTS(i) {
+ for (uint32_t j = 0; j < 64; j++) {
+ m.Call(*i, j);
+ uint32_t inputs[] = {*i, j};
+ CHECK_EQ(ToInt64(inputs[a], inputs[b]) << j, ToInt64(low, high));
+ }
+ }
+}
+
+TEST(RunWord32PairShlWithSharedInput) {
+ TestWord32PairShlWithSharedInput(0, 0);
+ TestWord32PairShlWithSharedInput(0, 1);
+ TestWord32PairShlWithSharedInput(1, 0);
+ TestWord32PairShlWithSharedInput(1, 1);
+}
+
+#endif
TEST(RunDeadChangeFloat64ToInt32) {
RawMachineAssemblerTester<int32_t> m;
@@ -5298,7 +5495,9 @@
m.Return(m.ChangeFloat32ToFloat64(m.Parameter(0)));
- FOR_FLOAT32_INPUTS(i) { CheckDoubleEq(static_cast<double>(*i), m.Call(*i)); }
+ FOR_FLOAT32_INPUTS(i) {
+ CHECK_DOUBLE_EQ(static_cast<double>(*i), m.Call(*i));
+ }
}
@@ -5306,7 +5505,7 @@
FOR_FLOAT32_INPUTS(i) {
BufferedRawMachineAssemblerTester<float> m;
m.Return(m.Float32Constant(*i));
- CheckFloatEq(*i, m.Call());
+ CHECK_FLOAT_EQ(*i, m.Call());
}
}
@@ -5340,7 +5539,7 @@
double expected = bit_cast<double>(
(bit_cast<uint64_t>(*i) & ~(V8_UINT64_C(0xFFFFFFFF))) |
(static_cast<uint64_t>(bit_cast<uint32_t>(*j))));
- CheckDoubleEq(expected, m.Call(*i, *j));
+ CHECK_DOUBLE_EQ(expected, m.Call(*i, *j));
}
}
}
@@ -5355,7 +5554,7 @@
uint64_t expected = (bit_cast<uint64_t>(*i) & 0xFFFFFFFF) |
(static_cast<uint64_t>(*j) << 32);
- CheckDoubleEq(bit_cast<double>(expected), m.Call(*i, *j));
+ CHECK_DOUBLE_EQ(bit_cast<double>(expected), m.Call(*i, *j));
}
}
}
@@ -5364,14 +5563,14 @@
TEST(RunFloat32Abs) {
BufferedRawMachineAssemblerTester<float> m(MachineType::Float32());
m.Return(m.Float32Abs(m.Parameter(0)));
- FOR_FLOAT32_INPUTS(i) { CheckFloatEq(std::abs(*i), m.Call(*i)); }
+ FOR_FLOAT32_INPUTS(i) { CHECK_FLOAT_EQ(std::abs(*i), m.Call(*i)); }
}
TEST(RunFloat64Abs) {
BufferedRawMachineAssemblerTester<double> m(MachineType::Float64());
m.Return(m.Float64Abs(m.Parameter(0)));
- FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(std::abs(*i), m.Call(*i)); }
+ FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(std::abs(*i), m.Call(*i)); }
}
@@ -5479,7 +5678,7 @@
m.Return(m.Float32RoundDown(m.Parameter(0)));
- FOR_FLOAT32_INPUTS(i) { CheckFloatEq(floorf(*i), m.Call(*i)); }
+ FOR_FLOAT32_INPUTS(i) { CHECK_FLOAT_EQ(floorf(*i), m.Call(*i)); }
}
@@ -5489,7 +5688,7 @@
m.Return(m.Float64RoundDown(m.Parameter(0)));
- FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(floor(*i), m.Call(*i)); }
+ FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(floor(*i), m.Call(*i)); }
}
@@ -5511,7 +5710,7 @@
if (!m.machine()->Float32RoundUp().IsSupported()) return;
m.Return(m.Float32RoundUp(m.Parameter(0)));
- FOR_FLOAT32_INPUTS(i) { CheckFloatEq(ceilf(*i), m.Call(*i)); }
+ FOR_FLOAT32_INPUTS(i) { CHECK_FLOAT_EQ(ceilf(*i), m.Call(*i)); }
}
@@ -5520,7 +5719,7 @@
if (!m.machine()->Float64RoundUp().IsSupported()) return;
m.Return(m.Float64RoundUp(m.Parameter(0)));
- FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(ceil(*i), m.Call(*i)); }
+ FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(ceil(*i), m.Call(*i)); }
}
@@ -5529,7 +5728,7 @@
if (!m.machine()->Float32RoundTiesEven().IsSupported()) return;
m.Return(m.Float32RoundTiesEven(m.Parameter(0)));
- FOR_FLOAT32_INPUTS(i) { CheckFloatEq(nearbyint(*i), m.Call(*i)); }
+ FOR_FLOAT32_INPUTS(i) { CHECK_FLOAT_EQ(nearbyint(*i), m.Call(*i)); }
}
@@ -5538,7 +5737,7 @@
if (!m.machine()->Float64RoundTiesEven().IsSupported()) return;
m.Return(m.Float64RoundTiesEven(m.Parameter(0)));
- FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(nearbyint(*i), m.Call(*i)); }
+ FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(nearbyint(*i), m.Call(*i)); }
}
@@ -5548,7 +5747,7 @@
m.Return(m.Float32RoundTruncate(m.Parameter(0)));
- FOR_FLOAT32_INPUTS(i) { CheckFloatEq(truncf(*i), m.Call(*i)); }
+ FOR_FLOAT32_INPUTS(i) { CHECK_FLOAT_EQ(truncf(*i), m.Call(*i)); }
}
@@ -5653,79 +5852,6 @@
}
#endif // USE_SIMULATOR
-template <typename T>
-void TestExternalReferenceFunction(
- BufferedRawMachineAssemblerTester<int32_t>* m, ExternalReference ref,
- T (*comparison)(T)) {
- T parameter;
-
- Node* function = m->ExternalConstant(ref);
- m->CallCFunction1(MachineType::Pointer(), MachineType::Pointer(), function,
- m->PointerConstant(¶meter));
- m->Return(m->Int32Constant(4356));
- FOR_FLOAT64_INPUTS(i) {
- parameter = *i;
- m->Call();
- CheckDoubleEq(comparison(*i), parameter);
- }
-}
-
-TEST(RunCallExternalReferenceF32Trunc) {
- BufferedRawMachineAssemblerTester<int32_t> m;
- ExternalReference ref =
- ExternalReference::f32_trunc_wrapper_function(m.isolate());
- TestExternalReferenceFunction<float>(&m, ref, truncf);
-}
-
-TEST(RunCallExternalReferenceF32Floor) {
- BufferedRawMachineAssemblerTester<int32_t> m;
- ExternalReference ref =
- ExternalReference::f32_floor_wrapper_function(m.isolate());
- TestExternalReferenceFunction<float>(&m, ref, floorf);
-}
-
-TEST(RunCallExternalReferenceF32Ceil) {
- BufferedRawMachineAssemblerTester<int32_t> m;
- ExternalReference ref =
- ExternalReference::f32_ceil_wrapper_function(m.isolate());
- TestExternalReferenceFunction<float>(&m, ref, ceilf);
-}
-
-TEST(RunCallExternalReferenceF32RoundTiesEven) {
- BufferedRawMachineAssemblerTester<int32_t> m;
- ExternalReference ref =
- ExternalReference::f32_nearest_int_wrapper_function(m.isolate());
- TestExternalReferenceFunction<float>(&m, ref, nearbyintf);
-}
-
-TEST(RunCallExternalReferenceF64Trunc) {
- BufferedRawMachineAssemblerTester<int32_t> m;
- ExternalReference ref =
- ExternalReference::f64_trunc_wrapper_function(m.isolate());
- TestExternalReferenceFunction<double>(&m, ref, trunc);
-}
-
-TEST(RunCallExternalReferenceF64Floor) {
- BufferedRawMachineAssemblerTester<int32_t> m;
- ExternalReference ref =
- ExternalReference::f64_floor_wrapper_function(m.isolate());
- TestExternalReferenceFunction<double>(&m, ref, floor);
-}
-
-TEST(RunCallExternalReferenceF64Ceil) {
- BufferedRawMachineAssemblerTester<int32_t> m;
- ExternalReference ref =
- ExternalReference::f64_ceil_wrapper_function(m.isolate());
- TestExternalReferenceFunction<double>(&m, ref, ceil);
-}
-
-TEST(RunCallExternalReferenceF64RoundTiesEven) {
- BufferedRawMachineAssemblerTester<int32_t> m;
- ExternalReference ref =
- ExternalReference::f64_nearest_int_wrapper_function(m.isolate());
- TestExternalReferenceFunction<double>(&m, ref, nearbyint);
-}
-
#if V8_TARGET_ARCH_64_BIT
// TODO(titzer): run int64 tests on all platforms when supported.
TEST(RunCheckedLoadInt64) {
@@ -5907,7 +6033,7 @@
TEST(RunTryTruncateFloat64ToUint64WithoutCheck) {
BufferedRawMachineAssemblerTester<uint64_t> m(MachineType::Float64());
- m.Return(m.TruncateFloat64ToUint64(m.Parameter(0)));
+ m.Return(m.TryTruncateFloat64ToUint64(m.Parameter(0)));
FOR_UINT64_INPUTS(j) {
double input = static_cast<double>(*j);
diff --git a/test/cctest/compiler/test-run-native-calls.cc b/test/cctest/compiler/test-run-native-calls.cc
index 8911409..bfdcc0e 100644
--- a/test/cctest/compiler/test-run-native-calls.cc
+++ b/test/cctest/compiler/test-run-native-calls.cc
@@ -270,7 +270,7 @@
Handle<Code> WrapWithCFunction(Handle<Code> inner, CallDescriptor* desc) {
- Zone zone;
+ Zone zone(inner->GetIsolate()->allocator());
MachineSignature* msig =
const_cast<MachineSignature*>(desc->GetMachineSignature());
int param_count = static_cast<int>(msig->parameter_count());
@@ -437,7 +437,7 @@
Handle<Code> inner = Handle<Code>::null();
{
// Build the graph for the computation.
- Zone zone;
+ Zone zone(isolate->allocator());
Graph graph(&zone);
RawMachineAssembler raw(isolate, &graph, desc);
build(desc, raw);
@@ -452,7 +452,7 @@
Handle<Code> wrapper = Handle<Code>::null();
{
// Wrap the above code with a callable function that passes constants.
- Zone zone;
+ Zone zone(isolate->allocator());
Graph graph(&zone);
CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig);
RawMachineAssembler raw(isolate, &graph, cdesc);
@@ -484,7 +484,7 @@
Handle<Code> wrapper = Handle<Code>::null();
{
// Wrap the above code with a callable function that loads from {input}.
- Zone zone;
+ Zone zone(isolate->allocator());
Graph graph(&zone);
CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig);
RawMachineAssembler raw(isolate, &graph, cdesc);
@@ -522,7 +522,7 @@
static void TestInt32Sub(CallDescriptor* desc) {
Isolate* isolate = CcTest::InitIsolateOnce();
HandleScope scope(isolate);
- Zone zone;
+ Zone zone(isolate->allocator());
GraphAndBuilders inner(&zone);
{
// Build the add function.
@@ -563,7 +563,7 @@
Handle<Code> inner = Handle<Code>::null();
{
// Writes all parameters into the output buffer.
- Zone zone;
+ Zone zone(isolate->allocator());
Graph graph(&zone);
RawMachineAssembler raw(isolate, &graph, desc);
Node* base = raw.PointerConstant(output);
@@ -580,7 +580,7 @@
Handle<Code> wrapper = Handle<Code>::null();
{
// Loads parameters from the input buffer and calls the above code.
- Zone zone;
+ Zone zone(isolate->allocator());
Graph graph(&zone);
CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig);
RawMachineAssembler raw(isolate, &graph, cdesc);
@@ -619,7 +619,8 @@
static void Test_RunInt32SubWithRet(int retreg) {
Int32Signature sig(2);
- Zone zone;
+ base::AccountingAllocator allocator;
+ Zone zone(&allocator);
RegisterPairs pairs;
while (pairs.More()) {
int parray[2];
@@ -670,7 +671,8 @@
Int32Signature sig(2);
RegisterPairs pairs;
while (pairs.More()) {
- Zone zone;
+ base::AccountingAllocator allocator;
+ Zone zone(&allocator);
int parray[1];
int rarray[1];
pairs.Next(&rarray[0], &parray[0], true);
@@ -687,7 +689,8 @@
Int32Signature sig(20);
RegisterPairs pairs;
while (pairs.More()) {
- Zone zone;
+ base::AccountingAllocator allocator;
+ Zone zone(&allocator);
int parray[2];
int rarray[] = {
RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN)
@@ -739,7 +742,8 @@
Int32Signature sig(count);
for (int p0 = 0; p0 < Register::kNumRegisters; p0++) {
if (Register::from_code(p0).IsAllocatable()) {
- Zone zone;
+ base::AccountingAllocator allocator;
+ Zone zone(&allocator);
int parray[] = {p0};
int rarray[] = {
@@ -807,7 +811,8 @@
Allocator rets(rarray, 1, nullptr, 0);
RegisterConfig config(params, rets);
- Zone zone;
+ base::AccountingAllocator allocator;
+ Zone zone(&allocator);
for (int i = which + 1; i <= 64; i++) {
Int32Signature sig(i);
@@ -849,7 +854,8 @@
ArgsBuffer<int64_t>::Sig sig(2);
RegisterPairs pairs;
- Zone zone;
+ base::AccountingAllocator allocator;
+ Zone zone(&allocator);
while (pairs.More()) {
int parray[2];
pairs.Next(&parray[0], &parray[1], false);
@@ -876,7 +882,8 @@
ArgsBuffer<float32>::Sig sig(2);
Float32RegisterPairs pairs;
- Zone zone;
+ base::AccountingAllocator allocator;
+ Zone zone(&allocator);
while (pairs.More()) {
int parray[2];
pairs.Next(&parray[0], &parray[1], false);
@@ -904,7 +911,8 @@
ArgsBuffer<float64>::Sig sig(2);
Float64RegisterPairs pairs;
- Zone zone;
+ base::AccountingAllocator allocator;
+ Zone zone(&allocator);
while (pairs.More()) {
int parray[2];
pairs.Next(&parray[0], &parray[1], false);
@@ -927,7 +935,8 @@
Allocator rets(nullptr, 0, rarray, 1);
RegisterConfig config(params, rets);
- Zone zone;
+ base::AccountingAllocator allocator;
+ Zone zone(&allocator);
for (int count = 1; count < 6; count++) {
ArgsBuffer<float32>::Sig sig(count);
CallDescriptor* desc = config.Create(&zone, &sig);
@@ -949,7 +958,8 @@
Allocator rets(nullptr, 0, rarray, 1);
RegisterConfig config(params, rets);
- Zone zone;
+ base::AccountingAllocator allocator;
+ Zone zone(&allocator);
for (int count = 1; count < 6; count++) {
ArgsBuffer<float64>::Sig sig(count);
CallDescriptor* desc = config.Create(&zone, &sig);
@@ -972,7 +982,7 @@
{
Isolate* isolate = CcTest::InitIsolateOnce();
// Build the actual select.
- Zone zone;
+ Zone zone(isolate->allocator());
Graph graph(&zone);
RawMachineAssembler raw(isolate, &graph, desc);
raw.Return(raw.Parameter(which));
@@ -1002,7 +1012,8 @@
Allocator params(nullptr, 0, nullptr, 0);
Allocator rets(nullptr, 0, rarray, 1);
- Zone zone;
+ base::AccountingAllocator allocator;
+ Zone zone(&allocator);
ArgsBuffer<float64>::Sig sig(2);
RegisterConfig config(params, rets);
CallDescriptor* desc = config.Create(&zone, &sig);
@@ -1068,7 +1079,8 @@
RegisterConfig config(palloc, ralloc);
for (int which = 0; which < num_params; which++) {
- Zone zone;
+ base::AccountingAllocator allocator;
+ Zone zone(&allocator);
HandleScope scope(isolate);
MachineSignature::Builder builder(&zone, 1, num_params);
builder.AddReturn(params[which]);
@@ -1079,7 +1091,7 @@
Handle<Code> select;
{
// build the select.
- Zone zone;
+ Zone zone(&allocator);
Graph graph(&zone);
RawMachineAssembler raw(isolate, &graph, desc);
raw.Return(raw.Parameter(which));
@@ -1096,7 +1108,7 @@
CSignature0<int32_t> csig;
{
// Wrap the select code with a callable function that passes constants.
- Zone zone;
+ Zone zone(&allocator);
Graph graph(&zone);
CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig);
RawMachineAssembler raw(isolate, &graph, cdesc);
@@ -1189,7 +1201,7 @@
Allocator ralloc(rarray_gp, 1, rarray_fp, 1);
RegisterConfig config(palloc, ralloc);
- Zone zone;
+ Zone zone(isolate->allocator());
HandleScope scope(isolate);
MachineSignature::Builder builder(&zone, 1, 12);
builder.AddReturn(MachineType::Int32());
diff --git a/test/cctest/compiler/test-run-variables.cc b/test/cctest/compiler/test-run-variables.cc
index f856368..6997967 100644
--- a/test/cctest/compiler/test-run-variables.cc
+++ b/test/cctest/compiler/test-run-variables.cc
@@ -15,7 +15,6 @@
"var x = (r = x)", "undefined", "undefined",
"var x = (a?1:2); r = x", "1", "2",
"const x = a; r = x", "123", "0",
- "const x = (r = x)", "undefined", "undefined",
"const x = (a?3:4); r = x", "3", "4",
"'use strict'; const x = a; r = x", "123", "0",
"'use strict'; const x = (r = x)", throws, throws,
@@ -29,9 +28,6 @@
"var x = 1; x = a; r = x", "123", "0",
"var x = (a?(x=4,2):3); r = x", "2", "3",
"var x = (a?4:5); x = a; r = x", "123", "0",
- "const x = 1; x = a; r = x", "1", "1",
- "const x = (a?(x=4,2):3); r = x", "2", "3",
- "const x = (a?4:5); x = a; r = x", "4", "5",
// Assignments to 'const' are SyntaxErrors, handled by the parser,
// hence we cannot test them here because they are early errors.
"'use strict'; let x = 1; x = a; r = x", "123", "0",
@@ -39,16 +35,8 @@
"'use strict'; let x = (a?4:5); x = a; r = x", "123", "0",
NULL};
-static const char* bind_tests[] = {
- "if (a) { const x = a }; r = x;", "123", "undefined",
- "for (; a > 0; a--) { const x = a }; r = x", "123", "undefined",
- // Re-initialization of variables other than legacy 'const' is not
- // possible due to sane variable scoping, hence no tests here.
- NULL};
-
static void RunVariableTests(const char* source, const char* tests[]) {
- i::FLAG_legacy_const = true;
EmbeddedVector<char, 512> buffer;
for (int i = 0; tests[i] != NULL; i += 3) {
@@ -99,18 +87,6 @@
}
-TEST(StackInitializeVariables) {
- const char* source = "(function(a,r) { %s; return r; })";
- RunVariableTests(source, bind_tests);
-}
-
-
-TEST(ContextInitializeVariables) {
- const char* source = "(function(a,r) { %s; function f() {x} return r; })";
- RunVariableTests(source, bind_tests);
-}
-
-
TEST(SelfReferenceVariable) {
FunctionTester T("(function self() { return self; })");
diff --git a/test/cctest/compiler/test-simplified-lowering.cc b/test/cctest/compiler/test-simplified-lowering.cc
index 1b752ed..b5e9929 100644
--- a/test/cctest/compiler/test-simplified-lowering.cc
+++ b/test/cctest/compiler/test-simplified-lowering.cc
@@ -928,10 +928,8 @@
CHECK(c == cnv->InputAt(0) || c == cnv->InputAt(1));
}
-
static Type* test_types[] = {Type::Signed32(), Type::Unsigned32(),
- Type::Number(), Type::Any()};
-
+ Type::Number()};
TEST(LowerNumberCmp_to_int32) {
TestingGraph t(Type::Signed32(), Type::Signed32());
@@ -956,18 +954,13 @@
TEST(LowerNumberCmp_to_float64) {
- static Type* types[] = {Type::Number(), Type::Any()};
+ TestingGraph t(Type::Number(), Type::Number());
- for (size_t i = 0; i < arraysize(types); i++) {
- TestingGraph t(types[i], types[i]);
-
- t.CheckLoweringBinop(IrOpcode::kFloat64Equal,
- t.simplified()->NumberEqual());
- t.CheckLoweringBinop(IrOpcode::kFloat64LessThan,
- t.simplified()->NumberLessThan());
- t.CheckLoweringBinop(IrOpcode::kFloat64LessThanOrEqual,
- t.simplified()->NumberLessThanOrEqual());
- }
+ t.CheckLoweringBinop(IrOpcode::kFloat64Equal, t.simplified()->NumberEqual());
+ t.CheckLoweringBinop(IrOpcode::kFloat64LessThan,
+ t.simplified()->NumberLessThan());
+ t.CheckLoweringBinop(IrOpcode::kFloat64LessThanOrEqual,
+ t.simplified()->NumberLessThanOrEqual());
}
@@ -1140,25 +1133,8 @@
t.CheckLoweringBinop(opcode, t.simplified()->ReferenceEqual(Type::Any()));
}
-
-TEST(LowerStringOps_to_call_and_compare) {
- // These tests need linkage for the calls.
- TestingGraph t(Type::String(), Type::String());
- IrOpcode::Value compare_eq =
- static_cast<IrOpcode::Value>(t.machine()->WordEqual()->opcode());
- IrOpcode::Value compare_lt =
- static_cast<IrOpcode::Value>(t.machine()->IntLessThan()->opcode());
- IrOpcode::Value compare_le = static_cast<IrOpcode::Value>(
- t.machine()->IntLessThanOrEqual()->opcode());
- t.CheckLoweringStringBinop(compare_eq, t.simplified()->StringEqual());
- t.CheckLoweringStringBinop(compare_lt, t.simplified()->StringLessThan());
- t.CheckLoweringStringBinop(compare_le,
- t.simplified()->StringLessThanOrEqual());
- }
-
-
- void CheckChangeInsertion(IrOpcode::Value expected, MachineType from,
- MachineType to, Type* type = Type::Any()) {
+void CheckChangeInsertion(IrOpcode::Value expected, MachineType from,
+ MachineType to, Type* type = Type::Any()) {
TestingGraph t(Type::Any());
Node* in = t.ExampleWithOutput(from);
NodeProperties::SetType(in, type);
@@ -1169,7 +1145,6 @@
CHECK_EQ(in, use->InputAt(0)->InputAt(0));
}
-
TEST(InsertBasicChanges) {
CheckChangeInsertion(IrOpcode::kChangeFloat64ToInt32, MachineType::Float64(),
MachineType::Int32(), Type::Signed32());
@@ -1187,27 +1162,29 @@
CheckChangeInsertion(IrOpcode::kChangeFloat64ToTagged, MachineType::Float64(),
MachineType::AnyTagged());
CheckChangeInsertion(IrOpcode::kChangeTaggedToFloat64,
- MachineType::AnyTagged(), MachineType::Float64());
+ MachineType::AnyTagged(), MachineType::Float64(),
+ Type::Number());
CheckChangeInsertion(IrOpcode::kChangeInt32ToFloat64, MachineType::Int32(),
- MachineType::Float64());
+ MachineType::Float64(), Type::Signed32());
CheckChangeInsertion(IrOpcode::kChangeInt32ToTagged, MachineType::Int32(),
- MachineType::AnyTagged());
+ MachineType::AnyTagged(), Type::Signed32());
CheckChangeInsertion(IrOpcode::kChangeUint32ToFloat64, MachineType::Uint32(),
- MachineType::Float64());
+ MachineType::Float64(), Type::Unsigned32());
CheckChangeInsertion(IrOpcode::kChangeUint32ToTagged, MachineType::Uint32(),
- MachineType::AnyTagged());
+ MachineType::AnyTagged(), Type::Unsigned32());
}
-
static void CheckChangesAroundBinop(TestingGraph* t, const Operator* op,
IrOpcode::Value input_change,
- IrOpcode::Value output_change) {
+ IrOpcode::Value output_change,
+ Type* type = Type::Any()) {
Node* binop =
op->ControlInputCount() == 0
? t->graph()->NewNode(op, t->p0, t->p1)
: t->graph()->NewNode(op, t->p0, t->p1, t->graph()->start());
+ NodeProperties::SetType(binop, type);
t->Return(binop);
t->Lower();
CHECK_EQ(input_change, binop->InputAt(0)->opcode());
@@ -1230,7 +1207,9 @@
for (size_t i = 0; i < arraysize(ops); i++) {
CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToInt32,
- IrOpcode::kChangeInt32ToTagged);
+ IrOpcode::kChangeInt32ToTagged, Type::Signed32());
+ CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToInt32,
+ IrOpcode::kChangeInt32ToTagged, Type::Signed32());
}
}
diff --git a/test/cctest/compiler/value-helper.h b/test/cctest/compiler/value-helper.h
index 83cd33c..7d26dba 100644
--- a/test/cctest/compiler/value-helper.h
+++ b/test/cctest/compiler/value-helper.h
@@ -274,7 +274,7 @@
0x00003fffffffffff, 0x00001fffffffffff, 0x00000fffffffffff,
0x000007ffffffffff, 0x000003ffffffffff, 0x000001ffffffffff,
0x8000008000000000, 0x8000008000000001, 0x8000000000000400,
- 0x8000000000000401};
+ 0x8000000000000401, 0x0000000000000020};
return std::vector<uint64_t>(&kValues[0], &kValues[arraysize(kValues)]);
}
@@ -321,6 +321,12 @@
}
}
+#define CHECK_FLOAT_EQ(lhs, rhs) \
+ do { \
+ volatile float tmp = lhs; \
+ CheckFloatEq(tmp, rhs); \
+ } while (0)
+
static inline void CheckDoubleEq(volatile double x, volatile double y) {
if (std::isnan(x)) {
CHECK(std::isnan(y));
@@ -329,6 +335,12 @@
}
}
+#define CHECK_DOUBLE_EQ(lhs, rhs) \
+ do { \
+ volatile double tmp = lhs; \
+ CheckDoubleEq(tmp, rhs); \
+ } while (0)
+
} // namespace compiler
} // namespace internal
} // namespace v8