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

Unified Diff: test/cctest/compiler/test-run-stubs.cc

Issue 1137703002: Add a MathFloor stub generated with TurboFan (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix ARM + co. Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/x64/interface-descriptors-x64.cc ('k') | test/mjsunit/compiler/stubs/floor-stub.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/compiler/test-run-stubs.cc
diff --git a/test/cctest/compiler/test-run-stubs.cc b/test/cctest/compiler/test-run-stubs.cc
index c81f0f184db0e9ff02f521ebe5322619f21938e1..4e34aaafbb302b5eca202f6384cb9d2497163a78 100644
--- a/test/cctest/compiler/test-run-stubs.cc
+++ b/test/cctest/compiler/test-run-stubs.cc
@@ -6,7 +6,10 @@
#include "src/code-stubs.h"
#include "src/compiler/common-operator.h"
#include "src/compiler/graph.h"
+#include "src/compiler/js-graph.h"
+#include "src/compiler/js-operator.h"
#include "src/compiler/linkage.h"
+#include "src/compiler/machine-operator.h"
#include "src/compiler/pipeline.h"
#include "src/parser.h"
#include "test/cctest/compiler/function-tester.h"
@@ -17,60 +20,54 @@ using namespace v8::internal;
using namespace v8::internal::compiler;
-static Handle<JSFunction> GetFunction(Isolate* isolate, const char* name) {
- v8::ExtensionConfiguration no_extensions;
- Handle<Context> ctx = isolate->bootstrapper()->CreateEnvironment(
- MaybeHandle<JSGlobalProxy>(), v8::Handle<v8::ObjectTemplate>(),
- &no_extensions);
- Handle<JSBuiltinsObject> builtins = handle(ctx->builtins());
- MaybeHandle<Object> fun = Object::GetProperty(isolate, builtins, name);
- Handle<JSFunction> function = Handle<JSFunction>::cast(fun.ToHandleChecked());
- // Just to make sure nobody calls this...
- function->set_code(isolate->builtins()->builtin(Builtins::kIllegal));
- return function;
-}
-
-
-class StringLengthStubTF : public CodeStub {
- public:
- explicit StringLengthStubTF(Isolate* isolate) : CodeStub(isolate) {}
+TEST(RunMathFloorStub) {
+ HandleAndZoneScope scope;
+ Isolate* isolate = scope.main_isolate();
- StringLengthStubTF(uint32_t key, Isolate* isolate) : CodeStub(key, isolate) {}
+ // Create code and an accompanying descriptor.
+ MathFloorStub stub(isolate);
+ Handle<Code> code = stub.GenerateCode();
+ Zone* zone = scope.main_zone();
- CallInterfaceDescriptor GetCallInterfaceDescriptor() override {
- return LoadDescriptor(isolate());
- };
+ CompilationInfo info(&stub, isolate, zone);
+ CallDescriptor* descriptor = Linkage::ComputeIncoming(zone, &info);
- Handle<Code> GenerateCode() override {
- Zone zone;
- // Build a "hybrid" CompilationInfo for a JSFunction/CodeStub pair.
- ParseInfo parse_info(&zone, GetFunction(isolate(), "STRING_LENGTH_STUB"));
- CompilationInfo info(&parse_info);
- info.SetStub(this);
- // Run a "mini pipeline", extracted from compiler.cc.
- CHECK(Parser::ParseStatic(info.parse_info()));
- CHECK(Compiler::Analyze(info.parse_info()));
- return Pipeline(&info).GenerateCode();
- }
+ // Create a function to call the code using the descriptor.
+ Graph graph(zone);
+ CommonOperatorBuilder common(zone);
+ JSOperatorBuilder javascript(zone);
+ MachineOperatorBuilder machine(zone);
+ JSGraph js(isolate, &graph, &common, &javascript, &machine);
- Major MajorKey() const override { return StringLength; };
- Code::Kind GetCodeKind() const override { return Code::HANDLER; }
- InlineCacheState GetICState() const override { return MONOMORPHIC; }
- ExtraICState GetExtraICState() const override { return Code::LOAD_IC; }
- Code::StubType GetStubType() const override { return Code::FAST; }
+ // FunctionTester (ab)uses a 2-argument function
+ Node* start = graph.NewNode(common.Start(2));
+ // Parameter 0 is the number to round
+ Node* numberParam = graph.NewNode(common.Parameter(1), start);
+ Unique<HeapObject> u = Unique<HeapObject>::CreateImmovable(code);
+ Node* theCode = graph.NewNode(common.HeapConstant(u));
+ Node* dummyContext = graph.NewNode(common.NumberConstant(0.0));
+ Node* call = graph.NewNode(common.Call(descriptor), theCode,
+ js.UndefinedConstant(), js.UndefinedConstant(),
+ numberParam, dummyContext, start, start);
+ Node* ret = graph.NewNode(common.Return(), call, call, start);
+ Node* end = graph.NewNode(common.End(), ret);
+ graph.SetStart(start);
+ graph.SetEnd(end);
+ FunctionTester ft(&graph);
- private:
- DISALLOW_COPY_AND_ASSIGN(StringLengthStubTF);
-};
+ Handle<Object> value = ft.Val(1.5);
+ Handle<Object> result = ft.Call(value, value).ToHandleChecked();
+ CHECK_EQ(1, Smi::cast(*result)->value());
+}
-TEST(RunStringLengthStubTF) {
+TEST(RunStringLengthTFStub) {
HandleAndZoneScope scope;
Isolate* isolate = scope.main_isolate();
Zone* zone = scope.main_zone();
// Create code and an accompanying descriptor.
- StringLengthStubTF stub(isolate);
+ StringLengthTFStub stub(isolate);
Handle<Code> code = stub.GenerateCode();
CompilationInfo info(&stub, isolate, zone);
CallDescriptor* descriptor = Linkage::ComputeIncoming(zone, &info);
« no previous file with comments | « src/x64/interface-descriptors-x64.cc ('k') | test/mjsunit/compiler/stubs/floor-stub.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698