Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(369)

Side by Side Diff: test/cctest/compiler/test-run-stubs.cc

Issue 1225943002: Reland: Add unoptimized/optimized variants of MathFloor TF code stub (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Tweak tests Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/bootstrapper.h" 5 #include "src/bootstrapper.h"
6 #include "src/code-stubs.h" 6 #include "src/code-stubs.h"
7 #include "src/compiler/common-operator.h" 7 #include "src/compiler/common-operator.h"
8 #include "src/compiler/graph.h" 8 #include "src/compiler/graph.h"
9 #include "src/compiler/js-graph.h" 9 #include "src/compiler/js-graph.h"
10 #include "src/compiler/js-operator.h" 10 #include "src/compiler/js-operator.h"
11 #include "src/compiler/linkage.h" 11 #include "src/compiler/linkage.h"
12 #include "src/compiler/machine-operator.h" 12 #include "src/compiler/machine-operator.h"
13 #include "src/compiler/pipeline.h" 13 #include "src/compiler/pipeline.h"
14 #include "src/parser.h" 14 #include "src/parser.h"
15 #include "test/cctest/compiler/function-tester.h" 15 #include "test/cctest/compiler/function-tester.h"
16 16
17 #if V8_TURBOFAN_TARGET 17 #if V8_TURBOFAN_TARGET
18 18
19 using namespace v8::internal; 19 using namespace v8::internal;
20 using namespace v8::internal::compiler; 20 using namespace v8::internal::compiler;
21 21
22 22
23 TEST(RunMathFloorStub) { 23 TEST(RunOptimizedMathFloorStub) {
24 HandleAndZoneScope scope; 24 HandleAndZoneScope scope;
25 Isolate* isolate = scope.main_isolate(); 25 Isolate* isolate = scope.main_isolate();
26 26
27 // Create code and an accompanying descriptor. 27 // Create code and an accompanying descriptor.
28 MathFloorStub stub(isolate); 28 MathFloorStub stub(isolate, TurboFanIC::CALL_FROM_OPTIMIZED_CODE);
29 Handle<Code> code = stub.GenerateCode(); 29 Handle<Code> code = stub.GenerateCode();
30 Zone* zone = scope.main_zone(); 30 Zone* zone = scope.main_zone();
31
32 CompilationInfo info(&stub, isolate, zone); 31 CompilationInfo info(&stub, isolate, zone);
33 CallDescriptor* descriptor = Linkage::ComputeIncoming(zone, &info); 32 CallDescriptor* descriptor = Linkage::ComputeIncoming(zone, &info);
33 Handle<FixedArray> tv = isolate->factory()->NewFixedArray(10);
34 34
35 // Create a function to call the code using the descriptor. 35 // Create a function to call the code using the descriptor.
36 Graph graph(zone); 36 Graph graph(zone);
37 CommonOperatorBuilder common(zone);
38 JSOperatorBuilder javascript(zone);
39 MachineOperatorBuilder machine(zone);
40 JSGraph js(isolate, &graph, &common, &javascript, &machine);
41
42 // FunctionTester (ab)uses a 2-argument function
43 Node* start = graph.NewNode(common.Start(4));
44 // Parameter 0 is the number to round
45 Node* numberParam = graph.NewNode(common.Parameter(1), start);
46 Unique<HeapObject> u = Unique<HeapObject>::CreateImmovable(code);
47 Node* theCode = graph.NewNode(common.HeapConstant(u));
48 Unique<HeapObject> tvu = Unique<HeapObject>::CreateImmovable(tv);
49 Node* vector = graph.NewNode(common.HeapConstant(tvu));
50 Node* dummyContext = graph.NewNode(common.NumberConstant(0.0));
51 Node* call =
52 graph.NewNode(common.Call(descriptor), theCode, js.UndefinedConstant(),
53 js.OneConstant(), vector, js.UndefinedConstant(),
54 numberParam, dummyContext, start, start);
55 Node* ret = graph.NewNode(common.Return(), call, call, start);
56 Node* end = graph.NewNode(common.End(1), ret);
57 graph.SetStart(start);
58 graph.SetEnd(end);
59 FunctionTester ft(&graph);
60
61 Handle<Object> value = ft.Val(1.5);
62 Handle<Object> result = ft.Call(value, value).ToHandleChecked();
63 CHECK_EQ(1, Smi::cast(*result)->value());
64 }
65
66
67 TEST(RunUnoptimizedMathFloorStub) {
68 HandleAndZoneScope scope;
69 Isolate* isolate = scope.main_isolate();
70
71 // Create code and an accompanying descriptor.
72 MathFloorStub stub(isolate, TurboFanIC::CALL_FROM_UNOPTIMIZED_CODE);
73 Handle<Code> code = stub.GenerateCode();
74 Zone* zone = scope.main_zone();
75 CompilationInfo info(&stub, isolate, zone);
76 CallDescriptor* descriptor = Linkage::ComputeIncoming(zone, &info);
77 Handle<FixedArray> tv = isolate->factory()->NewFixedArray(10);
78
79 // Create a function to call the code using the descriptor.
80 Graph graph(zone);
37 CommonOperatorBuilder common(zone); 81 CommonOperatorBuilder common(zone);
38 JSOperatorBuilder javascript(zone); 82 JSOperatorBuilder javascript(zone);
39 MachineOperatorBuilder machine(zone); 83 MachineOperatorBuilder machine(zone);
40 JSGraph js(isolate, &graph, &common, &javascript, &machine); 84 JSGraph js(isolate, &graph, &common, &javascript, &machine);
41 85
42 // FunctionTester (ab)uses a 2-argument function 86 // FunctionTester (ab)uses a 2-argument function
43 Node* start = graph.NewNode(common.Start(4)); 87 Node* start = graph.NewNode(common.Start(4));
44 // Parameter 0 is the number to round 88 // Parameter 0 is the number to round
45 Node* numberParam = graph.NewNode(common.Parameter(1), start); 89 Node* numberParam = graph.NewNode(common.Parameter(1), start);
46 Unique<HeapObject> u = Unique<HeapObject>::CreateImmovable(code); 90 Unique<HeapObject> u = Unique<HeapObject>::CreateImmovable(code);
47 Node* theCode = graph.NewNode(common.HeapConstant(u)); 91 Node* theCode = graph.NewNode(common.HeapConstant(u));
92 Unique<HeapObject> tvu = Unique<HeapObject>::CreateImmovable(tv);
93 Node* vector = graph.NewNode(common.HeapConstant(tvu));
48 Node* dummyContext = graph.NewNode(common.NumberConstant(0.0)); 94 Node* dummyContext = graph.NewNode(common.NumberConstant(0.0));
49 Node* call = graph.NewNode(common.Call(descriptor), theCode, 95 Node* call =
50 js.UndefinedConstant(), js.UndefinedConstant(), 96 graph.NewNode(common.Call(descriptor), theCode, js.UndefinedConstant(),
51 numberParam, dummyContext, start, start); 97 js.OneConstant(), vector, js.UndefinedConstant(),
98 numberParam, dummyContext, start, start);
52 Node* ret = graph.NewNode(common.Return(), call, call, start); 99 Node* ret = graph.NewNode(common.Return(), call, call, start);
53 Node* end = graph.NewNode(common.End(1), ret); 100 Node* end = graph.NewNode(common.End(1), ret);
54 graph.SetStart(start); 101 graph.SetStart(start);
55 graph.SetEnd(end); 102 graph.SetEnd(end);
56 FunctionTester ft(&graph); 103 FunctionTester ft(&graph);
57 104
58 Handle<Object> value = ft.Val(1.5); 105 Handle<Object> value = ft.Val(1.5);
59 Handle<Object> result = ft.Call(value, value).ToHandleChecked(); 106 Handle<Object> result = ft.Call(value, value).ToHandleChecked();
60 CHECK_EQ(1, Smi::cast(*result)->value()); 107 CHECK_EQ(1, Smi::cast(*result)->value());
61 } 108 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 FunctionTester ft(&graph); 185 FunctionTester ft(&graph);
139 186
140 // Actuall call through to the stub, verifying its result. 187 // Actuall call through to the stub, verifying its result.
141 Handle<String> leftArg = ft.Val("links"); 188 Handle<String> leftArg = ft.Val("links");
142 Handle<String> rightArg = ft.Val("rechts"); 189 Handle<String> rightArg = ft.Val("rechts");
143 Handle<Object> result = ft.Call(leftArg, rightArg).ToHandleChecked(); 190 Handle<Object> result = ft.Call(leftArg, rightArg).ToHandleChecked();
144 CHECK(String::Equals(ft.Val("linksrechts"), Handle<String>::cast(result))); 191 CHECK(String::Equals(ft.Val("linksrechts"), Handle<String>::cast(result)));
145 } 192 }
146 193
147 #endif // V8_TURBOFAN_TARGET 194 #endif // V8_TURBOFAN_TARGET
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698