| 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);
|
|
|